ts2famix 2.0.0 → 2.0.1
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/LICENSE +1 -0
- package/README.md +29 -60
- package/dist/analyze.js +1 -1
- package/dist/analyze_functions/process_functions.js +49 -43
- package/dist/famix_functions/EntityDictionary.js +309 -182
- package/dist/famix_functions/helpers_creation.js +36 -5
- package/dist/fqn.js +76 -114
- package/dist/lib/famix/famix_JSON_exporter.js +55 -0
- package/dist/lib/famix/famix_base_element.js +18 -0
- package/dist/lib/famix/famix_repository.js +224 -0
- package/dist/lib/famix/{src/index.js → index.js} +1 -1
- package/dist/lib/famix/model/famix/access.js +40 -0
- package/dist/lib/famix/model/famix/accessor.js +17 -0
- package/dist/lib/famix/model/famix/alias.js +33 -0
- package/dist/lib/famix/model/famix/arrow_function.js +17 -0
- package/dist/lib/famix/model/famix/behavioral_entity.js +79 -0
- package/dist/lib/famix/model/famix/class.js +71 -0
- package/dist/lib/famix/model/famix/comment.js +39 -0
- package/dist/lib/famix/model/famix/concretisation.js +31 -0
- package/dist/lib/famix/model/famix/container_entity.js +126 -0
- package/dist/lib/famix/model/famix/decorator.js +32 -0
- package/dist/lib/famix/model/famix/entity.js +17 -0
- package/dist/lib/famix/model/famix/enum.js +31 -0
- package/dist/lib/famix/model/famix/enum_value.js +25 -0
- package/dist/lib/famix/model/famix/function.js +17 -0
- package/dist/lib/famix/model/famix/import_clause.js +41 -0
- package/dist/lib/famix/{src/model → model}/famix/index.js +6 -10
- package/dist/lib/famix/model/famix/indexed_file_anchor.js +38 -0
- package/dist/lib/famix/model/famix/inheritance.js +33 -0
- package/dist/lib/famix/model/famix/interface.js +64 -0
- package/dist/lib/famix/model/famix/invocation.js +54 -0
- package/dist/lib/famix/model/famix/method.js +67 -0
- package/dist/lib/famix/model/famix/module.js +60 -0
- package/dist/lib/famix/model/famix/named_entity.js +78 -0
- package/dist/lib/famix/model/famix/parameter.js +25 -0
- package/dist/lib/famix/model/famix/parameter_concretisation.js +44 -0
- package/dist/lib/famix/model/famix/parameter_type.js +45 -0
- package/dist/lib/famix/model/famix/parametric_arrow_function.js +31 -0
- package/dist/lib/famix/model/famix/parametric_class.js +44 -0
- package/dist/lib/famix/model/famix/parametric_function.js +31 -0
- package/dist/lib/famix/model/famix/parametric_interface.js +44 -0
- package/dist/lib/famix/model/famix/parametric_method.js +31 -0
- package/dist/lib/famix/model/famix/primitive_type.js +17 -0
- package/dist/lib/famix/model/famix/property.js +73 -0
- package/dist/lib/famix/model/famix/reference.js +33 -0
- package/dist/lib/famix/model/famix/scoping_entity.js +36 -0
- package/dist/lib/famix/model/famix/script_entity.js +29 -0
- package/dist/lib/famix/model/famix/source_anchor.js +27 -0
- package/dist/lib/famix/model/famix/source_language.js +35 -0
- package/dist/lib/famix/model/famix/sourced_entity.js +60 -0
- package/dist/lib/famix/model/famix/structural_entity.js +39 -0
- package/dist/lib/famix/model/famix/type.js +73 -0
- package/dist/lib/famix/model/famix/variable.js +24 -0
- package/dist/lib/ts-complex/cyclomatic-service.js +2 -2
- package/dist/refactorer/refactor-getter-setter.js +142 -0
- package/dist/ts2famix-cli-wrapper.js +29 -3
- package/dist/ts2famix-cli.js +1 -1
- package/doc-uml/famix-typescript-model.puml +390 -341
- package/doc-uml/famix-typescript-model.svg +1 -1
- package/package.json +8 -7
- package/src/analyze.ts +2 -2
- package/src/analyze_functions/process_functions.ts +49 -44
- package/src/famix_functions/EntityDictionary.ts +345 -216
- package/src/famix_functions/helpers_creation.ts +36 -4
- package/src/fqn.ts +76 -125
- package/src/lib/famix/famix_JSON_exporter.ts +56 -0
- package/src/lib/famix/famix_base_element.ts +22 -0
- package/src/lib/famix/famix_repository.ts +243 -0
- package/src/lib/famix/model/famix/access.ts +50 -0
- package/src/lib/famix/model/famix/alias.ts +39 -0
- package/src/lib/famix/model/famix/behavioral_entity.ts +97 -0
- package/src/lib/famix/model/famix/class.ts +85 -0
- package/src/lib/famix/model/famix/comment.ts +47 -0
- package/src/lib/famix/model/famix/concretisation.ts +40 -0
- package/src/lib/famix/model/famix/container_entity.ts +160 -0
- package/src/lib/famix/model/famix/decorator.ts +37 -0
- package/src/lib/famix/model/famix/enum.ts +30 -0
- package/src/lib/famix/model/famix/enum_value.ts +28 -0
- package/src/lib/famix/model/famix/import_clause.ts +51 -0
- package/src/lib/famix/{src/model → model}/famix/index.ts +2 -4
- package/src/lib/famix/model/famix/indexed_file_anchor.ts +46 -0
- package/src/lib/famix/model/famix/inheritance.ts +40 -0
- package/src/lib/famix/model/famix/interface.ts +75 -0
- package/src/lib/famix/model/famix/invocation.ts +65 -0
- package/src/lib/famix/model/famix/method.ts +89 -0
- package/src/lib/famix/model/famix/module.ts +71 -0
- package/src/lib/famix/model/famix/named_entity.ts +95 -0
- package/src/lib/famix/{src/model → model}/famix/parameter.ts +11 -12
- package/src/lib/famix/model/famix/parameter_concretisation.ts +51 -0
- package/src/lib/famix/model/famix/parameter_type.ts +58 -0
- package/src/lib/famix/model/famix/parametric_arrow_function.ts +32 -0
- package/src/lib/famix/model/famix/parametric_class.ts +49 -0
- package/src/lib/famix/model/famix/parametric_function.ts +32 -0
- package/src/lib/famix/model/famix/parametric_interface.ts +49 -0
- package/src/lib/famix/model/famix/parametric_method.ts +32 -0
- package/src/lib/famix/model/famix/primitive_type.ts +15 -0
- package/src/lib/famix/model/famix/property.ts +94 -0
- package/src/lib/famix/model/famix/reference.ts +40 -0
- package/src/lib/famix/model/famix/scoping_entity.ts +35 -0
- package/src/lib/famix/model/famix/script_entity.ts +34 -0
- package/src/lib/famix/model/famix/source_anchor.ts +30 -0
- package/src/lib/famix/model/famix/source_language.ts +35 -0
- package/src/lib/famix/model/famix/sourced_entity.ts +70 -0
- package/src/lib/famix/model/famix/structural_entity.ts +43 -0
- package/src/lib/famix/model/famix/type.ts +87 -0
- package/src/lib/famix/model/famix/variable.ts +27 -0
- package/src/lib/famix/package.json +1 -1
- package/src/lib/ts-complex/cyclomatic-service.ts +10 -10
- package/src/refactorer/refactor-getter-setter.ts +140 -0
- package/src/ts2famix-cli-wrapper.ts +6 -2
- package/src/ts2famix-cli.ts +1 -1
- package/tsconfig.check-tests.json +14 -0
- package/tsconfig.json +70 -68
- package/dist/famix2puml.js +0 -126
- package/dist/lib/famix/src/famix_JSON_exporter.js +0 -55
- package/dist/lib/famix/src/famix_base_element.js +0 -18
- package/dist/lib/famix/src/famix_repository.js +0 -223
- package/dist/lib/famix/src/model/famix/access.js +0 -40
- package/dist/lib/famix/src/model/famix/accessor.js +0 -17
- package/dist/lib/famix/src/model/famix/alias.js +0 -33
- package/dist/lib/famix/src/model/famix/arrowFunction.js +0 -17
- package/dist/lib/famix/src/model/famix/behavioral_entity.js +0 -79
- package/dist/lib/famix/src/model/famix/class.js +0 -71
- package/dist/lib/famix/src/model/famix/comment.js +0 -39
- package/dist/lib/famix/src/model/famix/concretisation.js +0 -31
- package/dist/lib/famix/src/model/famix/container_entity.js +0 -126
- package/dist/lib/famix/src/model/famix/decorator.js +0 -32
- package/dist/lib/famix/src/model/famix/entity.js +0 -17
- package/dist/lib/famix/src/model/famix/enum.js +0 -31
- package/dist/lib/famix/src/model/famix/enum_value.js +0 -25
- package/dist/lib/famix/src/model/famix/function.js +0 -17
- package/dist/lib/famix/src/model/famix/implicit_variable.js +0 -17
- package/dist/lib/famix/src/model/famix/import_clause.js +0 -41
- package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +0 -52
- package/dist/lib/famix/src/model/famix/inheritance.js +0 -33
- package/dist/lib/famix/src/model/famix/interface.js +0 -64
- package/dist/lib/famix/src/model/famix/invocation.js +0 -54
- package/dist/lib/famix/src/model/famix/method.js +0 -67
- package/dist/lib/famix/src/model/famix/module.js +0 -84
- package/dist/lib/famix/src/model/famix/named_entity.js +0 -78
- package/dist/lib/famix/src/model/famix/parameter.js +0 -25
- package/dist/lib/famix/src/model/famix/parameterConcretisation.js +0 -44
- package/dist/lib/famix/src/model/famix/parameter_type.js +0 -45
- package/dist/lib/famix/src/model/famix/parametric_arrow_function.js +0 -31
- package/dist/lib/famix/src/model/famix/parametric_class.js +0 -44
- package/dist/lib/famix/src/model/famix/parametric_function.js +0 -31
- package/dist/lib/famix/src/model/famix/parametric_interface.js +0 -44
- package/dist/lib/famix/src/model/famix/parametric_method.js +0 -31
- package/dist/lib/famix/src/model/famix/primitive_type.js +0 -17
- package/dist/lib/famix/src/model/famix/property.js +0 -126
- package/dist/lib/famix/src/model/famix/reference.js +0 -33
- package/dist/lib/famix/src/model/famix/scoping_entity.js +0 -37
- package/dist/lib/famix/src/model/famix/script_entity.js +0 -29
- package/dist/lib/famix/src/model/famix/source_anchor.js +0 -27
- package/dist/lib/famix/src/model/famix/source_language.js +0 -35
- package/dist/lib/famix/src/model/famix/sourced_entity.js +0 -60
- package/dist/lib/famix/src/model/famix/structural_entity.js +0 -39
- package/dist/lib/famix/src/model/famix/text_anchor.js +0 -38
- package/dist/lib/famix/src/model/famix/type.js +0 -73
- package/dist/lib/famix/src/model/famix/variable.js +0 -24
- package/jest.config-old.ts +0 -199
- package/src/famix2puml.ts +0 -119
- package/src/lib/famix/package-lock.json +0 -301
- package/src/lib/famix/readme.md +0 -5
- package/src/lib/famix/src/famix_JSON_exporter.ts +0 -56
- package/src/lib/famix/src/famix_base_element.ts +0 -22
- package/src/lib/famix/src/famix_repository.ts +0 -243
- package/src/lib/famix/src/model/famix/access.ts +0 -53
- package/src/lib/famix/src/model/famix/alias.ts +0 -41
- package/src/lib/famix/src/model/famix/behavioral_entity.ts +0 -100
- package/src/lib/famix/src/model/famix/class.ts +0 -86
- package/src/lib/famix/src/model/famix/comment.ts +0 -50
- package/src/lib/famix/src/model/famix/concretisation.ts +0 -42
- package/src/lib/famix/src/model/famix/container_entity.ts +0 -165
- package/src/lib/famix/src/model/famix/decorator.ts +0 -39
- package/src/lib/famix/src/model/famix/enum.ts +0 -31
- package/src/lib/famix/src/model/famix/enum_value.ts +0 -29
- package/src/lib/famix/src/model/famix/implicit_variable.ts +0 -15
- package/src/lib/famix/src/model/famix/import_clause.ts +0 -54
- package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +0 -71
- package/src/lib/famix/src/model/famix/inheritance.ts +0 -41
- package/src/lib/famix/src/model/famix/interface.ts +0 -75
- package/src/lib/famix/src/model/famix/invocation.ts +0 -68
- package/src/lib/famix/src/model/famix/method.ts +0 -96
- package/src/lib/famix/src/model/famix/module.ts +0 -97
- package/src/lib/famix/src/model/famix/named_entity.ts +0 -98
- package/src/lib/famix/src/model/famix/parameterConcretisation.ts +0 -54
- package/src/lib/famix/src/model/famix/parameter_type.ts +0 -60
- package/src/lib/famix/src/model/famix/parametric_arrow_function.ts +0 -32
- package/src/lib/famix/src/model/famix/parametric_class.ts +0 -49
- package/src/lib/famix/src/model/famix/parametric_function.ts +0 -32
- package/src/lib/famix/src/model/famix/parametric_interface.ts +0 -49
- package/src/lib/famix/src/model/famix/parametric_method.ts +0 -32
- package/src/lib/famix/src/model/famix/primitive_type.ts +0 -15
- package/src/lib/famix/src/model/famix/property.ts +0 -152
- package/src/lib/famix/src/model/famix/reference.ts +0 -42
- package/src/lib/famix/src/model/famix/scoping_entity.ts +0 -36
- package/src/lib/famix/src/model/famix/script_entity.ts +0 -36
- package/src/lib/famix/src/model/famix/source_anchor.ts +0 -31
- package/src/lib/famix/src/model/famix/source_language.ts +0 -36
- package/src/lib/famix/src/model/famix/sourced_entity.ts +0 -73
- package/src/lib/famix/src/model/famix/structural_entity.ts +0 -44
- package/src/lib/famix/src/model/famix/text_anchor.ts +0 -49
- package/src/lib/famix/src/model/famix/type.ts +0 -89
- package/src/lib/famix/src/model/famix/variable.ts +0 -28
- package/src/lib/famix/tsconfig.json +0 -27
- package/src/lib/famix/tslint.json +0 -15
- /package/src/lib/famix/{src/index.ts → index.ts} +0 -0
- /package/src/lib/famix/{src/model → model}/famix/accessor.ts +0 -0
- /package/src/lib/famix/{src/model/famix/arrowFunction.ts → model/famix/arrow_function.ts} +0 -0
- /package/src/lib/famix/{src/model → model}/famix/entity.ts +0 -0
- /package/src/lib/famix/{src/model → model}/famix/function.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassDeclaration, MethodDeclaration, VariableStatement, FunctionDeclaration, VariableDeclaration, InterfaceDeclaration, ParameterDeclaration, ConstructorDeclaration, MethodSignature, SourceFile, ModuleDeclaration, PropertyDeclaration, PropertySignature, Decorator, GetAccessorDeclaration, SetAccessorDeclaration, ExportedDeclarations, CommentRange, EnumDeclaration, EnumMember, TypeParameterDeclaration, TypeAliasDeclaration, SyntaxKind, FunctionExpression, Block, Identifier, ExpressionWithTypeArguments, ImportDeclaration, Node, ArrowFunction, Scope, ClassExpression } from "ts-morph";
|
|
2
|
-
import * as Famix from "../lib/famix/
|
|
2
|
+
import * as Famix from "../lib/famix/model/famix";
|
|
3
3
|
import { calculate } from "../lib/ts-complex/cyclomatic-service";
|
|
4
4
|
import * as fs from 'fs';
|
|
5
5
|
import { logger , entityDictionary } from "../analyze";
|
|
@@ -15,7 +15,7 @@ export const classes = new Array<ClassDeclaration>(); // Array of all the classe
|
|
|
15
15
|
export const interfaces = new Array<InterfaceDeclaration>(); // Array of all the interfaces of the source files
|
|
16
16
|
export const modules = new Array<SourceFile>(); // Array of all the source files which are modules
|
|
17
17
|
export const listOfExportMaps = new Array<ReadonlyMap<string, ExportedDeclarations[]>>(); // Array of all the export maps
|
|
18
|
-
export let currentCC:
|
|
18
|
+
export let currentCC: { [key: string]: number }; // Stores the cyclomatic complexity metrics for the current source file
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Checks if the file has any imports or exports to be considered a module
|
|
@@ -28,21 +28,21 @@ function isSourceFileAModule(sourceFile: SourceFile): boolean {
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* Gets the path of a module to be imported
|
|
31
|
-
* @param
|
|
31
|
+
* @param importDecl An import declaration
|
|
32
32
|
* @returns The path of the module to be imported
|
|
33
33
|
*/
|
|
34
|
-
export function getModulePath(
|
|
34
|
+
export function getModulePath(importDecl: ImportDeclaration): string {
|
|
35
35
|
let path: string;
|
|
36
|
-
if (
|
|
37
|
-
if (
|
|
38
|
-
path =
|
|
36
|
+
if (importDecl.getModuleSpecifierSourceFile() === undefined) {
|
|
37
|
+
if (importDecl.getModuleSpecifierValue().substring(importDecl.getModuleSpecifierValue().length - 3) === ".ts") {
|
|
38
|
+
path = importDecl.getModuleSpecifierValue();
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
path =
|
|
41
|
+
path = importDecl.getModuleSpecifierValue() + ".ts";
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
|
-
path =
|
|
45
|
+
path = importDecl.getModuleSpecifierSourceFile()!.getFilePath();
|
|
46
46
|
}
|
|
47
47
|
return path;
|
|
48
48
|
}
|
|
@@ -89,7 +89,7 @@ export function processFiles(sourceFiles: Array<SourceFile>): void {
|
|
|
89
89
|
if (fs.existsSync(file.getFilePath()))
|
|
90
90
|
currentCC = calculate(file.getFilePath());
|
|
91
91
|
else
|
|
92
|
-
currentCC =
|
|
92
|
+
currentCC = {};
|
|
93
93
|
|
|
94
94
|
processFile(file);
|
|
95
95
|
});
|
|
@@ -111,7 +111,7 @@ function processFile(f: SourceFile): void {
|
|
|
111
111
|
|
|
112
112
|
const fmxFile = entityDictionary.createOrGetFamixFile(f, isModule);
|
|
113
113
|
|
|
114
|
-
logger.debug(`processFile: file: ${f.getBaseName()}, fqn = ${fmxFile.
|
|
114
|
+
logger.debug(`processFile: file: ${f.getBaseName()}, fqn = ${fmxFile.fullyQualifiedName}`);
|
|
115
115
|
|
|
116
116
|
processComments(f, fmxFile);
|
|
117
117
|
|
|
@@ -149,7 +149,7 @@ export function isNamespace(node: ModuleDeclaration): boolean {
|
|
|
149
149
|
function processModule(m: ModuleDeclaration): Famix.Module {
|
|
150
150
|
const fmxModule = entityDictionary.createOrGetFamixModule(m);
|
|
151
151
|
|
|
152
|
-
logger.debug(`module: ${m.getName()}, (${m.getType().getText()}), ${fmxModule.
|
|
152
|
+
logger.debug(`module: ${m.getName()}, (${m.getType().getText()}), ${fmxModule.fullyQualifiedName}`);
|
|
153
153
|
|
|
154
154
|
processComments(m, fmxModule);
|
|
155
155
|
|
|
@@ -310,7 +310,7 @@ function processModules(m: SourceFile | ModuleDeclaration, fmxScope: Famix.Scrip
|
|
|
310
310
|
function processAlias(a: TypeAliasDeclaration): Famix.Alias {
|
|
311
311
|
const fmxAlias = entityDictionary.createFamixAlias(a);
|
|
312
312
|
|
|
313
|
-
logger.debug(`Alias: ${a.getName()}, (${a.getType().getText()}), fqn = ${fmxAlias.
|
|
313
|
+
logger.debug(`Alias: ${a.getName()}, (${a.getType().getText()}), fqn = ${fmxAlias.fullyQualifiedName}`);
|
|
314
314
|
|
|
315
315
|
processComments(a, fmxAlias);
|
|
316
316
|
|
|
@@ -327,7 +327,7 @@ function processClass(c: ClassDeclaration): Famix.Class | Famix.ParametricClass
|
|
|
327
327
|
|
|
328
328
|
const fmxClass = entityDictionary.createOrGetFamixClass(c);
|
|
329
329
|
|
|
330
|
-
logger.debug(`Class: ${c.getName()}, (${c.getType().getText()}), fqn = ${fmxClass.
|
|
330
|
+
logger.debug(`Class: ${c.getName()}, (${c.getType().getText()}), fqn = ${fmxClass.fullyQualifiedName}`);
|
|
331
331
|
|
|
332
332
|
processComments(c, fmxClass);
|
|
333
333
|
|
|
@@ -363,7 +363,7 @@ function processInterface(i: InterfaceDeclaration): Famix.Interface | Famix.Para
|
|
|
363
363
|
|
|
364
364
|
const fmxInterface = entityDictionary.createOrGetFamixInterface(i);
|
|
365
365
|
|
|
366
|
-
logger.debug(`Interface: ${i.getName()}, (${i.getType().getText()}), fqn = ${fmxInterface.
|
|
366
|
+
logger.debug(`Interface: ${i.getName()}, (${i.getType().getText()}), fqn = ${fmxInterface.fullyQualifiedName}`);
|
|
367
367
|
|
|
368
368
|
processComments(i, fmxInterface);
|
|
369
369
|
|
|
@@ -402,7 +402,7 @@ function processStructuredType(c: ClassDeclaration | InterfaceDeclaration, fmxSc
|
|
|
402
402
|
function processProperty(p: PropertyDeclaration | PropertySignature): Famix.Property {
|
|
403
403
|
const fmxProperty = entityDictionary.createFamixProperty(p);
|
|
404
404
|
|
|
405
|
-
logger.debug(`property: ${p.getName()}, (${p.getType().getText()}), fqn = ${fmxProperty.
|
|
405
|
+
logger.debug(`property: ${p.getName()}, (${p.getType().getText()}), fqn = ${fmxProperty.fullyQualifiedName}`);
|
|
406
406
|
logger.debug(` ---> It's a Property${(p instanceof PropertySignature) ? "Signature" : "Declaration"}!`);
|
|
407
407
|
const ancestor = p.getFirstAncestorOrThrow();
|
|
408
408
|
logger.debug(` ---> Its first ancestor is a ${ancestor.getKindName()}`);
|
|
@@ -412,7 +412,7 @@ function processProperty(p: PropertyDeclaration | PropertySignature): Famix.Prop
|
|
|
412
412
|
processDecorators(p, fmxProperty);
|
|
413
413
|
// only add access if the p's first ancestor is not a PropertyDeclaration
|
|
414
414
|
if (ancestor.getKindName() !== "PropertyDeclaration") {
|
|
415
|
-
logger.debug(`adding access to map: ${p.getName()}, (${p.getType().getText()}) Famix ${fmxProperty.
|
|
415
|
+
logger.debug(`adding access to map: ${p.getName()}, (${p.getType().getText()}) Famix ${fmxProperty.name} id: ${fmxProperty.id}`);
|
|
416
416
|
accessMap.set(fmxProperty.id, p);
|
|
417
417
|
}
|
|
418
418
|
}
|
|
@@ -430,7 +430,7 @@ function processProperty(p: PropertyDeclaration | PropertySignature): Famix.Prop
|
|
|
430
430
|
function processMethod(m: MethodDeclaration | ConstructorDeclaration | MethodSignature | GetAccessorDeclaration | SetAccessorDeclaration): Famix.Method | Famix.Accessor {
|
|
431
431
|
const fmxMethod = entityDictionary.createOrGetFamixMethod(m, currentCC);
|
|
432
432
|
|
|
433
|
-
logger.debug(`Method: ${!(m instanceof ConstructorDeclaration) ? m.getName() : "constructor"}, (${m.getType().getText()}), parent: ${(m.getParent() as ClassDeclaration | InterfaceDeclaration).getName()}, fqn = ${fmxMethod.
|
|
433
|
+
logger.debug(`Method: ${!(m instanceof ConstructorDeclaration) ? m.getName() : "constructor"}, (${m.getType().getText()}), parent: ${(m.getParent() as ClassDeclaration | InterfaceDeclaration).getName()}, fqn = ${fmxMethod.fullyQualifiedName}`);
|
|
434
434
|
|
|
435
435
|
processComments(m, fmxMethod);
|
|
436
436
|
|
|
@@ -539,26 +539,29 @@ function processParameters(m: MethodDeclaration | ConstructorDeclaration | Metho
|
|
|
539
539
|
|
|
540
540
|
// This function should create a Famix.Property model from a ParameterDeclaration
|
|
541
541
|
// You'll need to implement it according to your Famix model structure
|
|
542
|
-
function processParameterAsProperty(param: ParameterDeclaration,
|
|
542
|
+
function processParameterAsProperty(param: ParameterDeclaration, classDecl: ClassDeclaration | ClassExpression): Famix.Property {
|
|
543
543
|
// Convert the parameter into a Property
|
|
544
544
|
const propertyRepresentation = convertParameterToPropertyRepresentation(param);
|
|
545
545
|
|
|
546
546
|
// Add the property to the class so we can have a PropertyDeclaration object
|
|
547
|
-
|
|
547
|
+
classDecl.addProperty(propertyRepresentation);
|
|
548
548
|
|
|
549
|
-
const
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
549
|
+
const property = classDecl.getProperty(propertyRepresentation.name);
|
|
550
|
+
if (!property) {
|
|
551
|
+
throw new Error(`Property ${propertyRepresentation.name} not found in class ${classDecl.getName()}`);
|
|
552
|
+
}
|
|
553
|
+
const fmxProperty = entityDictionary.createFamixProperty(property);
|
|
554
|
+
if (classDecl instanceof ClassDeclaration) {
|
|
555
|
+
const fmxClass = entityDictionary.createOrGetFamixClass(classDecl);
|
|
553
556
|
fmxClass.addProperty(fmxProperty);
|
|
554
557
|
} else {
|
|
555
558
|
throw new Error("Unexpected type ClassExpression.");
|
|
556
559
|
}
|
|
557
560
|
|
|
558
|
-
processComments(
|
|
561
|
+
processComments(property, fmxProperty);
|
|
559
562
|
|
|
560
563
|
// remove the property from the class
|
|
561
|
-
|
|
564
|
+
property.remove();
|
|
562
565
|
|
|
563
566
|
return fmxProperty;
|
|
564
567
|
|
|
@@ -579,6 +582,8 @@ function convertParameterToPropertyRepresentation(param: ParameterDeclaration) {
|
|
|
579
582
|
scope = Scope.Protected;
|
|
580
583
|
} else if (param.hasModifier(SyntaxKind.PublicKeyword)) {
|
|
581
584
|
scope = Scope.Public;
|
|
585
|
+
} else {
|
|
586
|
+
throw new Error(`Parameter property ${paramName} in constructor does not have a visibility modifier.`);
|
|
582
587
|
}
|
|
583
588
|
|
|
584
589
|
// Determine if readonly
|
|
@@ -597,23 +602,23 @@ function convertParameterToPropertyRepresentation(param: ParameterDeclaration) {
|
|
|
597
602
|
|
|
598
603
|
/**
|
|
599
604
|
* Builds a Famix model for a parameter
|
|
600
|
-
* @param
|
|
605
|
+
* @param paramDecl A parameter
|
|
601
606
|
* @returns A Famix.Parameter representing the parameter
|
|
602
607
|
*/
|
|
603
|
-
function processParameter(
|
|
604
|
-
const fmxParam = entityDictionary.createFamixParameter(
|
|
608
|
+
function processParameter(paramDecl: ParameterDeclaration): Famix.Parameter {
|
|
609
|
+
const fmxParam = entityDictionary.createFamixParameter(paramDecl);
|
|
605
610
|
|
|
606
|
-
logger.debug(`parameter: ${
|
|
611
|
+
logger.debug(`parameter: ${paramDecl.getName()}, (${paramDecl.getType().getText()}), fqn = ${fmxParam.fullyQualifiedName}`);
|
|
607
612
|
|
|
608
|
-
processComments(
|
|
613
|
+
processComments(paramDecl, fmxParam);
|
|
609
614
|
|
|
610
|
-
processDecorators(
|
|
615
|
+
processDecorators(paramDecl, fmxParam);
|
|
611
616
|
|
|
612
|
-
const parent =
|
|
617
|
+
const parent = paramDecl.getParent();
|
|
613
618
|
|
|
614
619
|
if (!(parent instanceof MethodSignature)) {
|
|
615
|
-
logger.debug(`adding access: ${
|
|
616
|
-
accessMap.set(fmxParam.id,
|
|
620
|
+
logger.debug(`adding access: ${paramDecl.getName()}, (${paramDecl.getType().getText()}) Famix ${fmxParam.name}`);
|
|
621
|
+
accessMap.set(fmxParam.id, paramDecl);
|
|
617
622
|
}
|
|
618
623
|
|
|
619
624
|
return fmxParam;
|
|
@@ -640,7 +645,7 @@ function processTypeParameters(e: ClassDeclaration | InterfaceDeclaration | Meth
|
|
|
640
645
|
function processTypeParameter(tp: TypeParameterDeclaration): Famix.ParameterType {
|
|
641
646
|
const fmxTypeParameter = entityDictionary.createFamixParameterType(tp);
|
|
642
647
|
|
|
643
|
-
logger.debug(`type parameter: ${tp.getName()}, (${tp.getType().getText()}), fqn = ${fmxTypeParameter.
|
|
648
|
+
logger.debug(`type parameter: ${tp.getName()}, (${tp.getType().getText()}), fqn = ${fmxTypeParameter.fullyQualifiedName}`);
|
|
644
649
|
|
|
645
650
|
processComments(tp, fmxTypeParameter);
|
|
646
651
|
|
|
@@ -674,11 +679,11 @@ function processVariableStatement(v: VariableStatement): Array<Famix.Variable> {
|
|
|
674
679
|
function processVariable(v: VariableDeclaration): Famix.Variable {
|
|
675
680
|
const fmxVar = entityDictionary.createFamixVariable(v);
|
|
676
681
|
|
|
677
|
-
logger.debug(`variable: ${v.getName()}, (${v.getType().getText()}), ${v.getInitializer() ? "initializer: " + v.getInitializer()
|
|
682
|
+
logger.debug(`variable: ${v.getName()}, (${v.getType().getText()}), ${v.getInitializer() ? "initializer: " + v.getInitializer()!.getText() : "initializer: "}, fqn = ${fmxVar.fullyQualifiedName}`);
|
|
678
683
|
|
|
679
684
|
processComments(v, fmxVar);
|
|
680
685
|
|
|
681
|
-
logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxVar.
|
|
686
|
+
logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxVar.name}`);
|
|
682
687
|
accessMap.set(fmxVar.id, v);
|
|
683
688
|
|
|
684
689
|
return fmxVar;
|
|
@@ -692,7 +697,7 @@ function processVariable(v: VariableDeclaration): Famix.Variable {
|
|
|
692
697
|
function processEnum(e: EnumDeclaration): Famix.Enum {
|
|
693
698
|
const fmxEnum = entityDictionary.createFamixEnum(e);
|
|
694
699
|
|
|
695
|
-
logger.debug(`enum: ${e.getName()}, (${e.getType().getText()}), fqn = ${fmxEnum.
|
|
700
|
+
logger.debug(`enum: ${e.getName()}, (${e.getType().getText()}), fqn = ${fmxEnum.fullyQualifiedName}`);
|
|
696
701
|
|
|
697
702
|
processComments(e, fmxEnum);
|
|
698
703
|
|
|
@@ -712,11 +717,11 @@ function processEnum(e: EnumDeclaration): Famix.Enum {
|
|
|
712
717
|
function processEnumValue(v: EnumMember): Famix.EnumValue {
|
|
713
718
|
const fmxEnumValue = entityDictionary.createFamixEnumValue(v);
|
|
714
719
|
|
|
715
|
-
logger.debug(`enum value: ${v.getName()}, (${v.getType().getText()}), fqn = ${fmxEnumValue.
|
|
720
|
+
logger.debug(`enum value: ${v.getName()}, (${v.getType().getText()}), fqn = ${fmxEnumValue.fullyQualifiedName}`);
|
|
716
721
|
|
|
717
722
|
processComments(v, fmxEnumValue);
|
|
718
723
|
|
|
719
|
-
logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxEnumValue.
|
|
724
|
+
logger.debug(`adding access: ${v.getName()}, (${v.getType().getText()}) Famix ${fmxEnumValue.name}`);
|
|
720
725
|
accessMap.set(fmxEnumValue.id, v);
|
|
721
726
|
|
|
722
727
|
return fmxEnumValue;
|
|
@@ -744,7 +749,7 @@ function processDecorators(e: ClassDeclaration | MethodDeclaration | GetAccessor
|
|
|
744
749
|
function processDecorator(d: Decorator, e: ClassDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ParameterDeclaration | PropertyDeclaration): Famix.Decorator {
|
|
745
750
|
const fmxDec = entityDictionary.createOrGetFamixDecorator(d, e);
|
|
746
751
|
|
|
747
|
-
logger.debug(`decorator: ${d.getName()}, (${d.getType().getText()}), fqn = ${fmxDec.
|
|
752
|
+
logger.debug(`decorator: ${d.getName()}, (${d.getType().getText()}), fqn = ${fmxDec.fullyQualifiedName}`);
|
|
748
753
|
|
|
749
754
|
processComments(d, fmxDec);
|
|
750
755
|
|
|
@@ -819,7 +824,7 @@ function processNodeForAccesses(n: Identifier, id: number): void {
|
|
|
819
824
|
entityDictionary.createFamixAccess(n, id);
|
|
820
825
|
logger.debug(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})`);
|
|
821
826
|
// } catch (error) {
|
|
822
|
-
// logger.error(`> Got exception "${error}".\nScopeDeclaration invalid for "${n.getSymbol().
|
|
827
|
+
// logger.error(`> Got exception "${error}".\nScopeDeclaration invalid for "${n.getSymbol().fullyQualifiedName}".\nContinuing...`);
|
|
823
828
|
// }
|
|
824
829
|
}
|
|
825
830
|
|
|
@@ -981,7 +986,7 @@ function processNodeForInvocations(n: Identifier, m: MethodDeclaration | Constru
|
|
|
981
986
|
|
|
982
987
|
logger.debug(`node: node, (${n.getType().getText()})`);
|
|
983
988
|
} catch (error) {
|
|
984
|
-
logger.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol()
|
|
989
|
+
logger.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol()!.getFullyQualifiedName()}. Continuing...`);
|
|
985
990
|
}
|
|
986
991
|
}
|
|
987
992
|
|