ts2famix 1.0.17 → 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
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ClassDeclaration, ConstructorDeclaration, FunctionDeclaration, Identifier, InterfaceDeclaration, MethodDeclaration, SourceFile, GetAccessorDeclaration, SetAccessorDeclaration, Node, ImportSpecifier, SyntaxKind, FunctionExpression, ExpressionWithTypeArguments } from "ts-morph";
|
|
1
|
+
import { ClassDeclaration, ConstructorDeclaration, FunctionDeclaration, Identifier, InterfaceDeclaration, MethodDeclaration, SourceFile, GetAccessorDeclaration, SetAccessorDeclaration, Node, ImportSpecifier, SyntaxKind, 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
|
-
import {
|
|
6
|
+
import { logger } from "../analyze";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* This class is used to build a Famix model for the associations
|
|
@@ -79,7 +79,7 @@ export class FamixFunctionsAssociations {
|
|
|
79
79
|
const fmxInheritance = new Famix.Inheritance(this.famixRep);
|
|
80
80
|
// const clsName = cls.getName();
|
|
81
81
|
const classFullyQualifiedName = this.FQNFunctions.getFQN(cls);
|
|
82
|
-
|
|
82
|
+
logger.debug(`createFamixInheritance: classFullyQualifiedName: class fqn = ${classFullyQualifiedName}`);
|
|
83
83
|
let subClass: Famix.Class | Famix.Interface;
|
|
84
84
|
if (cls instanceof ClassDeclaration) {
|
|
85
85
|
subClass = this.famixClassMap.get(classFullyQualifiedName);
|
|
@@ -133,15 +133,17 @@ export class FamixFunctionsAssociations {
|
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* Creates a Famix import clause
|
|
136
|
+
* @param importClauseInfo The information needed to create a Famix import clause
|
|
137
|
+
* @param importDeclaration The import declaration
|
|
136
138
|
* @param importer A source file which is a module
|
|
137
|
-
* @param moduleSpecifier The name of the module where the export declaration is
|
|
138
139
|
* @param moduleSpecifierFilePath The path of the module where the export declaration is
|
|
139
140
|
* @param importElement The imported entity
|
|
140
141
|
* @param isInExports A boolean indicating if the imported entity is in the exports
|
|
141
142
|
* @param isDefaultExport A boolean indicating if the imported entity is a default export
|
|
142
143
|
*/
|
|
143
|
-
public createFamixImportClause(
|
|
144
|
-
|
|
144
|
+
public createFamixImportClause(importClauseInfo: {importDeclaration?: ImportDeclaration, importer: SourceFile, moduleSpecifierFilePath: string, importElement: ImportSpecifier | Identifier, isInExports: boolean, isDefaultExport: boolean}): void {
|
|
145
|
+
const {importDeclaration, importer, moduleSpecifierFilePath, importElement, isInExports, isDefaultExport} = importClauseInfo;
|
|
146
|
+
logger.debug(`createFamixImportClause: Creating import clause:`);
|
|
145
147
|
const fmxImportClause = new Famix.ImportClause(this.famixRep);
|
|
146
148
|
|
|
147
149
|
let importedEntity: Famix.NamedEntity;
|
|
@@ -181,17 +183,13 @@ export class FamixFunctionsAssociations {
|
|
|
181
183
|
const fmxImporter = this.getFamixEntityByFullyQualifiedName(importerFullyQualifiedName) as Famix.Module;
|
|
182
184
|
fmxImportClause.setImportingEntity(fmxImporter);
|
|
183
185
|
fmxImportClause.setImportedEntity(importedEntity);
|
|
184
|
-
fmxImportClause.setModuleSpecifier(
|
|
186
|
+
fmxImportClause.setModuleSpecifier(importDeclaration?.getModuleSpecifierValue() as string);
|
|
185
187
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
fmxImportClause.getImportedEntity() instanceof Function ? 'Function' :
|
|
189
|
-
fmxImportClause.getImportedEntity() instanceof Enum ? 'Enum' :
|
|
190
|
-
fmxImportClause.getImportedEntity() instanceof Alias ? 'Alias' :
|
|
191
|
-
fmxImportClause.getImportedEntity() instanceof Variable ? 'Variable' :
|
|
192
|
-
'NamedEntity'}) is imported by ${fmxImportClause.getImportingEntity()?.getName()}`);
|
|
188
|
+
logger.debug(`createFamixImportClause: ${fmxImportClause.getImportedEntity()?.getName()} (of type ${
|
|
189
|
+
getSubTypeName(fmxImportClause.getImportedEntity())}) is imported by ${fmxImportClause.getImportingEntity()?.getName()}`);
|
|
193
190
|
|
|
194
|
-
|
|
191
|
+
// make an index file anchor for the import clause
|
|
192
|
+
this.famixFunctionsIndex.makeFamixIndexFileAnchor(importDeclaration, fmxImportClause);
|
|
195
193
|
|
|
196
194
|
fmxImporter.addOutgoingImport(fmxImportClause);
|
|
197
195
|
}
|
|
@@ -223,3 +221,22 @@ export class FamixFunctionsAssociations {
|
|
|
223
221
|
return node.getAncestors().find(a => a.getKind() === SyntaxKind.MethodDeclaration || a.getKind() === SyntaxKind.Constructor || a.getKind() === SyntaxKind.FunctionDeclaration || a.getKind() === SyntaxKind.FunctionExpression || a.getKind() === SyntaxKind.ModuleDeclaration || a.getKind() === SyntaxKind.SourceFile || a.getKindName() === "GetAccessor" || a.getKindName() === "SetAccessor" || a.getKind() === SyntaxKind.ClassDeclaration);
|
|
224
222
|
}
|
|
225
223
|
}
|
|
224
|
+
function getSubTypeName(fmxNamedEntity: Famix.NamedEntity) {
|
|
225
|
+
const name = fmxNamedEntity instanceof Famix.Class ? 'Class' :
|
|
226
|
+
fmxNamedEntity instanceof Famix.Interface ? 'Interface' :
|
|
227
|
+
fmxNamedEntity instanceof Famix.Function ? 'Function' :
|
|
228
|
+
fmxNamedEntity instanceof Famix.Enum ? 'Enum' :
|
|
229
|
+
fmxNamedEntity instanceof Famix.EnumValue ? 'EnumValue' :
|
|
230
|
+
fmxNamedEntity instanceof Famix.Alias ? 'Alias' :
|
|
231
|
+
fmxNamedEntity instanceof Famix.Variable ? 'Variable' :
|
|
232
|
+
fmxNamedEntity instanceof Famix.Type ? 'Type' :
|
|
233
|
+
fmxNamedEntity instanceof Famix.Method ? 'Method' :
|
|
234
|
+
fmxNamedEntity instanceof Famix.Decorator ? 'Decorator' :
|
|
235
|
+
fmxNamedEntity instanceof Famix.Accessor ? 'Accessor' :
|
|
236
|
+
fmxNamedEntity instanceof Famix.Parameter ? 'Parameter' :
|
|
237
|
+
fmxNamedEntity instanceof Famix.Property ? 'Property' :
|
|
238
|
+
'NamedEntity';
|
|
239
|
+
logger.debug(`${fmxNamedEntity.getName()} is of type ${name}`);
|
|
240
|
+
return name;
|
|
241
|
+
}
|
|
242
|
+
|
|
@@ -1,8 +1,9 @@
|
|
|
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 GraphemeSplitter from "grapheme-splitter";
|
|
6
|
+
import { logger, config } from "../analyze";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This class is used to build a Famix model for the index file anchors
|
|
@@ -25,14 +26,22 @@ export class FamixFunctionsIndex {
|
|
|
25
26
|
* @param sourceElement A source element
|
|
26
27
|
* @param famixElement The Famix model of the source element
|
|
27
28
|
*/
|
|
28
|
-
public makeFamixIndexFileAnchor(sourceElement: SourceFile | ModuleDeclaration | ClassDeclaration | InterfaceDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature | FunctionDeclaration | FunctionExpression | ParameterDeclaration | VariableDeclaration | PropertyDeclaration | PropertySignature | TypeParameterDeclaration | Identifier | Decorator | GetAccessorDeclaration | SetAccessorDeclaration | ImportSpecifier | CommentRange | EnumDeclaration | EnumMember | TypeAliasDeclaration | ExpressionWithTypeArguments, famixElement: Famix.SourcedEntity): void {
|
|
29
|
+
public makeFamixIndexFileAnchor(sourceElement: ImportDeclaration | SourceFile | ModuleDeclaration | ClassDeclaration | InterfaceDeclaration | MethodDeclaration | ConstructorDeclaration | MethodSignature | FunctionDeclaration | FunctionExpression | ParameterDeclaration | VariableDeclaration | PropertyDeclaration | PropertySignature | TypeParameterDeclaration | Identifier | Decorator | GetAccessorDeclaration | SetAccessorDeclaration | ImportSpecifier | CommentRange | EnumDeclaration | EnumMember | TypeAliasDeclaration | ExpressionWithTypeArguments, famixElement: Famix.SourcedEntity): void {
|
|
30
|
+
logger.debug("making index file anchor for '" + sourceElement?.getText() + "' with famixElement " + famixElement.getJSON());
|
|
29
31
|
const fmxIndexFileAnchor = new Famix.IndexedFileAnchor(this.famixRep);
|
|
30
32
|
fmxIndexFileAnchor.setElement(famixElement);
|
|
31
33
|
|
|
32
34
|
if (sourceElement !== null) {
|
|
33
35
|
fmxIndexFileAnchor.setFileName(sourceElement.getSourceFile().getFilePath());
|
|
36
|
+
let sourceStart, sourceEnd: number;
|
|
34
37
|
if (!(sourceElement instanceof CommentRange)) {
|
|
35
|
-
|
|
38
|
+
sourceStart = sourceElement.getStart();
|
|
39
|
+
sourceEnd = sourceElement.getEnd();
|
|
40
|
+
} else {
|
|
41
|
+
sourceStart = sourceElement.getPos();
|
|
42
|
+
sourceEnd = sourceElement.getEnd();
|
|
43
|
+
}
|
|
44
|
+
if (config.expectGraphemes) {
|
|
36
45
|
/**
|
|
37
46
|
* The following logic handles the case of multi-code point characters (e.g. emoji) in the source text.
|
|
38
47
|
* This is needed because Pharo/Smalltalk treats multi-code point characters as a single character,
|
|
@@ -47,31 +56,32 @@ export class FamixFunctionsIndex {
|
|
|
47
56
|
const sourceFileText = sourceElement.getSourceFile().getFullText();
|
|
48
57
|
const hasGraphemeClusters = splitter.countGraphemes(sourceFileText) > 1;
|
|
49
58
|
if (hasGraphemeClusters) {
|
|
50
|
-
const sourceElementText = sourceFileText.substring(
|
|
59
|
+
const sourceElementText = sourceFileText.substring(sourceStart, sourceEnd);
|
|
51
60
|
const sourceElementTextGraphemes = splitter.splitGraphemes(sourceElementText);
|
|
52
61
|
const sourceFileTextGraphemes = splitter.splitGraphemes(sourceFileText);
|
|
53
|
-
const
|
|
54
|
-
const numberOfGraphemeClustersBeforeStart = splitter.countGraphemes(sourceFileText.substring(0, start));
|
|
62
|
+
const numberOfGraphemeClustersBeforeStart = splitter.countGraphemes(sourceFileText.substring(0, sourceStart));
|
|
55
63
|
|
|
56
64
|
// find the start of the sourceElementTextGraphemes array in the sourceFileTextGraphemes array
|
|
57
|
-
|
|
65
|
+
sourceStart = indexOfSplitArray({searchArray: sourceFileTextGraphemes,
|
|
58
66
|
targetArray: sourceElementTextGraphemes,
|
|
59
|
-
start:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// note: the +1 is because the source anchor is 1-based, but ts-morph is 0-based
|
|
63
|
-
fmxIndexFileAnchor.setStartPos(newStart + 1);
|
|
64
|
-
fmxIndexFileAnchor.setEndPos(newEnd + 1);
|
|
65
|
-
} else {
|
|
66
|
-
// note: the +1 is because the source anchor is 1-based, but ts-morph is 0-based
|
|
67
|
-
fmxIndexFileAnchor.setStartPos(sourceElement.getStart() + 1);
|
|
68
|
-
fmxIndexFileAnchor.setEndPos(sourceElement.getEnd() + 1);
|
|
69
|
-
}
|
|
67
|
+
start: sourceStart - numberOfGraphemeClustersBeforeStart});
|
|
68
|
+
sourceEnd = sourceStart + sourceElementTextGraphemes.length;
|
|
69
|
+
}
|
|
70
70
|
}
|
|
71
|
+
// note: the +1 is because the source anchor is 1-based, but ts-morph is 0-based
|
|
72
|
+
fmxIndexFileAnchor.setStartPos(sourceStart + 1);
|
|
73
|
+
fmxIndexFileAnchor.setEndPos(sourceEnd + 1);
|
|
71
74
|
|
|
72
75
|
if (!(famixElement instanceof Famix.Association) && !(famixElement instanceof Famix.Comment) && !(sourceElement instanceof CommentRange) && !(sourceElement instanceof Identifier) && !(sourceElement instanceof ImportSpecifier) && !(sourceElement instanceof ExpressionWithTypeArguments)) {
|
|
73
76
|
(famixElement as Famix.NamedEntity).setFullyQualifiedName(this.FQNFunctions.getFQN(sourceElement));
|
|
74
77
|
}
|
|
78
|
+
} else {
|
|
79
|
+
// sourceElement is null
|
|
80
|
+
logger.warn("sourceElement is null for famixElement " + famixElement.getJSON());
|
|
81
|
+
fmxIndexFileAnchor.setFileName("unknown");
|
|
82
|
+
fmxIndexFileAnchor.setStartPos(0);
|
|
83
|
+
fmxIndexFileAnchor.setEndPos(0);
|
|
84
|
+
|
|
75
85
|
}
|
|
76
86
|
}
|
|
77
87
|
}
|
|
@@ -3,6 +3,7 @@ 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
|
+
import { logger } from "../analyze";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* This class is used to build a Famix model for the types
|
|
@@ -34,7 +35,7 @@ export class FamixFunctionsTypes {
|
|
|
34
35
|
let isPrimitiveType = false;
|
|
35
36
|
let isParameterizedType = false;
|
|
36
37
|
|
|
37
|
-
|
|
38
|
+
logger.debug("Creating (or getting) type: '" + typeName + "' of element: " + element.getText() + " of kind: " + element.getKindName());
|
|
38
39
|
|
|
39
40
|
const typeAncestor = this.findTypeAncestor(element);
|
|
40
41
|
const ancestorFullyQualifiedName = this.FQNFunctions.getFQN(typeAncestor);
|
package/src/generate_uml.sh
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { FamixBaseElement } from "./famix_base_element";
|
|
2
|
-
import { Class, Interface, Namespace, Variable, Method, Function as FamixFunctionEntity, Type, NamedEntity, ScriptEntity, Module } from "./model/famix";
|
|
2
|
+
import { Class, Interface, Namespace, Variable, Method, Function as FamixFunctionEntity, Type, NamedEntity, ScriptEntity, Module, SourceLanguage } from "./model/famix";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* This class is used to store all Famix elements
|
|
6
6
|
*/
|
|
7
7
|
export class FamixRepository {
|
|
8
|
-
|
|
9
8
|
private elements = new Set<FamixBaseElement>(); // All Famix elements
|
|
10
9
|
private famixClasses = new Set<Class>(); // All Famix classes
|
|
11
10
|
private famixInterfaces = new Set<Interface>(); // All Famix interfaces
|
|
@@ -16,6 +15,10 @@ export class FamixRepository {
|
|
|
16
15
|
private famixFiles = new Set<ScriptEntity | Module>(); // All Famix files
|
|
17
16
|
private idCounter = 1; // Id counter
|
|
18
17
|
|
|
18
|
+
constructor() {
|
|
19
|
+
this.addElement(new SourceLanguage(this)); // add the source language entity (TypeScript)
|
|
20
|
+
}
|
|
21
|
+
|
|
19
22
|
/**
|
|
20
23
|
* Gets a Famix entity by id
|
|
21
24
|
* @param id An id of a Famix entity
|
|
@@ -37,7 +40,13 @@ export class FamixRepository {
|
|
|
37
40
|
return entity;
|
|
38
41
|
}
|
|
39
42
|
|
|
40
|
-
|
|
43
|
+
export(arg0: { format: string; }) {
|
|
44
|
+
if(arg0.format === "json") {
|
|
45
|
+
return this.getJSON();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
41
50
|
// Only for tests
|
|
42
51
|
|
|
43
52
|
/**
|
|
@@ -39,9 +39,9 @@ export class Access extends Association {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
public getJSON(): string {
|
|
42
|
-
const
|
|
43
|
-
this.addPropertiesToExporter(
|
|
44
|
-
return
|
|
42
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Access", this);
|
|
43
|
+
this.addPropertiesToExporter(json);
|
|
44
|
+
return json.getJSON();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -4,9 +4,9 @@ import { Method } from "./method";
|
|
|
4
4
|
export class Accessor extends Method {
|
|
5
5
|
|
|
6
6
|
public getJSON(): string {
|
|
7
|
-
const
|
|
8
|
-
this.addPropertiesToExporter(
|
|
9
|
-
return
|
|
7
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Accessor", this);
|
|
8
|
+
this.addPropertiesToExporter(json);
|
|
9
|
+
return json.getJSON();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -28,9 +28,9 @@ export class Alias extends NamedEntity {
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
public getJSON(): string {
|
|
31
|
-
const
|
|
32
|
-
this.addPropertiesToExporter(
|
|
33
|
-
return
|
|
31
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Alias", this);
|
|
32
|
+
this.addPropertiesToExporter(json);
|
|
33
|
+
return json.getJSON();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -31,9 +31,9 @@ export class Association extends SourcedEntity {
|
|
|
31
31
|
|
|
32
32
|
|
|
33
33
|
public getJSON(): string {
|
|
34
|
-
const
|
|
35
|
-
this.addPropertiesToExporter(
|
|
36
|
-
return
|
|
34
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Association", this);
|
|
35
|
+
this.addPropertiesToExporter(json);
|
|
36
|
+
return json.getJSON();
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -3,7 +3,7 @@ import { Type } from "./type";
|
|
|
3
3
|
import { ContainerEntity } from "./container_entity";
|
|
4
4
|
import { Parameter } from "./parameter";
|
|
5
5
|
import { Invocation } from "./invocation";
|
|
6
|
-
import {
|
|
6
|
+
import { ParameterType } from "./parameter_type";
|
|
7
7
|
|
|
8
8
|
export class BehavioralEntity extends ContainerEntity {
|
|
9
9
|
|
|
@@ -74,13 +74,13 @@ export class BehavioralEntity extends ContainerEntity {
|
|
|
74
74
|
declaredType.addBehavioralEntityWithDeclaredType(this);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
private typeParameters: Set<
|
|
77
|
+
private typeParameters: Set<ParameterType> = new Set();
|
|
78
78
|
|
|
79
|
-
public
|
|
79
|
+
public getParameterTypes(): Set<ParameterType> {
|
|
80
80
|
return this.typeParameters;
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
public
|
|
83
|
+
public addParameterType(typeParameter: ParameterType): void {
|
|
84
84
|
if (!this.typeParameters.has(typeParameter)) {
|
|
85
85
|
this.typeParameters.add(typeParameter);
|
|
86
86
|
typeParameter.setParentGeneric(this);
|
|
@@ -89,9 +89,9 @@ export class BehavioralEntity extends ContainerEntity {
|
|
|
89
89
|
|
|
90
90
|
|
|
91
91
|
public getJSON(): string {
|
|
92
|
-
const
|
|
93
|
-
this.addPropertiesToExporter(
|
|
94
|
-
return
|
|
92
|
+
const json: FamixJSONExporter = new FamixJSONExporter("BehavioralEntity", this);
|
|
93
|
+
this.addPropertiesToExporter(json);
|
|
94
|
+
return json.getJSON();
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -102,6 +102,6 @@ export class BehavioralEntity extends ContainerEntity {
|
|
|
102
102
|
exporter.addProperty("numberOfParameters", this.getNumberOfParameters());
|
|
103
103
|
exporter.addProperty("incomingInvocations", this.getIncomingInvocations());
|
|
104
104
|
exporter.addProperty("declaredType", this.getDeclaredType());
|
|
105
|
-
exporter.addProperty("typeParameters", this.
|
|
105
|
+
exporter.addProperty("typeParameters", this.getParameterTypes());
|
|
106
106
|
}
|
|
107
107
|
}
|
|
@@ -70,9 +70,9 @@ export class Class extends Type {
|
|
|
70
70
|
|
|
71
71
|
|
|
72
72
|
public getJSON(): string {
|
|
73
|
-
const
|
|
74
|
-
this.addPropertiesToExporter(
|
|
75
|
-
return
|
|
73
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Class", this);
|
|
74
|
+
this.addPropertiesToExporter(json);
|
|
75
|
+
return json.getJSON();
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -36,9 +36,9 @@ export class Comment extends SourcedEntity {
|
|
|
36
36
|
|
|
37
37
|
|
|
38
38
|
public getJSON(): string {
|
|
39
|
-
const
|
|
40
|
-
this.addPropertiesToExporter(
|
|
41
|
-
return
|
|
39
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Comment", this);
|
|
40
|
+
this.addPropertiesToExporter(json);
|
|
41
|
+
return json.getJSON();
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -143,9 +143,9 @@ export class ContainerEntity extends NamedEntity {
|
|
|
143
143
|
|
|
144
144
|
|
|
145
145
|
public getJSON(): string {
|
|
146
|
-
const
|
|
147
|
-
this.addPropertiesToExporter(
|
|
148
|
-
return
|
|
146
|
+
const json: FamixJSONExporter = new FamixJSONExporter("ContainerEntity", this);
|
|
147
|
+
this.addPropertiesToExporter(json);
|
|
148
|
+
return json.getJSON();
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -26,9 +26,9 @@ export class Decorator extends NamedEntity {
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
public getJSON(): string {
|
|
29
|
-
const
|
|
30
|
-
this.addPropertiesToExporter(
|
|
31
|
-
return
|
|
29
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Decorator", this);
|
|
30
|
+
this.addPropertiesToExporter(json);
|
|
31
|
+
return json.getJSON();
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -4,9 +4,9 @@ import { FamixBaseElement } from "../../famix_base_element";
|
|
|
4
4
|
export class Entity extends FamixBaseElement {
|
|
5
5
|
|
|
6
6
|
public getJSON(): string {
|
|
7
|
-
const
|
|
8
|
-
this.addPropertiesToExporter(
|
|
9
|
-
return
|
|
7
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Entity", this);
|
|
8
|
+
this.addPropertiesToExporter(json);
|
|
9
|
+
return json.getJSON();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -19,9 +19,9 @@ export class Enum extends Type {
|
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
public getJSON(): string {
|
|
22
|
-
const
|
|
23
|
-
this.addPropertiesToExporter(
|
|
24
|
-
return
|
|
22
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Enum", this);
|
|
23
|
+
this.addPropertiesToExporter(json);
|
|
24
|
+
return json.getJSON();
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -17,9 +17,9 @@ export class EnumValue extends StructuralEntity {
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
public getJSON(): string {
|
|
20
|
-
const
|
|
21
|
-
this.addPropertiesToExporter(
|
|
22
|
-
return
|
|
20
|
+
const json: FamixJSONExporter = new FamixJSONExporter("EnumValue", this);
|
|
21
|
+
this.addPropertiesToExporter(json);
|
|
22
|
+
return json.getJSON();
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -4,9 +4,9 @@ import { BehavioralEntity } from "./behavioral_entity";
|
|
|
4
4
|
export class Function extends BehavioralEntity {
|
|
5
5
|
|
|
6
6
|
public getJSON(): string {
|
|
7
|
-
const
|
|
8
|
-
this.addPropertiesToExporter(
|
|
9
|
-
return
|
|
7
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Function", this);
|
|
8
|
+
this.addPropertiesToExporter(json);
|
|
9
|
+
return json.getJSON();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -4,9 +4,9 @@ import { Variable } from "./variable";
|
|
|
4
4
|
export class ImplicitVariable extends Variable {
|
|
5
5
|
|
|
6
6
|
public getJSON(): string {
|
|
7
|
-
const
|
|
8
|
-
this.addPropertiesToExporter(
|
|
9
|
-
return
|
|
7
|
+
const json: FamixJSONExporter = new FamixJSONExporter("ImplicitVariable", this);
|
|
8
|
+
this.addPropertiesToExporter(json);
|
|
9
|
+
return json.getJSON();
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -39,9 +39,9 @@ export class ImportClause extends Association {
|
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
public getJSON(): string {
|
|
42
|
-
const
|
|
43
|
-
this.addPropertiesToExporter(
|
|
44
|
-
return
|
|
42
|
+
const json: FamixJSONExporter = new FamixJSONExporter("ImportClause", this);
|
|
43
|
+
this.addPropertiesToExporter(json);
|
|
44
|
+
return json.getJSON();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -1,42 +1,40 @@
|
|
|
1
|
-
export {Access} from "./access";
|
|
2
|
-
export {Accessor} from "./accessor";
|
|
3
|
-
export {Alias} from "./alias";
|
|
4
|
-
export {Association} from "./association";
|
|
5
|
-
export {BehavioralEntity} from "./behavioral_entity";
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
22
|
-
export {
|
|
23
|
-
export {
|
|
24
|
-
export {
|
|
25
|
-
export {
|
|
26
|
-
export {
|
|
27
|
-
export {
|
|
28
|
-
export {
|
|
29
|
-
export {
|
|
30
|
-
export {
|
|
31
|
-
export {
|
|
32
|
-
export {
|
|
33
|
-
export {
|
|
34
|
-
export {
|
|
35
|
-
export {
|
|
36
|
-
export {
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
export {
|
|
40
|
-
export {
|
|
41
|
-
export {Type} from "./type";
|
|
42
|
-
export {Variable} from "./variable";
|
|
1
|
+
export { Access } from "./access";
|
|
2
|
+
export { Accessor } from "./accessor";
|
|
3
|
+
export { Alias } from "./alias";
|
|
4
|
+
export { Association } from "./association";
|
|
5
|
+
export { BehavioralEntity } from "./behavioral_entity";
|
|
6
|
+
export { Class } from "./class";
|
|
7
|
+
export { Comment } from "./comment";
|
|
8
|
+
export { ContainerEntity } from "./container_entity";
|
|
9
|
+
export { Decorator } from "./decorator";
|
|
10
|
+
export { Entity } from "./entity";
|
|
11
|
+
export { EnumValue } from "./enum_value";
|
|
12
|
+
export { Enum } from "./enum";
|
|
13
|
+
export { Property } from "./property";
|
|
14
|
+
export { Function } from "./function";
|
|
15
|
+
export { ImplicitVariable } from "./implicit_variable";
|
|
16
|
+
export { ImportClause } from "./import_clause";
|
|
17
|
+
export { IndexedFileAnchor } from "./indexed_file_anchor";
|
|
18
|
+
export { Inheritance } from "./inheritance";
|
|
19
|
+
export { Interface } from "./interface";
|
|
20
|
+
export { Invocation } from "./invocation";
|
|
21
|
+
export { Method } from "./method";
|
|
22
|
+
export { Module } from "./module";
|
|
23
|
+
export { NamedEntity } from "./named_entity";
|
|
24
|
+
export { Namespace } from "./namespace";
|
|
25
|
+
export { ParameterType } from "./parameter_type";
|
|
26
|
+
export { Parameter } from "./parameter";
|
|
27
|
+
export { ParameterizableClass } from "./parameterizable_class";
|
|
28
|
+
export { ParameterizableInterface } from "./parameterizable_interface";
|
|
29
|
+
export { ParameterizedType } from "./parameterized_type";
|
|
30
|
+
export { PrimitiveType } from "./primitive_type";
|
|
31
|
+
export { Reference } from "./reference";
|
|
32
|
+
export { ScopingEntity } from "./scoping_entity";
|
|
33
|
+
export { ScriptEntity } from "./script_entity";
|
|
34
|
+
export { SourceAnchor } from "./source_anchor";
|
|
35
|
+
export { SourceLanguage } from "./source_language";
|
|
36
|
+
export { SourcedEntity } from "./sourced_entity";
|
|
37
|
+
export { StructuralEntity } from "./structural_entity";
|
|
38
|
+
export { TextAnchor } from "./text_anchor";
|
|
39
|
+
export { Type } from "./type";
|
|
40
|
+
export { Variable } from "./variable";
|
|
@@ -35,9 +35,9 @@ export class IndexedFileAnchor extends SourceAnchor {
|
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
public getJSON(): string {
|
|
38
|
-
const
|
|
39
|
-
this.addPropertiesToExporter(
|
|
40
|
-
return
|
|
38
|
+
const json: FamixJSONExporter = new FamixJSONExporter("IndexedFileAnchor", this);
|
|
39
|
+
this.addPropertiesToExporter(json);
|
|
40
|
+
return json.getJSON();
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -29,9 +29,9 @@ export class Inheritance extends Association {
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
public getJSON(): string {
|
|
32
|
-
const
|
|
33
|
-
this.addPropertiesToExporter(
|
|
34
|
-
return
|
|
32
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Inheritance", this);
|
|
33
|
+
this.addPropertiesToExporter(json);
|
|
34
|
+
return json.getJSON();
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -60,9 +60,9 @@ export class Interface extends Type {
|
|
|
60
60
|
|
|
61
61
|
|
|
62
62
|
public getJSON(): string {
|
|
63
|
-
const
|
|
64
|
-
this.addPropertiesToExporter(
|
|
65
|
-
return
|
|
63
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Interface", this);
|
|
64
|
+
this.addPropertiesToExporter(json);
|
|
65
|
+
return json.getJSON();
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
@@ -53,9 +53,9 @@ export class Invocation extends Association {
|
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
public getJSON(): string {
|
|
56
|
-
const
|
|
57
|
-
this.addPropertiesToExporter(
|
|
58
|
-
return
|
|
56
|
+
const json: FamixJSONExporter = new FamixJSONExporter("Invocation", this);
|
|
57
|
+
this.addPropertiesToExporter(json);
|
|
58
|
+
return json.getJSON();
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|