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.
- package/dist/analyze.js +37 -27
- package/dist/analyze_functions/process_functions.js +723 -0
- package/dist/famix_functions/EntityDictionary.js +798 -0
- package/dist/famix_functions/helpers_creation.js +97 -0
- package/dist/fqn.js +106 -95
- package/dist/lib/famix/src/famix_base_element.js +8 -4
- package/dist/lib/famix/src/famix_repository.js +32 -15
- package/dist/lib/famix/src/model/famix/class.js +1 -1
- package/dist/lib/ts-complex/cyclomatic-service.js +2 -3
- package/doc-uml/metamodel-full.svg +1 -0
- package/doc-uml/metamodel.svg +1 -0
- package/package.json +4 -4
- package/plantuml.jar +0 -0
- package/src/analyze.ts +46 -29
- package/src/analyze_functions/process_functions.ts +838 -0
- package/src/famix_functions/EntityDictionary.ts +915 -0
- package/src/famix_functions/helpers_creation.ts +77 -0
- package/src/fqn.ts +101 -92
- package/src/generate_uml.sh +3 -0
- package/src/lib/famix/src/famix_base_element.ts +9 -5
- package/src/lib/famix/src/famix_repository.ts +45 -23
- package/src/lib/famix/src/model/famix/class.ts +1 -1
- package/src/lib/ts-complex/cyclomatic-service.ts +2 -4
- package/src/ts2famix-cli.ts +1 -0
- package/dist/analyze_functions/processAccesses.js +0 -56
- package/dist/analyze_functions/processFiles.js +0 -554
- package/dist/analyze_functions/processImportClauses.js +0 -88
- package/dist/analyze_functions/processInheritances.js +0 -74
- package/dist/analyze_functions/processInvocations.js +0 -50
- package/dist/famix_functions/famix_functions.js +0 -523
- package/dist/famix_functions/famix_functions_associations.js +0 -238
- package/dist/famix_functions/famix_functions_index.js +0 -135
- package/dist/famix_functions/famix_functions_types.js +0 -115
- package/docs/.gitkeep +0 -0
- package/src/analyze_functions/processAccesses.ts +0 -58
- package/src/analyze_functions/processFiles.ts +0 -667
- package/src/analyze_functions/processImportClauses.ts +0 -95
- package/src/analyze_functions/processInheritances.ts +0 -85
- package/src/analyze_functions/processInvocations.ts +0 -52
- package/src/famix_functions/famix_functions.ts +0 -562
- package/src/famix_functions/famix_functions_associations.ts +0 -242
- package/src/famix_functions/famix_functions_index.ts +0 -120
- 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(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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 =
|
|
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
|
-
|
|
73
|
-
const accesses =
|
|
74
|
-
const methodsAndFunctionsWithId =
|
|
75
|
-
const classes =
|
|
76
|
-
const interfaces =
|
|
77
|
-
const modules =
|
|
78
|
-
const exports =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
|
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
|
+
}
|