Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
475b2dd
Add the source anchor deletion implementation
norilanda Aug 4, 2025
0a60581
Refactor inheritance and interface creation
norilanda Aug 6, 2025
b730491
Add a FullyQualifiedNameEntity interface
norilanda Aug 6, 2025
71c4735
Add catching the error for the extension incremental update
norilanda Aug 6, 2025
c863702
Update test/incremental-update/incrementalUpdateExpect.ts
norilanda Aug 6, 2025
260619b
Update vscode-extension/server/src/eventHandlers/onDidChangeWatchedFi…
norilanda Aug 6, 2025
5301505
Remove the famixInterfaces list from the repository
norilanda Aug 6, 2025
c6cc6d8
Merge branch 'inheritance-incremental-update' of https://github.com/n…
norilanda Aug 6, 2025
8c9d282
Change ensure to create for inheritance famix element
norilanda Aug 7, 2025
9d86423
Remove the comment
norilanda Aug 7, 2025
bedc156
Update README.md
norilanda Aug 8, 2025
c98fd73
Split SourcedEntity class into 2 classes: SourcedEntity and EntityWit…
norilanda Aug 8, 2025
1af4659
Merge branch 'feature/incremental-update' into import-clause-incremen…
norilanda Aug 8, 2025
d737490
Add tests for import clause
norilanda Aug 14, 2025
308de34
Implement ImportClause for named imports. Add incremental update for …
norilanda Aug 14, 2025
677b46e
Add reexport tests
norilanda Aug 20, 2025
958a03e
Add namespace import tests
norilanda Aug 21, 2025
a088c2f
Add implementation for the Imoprt Clause for
norilanda Aug 21, 2025
26ab8b6
Add test with exporting interfaces for the inheritance
norilanda Aug 22, 2025
ad758b6
Remove the old ImportClause test
norilanda Aug 22, 2025
00b414a
Add todo to the module tests
norilanda Aug 22, 2025
1f7cd98
Fix resolving file path for the transient dependency search
norilanda Aug 22, 2025
de61925
Fix getFamixEntityByFullyQualifiedName to work with all the entities …
norilanda Aug 22, 2025
5a92ba7
Fix getModuleSpecifierFromDeclaration to work with import without ts.…
norilanda Aug 22, 2025
611606a
Add a comment
norilanda Aug 22, 2025
859ef15
Add more properties to Module. Rename methods
norilanda Aug 22, 2025
8a2e4ab
Add todo for import clause: currently we have a bug where namedEntiti…
norilanda Aug 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions src/analyze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import { Logger } from "tslog";
import { EntityDictionary, EntityDictionaryConfig } from "./famix_functions/EntityDictionary";
import path from "path";
import { TypeScriptToFamixProcessor } from "./analyze_functions/process_functions";
import { getFamixIndexFileAnchorFileName } from "./famix_functions/famixIndexFileAnchorHelper";
import { getFamixIndexFileAnchorFileName, getTransientDependentEntities } from "./helpers";
import { isSourceFileAModule } from "./famix_functions/helpersTsMorphElementsProcessing";
import { FamixBaseElement } from "./lib/famix/famix_base_element";
import { getDependentAssociations, getSourceFilesToUpdate, removeDependentAssociations } from "./helpers";

export const logger = new Logger({ name: "ts2famix", minLevel: 2 });

Expand Down Expand Up @@ -70,29 +73,23 @@ export class Importer {
this.processReferences(onlyTypeScriptFiles, onlyTypeScriptFiles);
}

private processReferences(sourceFiles: SourceFile[], allExistingSourceFiles: SourceFile[]): void {
private processReferences(sourceFiles: SourceFile[], allExistingSourceFiles: SourceFile[]): void {
sourceFiles.forEach(sourceFile => {
const fileName = sourceFile.getFilePath();
const accesses = this.processFunctions.accessMap.getBySourceFileName(fileName);
const methodsAndFunctionsWithId = this.processFunctions.methodsAndFunctionsWithId.getBySourceFileName(fileName);
// const classes = this.processFunctions.classes.getBySourceFileName(fileName);
// const interfaces = this.processFunctions.interfaces.getBySourceFileName(fileName);
const modules = this.processFunctions.modules.getBySourceFileName(fileName);
const exports = this.processFunctions.listOfExportMaps.getBySourceFileName(fileName);

// this.entityDictionary.setCurrentSourceFileName(fileName);

// TODO: check if it is working correctly
this.processFunctions.processImportClausesForImportEqualsDeclarations(allExistingSourceFiles, exports);
this.processFunctions.processImportClausesForModules(modules, exports);
this.processFunctions.processAccesses(accesses);
this.processFunctions.processInvocations(methodsAndFunctionsWithId);
// this.processFunctions.processInheritances(classes, interfaces, this.processFunctions.interfaces.getAll());

// this.processFunctions.processConcretisations(classes, interfaces, methodsAndFunctionsWithId);
//TODO: fix concretisatoion
this.processFunctions.processConcretisations([], [], methodsAndFunctionsWithId);
});
this.processFunctions.processImportClausesForImportEqualsDeclarations(allExistingSourceFiles);

const modules = sourceFiles.filter(f => isSourceFileAModule(f));
this.processFunctions.processImportClausesForModules(modules);
}

/**
Expand Down Expand Up @@ -132,27 +129,35 @@ export class Importer {
}

public updateFamixModelIncrementally(sourceFileChangeMap: Map<SourceFileChangeType, SourceFile[]>): void {
const allSourceFiles = Array.from(sourceFileChangeMap.values()).flat();
const sourceFilesToCreateEntities = [
...(sourceFileChangeMap.get(SourceFileChangeType.Create) || []),
...(sourceFileChangeMap.get(SourceFileChangeType.Update) || []),
];
const allChangedSourceFiles = Array.from(sourceFileChangeMap.values()).flat();

allSourceFiles.forEach(
const removedEntities: FamixBaseElement[] = [];
allChangedSourceFiles.forEach(
file => {
const filePath = getFamixIndexFileAnchorFileName(file.getFilePath(), this.entityDictionary.getAbsolutePath());
this.entityDictionary.famixRep.removeEntitiesBySourceFile(filePath);
// this.entityDictionary.removeEntitiesBySourceFilePath(filePath);
// this.processFunctions.removeNodesBySourceFile(filePath);
const removed = this.entityDictionary.famixRep.removeEntitiesBySourceFile(filePath);
removedEntities.push(...removed);
}
);

this.processFunctions.processFiles(sourceFilesToCreateEntities);
const allSourceFiles = this.project.getSourceFiles();
const dependentAssociations = getDependentAssociations(removedEntities);
const transientDependentAssociations = getTransientDependentEntities(this.entityDictionary, sourceFileChangeMap);

const associationsToRemove = [...dependentAssociations, ...transientDependentAssociations];

removeDependentAssociations(this.entityDictionary.famixRep, associationsToRemove);

const sourceFilesToEnsure = getSourceFilesToUpdate(
associationsToRemove, sourceFileChangeMap, allSourceFiles, this.entityDictionary.getAbsolutePath()
);

this.processFunctions.processFiles(sourceFilesToEnsure);
const sourceFilesToDelete = sourceFileChangeMap.get(SourceFileChangeType.Delete) || [];
const existingSourceFiles = this.project.getSourceFiles().filter(
const existingSourceFiles = allSourceFiles.filter(
file => !sourceFilesToDelete.includes(file)
);
this.processReferences(sourceFilesToCreateEntities, existingSourceFiles);
this.processReferences(sourceFilesToEnsure, existingSourceFiles);

}

Expand Down
Loading
Loading