ts2famix 1.3.1 → 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 (40) 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/ts-complex/cyclomatic-service.js +2 -3
  9. package/doc-uml/metamodel-full.svg +1 -0
  10. package/doc-uml/metamodel.svg +1 -0
  11. package/package.json +1 -1
  12. package/plantuml.jar +0 -0
  13. package/src/analyze.ts +46 -29
  14. package/src/analyze_functions/process_functions.ts +838 -0
  15. package/src/famix_functions/EntityDictionary.ts +915 -0
  16. package/src/famix_functions/helpers_creation.ts +77 -0
  17. package/src/fqn.ts +101 -92
  18. package/src/lib/famix/src/famix_base_element.ts +9 -5
  19. package/src/lib/famix/src/famix_repository.ts +45 -23
  20. package/src/lib/ts-complex/cyclomatic-service.ts +2 -4
  21. package/src/ts2famix-cli.ts +1 -0
  22. package/dist/analyze_functions/processAccesses.js +0 -56
  23. package/dist/analyze_functions/processFiles.js +0 -554
  24. package/dist/analyze_functions/processImportClauses.js +0 -88
  25. package/dist/analyze_functions/processInheritances.js +0 -74
  26. package/dist/analyze_functions/processInvocations.js +0 -50
  27. package/dist/famix_functions/famix_functions.js +0 -523
  28. package/dist/famix_functions/famix_functions_associations.js +0 -238
  29. package/dist/famix_functions/famix_functions_index.js +0 -135
  30. package/dist/famix_functions/famix_functions_types.js +0 -115
  31. package/docs/.gitkeep +0 -0
  32. package/src/analyze_functions/processAccesses.ts +0 -58
  33. package/src/analyze_functions/processFiles.ts +0 -667
  34. package/src/analyze_functions/processImportClauses.ts +0 -95
  35. package/src/analyze_functions/processInheritances.ts +0 -85
  36. package/src/analyze_functions/processInvocations.ts +0 -52
  37. package/src/famix_functions/famix_functions.ts +0 -562
  38. package/src/famix_functions/famix_functions_associations.ts +0 -242
  39. package/src/famix_functions/famix_functions_index.ts +0 -120
  40. package/src/famix_functions/famix_functions_types.ts +0 -106
package/dist/analyze.js CHANGED
@@ -22,31 +22,30 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Importer = exports.config = exports.logger = void 0;
29
+ exports.Importer = exports.entityDictionary = exports.config = exports.logger = void 0;
27
30
  const ts_morph_1 = require("ts-morph");
28
31
  const fs = __importStar(require("fs"));
29
- const famix_functions_1 = require("./famix_functions/famix_functions");
30
- const processFiles_1 = require("./analyze_functions/processFiles");
31
- const processAccesses_1 = require("./analyze_functions/processAccesses");
32
- const processInvocations_1 = require("./analyze_functions/processInvocations");
33
- const processInheritances_1 = require("./analyze_functions/processInheritances");
34
- const processImportClauses_1 = require("./analyze_functions/processImportClauses");
35
32
  const tslog_1 = require("tslog");
33
+ const processFunctions = __importStar(require("./analyze_functions/process_functions"));
34
+ const EntityDictionary_1 = require("./famix_functions/EntityDictionary");
35
+ const path_1 = __importDefault(require("path"));
36
36
  exports.logger = new tslog_1.Logger({ name: "ts2famix", minLevel: 3 });
37
37
  exports.config = { "expectGraphemes": false };
38
+ exports.entityDictionary = new EntityDictionary_1.EntityDictionary();
38
39
  /**
39
40
  * This class is used to build a Famix model from a TypeScript source code
40
41
  */
41
42
  class Importer {
42
43
  constructor() {
43
- this.project = new ts_morph_1.Project(); // The project containing the source files to analyze
44
- this.famixFunctions = new famix_functions_1.FamixFunctions(); // FamixFunctions object, it contains all the functions needed to create Famix entities
45
- this.processFiles = new processFiles_1.ProcessFiles(this.famixFunctions); // ProcessFiles object, it contains all the functions needed to process the source files
46
- this.processAccesses = new processAccesses_1.ProcessAccesses(this.famixFunctions); // ProcessAccesses object, it contains all the functions needed to process the accesses
47
- this.processInvocations = new processInvocations_1.ProcessInvocations(this.famixFunctions); // ProcessInvocations object, it contains all the functions needed to process the invocations
48
- this.processInheritances = new processInheritances_1.ProcessInheritances(this.famixFunctions); // ProcessInheritances object, it contains all the functions needed to process the inheritances
49
- this.processImportClauses = new processImportClauses_1.ProcessImportClauses(this.famixFunctions); // ProcessImportClauses object, it contains all the functions needed to process the import clauses
44
+ this.project = new ts_morph_1.Project({
45
+ compilerOptions: {
46
+ baseUrl: "./test_src"
47
+ }
48
+ }); // The project containing the source files to analyze
50
49
  }
51
50
  /**
52
51
  * Main method
@@ -57,8 +56,9 @@ class Importer {
57
56
  // try {
58
57
  exports.logger.debug(`famixRepFromPaths: paths: ${paths}`);
59
58
  this.project.addSourceFilesAtPaths(paths);
59
+ initFamixRep(this.project);
60
60
  this.processEntities(this.project);
61
- const famixRep = this.famixFunctions.getFamixRepository();
61
+ const famixRep = exports.entityDictionary.famixRep;
62
62
  // }
63
63
  // catch (error) {
64
64
  // logger.error(`> ERROR: got exception ${error}. Exiting...`);
@@ -69,17 +69,18 @@ class Importer {
69
69
  return famixRep;
70
70
  }
71
71
  processEntities(project) {
72
- this.processFiles.processFiles(project.getSourceFiles());
73
- const accesses = this.processFiles.getAccesses();
74
- const methodsAndFunctionsWithId = this.processFiles.getMethodsAndFunctionsWithId();
75
- const classes = this.processFiles.getClasses();
76
- const interfaces = this.processFiles.getInterfaces();
77
- const modules = this.processFiles.getModules();
78
- const exports = this.processFiles.getExports();
79
- this.processImportClauses.processImportClauses(modules, exports);
80
- this.processAccesses.processAccesses(accesses);
81
- this.processInvocations.processInvocations(methodsAndFunctionsWithId);
82
- this.processInheritances.processInheritances(classes, interfaces);
72
+ processFunctions.processFiles(project.getSourceFiles());
73
+ const accesses = processFunctions.accessMap;
74
+ const methodsAndFunctionsWithId = processFunctions.methodsAndFunctionsWithId;
75
+ const classes = processFunctions.classes;
76
+ const interfaces = processFunctions.interfaces;
77
+ const modules = processFunctions.modules;
78
+ const exports = processFunctions.exportedMap;
79
+ processFunctions.processImportClausesForImportEqualsDeclarations(project.getSourceFiles(), exports);
80
+ processFunctions.processImportClausesForModules(modules, exports);
81
+ processFunctions.processAccesses(accesses);
82
+ processFunctions.processInvocations(methodsAndFunctionsWithId);
83
+ processFunctions.processInheritances(classes, interfaces);
83
84
  }
84
85
  /**
85
86
  * Main method for tests
@@ -103,8 +104,17 @@ class Importer {
103
104
  famixRepFromProject(project) {
104
105
  //const sourceFileNames = project.getSourceFiles().map(f => f.getFilePath()) as Array<string>;
105
106
  //const famixRep = this.famixRepFromPaths(sourceFileNames);
107
+ initFamixRep(project);
106
108
  this.processEntities(project);
107
- return this.famixFunctions.getFamixRepository();
109
+ return exports.entityDictionary.famixRep;
108
110
  }
109
111
  }
110
112
  exports.Importer = Importer;
113
+ function initFamixRep(project) {
114
+ // get compiler options
115
+ const compilerOptions = project.getCompilerOptions();
116
+ // get baseUrl
117
+ const baseUrl = compilerOptions.baseUrl;
118
+ const absoluteBaseUrl = path_1.default.resolve(baseUrl);
119
+ exports.entityDictionary.famixRep.setAbsolutePath(path_1.default.normalize(absoluteBaseUrl));
120
+ }