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/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(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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 =
|
|
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
|
-
|
|
55
|
-
const accesses =
|
|
56
|
-
const methodsAndFunctionsWithId =
|
|
57
|
-
const classes =
|
|
58
|
-
const interfaces =
|
|
59
|
-
const modules =
|
|
60
|
-
const exports =
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
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
|
+
}
|