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
|
@@ -3,6 +3,7 @@ import * as Famix from "../lib/famix/src/model/famix";
|
|
|
3
3
|
import { FamixFunctions } from "../famix_functions/famix_functions";
|
|
4
4
|
import { calculate } from "../lib/ts-complex/cyclomatic-service";
|
|
5
5
|
import * as fs from 'fs';
|
|
6
|
+
import { logger } from "../analyze";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This class is used to build a Famix model for an array of source files
|
|
@@ -32,7 +33,7 @@ export class ProcessFiles {
|
|
|
32
33
|
*/
|
|
33
34
|
public processFiles(sourceFiles: Array<SourceFile>): void {
|
|
34
35
|
sourceFiles.forEach(file => {
|
|
35
|
-
|
|
36
|
+
logger.info(`File: >>>>>>>>>> ${file.getFilePath()}`);
|
|
36
37
|
|
|
37
38
|
// Computes the cyclomatic complexity metrics for the current source file if it exists (i.e. if it is not from a jest test)
|
|
38
39
|
if (fs.existsSync(file.getFilePath()))
|
|
@@ -105,7 +106,7 @@ export class ProcessFiles {
|
|
|
105
106
|
|
|
106
107
|
const fmxFile = this.famixFunctions.createOrGetFamixFile(f, isModule);
|
|
107
108
|
|
|
108
|
-
|
|
109
|
+
logger.debug(`processFile: file: ${f.getBaseName()}, fqn = ${fmxFile.getFullyQualifiedName()}`);
|
|
109
110
|
|
|
110
111
|
this.processComments(f, fmxFile);
|
|
111
112
|
|
|
@@ -132,7 +133,7 @@ export class ProcessFiles {
|
|
|
132
133
|
private processNamespace(m: ModuleDeclaration): Famix.Namespace {
|
|
133
134
|
const fmxNamespace = this.famixFunctions.createOrGetFamixNamespace(m);
|
|
134
135
|
|
|
135
|
-
|
|
136
|
+
logger.debug(`processNamespace: namespace: ${m.getName()}, (${m.getType().getText()}), ${fmxNamespace.getFullyQualifiedName()}`);
|
|
136
137
|
|
|
137
138
|
this.processComments(m, fmxNamespace);
|
|
138
139
|
|
|
@@ -159,7 +160,7 @@ export class ProcessFiles {
|
|
|
159
160
|
* @param fmxScope The Famix model of the container
|
|
160
161
|
*/
|
|
161
162
|
private processAliases(m: SourceFile | ModuleDeclaration | FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace | Famix.Function | Famix.Method | Famix.Accessor): void {
|
|
162
|
-
|
|
163
|
+
logger.debug(`processAliases: ---------- Finding Aliases:`);
|
|
163
164
|
m.getTypeAliases().forEach(a => {
|
|
164
165
|
const fmxAlias = this.processAlias(a);
|
|
165
166
|
fmxScope.addAlias(fmxAlias);
|
|
@@ -172,7 +173,7 @@ export class ProcessFiles {
|
|
|
172
173
|
* @param fmxScope The Famix model of the container
|
|
173
174
|
*/
|
|
174
175
|
private processClasses(m: SourceFile | ModuleDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace): void {
|
|
175
|
-
|
|
176
|
+
logger.debug(`processClasses: ---------- Finding Classes:`);
|
|
176
177
|
m.getClasses().forEach(c => {
|
|
177
178
|
const fmxClass = this.processClass(c);
|
|
178
179
|
fmxScope.addType(fmxClass);
|
|
@@ -185,7 +186,7 @@ export class ProcessFiles {
|
|
|
185
186
|
* @param fmxScope The Famix model of the container
|
|
186
187
|
*/
|
|
187
188
|
private processInterfaces(m: SourceFile | ModuleDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace): void {
|
|
188
|
-
|
|
189
|
+
logger.debug(`processInterfaces: ---------- Finding Interfaces:`);
|
|
189
190
|
m.getInterfaces().forEach(i => {
|
|
190
191
|
const fmxInterface = this.processInterface(i);
|
|
191
192
|
fmxScope.addType(fmxInterface);
|
|
@@ -198,7 +199,7 @@ export class ProcessFiles {
|
|
|
198
199
|
* @param fmxScope The Famix model of the container
|
|
199
200
|
*/
|
|
200
201
|
private processVariables(m: SourceFile | ModuleDeclaration | FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace | Famix.Function | Famix.Method | Famix.Accessor): void {
|
|
201
|
-
|
|
202
|
+
logger.debug(`processVariables: ---------- Finding Variables:`);
|
|
202
203
|
m.getVariableStatements().forEach(v => {
|
|
203
204
|
const fmxVariables = this.processVariableStatement(v);
|
|
204
205
|
fmxVariables.forEach(fmxVariable => {
|
|
@@ -213,7 +214,7 @@ export class ProcessFiles {
|
|
|
213
214
|
* @param fmxScope The Famix model of the container
|
|
214
215
|
*/
|
|
215
216
|
private processEnums(m: SourceFile | ModuleDeclaration | FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace | Famix.Function | Famix.Method | Famix.Accessor): void {
|
|
216
|
-
|
|
217
|
+
logger.debug(`processEnums: ---------- Finding Enums:`);
|
|
217
218
|
m.getEnums().forEach(e => {
|
|
218
219
|
const fmxEnum = this.processEnum(e);
|
|
219
220
|
fmxScope.addType(fmxEnum);
|
|
@@ -226,7 +227,7 @@ export class ProcessFiles {
|
|
|
226
227
|
* @param fmxScope The Famix model of the container
|
|
227
228
|
*/
|
|
228
229
|
private processFunctions(m: SourceFile | ModuleDeclaration | FunctionDeclaration | FunctionExpression | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace | Famix.Function | Famix.Method | Famix.Accessor): void {
|
|
229
|
-
|
|
230
|
+
logger.debug(`Finding Functions:`);
|
|
230
231
|
m.getFunctions().forEach(f => {
|
|
231
232
|
const fmxFunction = this.processFunction(f);
|
|
232
233
|
fmxScope.addFunction(fmxFunction);
|
|
@@ -239,7 +240,7 @@ export class ProcessFiles {
|
|
|
239
240
|
* @param fmxScope The Famix model of the container
|
|
240
241
|
*/
|
|
241
242
|
private processNamespaces(m: SourceFile | ModuleDeclaration, fmxScope: Famix.ScriptEntity | Famix.Module | Famix.Namespace): void {
|
|
242
|
-
|
|
243
|
+
logger.debug(`Finding Namespaces:`);
|
|
243
244
|
m.getModules().forEach(md => {
|
|
244
245
|
const fmxNsp = this.processNamespace(md);
|
|
245
246
|
fmxScope.addNamespace(fmxNsp);
|
|
@@ -254,7 +255,7 @@ export class ProcessFiles {
|
|
|
254
255
|
private processAlias(a: TypeAliasDeclaration): Famix.Alias {
|
|
255
256
|
const fmxAlias = this.famixFunctions.createFamixAlias(a);
|
|
256
257
|
|
|
257
|
-
|
|
258
|
+
logger.debug(`Alias: ${a.getName()}, (${a.getType().getText()}), fqn = ${fmxAlias.getFullyQualifiedName()}`);
|
|
258
259
|
|
|
259
260
|
this.processComments(a, fmxAlias);
|
|
260
261
|
|
|
@@ -271,7 +272,7 @@ export class ProcessFiles {
|
|
|
271
272
|
|
|
272
273
|
const fmxClass = this.famixFunctions.createOrGetFamixClass(c);
|
|
273
274
|
|
|
274
|
-
|
|
275
|
+
logger.debug(`Class: ${c.getName()}, (${c.getType().getText()}), fqn = ${fmxClass.getFullyQualifiedName()}`);
|
|
275
276
|
|
|
276
277
|
this.processComments(c, fmxClass);
|
|
277
278
|
|
|
@@ -307,7 +308,7 @@ export class ProcessFiles {
|
|
|
307
308
|
|
|
308
309
|
const fmxInterface = this.famixFunctions.createOrGetFamixInterface(i);
|
|
309
310
|
|
|
310
|
-
|
|
311
|
+
logger.debug(`Interface: ${i.getName()}, (${i.getType().getText()}), fqn = ${fmxInterface.getFullyQualifiedName()}`);
|
|
311
312
|
|
|
312
313
|
this.processComments(i, fmxInterface);
|
|
313
314
|
|
|
@@ -322,7 +323,7 @@ export class ProcessFiles {
|
|
|
322
323
|
* @param fmxScope The Famix model of the structured type
|
|
323
324
|
*/
|
|
324
325
|
private processStructuredType(c: ClassDeclaration | InterfaceDeclaration, fmxScope: Famix.Class | Famix.ParameterizableClass | Famix.Interface | Famix.ParameterizableInterface): void {
|
|
325
|
-
|
|
326
|
+
logger.debug(`Finding Properties and Methods:`);
|
|
326
327
|
if (fmxScope instanceof Famix.ParameterizableClass || fmxScope instanceof Famix.ParameterizableInterface) {
|
|
327
328
|
this.processTypeParameters(c, fmxScope);
|
|
328
329
|
}
|
|
@@ -346,16 +347,16 @@ export class ProcessFiles {
|
|
|
346
347
|
private processProperty(p: PropertyDeclaration | PropertySignature): Famix.Property {
|
|
347
348
|
const fmxProperty = this.famixFunctions.createFamixProperty(p);
|
|
348
349
|
|
|
349
|
-
|
|
350
|
-
|
|
350
|
+
logger.debug(`property: ${p.getName()}, (${p.getType().getText()}), fqn = ${fmxProperty.getFullyQualifiedName()}`);
|
|
351
|
+
logger.debug(` ---> It's a Property${(p instanceof PropertySignature) ? "Signature" : "Declaration"}!`);
|
|
351
352
|
const ancestor = p.getFirstAncestorOrThrow();
|
|
352
|
-
|
|
353
|
+
logger.debug(` ---> Its first ancestor is a ${ancestor.getKindName()}`);
|
|
353
354
|
|
|
354
355
|
if (!(p instanceof PropertySignature)) {
|
|
355
356
|
this.processDecorators(p, fmxProperty);
|
|
356
357
|
// only add access if the p's first ancestor is not a PropertyDeclaration
|
|
357
358
|
if (ancestor.getKindName() !== "PropertyDeclaration") {
|
|
358
|
-
|
|
359
|
+
logger.debug(`adding access: ${p.getName()}, (${p.getType().getText()}) Famix ${fmxProperty.getName()}`);
|
|
359
360
|
this.accessMap.set(fmxProperty.id, p);
|
|
360
361
|
}
|
|
361
362
|
}
|
|
@@ -373,7 +374,7 @@ export class ProcessFiles {
|
|
|
373
374
|
private processMethod(m: MethodDeclaration | ConstructorDeclaration | MethodSignature | GetAccessorDeclaration | SetAccessorDeclaration): Famix.Method | Famix.Accessor {
|
|
374
375
|
const fmxMethod = this.famixFunctions.createFamixMethod(m, this.currentCC);
|
|
375
376
|
|
|
376
|
-
|
|
377
|
+
logger.debug(`Method: ${!(m instanceof ConstructorDeclaration) ? m.getName() : "constructor"}, (${m.getType().getText()}), parent: ${(m.getParent() as ClassDeclaration | InterfaceDeclaration).getName()}, fqn = ${fmxMethod.getFullyQualifiedName()}`);
|
|
377
378
|
|
|
378
379
|
this.processComments(m, fmxMethod);
|
|
379
380
|
|
|
@@ -410,7 +411,7 @@ export class ProcessFiles {
|
|
|
410
411
|
private processFunction(f: FunctionDeclaration | FunctionExpression): Famix.Function {
|
|
411
412
|
const fmxFunction = this.famixFunctions.createFamixFunction(f, this.currentCC);
|
|
412
413
|
|
|
413
|
-
|
|
414
|
+
logger.debug(`Function: ${(f.getName()) ? f.getName() : "anonymous"}, (${f.getType().getText()}), fqn = ${fmxFunction.getFullyQualifiedName()}`);
|
|
414
415
|
|
|
415
416
|
this.processComments(f, fmxFunction);
|
|
416
417
|
|
|
@@ -441,7 +442,7 @@ export class ProcessFiles {
|
|
|
441
442
|
* @param fmxScope The Famix model of the function or the method
|
|
442
443
|
*/
|
|
443
444
|
private processFunctionExpressions(f: FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration, fmxScope: Famix.Function | Famix.Method | Famix.Accessor): void {
|
|
444
|
-
|
|
445
|
+
logger.debug(`Finding Function Expressions:`);
|
|
445
446
|
const functionExpressions = f.getDescendantsOfKind(SyntaxKind.FunctionExpression);
|
|
446
447
|
functionExpressions.forEach((func) => {
|
|
447
448
|
const fmxFunc = this.processFunction(func);
|
|
@@ -455,7 +456,7 @@ export class ProcessFiles {
|
|
|
455
456
|
* @param fmxScope The Famix model of the method or the function
|
|
456
457
|
*/
|
|
457
458
|
private processParameters(m: MethodDeclaration | ConstructorDeclaration | MethodSignature | GetAccessorDeclaration | SetAccessorDeclaration | FunctionDeclaration | FunctionExpression, fmxScope: Famix.Method | Famix.Accessor | Famix.Function): void {
|
|
458
|
-
|
|
459
|
+
logger.debug(`Finding Parameters:`);
|
|
459
460
|
m.getParameters().forEach(param => {
|
|
460
461
|
const fmxParam = this.processParameter(param);
|
|
461
462
|
fmxScope.addParameter(fmxParam);
|
|
@@ -470,7 +471,7 @@ export class ProcessFiles {
|
|
|
470
471
|
private processParameter(p: ParameterDeclaration): Famix.Parameter {
|
|
471
472
|
const fmxParam = this.famixFunctions.createFamixParameter(p);
|
|
472
473
|
|
|
473
|
-
|
|
474
|
+
logger.debug(`parameter: ${p.getName()}, (${p.getType().getText()}), fqn = ${fmxParam.getFullyQualifiedName()}`);
|
|
474
475
|
|
|
475
476
|
this.processComments(p, fmxParam);
|
|
476
477
|
|
|
@@ -479,7 +480,7 @@ export class ProcessFiles {
|
|
|
479
480
|
const parent = p.getParent();
|
|
480
481
|
|
|
481
482
|
if (!(parent instanceof MethodSignature)) {
|
|
482
|
-
|
|
483
|
+
logger.debug(`adding access: ${p.getName()}, (${p.getType().getText()}) Famix ${fmxParam.getName()}`);
|
|
483
484
|
this.accessMap.set(fmxParam.id, p);
|
|
484
485
|
}
|
|
485
486
|
|
|
@@ -492,10 +493,10 @@ export class ProcessFiles {
|
|
|
492
493
|
* @param fmxScope The Famix model of the class, the interface, the method or the function
|
|
493
494
|
*/
|
|
494
495
|
private processTypeParameters(e: ClassDeclaration | InterfaceDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature | GetAccessorDeclaration | SetAccessorDeclaration | FunctionDeclaration | FunctionExpression, fmxScope: Famix.ParameterizableClass | Famix.ParameterizableInterface | Famix.Method | Famix.Accessor | Famix.Function): void {
|
|
495
|
-
|
|
496
|
+
logger.debug(`Finding Type Parameters:`);
|
|
496
497
|
e.getTypeParameters().forEach(tp => {
|
|
497
498
|
const fmxParam = this.processTypeParameter(tp);
|
|
498
|
-
fmxScope.
|
|
499
|
+
fmxScope.addParameterType(fmxParam);
|
|
499
500
|
});
|
|
500
501
|
}
|
|
501
502
|
|
|
@@ -504,10 +505,10 @@ export class ProcessFiles {
|
|
|
504
505
|
* @param tp A type parameter
|
|
505
506
|
* @returns A Famix.TypeParameter representing the type parameter
|
|
506
507
|
*/
|
|
507
|
-
private processTypeParameter(tp: TypeParameterDeclaration): Famix.
|
|
508
|
-
const fmxTypeParameter = this.famixFunctions.
|
|
508
|
+
private processTypeParameter(tp: TypeParameterDeclaration): Famix.ParameterType {
|
|
509
|
+
const fmxTypeParameter = this.famixFunctions.createFamixParameterType(tp);
|
|
509
510
|
|
|
510
|
-
|
|
511
|
+
logger.debug(`type parameter: ${tp.getName()}, (${tp.getType().getText()}), fqn = ${fmxTypeParameter.getFullyQualifiedName()}`);
|
|
511
512
|
|
|
512
513
|
this.processComments(tp, fmxTypeParameter);
|
|
513
514
|
|
|
@@ -522,7 +523,7 @@ export class ProcessFiles {
|
|
|
522
523
|
private processVariableStatement(v: VariableStatement): Array<Famix.Variable> {
|
|
523
524
|
const fmxVariables = new Array<Famix.Variable>();
|
|
524
525
|
|
|
525
|
-
|
|
526
|
+
logger.debug(`Variable statement: ${v.getText()}, (${v.getType().getText()}), ${v.getDeclarationKindKeywords()[0]}, fqn = ${v.getDeclarations()[0].getName()}`);
|
|
526
527
|
|
|
527
528
|
v.getDeclarations().forEach(variable => {
|
|
528
529
|
const fmxVar = this.processVariable(variable);
|
|
@@ -541,11 +542,11 @@ export class ProcessFiles {
|
|
|
541
542
|
private processVariable(v: VariableDeclaration): Famix.Variable {
|
|
542
543
|
const fmxVar = this.famixFunctions.createFamixVariable(v);
|
|
543
544
|
|
|
544
|
-
|
|
545
|
+
logger.debug(`variable: ${v.getName()}, (${v.getType().getText()}), ${v.getInitializer() ? "initializer: " + v.getInitializer().getText() : "initializer: "}, fqn = ${fmxVar.getFullyQualifiedName()}`);
|
|
545
546
|
|
|
546
547
|
this.processComments(v, fmxVar);
|
|
547
548
|
|
|
548
|
-
|
|
549
|
+
logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxVar.getName()}`);
|
|
549
550
|
this.accessMap.set(fmxVar.id, v);
|
|
550
551
|
|
|
551
552
|
return fmxVar;
|
|
@@ -559,7 +560,7 @@ export class ProcessFiles {
|
|
|
559
560
|
private processEnum(e: EnumDeclaration): Famix.Enum {
|
|
560
561
|
const fmxEnum = this.famixFunctions.createFamixEnum(e);
|
|
561
562
|
|
|
562
|
-
|
|
563
|
+
logger.debug(`enum: ${e.getName()}, (${e.getType().getText()}), fqn = ${fmxEnum.getFullyQualifiedName()}`);
|
|
563
564
|
|
|
564
565
|
this.processComments(e, fmxEnum);
|
|
565
566
|
|
|
@@ -579,11 +580,11 @@ export class ProcessFiles {
|
|
|
579
580
|
private processEnumValue(v: EnumMember): Famix.EnumValue {
|
|
580
581
|
const fmxEnumValue = this.famixFunctions.createFamixEnumValue(v);
|
|
581
582
|
|
|
582
|
-
|
|
583
|
+
logger.debug(`enum value: ${v.getName()}, (${v.getType().getText()}), fqn = ${fmxEnumValue.getFullyQualifiedName()}`);
|
|
583
584
|
|
|
584
585
|
this.processComments(v, fmxEnumValue);
|
|
585
586
|
|
|
586
|
-
|
|
587
|
+
logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxEnumValue.getName()}`);
|
|
587
588
|
this.accessMap.set(fmxEnumValue.id, v);
|
|
588
589
|
|
|
589
590
|
return fmxEnumValue;
|
|
@@ -595,7 +596,7 @@ export class ProcessFiles {
|
|
|
595
596
|
* @param fmxScope The Famix model of the class, the method, the parameter or the property
|
|
596
597
|
*/
|
|
597
598
|
private processDecorators(e: ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ParameterDeclaration | PropertyDeclaration, fmxScope: Famix.Class | Famix.ParameterizableClass | Famix.Method | Famix.Accessor | Famix.Parameter | Famix.Property): void {
|
|
598
|
-
|
|
599
|
+
logger.debug(`Finding Decorators:`);
|
|
599
600
|
e.getDecorators().forEach(dec => {
|
|
600
601
|
const fmxDec = this.processDecorator(dec, e);
|
|
601
602
|
fmxScope.addDecorator(fmxDec);
|
|
@@ -611,7 +612,7 @@ export class ProcessFiles {
|
|
|
611
612
|
private processDecorator(d: Decorator, e: ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ParameterDeclaration | PropertyDeclaration): Famix.Decorator {
|
|
612
613
|
const fmxDec = this.famixFunctions.createOrGetFamixDecorator(d, e);
|
|
613
614
|
|
|
614
|
-
|
|
615
|
+
logger.debug(`decorator: ${d.getName()}, (${d.getType().getText()}), fqn = ${fmxDec.getFullyQualifiedName()}`);
|
|
615
616
|
|
|
616
617
|
this.processComments(d, fmxDec);
|
|
617
618
|
|
|
@@ -624,13 +625,15 @@ export class ProcessFiles {
|
|
|
624
625
|
* @param fmxScope The Famix model of the named entity
|
|
625
626
|
*/
|
|
626
627
|
private processComments(e: SourceFile | ModuleDeclaration | ClassDeclaration | InterfaceDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature | GetAccessorDeclaration | SetAccessorDeclaration | FunctionDeclaration | FunctionExpression | ParameterDeclaration | VariableDeclaration | PropertyDeclaration | PropertySignature | Decorator | EnumDeclaration | EnumMember | TypeParameterDeclaration | VariableStatement | TypeAliasDeclaration, fmxScope: Famix.NamedEntity): void {
|
|
627
|
-
|
|
628
|
+
logger.debug(`Process comments:`);
|
|
628
629
|
e.getLeadingCommentRanges().forEach(c => {
|
|
629
630
|
const fmxComment = this.processComment(c, fmxScope);
|
|
630
|
-
|
|
631
|
+
logger.debug(`leading comments, addComment: '${c.getText()}'`);
|
|
632
|
+
fmxScope.addComment(fmxComment); // redundant, but just in case
|
|
631
633
|
});
|
|
632
634
|
e.getTrailingCommentRanges().forEach(c => {
|
|
633
635
|
const fmxComment = this.processComment(c, fmxScope);
|
|
636
|
+
logger.debug(`trailing comments, addComment: '${c.getText()}'`);
|
|
634
637
|
fmxScope.addComment(fmxComment);
|
|
635
638
|
});
|
|
636
639
|
}
|
|
@@ -642,15 +645,10 @@ export class ProcessFiles {
|
|
|
642
645
|
* @returns A Famix.Comment representing the comment
|
|
643
646
|
*/
|
|
644
647
|
private processComment(c: CommentRange, fmxScope: Famix.NamedEntity): Famix.Comment {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
isJSDoc = true;
|
|
648
|
-
}
|
|
649
|
-
|
|
648
|
+
const isJSDoc = c.getText().startsWith("/**");
|
|
649
|
+
logger.debug(`processComment: comment: ${c.getText()}, isJSDoc = ${isJSDoc}`);
|
|
650
650
|
const fmxComment = this.famixFunctions.createFamixComment(c, fmxScope, isJSDoc);
|
|
651
651
|
|
|
652
|
-
console.info(`processComment: comment: ${c.getText()}`);
|
|
653
|
-
|
|
654
652
|
return fmxComment;
|
|
655
653
|
}
|
|
656
654
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ImportDeclaration, SourceFile, ExportedDeclarations } from "ts-morph";
|
|
2
2
|
import { FamixFunctions } from "../famix_functions/famix_functions";
|
|
3
|
+
import { logger } from "../analyze";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class is used to build a Famix model for the import clauses
|
|
@@ -22,13 +23,13 @@ export class ProcessImportClauses {
|
|
|
22
23
|
* @param exports An array of maps of exported declarations
|
|
23
24
|
*/
|
|
24
25
|
public processImportClauses(modules: Array<SourceFile>, exports: Array<ReadonlyMap<string, ExportedDeclarations[]>>): void {
|
|
25
|
-
|
|
26
|
+
logger.info(`processImportClauses: Creating import clauses:`);
|
|
26
27
|
modules.forEach(module => {
|
|
27
28
|
module.getImportDeclarations().forEach(impDecl => {
|
|
28
29
|
const path = this.getModulePath(impDecl);
|
|
29
30
|
|
|
30
31
|
impDecl.getNamedImports().forEach(namedImport => {
|
|
31
|
-
|
|
32
|
+
logger.debug(`processImportClauses: Importing (named) ${namedImport.getName()} from ${impDecl.getModuleSpecifierValue()}`);
|
|
32
33
|
const importedEntityName = namedImport.getName();
|
|
33
34
|
let importFoundInExports = false;
|
|
34
35
|
exports.forEach(e => {
|
|
@@ -36,19 +37,36 @@ export class ProcessImportClauses {
|
|
|
36
37
|
importFoundInExports = true;
|
|
37
38
|
}
|
|
38
39
|
});
|
|
39
|
-
this.famixFunctions.
|
|
40
|
+
this.famixFunctions.createFamixImportClause({importDeclaration: impDecl,
|
|
41
|
+
importer: module,
|
|
42
|
+
moduleSpecifierFilePath: path,
|
|
43
|
+
importElement: namedImport,
|
|
44
|
+
isInExports: importFoundInExports,
|
|
45
|
+
isDefaultExport: false});
|
|
40
46
|
});
|
|
41
47
|
|
|
42
48
|
const defaultImport = impDecl.getDefaultImport();
|
|
43
49
|
if (defaultImport !== undefined) {
|
|
44
|
-
|
|
45
|
-
|
|
50
|
+
logger.debug(`processImportClauses: Importing (default) ${defaultImport.getText()} from ${impDecl.getModuleSpecifierValue()}`);
|
|
51
|
+
// call with module, impDecl.getModuleSpecifierValue(), path, defaultImport, false, true
|
|
52
|
+
this.famixFunctions.createFamixImportClause({importDeclaration: impDecl,
|
|
53
|
+
importer: module,
|
|
54
|
+
moduleSpecifierFilePath: path,
|
|
55
|
+
importElement: defaultImport,
|
|
56
|
+
isInExports: false,
|
|
57
|
+
isDefaultExport: true});
|
|
46
58
|
}
|
|
47
59
|
|
|
48
60
|
const namespaceImport = impDecl.getNamespaceImport();
|
|
49
61
|
if (namespaceImport !== undefined) {
|
|
50
|
-
|
|
51
|
-
this.famixFunctions.createFamixImportClause(
|
|
62
|
+
logger.debug(`processImportClauses: Importing (namespace) ${namespaceImport.getText()} from ${impDecl.getModuleSpecifierValue()}`);
|
|
63
|
+
this.famixFunctions.createFamixImportClause({importDeclaration: impDecl,
|
|
64
|
+
importer: module,
|
|
65
|
+
moduleSpecifierFilePath: path,
|
|
66
|
+
importElement: namespaceImport,
|
|
67
|
+
isInExports: false,
|
|
68
|
+
isDefaultExport: false});
|
|
69
|
+
// this.famixFunctions.createFamixImportClause(module, impDecl.getModuleSpecifierValue(), path, namespaceImport, false, false);
|
|
52
70
|
}
|
|
53
71
|
});
|
|
54
72
|
});
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ClassDeclaration, InterfaceDeclaration, ExpressionWithTypeArguments } from "ts-morph";
|
|
2
2
|
import { FamixFunctions } from "../famix_functions/famix_functions";
|
|
3
|
+
import { logger } from "../analyze";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class is used to build a Famix model for the inheritances
|
|
@@ -22,32 +23,32 @@ export class ProcessInheritances {
|
|
|
22
23
|
* @param interfaces An array of interfaces
|
|
23
24
|
*/
|
|
24
25
|
public processInheritances(classes: ClassDeclaration[], interfaces: InterfaceDeclaration[]): void {
|
|
25
|
-
|
|
26
|
+
logger.info(`processInheritances: Creating inheritances:`);
|
|
26
27
|
classes.forEach(cls => {
|
|
27
|
-
|
|
28
|
+
logger.debug(`processInheritances: Checking class inheritance for ${cls.getName()}`);
|
|
28
29
|
const extClass = cls.getBaseClass();
|
|
29
30
|
if (extClass !== undefined) {
|
|
30
31
|
this.famixFunctions.createFamixInheritance(cls, extClass);
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
logger.debug(`processInheritances: class: ${cls.getName()}, (${cls.getType().getText()}), extClass: ${extClass.getName()}, (${extClass.getType().getText()})`);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
logger.debug(`processInheritances: Checking interface inheritance for ${cls.getName()}`);
|
|
36
37
|
const implementedInterfaces = this.getImplementedOrExtendedInterfaces(interfaces, cls);
|
|
37
38
|
implementedInterfaces.forEach(impInter => {
|
|
38
39
|
this.famixFunctions.createFamixInheritance(cls, impInter);
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
logger.debug(`processInheritances: class: ${cls.getName()}, (${cls.getType().getText()}), impInter: ${(impInter instanceof InterfaceDeclaration) ? impInter.getName() : impInter.getExpression().getText()}, (${(impInter instanceof InterfaceDeclaration) ? impInter.getType().getText() : impInter.getExpression().getText()})`);
|
|
41
42
|
});
|
|
42
43
|
});
|
|
43
44
|
|
|
44
45
|
interfaces.forEach(inter => {
|
|
45
|
-
|
|
46
|
+
logger.debug(`processInheritances: Checking interface inheritance for ${inter.getName()}`);
|
|
46
47
|
const extendedInterfaces = this.getImplementedOrExtendedInterfaces(interfaces, inter);
|
|
47
48
|
extendedInterfaces.forEach(extInter => {
|
|
48
49
|
this.famixFunctions.createFamixInheritance(inter, extInter);
|
|
49
50
|
|
|
50
|
-
|
|
51
|
+
logger.debug(`processInheritances: inter: ${inter.getName()}, (${inter.getType().getText()}), extInter: ${(extInter instanceof InterfaceDeclaration) ? extInter.getName() : extInter.getExpression().getText()}, (${(extInter instanceof InterfaceDeclaration) ? extInter.getType().getText() : extInter.getExpression().getText()})`);
|
|
51
52
|
});
|
|
52
53
|
});
|
|
53
54
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MethodDeclaration, FunctionDeclaration, Identifier, ConstructorDeclaration, GetAccessorDeclaration, SetAccessorDeclaration, FunctionExpression } from "ts-morph";
|
|
2
2
|
import { FamixFunctions } from "../famix_functions/famix_functions";
|
|
3
|
+
import { logger } from "../analyze";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* This class is used to build a Famix model for the invocations
|
|
@@ -21,14 +22,14 @@ export class ProcessInvocations {
|
|
|
21
22
|
* @param methodsAndFunctionsWithId A map of methods and functions with their id
|
|
22
23
|
*/
|
|
23
24
|
public processInvocations(methodsAndFunctionsWithId: Map<number, MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | FunctionDeclaration | FunctionExpression>): void {
|
|
24
|
-
|
|
25
|
+
logger.info(`Creating invocations:`);
|
|
25
26
|
methodsAndFunctionsWithId.forEach((m, id) => {
|
|
26
|
-
|
|
27
|
+
logger.debug(`Invocations to ${(m instanceof MethodDeclaration || m instanceof GetAccessorDeclaration || m instanceof SetAccessorDeclaration || m instanceof FunctionDeclaration) ? m.getName() : ((m instanceof ConstructorDeclaration) ? 'constructor' : (m.getName() ? m.getName() : 'anonymous'))}`);
|
|
27
28
|
try {
|
|
28
29
|
const temp_nodes = m.findReferencesAsNodes() as Array<Identifier>;
|
|
29
30
|
temp_nodes.forEach(node => this.processNodeForInvocations(node, m, id));
|
|
30
31
|
} catch (error) {
|
|
31
|
-
|
|
32
|
+
logger.error(`> WARNING: got exception ${error}. Continuing...`);
|
|
32
33
|
}
|
|
33
34
|
});
|
|
34
35
|
}
|
|
@@ -43,9 +44,9 @@ export class ProcessInvocations {
|
|
|
43
44
|
try {
|
|
44
45
|
this.famixFunctions.createFamixInvocation(n, m, id);
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
logger.debug(`node: node, (${n.getType().getText()})`);
|
|
47
48
|
} catch (error) {
|
|
48
|
-
|
|
49
|
+
logger.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol().getFullyQualifiedName()}. Continuing...`);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ClassDeclaration, ConstructorDeclaration, FunctionDeclaration, Identifier, InterfaceDeclaration, MethodDeclaration, MethodSignature, ModuleDeclaration, PropertyDeclaration, PropertySignature, SourceFile, TypeParameterDeclaration, VariableDeclaration, ParameterDeclaration, Decorator, GetAccessorDeclaration, SetAccessorDeclaration, ImportSpecifier, CommentRange, EnumDeclaration, EnumMember, TypeAliasDeclaration, FunctionExpression, ExpressionWithTypeArguments } from "ts-morph";
|
|
1
|
+
import { ClassDeclaration, ConstructorDeclaration, FunctionDeclaration, Identifier, InterfaceDeclaration, MethodDeclaration, MethodSignature, ModuleDeclaration, PropertyDeclaration, PropertySignature, SourceFile, TypeParameterDeclaration, VariableDeclaration, ParameterDeclaration, Decorator, GetAccessorDeclaration, SetAccessorDeclaration, ImportSpecifier, CommentRange, EnumDeclaration, EnumMember, TypeAliasDeclaration, FunctionExpression, ExpressionWithTypeArguments, ImportDeclaration } from "ts-morph";
|
|
2
2
|
import * as Famix from "../lib/famix/src/model/famix";
|
|
3
3
|
import { FamixRepository } from "../lib/famix/src/famix_repository";
|
|
4
4
|
import { FQNFunctions } from "../fqn";
|
|
5
5
|
import { FamixFunctionsIndex } from "./famix_functions_index";
|
|
6
6
|
import { FamixFunctionsAssociations } from "./famix_functions_associations";
|
|
7
7
|
import { FamixFunctionsTypes } from "./famix_functions_types";
|
|
8
|
+
import { logger } from "../analyze";
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* This class contains all the functions needed to create Famix entities
|
|
@@ -97,7 +98,7 @@ export class FamixFunctions {
|
|
|
97
98
|
fmxAlias = new Famix.Alias(this.famixRep);
|
|
98
99
|
fmxAlias.setName(a.getName());
|
|
99
100
|
const aliasNameWithGenerics = aliasName + (a.getTypeParameters().length ? ("<" + a.getTypeParameters().map(tp => tp.getName()).join(", ") + ">") : "");
|
|
100
|
-
|
|
101
|
+
logger.debug(`> NOTE: alias ${aliasName} has fully qualified name ${aliasFullyQualifiedName} and name with generics ${aliasNameWithGenerics}.`);
|
|
101
102
|
|
|
102
103
|
const fmxType = this.createOrGetFamixType(aliasNameWithGenerics, a);
|
|
103
104
|
fmxAlias.setAliasedEntity(fmxType);
|
|
@@ -189,7 +190,7 @@ export class FamixFunctions {
|
|
|
189
190
|
try {
|
|
190
191
|
propTypeName = property.getType().getText().trim();
|
|
191
192
|
} catch (error) {
|
|
192
|
-
|
|
193
|
+
logger.error(`> WARNING: got exception ${error}. Failed to get usable name for property: ${property.getName()}. Continuing...`);
|
|
193
194
|
}
|
|
194
195
|
|
|
195
196
|
const fmxType = this.createOrGetFamixType(propTypeName, property);
|
|
@@ -288,7 +289,7 @@ export class FamixFunctions {
|
|
|
288
289
|
try {
|
|
289
290
|
methodTypeName = method.getReturnType().getText().trim();
|
|
290
291
|
} catch (error) {
|
|
291
|
-
|
|
292
|
+
logger.error(`> WARNING: got exception ${error}. Failed to get usable name for return type of method: ${fmxMethod.getName()}. Continuing...`);
|
|
292
293
|
}
|
|
293
294
|
|
|
294
295
|
const fmxType = this.createOrGetFamixType(methodTypeName, method);
|
|
@@ -332,7 +333,7 @@ export class FamixFunctions {
|
|
|
332
333
|
try {
|
|
333
334
|
functionTypeName = func.getReturnType().getText().trim();
|
|
334
335
|
} catch (error) {
|
|
335
|
-
|
|
336
|
+
logger.error(`> WARNING: got exception ${error}. Failed to get usable name for return type of function: ${func.getName()}. Continuing...`);
|
|
336
337
|
}
|
|
337
338
|
|
|
338
339
|
const fmxType = this.createOrGetFamixType(functionTypeName, func);
|
|
@@ -359,7 +360,7 @@ export class FamixFunctions {
|
|
|
359
360
|
try {
|
|
360
361
|
paramTypeName = param.getType().getText().trim();
|
|
361
362
|
} catch (error) {
|
|
362
|
-
|
|
363
|
+
logger.error(`> WARNING: got exception ${error}. Failed to get usable name for parameter: ${param.getName()}. Continuing...`);
|
|
363
364
|
}
|
|
364
365
|
|
|
365
366
|
const fmxType = this.createOrGetFamixType(paramTypeName, param);
|
|
@@ -376,13 +377,13 @@ export class FamixFunctions {
|
|
|
376
377
|
* @param tp A type parameter
|
|
377
378
|
* @returns The Famix model of the type parameter
|
|
378
379
|
*/
|
|
379
|
-
public
|
|
380
|
-
const
|
|
381
|
-
|
|
380
|
+
public createFamixParameterType(tp: TypeParameterDeclaration): Famix.ParameterType {
|
|
381
|
+
const fmxParameterType = new Famix.ParameterType(this.famixRep);
|
|
382
|
+
fmxParameterType.setName(tp.getName());
|
|
382
383
|
|
|
383
|
-
this.famixFunctionsIndex.makeFamixIndexFileAnchor(tp,
|
|
384
|
+
this.famixFunctionsIndex.makeFamixIndexFileAnchor(tp, fmxParameterType);
|
|
384
385
|
|
|
385
|
-
return
|
|
386
|
+
return fmxParameterType;
|
|
386
387
|
}
|
|
387
388
|
|
|
388
389
|
/**
|
|
@@ -397,7 +398,7 @@ export class FamixFunctions {
|
|
|
397
398
|
try {
|
|
398
399
|
variableTypeName = variable.getType().getText().trim();
|
|
399
400
|
} catch (error) {
|
|
400
|
-
|
|
401
|
+
logger.error(`> WARNING: got exception ${error}. Failed to get usable name for variable: ${variable.getName()}. Continuing...`);
|
|
401
402
|
}
|
|
402
403
|
|
|
403
404
|
const fmxType = this.createOrGetFamixType(variableTypeName, variable);
|
|
@@ -435,7 +436,7 @@ export class FamixFunctions {
|
|
|
435
436
|
try {
|
|
436
437
|
enumValueTypeName = enumMember.getType().getText().trim();
|
|
437
438
|
} catch (error) {
|
|
438
|
-
|
|
439
|
+
logger.error(`> WARNING: got exception ${error}. Failed to get usable name for enum value: ${enumMember.getName()}. Continuing...`);
|
|
439
440
|
}
|
|
440
441
|
|
|
441
442
|
const fmxType = this.createOrGetFamixType(enumValueTypeName, enumMember);
|
|
@@ -477,9 +478,9 @@ export class FamixFunctions {
|
|
|
477
478
|
* @returns The Famix model of the comment
|
|
478
479
|
*/
|
|
479
480
|
public createFamixComment(comment: CommentRange, fmxScope: Famix.NamedEntity, isJSDoc: boolean): Famix.Comment {
|
|
481
|
+
logger.debug(`> NOTE: creating comment ${comment.getText()} in scope ${fmxScope.getName()}.`);
|
|
480
482
|
const fmxComment = new Famix.Comment(this.famixRep);
|
|
481
|
-
fmxComment.
|
|
482
|
-
fmxComment.setContainer(fmxScope);
|
|
483
|
+
fmxComment.setContainer(fmxScope); // adds comment to the container's comments collection
|
|
483
484
|
fmxComment.setIsJSDoc(isJSDoc);
|
|
484
485
|
|
|
485
486
|
this.famixFunctionsIndex.makeFamixIndexFileAnchor(comment, fmxComment);
|
|
@@ -527,6 +528,8 @@ export class FamixFunctions {
|
|
|
527
528
|
|
|
528
529
|
/**
|
|
529
530
|
* Creates a Famix import clause
|
|
531
|
+
* @param importClauseInfo An import clause
|
|
532
|
+
* @param importDeclaration An import declaration (optional)
|
|
530
533
|
* @param importer A source file which is a module
|
|
531
534
|
* @param moduleSpecifier The name of the module where the export declaration is
|
|
532
535
|
* @param moduleSpecifierFilePath The path of the module where the export declaration is
|
|
@@ -534,14 +537,8 @@ export class FamixFunctions {
|
|
|
534
537
|
* @param isInExports A boolean indicating if the imported entity is in the exports
|
|
535
538
|
* @param isDefaultExport A boolean indicating if the imported entity is a default export
|
|
536
539
|
*/
|
|
537
|
-
public createFamixImportClause(
|
|
538
|
-
this.famixFunctionsAssociations.createFamixImportClause(
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// create the same function as createFamixImportClause but with a signature that has a single object parameter that has all the parameters
|
|
542
|
-
// this way we can call this function from the processImportClauses.ts file
|
|
543
|
-
public createFamixImportClause2(importClause: {importer: SourceFile, moduleSpecifier: string, moduleSpecifierFilePath: string, importElement: ImportSpecifier | Identifier, isInExports: boolean, isDefaultExport: boolean}): void {
|
|
544
|
-
this.famixFunctionsAssociations.createFamixImportClause(importClause.importer, importClause.moduleSpecifier, importClause.moduleSpecifierFilePath, importClause.importElement, importClause.isInExports, importClause.isDefaultExport);
|
|
540
|
+
public createFamixImportClause(importClauseInfo: {importDeclaration?: ImportDeclaration, importer: SourceFile, moduleSpecifierFilePath: string, importElement: ImportSpecifier | Identifier, isInExports: boolean, isDefaultExport: boolean}): void {
|
|
541
|
+
this.famixFunctionsAssociations.createFamixImportClause(importClauseInfo);
|
|
545
542
|
}
|
|
546
543
|
|
|
547
544
|
/**
|