ts2famix 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/analyze.js +37 -27
  2. package/dist/analyze_functions/process_functions.js +723 -0
  3. package/dist/famix_functions/EntityDictionary.js +798 -0
  4. package/dist/famix_functions/helpers_creation.js +97 -0
  5. package/dist/fqn.js +106 -95
  6. package/dist/lib/famix/src/famix_base_element.js +8 -4
  7. package/dist/lib/famix/src/famix_repository.js +32 -15
  8. package/dist/lib/famix/src/model/famix/class.js +1 -1
  9. package/dist/lib/ts-complex/cyclomatic-service.js +2 -3
  10. package/doc-uml/metamodel-full.svg +1 -0
  11. package/doc-uml/metamodel.svg +1 -0
  12. package/package.json +4 -4
  13. package/plantuml.jar +0 -0
  14. package/src/analyze.ts +46 -29
  15. package/src/analyze_functions/process_functions.ts +838 -0
  16. package/src/famix_functions/EntityDictionary.ts +915 -0
  17. package/src/famix_functions/helpers_creation.ts +77 -0
  18. package/src/fqn.ts +101 -92
  19. package/src/generate_uml.sh +3 -0
  20. package/src/lib/famix/src/famix_base_element.ts +9 -5
  21. package/src/lib/famix/src/famix_repository.ts +45 -23
  22. package/src/lib/famix/src/model/famix/class.ts +1 -1
  23. package/src/lib/ts-complex/cyclomatic-service.ts +2 -4
  24. package/src/ts2famix-cli.ts +1 -0
  25. package/dist/analyze_functions/processAccesses.js +0 -56
  26. package/dist/analyze_functions/processFiles.js +0 -554
  27. package/dist/analyze_functions/processImportClauses.js +0 -88
  28. package/dist/analyze_functions/processInheritances.js +0 -74
  29. package/dist/analyze_functions/processInvocations.js +0 -50
  30. package/dist/famix_functions/famix_functions.js +0 -523
  31. package/dist/famix_functions/famix_functions_associations.js +0 -238
  32. package/dist/famix_functions/famix_functions_index.js +0 -135
  33. package/dist/famix_functions/famix_functions_types.js +0 -115
  34. package/docs/.gitkeep +0 -0
  35. package/src/analyze_functions/processAccesses.ts +0 -58
  36. package/src/analyze_functions/processFiles.ts +0 -667
  37. package/src/analyze_functions/processImportClauses.ts +0 -95
  38. package/src/analyze_functions/processInheritances.ts +0 -85
  39. package/src/analyze_functions/processInvocations.ts +0 -52
  40. package/src/famix_functions/famix_functions.ts +0 -562
  41. package/src/famix_functions/famix_functions_associations.ts +0 -242
  42. package/src/famix_functions/famix_functions_index.ts +0 -120
  43. package/src/famix_functions/famix_functions_types.ts +0 -106
package/src/analyze.ts CHANGED
@@ -1,31 +1,28 @@
1
1
  import { Project } from "ts-morph";
2
2
  import * as fs from 'fs';
3
3
  import { FamixRepository } from "./lib/famix/src/famix_repository";
4
- import { FamixFunctions } from "./famix_functions/famix_functions";
5
- import { ProcessFiles } from "./analyze_functions/processFiles";
6
- import { ProcessAccesses } from "./analyze_functions/processAccesses";
7
- import { ProcessInvocations } from "./analyze_functions/processInvocations";
8
- import { ProcessInheritances } from "./analyze_functions/processInheritances";
9
- import { ProcessImportClauses } from "./analyze_functions/processImportClauses";
10
-
11
4
  import { Logger } from "tslog";
5
+ import * as processFunctions from "./analyze_functions/process_functions";
6
+ import { EntityDictionary } from "./famix_functions/EntityDictionary";
7
+ import path from "path";
12
8
 
13
9
  export const logger = new Logger({ name: "ts2famix", minLevel: 3});
14
10
  export const config = { "expectGraphemes": false };
11
+ export const entityDictionary = new EntityDictionary();
15
12
 
16
13
  /**
17
14
  * This class is used to build a Famix model from a TypeScript source code
18
15
  */
19
16
  export class Importer {
20
17
 
21
- private project = new Project(); // The project containing the source files to analyze
22
- private famixFunctions = new FamixFunctions(); // FamixFunctions object, it contains all the functions needed to create Famix entities
23
- private processFiles = new ProcessFiles(this.famixFunctions); // ProcessFiles object, it contains all the functions needed to process the source files
24
- private processAccesses = new ProcessAccesses(this.famixFunctions); // ProcessAccesses object, it contains all the functions needed to process the accesses
25
- private processInvocations = new ProcessInvocations(this.famixFunctions); // ProcessInvocations object, it contains all the functions needed to process the invocations
26
- private processInheritances = new ProcessInheritances(this.famixFunctions); // ProcessInheritances object, it contains all the functions needed to process the inheritances
27
- private processImportClauses = new ProcessImportClauses(this.famixFunctions); // ProcessImportClauses object, it contains all the functions needed to process the import clauses
28
-
18
+ private project = new Project(
19
+ {
20
+ compilerOptions: {
21
+ baseUrl: "./test_src"
22
+ }
23
+ }
24
+ ); // The project containing the source files to analyze
25
+
29
26
  /**
30
27
  * Main method
31
28
  * @param paths An array of paths to the source files to analyze
@@ -36,9 +33,12 @@ export class Importer {
36
33
  // try {
37
34
  logger.debug(`famixRepFromPaths: paths: ${paths}`);
38
35
  this.project.addSourceFilesAtPaths(paths);
36
+
37
+ initFamixRep(this.project);
38
+
39
39
  this.processEntities(this.project);
40
40
 
41
- const famixRep = this.famixFunctions.getFamixRepository();
41
+ const famixRep = entityDictionary.famixRep;
42
42
  // }
43
43
  // catch (error) {
44
44
  // logger.error(`> ERROR: got exception ${error}. Exiting...`);
@@ -51,18 +51,19 @@ export class Importer {
51
51
  }
52
52
 
53
53
  private processEntities(project) {
54
- this.processFiles.processFiles(project.getSourceFiles());
55
- const accesses = this.processFiles.getAccesses();
56
- const methodsAndFunctionsWithId = this.processFiles.getMethodsAndFunctionsWithId();
57
- const classes = this.processFiles.getClasses();
58
- const interfaces = this.processFiles.getInterfaces();
59
- const modules = this.processFiles.getModules();
60
- const exports = this.processFiles.getExports();
61
-
62
- this.processImportClauses.processImportClauses(modules, exports);
63
- this.processAccesses.processAccesses(accesses);
64
- this.processInvocations.processInvocations(methodsAndFunctionsWithId);
65
- this.processInheritances.processInheritances(classes, interfaces);
54
+ processFunctions.processFiles(project.getSourceFiles());
55
+ const accesses = processFunctions.accessMap;
56
+ const methodsAndFunctionsWithId = processFunctions.methodsAndFunctionsWithId;
57
+ const classes = processFunctions.classes;
58
+ const interfaces = processFunctions.interfaces;
59
+ const modules = processFunctions.modules;
60
+ const exports = processFunctions.exportedMap;
61
+
62
+ processFunctions.processImportClausesForImportEqualsDeclarations(project.getSourceFiles(), exports);
63
+ processFunctions.processImportClausesForModules(modules, exports);
64
+ processFunctions.processAccesses(accesses);
65
+ processFunctions.processInvocations(methodsAndFunctionsWithId);
66
+ processFunctions.processInheritances(classes, interfaces);
66
67
  }
67
68
 
68
69
  /**
@@ -92,9 +93,25 @@ export class Importer {
92
93
  //const sourceFileNames = project.getSourceFiles().map(f => f.getFilePath()) as Array<string>;
93
94
 
94
95
  //const famixRep = this.famixRepFromPaths(sourceFileNames);
96
+
97
+ initFamixRep(project);
98
+
95
99
  this.processEntities(project);
96
100
 
97
- return this.famixFunctions.getFamixRepository();
101
+ return entityDictionary.famixRep;
98
102
  }
99
103
 
100
104
  }
105
+
106
+ function initFamixRep(project :Project ): void {
107
+
108
+ // get compiler options
109
+ const compilerOptions = project.getCompilerOptions();
110
+
111
+ // get baseUrl
112
+ const baseUrl = compilerOptions.baseUrl;
113
+
114
+ const absoluteBaseUrl = path.resolve(baseUrl);
115
+
116
+ entityDictionary.famixRep.setAbsolutePath(path.normalize(absoluteBaseUrl));
117
+ }