ts2famix 1.1.0 → 1.2.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/README.md +3 -3
- package/dist/analyze.js +8 -5
- package/dist/analyze_functions/processAccesses.js +7 -6
- package/dist/analyze_functions/processFiles.js +43 -43
- package/dist/analyze_functions/processImportClauses.js +25 -7
- package/dist/analyze_functions/processInheritances.js +8 -7
- package/dist/analyze_functions/processInvocations.js +6 -5
- package/dist/famix_functions/famix_functions.js +19 -21
- package/dist/famix_functions/famix_functions_associations.js +29 -14
- package/dist/famix_functions/famix_functions_index.js +26 -15
- package/dist/famix_functions/famix_functions_types.js +2 -1
- package/dist/lib/famix/src/famix_repository.js +6 -0
- package/dist/lib/famix/src/model/famix/access.js +3 -3
- package/dist/lib/famix/src/model/famix/accessor.js +3 -3
- package/dist/lib/famix/src/model/famix/alias.js +3 -3
- package/dist/lib/famix/src/model/famix/association.js +3 -3
- package/dist/lib/famix/src/model/famix/behavioral_entity.js +6 -6
- package/dist/lib/famix/src/model/famix/class.js +3 -3
- package/dist/lib/famix/src/model/famix/comment.js +3 -3
- package/dist/lib/famix/src/model/famix/container_entity.js +3 -3
- package/dist/lib/famix/src/model/famix/decorator.js +3 -3
- package/dist/lib/famix/src/model/famix/entity.js +3 -3
- package/dist/lib/famix/src/model/famix/enum.js +3 -3
- package/dist/lib/famix/src/model/famix/enum_value.js +3 -3
- package/dist/lib/famix/src/model/famix/function.js +3 -3
- package/dist/lib/famix/src/model/famix/implicit_variable.js +3 -3
- package/dist/lib/famix/src/model/famix/import_clause.js +3 -3
- package/dist/lib/famix/src/model/famix/index.js +3 -7
- package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +3 -3
- package/dist/lib/famix/src/model/famix/inheritance.js +3 -3
- package/dist/lib/famix/src/model/famix/interface.js +3 -3
- package/dist/lib/famix/src/model/famix/invocation.js +3 -3
- package/dist/lib/famix/src/model/famix/method.js +3 -3
- package/dist/lib/famix/src/model/famix/module.js +3 -3
- package/dist/lib/famix/src/model/famix/named_entity.js +4 -4
- package/dist/lib/famix/src/model/famix/namespace.js +3 -3
- package/dist/lib/famix/src/model/famix/parameter.js +3 -3
- package/dist/lib/famix/src/model/famix/{type_parameter.js → parameter_type.js} +7 -7
- package/dist/lib/famix/src/model/famix/parameterizable_class.js +11 -11
- package/dist/lib/famix/src/model/famix/parameterizable_interface.js +11 -11
- package/dist/lib/famix/src/model/famix/parameterized_type.js +3 -3
- package/dist/lib/famix/src/model/famix/primitive_type.js +3 -3
- package/dist/lib/famix/src/model/famix/property.js +3 -3
- package/dist/lib/famix/src/model/famix/reference.js +3 -3
- package/dist/lib/famix/src/model/famix/scoping_entity.js +6 -5
- package/dist/lib/famix/src/model/famix/script_entity.js +3 -3
- package/dist/lib/famix/src/model/famix/source_anchor.js +3 -3
- package/dist/lib/famix/src/model/famix/source_language.js +8 -3
- package/dist/lib/famix/src/model/famix/sourced_entity.js +7 -3
- package/dist/lib/famix/src/model/famix/structural_entity.js +3 -3
- package/dist/lib/famix/src/model/famix/text_anchor.js +3 -3
- package/dist/lib/famix/src/model/famix/type.js +3 -3
- package/dist/lib/famix/src/model/famix/variable.js +3 -3
- package/dist/ts2famix-cli.js +16 -3
- package/package.json +14 -13
- package/src/analyze.ts +10 -4
- package/src/analyze_functions/processAccesses.ts +7 -6
- package/src/analyze_functions/processFiles.ts +44 -46
- package/src/analyze_functions/processImportClauses.ts +25 -7
- package/src/analyze_functions/processInheritances.ts +8 -7
- package/src/analyze_functions/processInvocations.ts +6 -5
- package/src/famix_functions/famix_functions.ts +20 -23
- package/src/famix_functions/famix_functions_associations.ts +32 -15
- package/src/famix_functions/famix_functions_index.ts +28 -18
- package/src/famix_functions/famix_functions_types.ts +2 -1
- package/src/generate_uml.sh +1 -0
- package/src/lib/famix/src/famix_repository.ts +12 -3
- package/src/lib/famix/src/model/famix/access.ts +3 -3
- package/src/lib/famix/src/model/famix/accessor.ts +3 -3
- package/src/lib/famix/src/model/famix/alias.ts +3 -3
- package/src/lib/famix/src/model/famix/association.ts +3 -3
- package/src/lib/famix/src/model/famix/behavioral_entity.ts +8 -8
- package/src/lib/famix/src/model/famix/class.ts +3 -3
- package/src/lib/famix/src/model/famix/comment.ts +3 -3
- package/src/lib/famix/src/model/famix/container_entity.ts +3 -3
- package/src/lib/famix/src/model/famix/decorator.ts +3 -3
- package/src/lib/famix/src/model/famix/entity.ts +3 -3
- package/src/lib/famix/src/model/famix/enum.ts +3 -3
- package/src/lib/famix/src/model/famix/enum_value.ts +3 -3
- package/src/lib/famix/src/model/famix/function.ts +3 -3
- package/src/lib/famix/src/model/famix/implicit_variable.ts +3 -3
- package/src/lib/famix/src/model/famix/import_clause.ts +3 -3
- package/src/lib/famix/src/model/famix/index.ts +40 -42
- package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +3 -3
- package/src/lib/famix/src/model/famix/inheritance.ts +3 -3
- package/src/lib/famix/src/model/famix/interface.ts +3 -3
- package/src/lib/famix/src/model/famix/invocation.ts +3 -3
- package/src/lib/famix/src/model/famix/method.ts +3 -3
- package/src/lib/famix/src/model/famix/module.ts +3 -3
- package/src/lib/famix/src/model/famix/named_entity.ts +4 -4
- package/src/lib/famix/src/model/famix/namespace.ts +3 -3
- package/src/lib/famix/src/model/famix/parameter.ts +3 -3
- package/src/lib/famix/src/model/famix/{type_parameter.ts → parameter_type.ts} +9 -9
- package/src/lib/famix/src/model/famix/parameterizable_class.ts +12 -12
- package/src/lib/famix/src/model/famix/parameterizable_interface.ts +12 -12
- package/src/lib/famix/src/model/famix/parameterized_type.ts +3 -3
- package/src/lib/famix/src/model/famix/primitive_type.ts +3 -3
- package/src/lib/famix/src/model/famix/property.ts +3 -3
- package/src/lib/famix/src/model/famix/reference.ts +3 -3
- package/src/lib/famix/src/model/famix/scoping_entity.ts +6 -5
- package/src/lib/famix/src/model/famix/script_entity.ts +3 -3
- package/src/lib/famix/src/model/famix/source_anchor.ts +3 -3
- package/src/lib/famix/src/model/famix/source_language.ts +9 -3
- package/src/lib/famix/src/model/famix/sourced_entity.ts +6 -3
- package/src/lib/famix/src/model/famix/structural_entity.ts +3 -3
- package/src/lib/famix/src/model/famix/text_anchor.ts +3 -3
- package/src/lib/famix/src/model/famix/type.ts +3 -3
- package/src/lib/famix/src/model/famix/variable.ts +3 -3
- package/src/ts2famix-cli.ts +17 -3
- package/dist/lib/famix/src/model/famix/c_source_language.js +0 -16
- package/dist/lib/famix/src/model/famix/custom_source_language.js +0 -23
- package/src/lib/famix/src/model/famix/c_source_language.ts +0 -15
- package/src/lib/famix/src/model/famix/custom_source_language.ts +0 -27
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ cp JSONModels/projectName.json ~/Pharo/images/Moose\ Suite\ 10\ \(stable\)/.
|
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
Then, in a Moose Playground, do :
|
|
41
|
-
```
|
|
41
|
+
```smalltalk
|
|
42
42
|
Metacello new
|
|
43
43
|
githubUser: 'fuhrmanator' project: 'FamixTypeScript' commitish: 'master' path: 'src';
|
|
44
44
|
baseline: 'FamixTypeScript';
|
|
@@ -51,7 +51,7 @@ Then, generate the metamodel with :
|
|
|
51
51
|
```Library > Famix > Manage metamodels > Regenerate all metamodels```
|
|
52
52
|
|
|
53
53
|
Then, in a Moose Playground, do :
|
|
54
|
-
```
|
|
54
|
+
```smalltalk
|
|
55
55
|
'projectName.json' asFileReference readStreamDo:
|
|
56
56
|
[ :stream | model := FamixTypeScriptModel new
|
|
57
57
|
importFromJSONStream: stream. model install ].
|
|
@@ -104,6 +104,6 @@ ts-node src/famix2puml.ts -i JSONModels/projectName.json -o PUMLModels/projectNa
|
|
|
104
104
|
|
|
105
105
|
## TypeScript Metamodel API documentation (visualization)
|
|
106
106
|
|
|
107
|
-
The following was generated by CI using [tplant](https://github.com/bafolts/tplant), in a similar fashion described [here](https://modularmoose.org/2021
|
|
107
|
+
The following was generated by CI using [tplant](https://github.com/bafolts/tplant), in a similar fashion described [here](https://modularmoose.org/posts/2021-07-19-automatic-metamodel-documentation-generation).
|
|
108
108
|
|
|
109
109
|

|
package/dist/analyze.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.Importer = void 0;
|
|
26
|
+
exports.Importer = exports.config = exports.logger = void 0;
|
|
27
27
|
const ts_morph_1 = require("ts-morph");
|
|
28
28
|
const fs = __importStar(require("fs"));
|
|
29
29
|
const famix_functions_1 = require("./famix_functions/famix_functions");
|
|
@@ -32,6 +32,9 @@ const processAccesses_1 = require("./analyze_functions/processAccesses");
|
|
|
32
32
|
const processInvocations_1 = require("./analyze_functions/processInvocations");
|
|
33
33
|
const processInheritances_1 = require("./analyze_functions/processInheritances");
|
|
34
34
|
const processImportClauses_1 = require("./analyze_functions/processImportClauses");
|
|
35
|
+
const tslog_1 = require("tslog");
|
|
36
|
+
exports.logger = new tslog_1.Logger({ name: "ts2famix", minLevel: 3 });
|
|
37
|
+
exports.config = { "expectGraphemes": false };
|
|
35
38
|
/**
|
|
36
39
|
* This class is used to build a Famix model from a TypeScript source code
|
|
37
40
|
*/
|
|
@@ -52,15 +55,15 @@ class Importer {
|
|
|
52
55
|
*/
|
|
53
56
|
famixRepFromPaths(paths) {
|
|
54
57
|
// try {
|
|
55
|
-
|
|
58
|
+
exports.logger.debug(`famixRepFromPaths: paths: ${paths}`);
|
|
56
59
|
this.project.addSourceFilesAtPaths(paths);
|
|
57
60
|
this.processEntities(this.project);
|
|
58
61
|
const famixRep = this.famixFunctions.getFamixRepository();
|
|
59
62
|
// }
|
|
60
63
|
// catch (error) {
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
+
// logger.error(`> ERROR: got exception ${error}. Exiting...`);
|
|
65
|
+
// logger.error(error.message);
|
|
66
|
+
// logger.error(error.stack);
|
|
64
67
|
// process.exit(1);
|
|
65
68
|
// }
|
|
66
69
|
return famixRep;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessAccesses = void 0;
|
|
4
|
+
const analyze_1 = require("../analyze");
|
|
4
5
|
/**
|
|
5
6
|
* This class is used to build a Famix model for the accesses
|
|
6
7
|
*/
|
|
@@ -17,15 +18,15 @@ class ProcessAccesses {
|
|
|
17
18
|
* @param accessMap A map of parameters, variables, properties and enum members with their id
|
|
18
19
|
*/
|
|
19
20
|
processAccesses(accessMap) {
|
|
20
|
-
|
|
21
|
+
analyze_1.logger.debug(`processAccesses: Creating accesses:`);
|
|
21
22
|
accessMap.forEach((v, id) => {
|
|
22
|
-
|
|
23
|
+
analyze_1.logger.debug(`processAccesses: Accesses to ${v.getName()}`);
|
|
23
24
|
try {
|
|
24
25
|
const temp_nodes = v.findReferencesAsNodes();
|
|
25
26
|
temp_nodes.forEach(node => this.processNodeForAccesses(node, id));
|
|
26
27
|
}
|
|
27
28
|
catch (error) {
|
|
28
|
-
|
|
29
|
+
analyze_1.logger.error(`> WARNING: got exception ${error}. Continuing...`);
|
|
29
30
|
}
|
|
30
31
|
});
|
|
31
32
|
}
|
|
@@ -41,14 +42,14 @@ class ProcessAccesses {
|
|
|
41
42
|
// check for a node whose first ancestor is a property declaration and bail?
|
|
42
43
|
// This may be a bug in ts-morph?
|
|
43
44
|
if (n.getFirstAncestorOrThrow().getKindName() === "PropertyDeclaration") {
|
|
44
|
-
|
|
45
|
+
analyze_1.logger.debug(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})'s first ancestor is a PropertyDeclaration. Skipping...`);
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
48
|
this.famixFunctions.createFamixAccess(n, id);
|
|
48
|
-
|
|
49
|
+
analyze_1.logger.debug(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})`);
|
|
49
50
|
}
|
|
50
51
|
catch (error) {
|
|
51
|
-
|
|
52
|
+
analyze_1.logger.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol().getFullyQualifiedName()}. Continuing...`);
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
}
|
|
@@ -28,6 +28,7 @@ const ts_morph_1 = require("ts-morph");
|
|
|
28
28
|
const Famix = __importStar(require("../lib/famix/src/model/famix"));
|
|
29
29
|
const cyclomatic_service_1 = require("../lib/ts-complex/cyclomatic-service");
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
|
+
const analyze_1 = require("../analyze");
|
|
31
32
|
/**
|
|
32
33
|
* This class is used to build a Famix model for an array of source files
|
|
33
34
|
*/
|
|
@@ -51,7 +52,7 @@ class ProcessFiles {
|
|
|
51
52
|
*/
|
|
52
53
|
processFiles(sourceFiles) {
|
|
53
54
|
sourceFiles.forEach(file => {
|
|
54
|
-
|
|
55
|
+
analyze_1.logger.info(`File: >>>>>>>>>> ${file.getFilePath()}`);
|
|
55
56
|
// Computes the cyclomatic complexity metrics for the current source file if it exists (i.e. if it is not from a jest test)
|
|
56
57
|
if (fs.existsSync(file.getFilePath()))
|
|
57
58
|
this.currentCC = (0, cyclomatic_service_1.calculate)(file.getFilePath());
|
|
@@ -112,7 +113,7 @@ class ProcessFiles {
|
|
|
112
113
|
this.modules.push(f);
|
|
113
114
|
}
|
|
114
115
|
const fmxFile = this.famixFunctions.createOrGetFamixFile(f, isModule);
|
|
115
|
-
|
|
116
|
+
analyze_1.logger.debug(`processFile: file: ${f.getBaseName()}, fqn = ${fmxFile.getFullyQualifiedName()}`);
|
|
116
117
|
this.processComments(f, fmxFile);
|
|
117
118
|
this.processAliases(f, fmxFile);
|
|
118
119
|
this.processClasses(f, fmxFile);
|
|
@@ -129,7 +130,7 @@ class ProcessFiles {
|
|
|
129
130
|
*/
|
|
130
131
|
processNamespace(m) {
|
|
131
132
|
const fmxNamespace = this.famixFunctions.createOrGetFamixNamespace(m);
|
|
132
|
-
|
|
133
|
+
analyze_1.logger.debug(`processNamespace: namespace: ${m.getName()}, (${m.getType().getText()}), ${fmxNamespace.getFullyQualifiedName()}`);
|
|
133
134
|
this.processComments(m, fmxNamespace);
|
|
134
135
|
this.processAliases(m, fmxNamespace);
|
|
135
136
|
this.processClasses(m, fmxNamespace);
|
|
@@ -146,7 +147,7 @@ class ProcessFiles {
|
|
|
146
147
|
* @param fmxScope The Famix model of the container
|
|
147
148
|
*/
|
|
148
149
|
processAliases(m, fmxScope) {
|
|
149
|
-
|
|
150
|
+
analyze_1.logger.debug(`processAliases: ---------- Finding Aliases:`);
|
|
150
151
|
m.getTypeAliases().forEach(a => {
|
|
151
152
|
const fmxAlias = this.processAlias(a);
|
|
152
153
|
fmxScope.addAlias(fmxAlias);
|
|
@@ -158,7 +159,7 @@ class ProcessFiles {
|
|
|
158
159
|
* @param fmxScope The Famix model of the container
|
|
159
160
|
*/
|
|
160
161
|
processClasses(m, fmxScope) {
|
|
161
|
-
|
|
162
|
+
analyze_1.logger.debug(`processClasses: ---------- Finding Classes:`);
|
|
162
163
|
m.getClasses().forEach(c => {
|
|
163
164
|
const fmxClass = this.processClass(c);
|
|
164
165
|
fmxScope.addType(fmxClass);
|
|
@@ -170,7 +171,7 @@ class ProcessFiles {
|
|
|
170
171
|
* @param fmxScope The Famix model of the container
|
|
171
172
|
*/
|
|
172
173
|
processInterfaces(m, fmxScope) {
|
|
173
|
-
|
|
174
|
+
analyze_1.logger.debug(`processInterfaces: ---------- Finding Interfaces:`);
|
|
174
175
|
m.getInterfaces().forEach(i => {
|
|
175
176
|
const fmxInterface = this.processInterface(i);
|
|
176
177
|
fmxScope.addType(fmxInterface);
|
|
@@ -182,7 +183,7 @@ class ProcessFiles {
|
|
|
182
183
|
* @param fmxScope The Famix model of the container
|
|
183
184
|
*/
|
|
184
185
|
processVariables(m, fmxScope) {
|
|
185
|
-
|
|
186
|
+
analyze_1.logger.debug(`processVariables: ---------- Finding Variables:`);
|
|
186
187
|
m.getVariableStatements().forEach(v => {
|
|
187
188
|
const fmxVariables = this.processVariableStatement(v);
|
|
188
189
|
fmxVariables.forEach(fmxVariable => {
|
|
@@ -196,7 +197,7 @@ class ProcessFiles {
|
|
|
196
197
|
* @param fmxScope The Famix model of the container
|
|
197
198
|
*/
|
|
198
199
|
processEnums(m, fmxScope) {
|
|
199
|
-
|
|
200
|
+
analyze_1.logger.debug(`processEnums: ---------- Finding Enums:`);
|
|
200
201
|
m.getEnums().forEach(e => {
|
|
201
202
|
const fmxEnum = this.processEnum(e);
|
|
202
203
|
fmxScope.addType(fmxEnum);
|
|
@@ -208,7 +209,7 @@ class ProcessFiles {
|
|
|
208
209
|
* @param fmxScope The Famix model of the container
|
|
209
210
|
*/
|
|
210
211
|
processFunctions(m, fmxScope) {
|
|
211
|
-
|
|
212
|
+
analyze_1.logger.debug(`Finding Functions:`);
|
|
212
213
|
m.getFunctions().forEach(f => {
|
|
213
214
|
const fmxFunction = this.processFunction(f);
|
|
214
215
|
fmxScope.addFunction(fmxFunction);
|
|
@@ -220,7 +221,7 @@ class ProcessFiles {
|
|
|
220
221
|
* @param fmxScope The Famix model of the container
|
|
221
222
|
*/
|
|
222
223
|
processNamespaces(m, fmxScope) {
|
|
223
|
-
|
|
224
|
+
analyze_1.logger.debug(`Finding Namespaces:`);
|
|
224
225
|
m.getModules().forEach(md => {
|
|
225
226
|
const fmxNsp = this.processNamespace(md);
|
|
226
227
|
fmxScope.addNamespace(fmxNsp);
|
|
@@ -233,7 +234,7 @@ class ProcessFiles {
|
|
|
233
234
|
*/
|
|
234
235
|
processAlias(a) {
|
|
235
236
|
const fmxAlias = this.famixFunctions.createFamixAlias(a);
|
|
236
|
-
|
|
237
|
+
analyze_1.logger.debug(`Alias: ${a.getName()}, (${a.getType().getText()}), fqn = ${fmxAlias.getFullyQualifiedName()}`);
|
|
237
238
|
this.processComments(a, fmxAlias);
|
|
238
239
|
return fmxAlias;
|
|
239
240
|
}
|
|
@@ -245,7 +246,7 @@ class ProcessFiles {
|
|
|
245
246
|
processClass(c) {
|
|
246
247
|
this.classes.push(c);
|
|
247
248
|
const fmxClass = this.famixFunctions.createOrGetFamixClass(c);
|
|
248
|
-
|
|
249
|
+
analyze_1.logger.debug(`Class: ${c.getName()}, (${c.getType().getText()}), fqn = ${fmxClass.getFullyQualifiedName()}`);
|
|
249
250
|
this.processComments(c, fmxClass);
|
|
250
251
|
this.processDecorators(c, fmxClass);
|
|
251
252
|
this.processStructuredType(c, fmxClass);
|
|
@@ -271,7 +272,7 @@ class ProcessFiles {
|
|
|
271
272
|
processInterface(i) {
|
|
272
273
|
this.interfaces.push(i);
|
|
273
274
|
const fmxInterface = this.famixFunctions.createOrGetFamixInterface(i);
|
|
274
|
-
|
|
275
|
+
analyze_1.logger.debug(`Interface: ${i.getName()}, (${i.getType().getText()}), fqn = ${fmxInterface.getFullyQualifiedName()}`);
|
|
275
276
|
this.processComments(i, fmxInterface);
|
|
276
277
|
this.processStructuredType(i, fmxInterface);
|
|
277
278
|
return fmxInterface;
|
|
@@ -282,7 +283,7 @@ class ProcessFiles {
|
|
|
282
283
|
* @param fmxScope The Famix model of the structured type
|
|
283
284
|
*/
|
|
284
285
|
processStructuredType(c, fmxScope) {
|
|
285
|
-
|
|
286
|
+
analyze_1.logger.debug(`Finding Properties and Methods:`);
|
|
286
287
|
if (fmxScope instanceof Famix.ParameterizableClass || fmxScope instanceof Famix.ParameterizableInterface) {
|
|
287
288
|
this.processTypeParameters(c, fmxScope);
|
|
288
289
|
}
|
|
@@ -302,15 +303,15 @@ class ProcessFiles {
|
|
|
302
303
|
*/
|
|
303
304
|
processProperty(p) {
|
|
304
305
|
const fmxProperty = this.famixFunctions.createFamixProperty(p);
|
|
305
|
-
|
|
306
|
-
|
|
306
|
+
analyze_1.logger.debug(`property: ${p.getName()}, (${p.getType().getText()}), fqn = ${fmxProperty.getFullyQualifiedName()}`);
|
|
307
|
+
analyze_1.logger.debug(` ---> It's a Property${(p instanceof ts_morph_1.PropertySignature) ? "Signature" : "Declaration"}!`);
|
|
307
308
|
const ancestor = p.getFirstAncestorOrThrow();
|
|
308
|
-
|
|
309
|
+
analyze_1.logger.debug(` ---> Its first ancestor is a ${ancestor.getKindName()}`);
|
|
309
310
|
if (!(p instanceof ts_morph_1.PropertySignature)) {
|
|
310
311
|
this.processDecorators(p, fmxProperty);
|
|
311
312
|
// only add access if the p's first ancestor is not a PropertyDeclaration
|
|
312
313
|
if (ancestor.getKindName() !== "PropertyDeclaration") {
|
|
313
|
-
|
|
314
|
+
analyze_1.logger.debug(`adding access: ${p.getName()}, (${p.getType().getText()}) Famix ${fmxProperty.getName()}`);
|
|
314
315
|
this.accessMap.set(fmxProperty.id, p);
|
|
315
316
|
}
|
|
316
317
|
}
|
|
@@ -324,7 +325,7 @@ class ProcessFiles {
|
|
|
324
325
|
*/
|
|
325
326
|
processMethod(m) {
|
|
326
327
|
const fmxMethod = this.famixFunctions.createFamixMethod(m, this.currentCC);
|
|
327
|
-
|
|
328
|
+
analyze_1.logger.debug(`Method: ${!(m instanceof ts_morph_1.ConstructorDeclaration) ? m.getName() : "constructor"}, (${m.getType().getText()}), parent: ${m.getParent().getName()}, fqn = ${fmxMethod.getFullyQualifiedName()}`);
|
|
328
329
|
this.processComments(m, fmxMethod);
|
|
329
330
|
this.processTypeParameters(m, fmxMethod);
|
|
330
331
|
this.processParameters(m, fmxMethod);
|
|
@@ -348,7 +349,7 @@ class ProcessFiles {
|
|
|
348
349
|
*/
|
|
349
350
|
processFunction(f) {
|
|
350
351
|
const fmxFunction = this.famixFunctions.createFamixFunction(f, this.currentCC);
|
|
351
|
-
|
|
352
|
+
analyze_1.logger.debug(`Function: ${(f.getName()) ? f.getName() : "anonymous"}, (${f.getType().getText()}), fqn = ${fmxFunction.getFullyQualifiedName()}`);
|
|
352
353
|
this.processComments(f, fmxFunction);
|
|
353
354
|
this.processAliases(f, fmxFunction);
|
|
354
355
|
this.processTypeParameters(f, fmxFunction);
|
|
@@ -368,7 +369,7 @@ class ProcessFiles {
|
|
|
368
369
|
* @param fmxScope The Famix model of the function or the method
|
|
369
370
|
*/
|
|
370
371
|
processFunctionExpressions(f, fmxScope) {
|
|
371
|
-
|
|
372
|
+
analyze_1.logger.debug(`Finding Function Expressions:`);
|
|
372
373
|
const functionExpressions = f.getDescendantsOfKind(ts_morph_1.SyntaxKind.FunctionExpression);
|
|
373
374
|
functionExpressions.forEach((func) => {
|
|
374
375
|
const fmxFunc = this.processFunction(func);
|
|
@@ -381,7 +382,7 @@ class ProcessFiles {
|
|
|
381
382
|
* @param fmxScope The Famix model of the method or the function
|
|
382
383
|
*/
|
|
383
384
|
processParameters(m, fmxScope) {
|
|
384
|
-
|
|
385
|
+
analyze_1.logger.debug(`Finding Parameters:`);
|
|
385
386
|
m.getParameters().forEach(param => {
|
|
386
387
|
const fmxParam = this.processParameter(param);
|
|
387
388
|
fmxScope.addParameter(fmxParam);
|
|
@@ -394,12 +395,12 @@ class ProcessFiles {
|
|
|
394
395
|
*/
|
|
395
396
|
processParameter(p) {
|
|
396
397
|
const fmxParam = this.famixFunctions.createFamixParameter(p);
|
|
397
|
-
|
|
398
|
+
analyze_1.logger.debug(`parameter: ${p.getName()}, (${p.getType().getText()}), fqn = ${fmxParam.getFullyQualifiedName()}`);
|
|
398
399
|
this.processComments(p, fmxParam);
|
|
399
400
|
this.processDecorators(p, fmxParam);
|
|
400
401
|
const parent = p.getParent();
|
|
401
402
|
if (!(parent instanceof ts_morph_1.MethodSignature)) {
|
|
402
|
-
|
|
403
|
+
analyze_1.logger.debug(`adding access: ${p.getName()}, (${p.getType().getText()}) Famix ${fmxParam.getName()}`);
|
|
403
404
|
this.accessMap.set(fmxParam.id, p);
|
|
404
405
|
}
|
|
405
406
|
return fmxParam;
|
|
@@ -410,10 +411,10 @@ class ProcessFiles {
|
|
|
410
411
|
* @param fmxScope The Famix model of the class, the interface, the method or the function
|
|
411
412
|
*/
|
|
412
413
|
processTypeParameters(e, fmxScope) {
|
|
413
|
-
|
|
414
|
+
analyze_1.logger.debug(`Finding Type Parameters:`);
|
|
414
415
|
e.getTypeParameters().forEach(tp => {
|
|
415
416
|
const fmxParam = this.processTypeParameter(tp);
|
|
416
|
-
fmxScope.
|
|
417
|
+
fmxScope.addParameterType(fmxParam);
|
|
417
418
|
});
|
|
418
419
|
}
|
|
419
420
|
/**
|
|
@@ -422,8 +423,8 @@ class ProcessFiles {
|
|
|
422
423
|
* @returns A Famix.TypeParameter representing the type parameter
|
|
423
424
|
*/
|
|
424
425
|
processTypeParameter(tp) {
|
|
425
|
-
const fmxTypeParameter = this.famixFunctions.
|
|
426
|
-
|
|
426
|
+
const fmxTypeParameter = this.famixFunctions.createFamixParameterType(tp);
|
|
427
|
+
analyze_1.logger.debug(`type parameter: ${tp.getName()}, (${tp.getType().getText()}), fqn = ${fmxTypeParameter.getFullyQualifiedName()}`);
|
|
427
428
|
this.processComments(tp, fmxTypeParameter);
|
|
428
429
|
return fmxTypeParameter;
|
|
429
430
|
}
|
|
@@ -434,7 +435,7 @@ class ProcessFiles {
|
|
|
434
435
|
*/
|
|
435
436
|
processVariableStatement(v) {
|
|
436
437
|
const fmxVariables = new Array();
|
|
437
|
-
|
|
438
|
+
analyze_1.logger.debug(`Variable statement: ${v.getText()}, (${v.getType().getText()}), ${v.getDeclarationKindKeywords()[0]}, fqn = ${v.getDeclarations()[0].getName()}`);
|
|
438
439
|
v.getDeclarations().forEach(variable => {
|
|
439
440
|
const fmxVar = this.processVariable(variable);
|
|
440
441
|
this.processComments(v, fmxVar);
|
|
@@ -449,9 +450,9 @@ class ProcessFiles {
|
|
|
449
450
|
*/
|
|
450
451
|
processVariable(v) {
|
|
451
452
|
const fmxVar = this.famixFunctions.createFamixVariable(v);
|
|
452
|
-
|
|
453
|
+
analyze_1.logger.debug(`variable: ${v.getName()}, (${v.getType().getText()}), ${v.getInitializer() ? "initializer: " + v.getInitializer().getText() : "initializer: "}, fqn = ${fmxVar.getFullyQualifiedName()}`);
|
|
453
454
|
this.processComments(v, fmxVar);
|
|
454
|
-
|
|
455
|
+
analyze_1.logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxVar.getName()}`);
|
|
455
456
|
this.accessMap.set(fmxVar.id, v);
|
|
456
457
|
return fmxVar;
|
|
457
458
|
}
|
|
@@ -462,7 +463,7 @@ class ProcessFiles {
|
|
|
462
463
|
*/
|
|
463
464
|
processEnum(e) {
|
|
464
465
|
const fmxEnum = this.famixFunctions.createFamixEnum(e);
|
|
465
|
-
|
|
466
|
+
analyze_1.logger.debug(`enum: ${e.getName()}, (${e.getType().getText()}), fqn = ${fmxEnum.getFullyQualifiedName()}`);
|
|
466
467
|
this.processComments(e, fmxEnum);
|
|
467
468
|
e.getMembers().forEach(m => {
|
|
468
469
|
const fmxEnumValue = this.processEnumValue(m);
|
|
@@ -477,9 +478,9 @@ class ProcessFiles {
|
|
|
477
478
|
*/
|
|
478
479
|
processEnumValue(v) {
|
|
479
480
|
const fmxEnumValue = this.famixFunctions.createFamixEnumValue(v);
|
|
480
|
-
|
|
481
|
+
analyze_1.logger.debug(`enum value: ${v.getName()}, (${v.getType().getText()}), fqn = ${fmxEnumValue.getFullyQualifiedName()}`);
|
|
481
482
|
this.processComments(v, fmxEnumValue);
|
|
482
|
-
|
|
483
|
+
analyze_1.logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxEnumValue.getName()}`);
|
|
483
484
|
this.accessMap.set(fmxEnumValue.id, v);
|
|
484
485
|
return fmxEnumValue;
|
|
485
486
|
}
|
|
@@ -489,7 +490,7 @@ class ProcessFiles {
|
|
|
489
490
|
* @param fmxScope The Famix model of the class, the method, the parameter or the property
|
|
490
491
|
*/
|
|
491
492
|
processDecorators(e, fmxScope) {
|
|
492
|
-
|
|
493
|
+
analyze_1.logger.debug(`Finding Decorators:`);
|
|
493
494
|
e.getDecorators().forEach(dec => {
|
|
494
495
|
const fmxDec = this.processDecorator(dec, e);
|
|
495
496
|
fmxScope.addDecorator(fmxDec);
|
|
@@ -503,7 +504,7 @@ class ProcessFiles {
|
|
|
503
504
|
*/
|
|
504
505
|
processDecorator(d, e) {
|
|
505
506
|
const fmxDec = this.famixFunctions.createOrGetFamixDecorator(d, e);
|
|
506
|
-
|
|
507
|
+
analyze_1.logger.debug(`decorator: ${d.getName()}, (${d.getType().getText()}), fqn = ${fmxDec.getFullyQualifiedName()}`);
|
|
507
508
|
this.processComments(d, fmxDec);
|
|
508
509
|
return fmxDec;
|
|
509
510
|
}
|
|
@@ -513,13 +514,15 @@ class ProcessFiles {
|
|
|
513
514
|
* @param fmxScope The Famix model of the named entity
|
|
514
515
|
*/
|
|
515
516
|
processComments(e, fmxScope) {
|
|
516
|
-
|
|
517
|
+
analyze_1.logger.debug(`Process comments:`);
|
|
517
518
|
e.getLeadingCommentRanges().forEach(c => {
|
|
518
519
|
const fmxComment = this.processComment(c, fmxScope);
|
|
519
|
-
|
|
520
|
+
analyze_1.logger.debug(`leading comments, addComment: '${c.getText()}'`);
|
|
521
|
+
fmxScope.addComment(fmxComment); // redundant, but just in case
|
|
520
522
|
});
|
|
521
523
|
e.getTrailingCommentRanges().forEach(c => {
|
|
522
524
|
const fmxComment = this.processComment(c, fmxScope);
|
|
525
|
+
analyze_1.logger.debug(`trailing comments, addComment: '${c.getText()}'`);
|
|
523
526
|
fmxScope.addComment(fmxComment);
|
|
524
527
|
});
|
|
525
528
|
}
|
|
@@ -530,12 +533,9 @@ class ProcessFiles {
|
|
|
530
533
|
* @returns A Famix.Comment representing the comment
|
|
531
534
|
*/
|
|
532
535
|
processComment(c, fmxScope) {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
isJSDoc = true;
|
|
536
|
-
}
|
|
536
|
+
const isJSDoc = c.getText().startsWith("/**");
|
|
537
|
+
analyze_1.logger.debug(`processComment: comment: ${c.getText()}, isJSDoc = ${isJSDoc}`);
|
|
537
538
|
const fmxComment = this.famixFunctions.createFamixComment(c, fmxScope, isJSDoc);
|
|
538
|
-
console.info(`processComment: comment: ${c.getText()}`);
|
|
539
539
|
return fmxComment;
|
|
540
540
|
}
|
|
541
541
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessImportClauses = void 0;
|
|
4
|
+
const analyze_1 = require("../analyze");
|
|
4
5
|
/**
|
|
5
6
|
* This class is used to build a Famix model for the import clauses
|
|
6
7
|
*/
|
|
@@ -18,12 +19,12 @@ class ProcessImportClauses {
|
|
|
18
19
|
* @param exports An array of maps of exported declarations
|
|
19
20
|
*/
|
|
20
21
|
processImportClauses(modules, exports) {
|
|
21
|
-
|
|
22
|
+
analyze_1.logger.info(`processImportClauses: Creating import clauses:`);
|
|
22
23
|
modules.forEach(module => {
|
|
23
24
|
module.getImportDeclarations().forEach(impDecl => {
|
|
24
25
|
const path = this.getModulePath(impDecl);
|
|
25
26
|
impDecl.getNamedImports().forEach(namedImport => {
|
|
26
|
-
|
|
27
|
+
analyze_1.logger.debug(`processImportClauses: Importing (named) ${namedImport.getName()} from ${impDecl.getModuleSpecifierValue()}`);
|
|
27
28
|
const importedEntityName = namedImport.getName();
|
|
28
29
|
let importFoundInExports = false;
|
|
29
30
|
exports.forEach(e => {
|
|
@@ -31,17 +32,34 @@ class ProcessImportClauses {
|
|
|
31
32
|
importFoundInExports = true;
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
|
-
this.famixFunctions.
|
|
35
|
+
this.famixFunctions.createFamixImportClause({ importDeclaration: impDecl,
|
|
36
|
+
importer: module,
|
|
37
|
+
moduleSpecifierFilePath: path,
|
|
38
|
+
importElement: namedImport,
|
|
39
|
+
isInExports: importFoundInExports,
|
|
40
|
+
isDefaultExport: false });
|
|
35
41
|
});
|
|
36
42
|
const defaultImport = impDecl.getDefaultImport();
|
|
37
43
|
if (defaultImport !== undefined) {
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
analyze_1.logger.debug(`processImportClauses: Importing (default) ${defaultImport.getText()} from ${impDecl.getModuleSpecifierValue()}`);
|
|
45
|
+
// call with module, impDecl.getModuleSpecifierValue(), path, defaultImport, false, true
|
|
46
|
+
this.famixFunctions.createFamixImportClause({ importDeclaration: impDecl,
|
|
47
|
+
importer: module,
|
|
48
|
+
moduleSpecifierFilePath: path,
|
|
49
|
+
importElement: defaultImport,
|
|
50
|
+
isInExports: false,
|
|
51
|
+
isDefaultExport: true });
|
|
40
52
|
}
|
|
41
53
|
const namespaceImport = impDecl.getNamespaceImport();
|
|
42
54
|
if (namespaceImport !== undefined) {
|
|
43
|
-
|
|
44
|
-
this.famixFunctions.createFamixImportClause(
|
|
55
|
+
analyze_1.logger.debug(`processImportClauses: Importing (namespace) ${namespaceImport.getText()} from ${impDecl.getModuleSpecifierValue()}`);
|
|
56
|
+
this.famixFunctions.createFamixImportClause({ importDeclaration: impDecl,
|
|
57
|
+
importer: module,
|
|
58
|
+
moduleSpecifierFilePath: path,
|
|
59
|
+
importElement: namespaceImport,
|
|
60
|
+
isInExports: false,
|
|
61
|
+
isDefaultExport: false });
|
|
62
|
+
// this.famixFunctions.createFamixImportClause(module, impDecl.getModuleSpecifierValue(), path, namespaceImport, false, false);
|
|
45
63
|
}
|
|
46
64
|
});
|
|
47
65
|
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessInheritances = void 0;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const analyze_1 = require("../analyze");
|
|
5
6
|
/**
|
|
6
7
|
* This class is used to build a Famix model for the inheritances
|
|
7
8
|
*/
|
|
@@ -19,27 +20,27 @@ class ProcessInheritances {
|
|
|
19
20
|
* @param interfaces An array of interfaces
|
|
20
21
|
*/
|
|
21
22
|
processInheritances(classes, interfaces) {
|
|
22
|
-
|
|
23
|
+
analyze_1.logger.info(`processInheritances: Creating inheritances:`);
|
|
23
24
|
classes.forEach(cls => {
|
|
24
|
-
|
|
25
|
+
analyze_1.logger.debug(`processInheritances: Checking class inheritance for ${cls.getName()}`);
|
|
25
26
|
const extClass = cls.getBaseClass();
|
|
26
27
|
if (extClass !== undefined) {
|
|
27
28
|
this.famixFunctions.createFamixInheritance(cls, extClass);
|
|
28
|
-
|
|
29
|
+
analyze_1.logger.debug(`processInheritances: class: ${cls.getName()}, (${cls.getType().getText()}), extClass: ${extClass.getName()}, (${extClass.getType().getText()})`);
|
|
29
30
|
}
|
|
30
|
-
|
|
31
|
+
analyze_1.logger.debug(`processInheritances: Checking interface inheritance for ${cls.getName()}`);
|
|
31
32
|
const implementedInterfaces = this.getImplementedOrExtendedInterfaces(interfaces, cls);
|
|
32
33
|
implementedInterfaces.forEach(impInter => {
|
|
33
34
|
this.famixFunctions.createFamixInheritance(cls, impInter);
|
|
34
|
-
|
|
35
|
+
analyze_1.logger.debug(`processInheritances: class: ${cls.getName()}, (${cls.getType().getText()}), impInter: ${(impInter instanceof ts_morph_1.InterfaceDeclaration) ? impInter.getName() : impInter.getExpression().getText()}, (${(impInter instanceof ts_morph_1.InterfaceDeclaration) ? impInter.getType().getText() : impInter.getExpression().getText()})`);
|
|
35
36
|
});
|
|
36
37
|
});
|
|
37
38
|
interfaces.forEach(inter => {
|
|
38
|
-
|
|
39
|
+
analyze_1.logger.debug(`processInheritances: Checking interface inheritance for ${inter.getName()}`);
|
|
39
40
|
const extendedInterfaces = this.getImplementedOrExtendedInterfaces(interfaces, inter);
|
|
40
41
|
extendedInterfaces.forEach(extInter => {
|
|
41
42
|
this.famixFunctions.createFamixInheritance(inter, extInter);
|
|
42
|
-
|
|
43
|
+
analyze_1.logger.debug(`processInheritances: inter: ${inter.getName()}, (${inter.getType().getText()}), extInter: ${(extInter instanceof ts_morph_1.InterfaceDeclaration) ? extInter.getName() : extInter.getExpression().getText()}, (${(extInter instanceof ts_morph_1.InterfaceDeclaration) ? extInter.getType().getText() : extInter.getExpression().getText()})`);
|
|
43
44
|
});
|
|
44
45
|
});
|
|
45
46
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ProcessInvocations = void 0;
|
|
4
4
|
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const analyze_1 = require("../analyze");
|
|
5
6
|
/**
|
|
6
7
|
* This class is used to build a Famix model for the invocations
|
|
7
8
|
*/
|
|
@@ -18,15 +19,15 @@ class ProcessInvocations {
|
|
|
18
19
|
* @param methodsAndFunctionsWithId A map of methods and functions with their id
|
|
19
20
|
*/
|
|
20
21
|
processInvocations(methodsAndFunctionsWithId) {
|
|
21
|
-
|
|
22
|
+
analyze_1.logger.info(`Creating invocations:`);
|
|
22
23
|
methodsAndFunctionsWithId.forEach((m, id) => {
|
|
23
|
-
|
|
24
|
+
analyze_1.logger.debug(`Invocations to ${(m instanceof ts_morph_1.MethodDeclaration || m instanceof ts_morph_1.GetAccessorDeclaration || m instanceof ts_morph_1.SetAccessorDeclaration || m instanceof ts_morph_1.FunctionDeclaration) ? m.getName() : ((m instanceof ts_morph_1.ConstructorDeclaration) ? 'constructor' : (m.getName() ? m.getName() : 'anonymous'))}`);
|
|
24
25
|
try {
|
|
25
26
|
const temp_nodes = m.findReferencesAsNodes();
|
|
26
27
|
temp_nodes.forEach(node => this.processNodeForInvocations(node, m, id));
|
|
27
28
|
}
|
|
28
29
|
catch (error) {
|
|
29
|
-
|
|
30
|
+
analyze_1.logger.error(`> WARNING: got exception ${error}. Continuing...`);
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
}
|
|
@@ -39,10 +40,10 @@ class ProcessInvocations {
|
|
|
39
40
|
processNodeForInvocations(n, m, id) {
|
|
40
41
|
try {
|
|
41
42
|
this.famixFunctions.createFamixInvocation(n, m, id);
|
|
42
|
-
|
|
43
|
+
analyze_1.logger.debug(`node: node, (${n.getType().getText()})`);
|
|
43
44
|
}
|
|
44
45
|
catch (error) {
|
|
45
|
-
|
|
46
|
+
analyze_1.logger.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol().getFullyQualifiedName()}. Continuing...`);
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
}
|