ts2famix 1.4.0 → 2.0.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.
Files changed (119) hide show
  1. package/README.md +1 -1
  2. package/dist/analyze.js +6 -3
  3. package/dist/analyze_functions/process_functions.js +248 -100
  4. package/dist/famix2puml.js +1 -0
  5. package/dist/famix_functions/EntityDictionary.js +661 -155
  6. package/dist/famix_functions/helpers_creation.js +26 -6
  7. package/dist/fqn.js +156 -69
  8. package/dist/lib/famix/src/famix_JSON_exporter.js +1 -0
  9. package/dist/lib/famix/src/famix_base_element.js +1 -0
  10. package/dist/lib/famix/src/famix_repository.js +9 -8
  11. package/dist/lib/famix/src/index.js +1 -0
  12. package/dist/lib/famix/src/model/famix/access.js +3 -2
  13. package/dist/lib/famix/src/model/famix/accessor.js +1 -0
  14. package/dist/lib/famix/src/model/famix/alias.js +2 -1
  15. package/dist/lib/famix/src/model/famix/arrowFunction.js +17 -0
  16. package/dist/lib/famix/src/model/famix/behavioral_entity.js +13 -15
  17. package/dist/lib/famix/src/model/famix/class.js +1 -0
  18. package/dist/lib/famix/src/model/famix/comment.js +2 -1
  19. package/dist/lib/famix/src/model/famix/concretisation.js +31 -0
  20. package/dist/lib/famix/src/model/famix/container_entity.js +7 -6
  21. package/dist/lib/famix/src/model/famix/decorator.js +2 -1
  22. package/dist/lib/famix/src/model/famix/entity.js +1 -0
  23. package/dist/lib/famix/src/model/famix/enum.js +2 -1
  24. package/dist/lib/famix/src/model/famix/enum_value.js +2 -1
  25. package/dist/lib/famix/src/model/famix/function.js +1 -0
  26. package/dist/lib/famix/src/model/famix/implicit_variable.js +1 -0
  27. package/dist/lib/famix/src/model/famix/import_clause.js +5 -3
  28. package/dist/lib/famix/src/model/famix/index.js +18 -11
  29. package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +3 -2
  30. package/dist/lib/famix/src/model/famix/inheritance.js +3 -2
  31. package/dist/lib/famix/src/model/famix/interface.js +2 -1
  32. package/dist/lib/famix/src/model/famix/invocation.js +3 -2
  33. package/dist/lib/famix/src/model/famix/method.js +2 -1
  34. package/dist/lib/famix/src/model/famix/module.js +53 -0
  35. package/dist/lib/famix/src/model/famix/named_entity.js +4 -3
  36. package/dist/lib/famix/src/model/famix/parameter.js +2 -1
  37. package/dist/lib/famix/src/model/famix/parameterConcretisation.js +44 -0
  38. package/dist/lib/famix/src/model/famix/parameter_type.js +22 -1
  39. package/dist/lib/famix/src/model/famix/parametric_arrow_function.js +31 -0
  40. package/dist/lib/famix/src/model/famix/parametric_class.js +44 -0
  41. package/dist/lib/famix/src/model/famix/parametric_function.js +31 -0
  42. package/dist/lib/famix/src/model/famix/parametric_interface.js +44 -0
  43. package/dist/lib/famix/src/model/famix/parametric_method.js +31 -0
  44. package/dist/lib/famix/src/model/famix/primitive_type.js +1 -0
  45. package/dist/lib/famix/src/model/famix/property.js +91 -9
  46. package/dist/lib/famix/src/model/famix/reference.js +3 -2
  47. package/dist/lib/famix/src/model/famix/scoping_entity.js +12 -10
  48. package/dist/lib/famix/src/model/famix/script_entity.js +1 -2
  49. package/dist/lib/famix/src/model/famix/source_anchor.js +1 -0
  50. package/dist/lib/famix/src/model/famix/source_language.js +1 -1
  51. package/dist/lib/famix/src/model/famix/sourced_entity.js +2 -1
  52. package/dist/lib/famix/src/model/famix/structural_entity.js +1 -0
  53. package/dist/lib/famix/src/model/famix/text_anchor.js +1 -0
  54. package/dist/lib/famix/src/model/famix/type.js +6 -4
  55. package/dist/lib/famix/src/model/famix/variable.js +1 -0
  56. package/dist/lib/ts-complex/cyclomatic-service.js +2 -2
  57. package/dist/ts2famix-cli-wrapper.js +16 -0
  58. package/dist/ts2famix-cli.js +8 -1
  59. package/dist/ts2famix-tsconfig.js +1 -0
  60. package/doc-uml/famix-typescript-model.puml +559 -0
  61. package/doc-uml/famix-typescript-model.svg +1 -0
  62. package/jest.config.json +2 -1
  63. package/package.json +10 -10
  64. package/src/analyze.ts +25 -22
  65. package/src/analyze_functions/process_functions.ts +272 -96
  66. package/src/famix_functions/EntityDictionary.ts +731 -182
  67. package/src/famix_functions/helpers_creation.ts +28 -2
  68. package/src/fqn.ts +132 -10
  69. package/src/lib/famix/src/famix_repository.ts +9 -9
  70. package/src/lib/famix/src/model/famix/access.ts +2 -2
  71. package/src/lib/famix/src/model/famix/alias.ts +1 -1
  72. package/src/lib/famix/src/model/famix/arrowFunction.ts +15 -0
  73. package/src/lib/famix/src/model/famix/behavioral_entity.ts +12 -19
  74. package/src/lib/famix/src/model/famix/comment.ts +1 -1
  75. package/src/lib/famix/src/model/famix/concretisation.ts +42 -0
  76. package/src/lib/famix/src/model/famix/container_entity.ts +6 -6
  77. package/src/lib/famix/src/model/famix/decorator.ts +1 -1
  78. package/src/lib/famix/src/model/famix/enum.ts +1 -1
  79. package/src/lib/famix/src/model/famix/enum_value.ts +1 -1
  80. package/src/lib/famix/src/model/famix/import_clause.ts +4 -3
  81. package/src/lib/famix/src/model/famix/index.ts +8 -5
  82. package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +2 -2
  83. package/src/lib/famix/src/model/famix/inheritance.ts +3 -4
  84. package/src/lib/famix/src/model/famix/interface.ts +1 -1
  85. package/src/lib/famix/src/model/famix/invocation.ts +2 -2
  86. package/src/lib/famix/src/model/famix/method.ts +1 -1
  87. package/src/lib/famix/src/model/famix/module.ts +67 -1
  88. package/src/lib/famix/src/model/famix/named_entity.ts +3 -3
  89. package/src/lib/famix/src/model/famix/parameter.ts +1 -1
  90. package/src/lib/famix/src/model/famix/parameterConcretisation.ts +54 -0
  91. package/src/lib/famix/src/model/famix/parameter_type.ts +33 -6
  92. package/src/lib/famix/src/model/famix/parametric_arrow_function.ts +32 -0
  93. package/src/lib/famix/src/model/famix/parametric_class.ts +49 -0
  94. package/src/lib/famix/src/model/famix/parametric_function.ts +32 -0
  95. package/src/lib/famix/src/model/famix/parametric_interface.ts +49 -0
  96. package/src/lib/famix/src/model/famix/parametric_method.ts +32 -0
  97. package/src/lib/famix/src/model/famix/property.ts +109 -11
  98. package/src/lib/famix/src/model/famix/reference.ts +2 -2
  99. package/src/lib/famix/src/model/famix/scoping_entity.ts +12 -11
  100. package/src/lib/famix/src/model/famix/script_entity.ts +0 -2
  101. package/src/lib/famix/src/model/famix/source_language.ts +0 -1
  102. package/src/lib/famix/src/model/famix/sourced_entity.ts +1 -1
  103. package/src/lib/famix/src/model/famix/type.ts +5 -4
  104. package/src/ts2famix-cli-wrapper.ts +17 -0
  105. package/src/ts2famix-cli.ts +7 -1
  106. package/tsconfig.json +5 -5
  107. package/dist/lib/famix/src/model/famix/association.js +0 -36
  108. package/dist/lib/famix/src/model/famix/namespace.js +0 -24
  109. package/dist/lib/famix/src/model/famix/parameterizable_class.js +0 -30
  110. package/dist/lib/famix/src/model/famix/parameterizable_interface.js +0 -30
  111. package/dist/lib/famix/src/model/famix/parameterized_type.js +0 -36
  112. package/doc-uml/metamodel-full.svg +0 -1
  113. package/doc-uml/metamodel.svg +0 -1
  114. package/plantuml.jar +0 -0
  115. package/src/lib/famix/src/model/famix/association.ts +0 -44
  116. package/src/lib/famix/src/model/famix/namespace.ts +0 -28
  117. package/src/lib/famix/src/model/famix/parameterizable_class.ts +0 -31
  118. package/src/lib/famix/src/model/famix/parameterizable_interface.ts +0 -31
  119. package/src/lib/famix/src/model/famix/parameterized_type.ts +0 -40
@@ -1,6 +1,7 @@
1
1
  import * as Famix from "../lib/famix/src/model/famix";
2
2
  import { logger } from "../analyze";
3
3
  import { ConstructorDeclaration, Identifier, FunctionDeclaration, MethodDeclaration, MethodSignature, PropertyDeclaration, PropertySignature, VariableDeclaration, ParameterDeclaration, GetAccessorDeclaration, SetAccessorDeclaration, EnumMember, TypeAliasDeclaration, Node, SyntaxKind, FunctionExpression } from "ts-morph";
4
+ import { TypeDeclaration } from "./EntityDictionary";
4
5
 
5
6
  interface SearchParameters {
6
7
  searchArray: string[];
@@ -72,6 +73,31 @@ export function findAncestor(node: Identifier): Node {
72
73
  * @param element A ts-morph element
73
74
  * @returns The ancestor of the ts-morph element
74
75
  */
75
- export function findTypeAncestor(element: TypeAliasDeclaration | PropertyDeclaration | PropertySignature | MethodDeclaration | ConstructorDeclaration | MethodSignature | GetAccessorDeclaration | SetAccessorDeclaration | FunctionDeclaration | FunctionExpression | ParameterDeclaration | VariableDeclaration | EnumMember): Node {
76
+ export function findTypeAncestor(element: TypeDeclaration): Node {
76
77
  return element.getAncestors().find(a => a.getKind() === SyntaxKind.MethodDeclaration || a.getKind() === SyntaxKind.Constructor || a.getKind() === SyntaxKind.MethodSignature || 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 || a.getKind() === SyntaxKind.InterfaceDeclaration);
77
- }
78
+ }
79
+
80
+ export function arraysAreEqual(array1: string[], array2: string[]): boolean {
81
+ if (array1 && array2 ) {
82
+ return array1.length === array2.length && array1.every((value, index) => value === array2[index]);
83
+ }
84
+ }
85
+
86
+ export function replaceLastBetweenTags(input: string, replacement: string): string {
87
+ const lastTagIndex = input.lastIndexOf('<');
88
+
89
+ if (lastTagIndex === -1) {
90
+ return input; // Return the original string if no tags are found
91
+ }
92
+
93
+ const closingTagIndex = input.indexOf('>', lastTagIndex);
94
+
95
+ if (closingTagIndex === -1) {
96
+ return input; // Return the original string if no closing tag is found
97
+ }
98
+
99
+ const beforeTag = input.substring(0, lastTagIndex + 1); // Include '<'
100
+ const afterTag = input.substring(closingTagIndex); // Include '>'
101
+
102
+ return beforeTag + replacement + afterTag;
103
+ }
package/src/fqn.ts CHANGED
@@ -1,16 +1,104 @@
1
- import * as ts from "ts-morph";
2
- import { entityDictionary } from "./analyze";
1
+ import { ArrowFunction, CallExpression, ClassDeclaration, ClassExpression, ConstructorDeclaration, Decorator, EnumDeclaration, FunctionDeclaration, FunctionExpression, GetAccessorDeclaration, Identifier, ImportDeclaration, ImportEqualsDeclaration, InterfaceDeclaration, MethodDeclaration, MethodSignature, ModuleDeclaration, Node, PropertyDeclaration, SetAccessorDeclaration, SourceFile, ts, TypeParameterDeclaration, VariableDeclaration } from "ts-morph";
2
+ import { entityDictionary, logger } from "./analyze";
3
3
  import path from "path";
4
+ import { TypeDeclaration } from "./famix_functions/EntityDictionary";
5
+
6
+
7
+ type FQNNode = SourceFile | VariableDeclaration | ArrowFunction | Identifier | MethodDeclaration | MethodSignature | FunctionDeclaration | FunctionExpression | PropertyDeclaration | TypeDeclaration | EnumDeclaration | ImportDeclaration | ImportEqualsDeclaration | CallExpression | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | TypeParameterDeclaration | ClassDeclaration | InterfaceDeclaration | Decorator | ModuleDeclaration;
8
+
9
+ function isFQNNode(node: Node): node is FQNNode {
10
+ return Node.isVariableDeclaration(node) || Node.isArrowFunction(node) || Node.isIdentifier(node) || Node.isMethodDeclaration(node) || Node.isClassDeclaration(node) || Node.isClassExpression(node) || Node.isDecorator(node) || Node.isModuleDeclaration(node) || Node.isCallExpression(node);
11
+
12
+ }
13
+
14
+ export function getFQN(node: FQNNode | Node): string {
15
+ const absolutePathProject = entityDictionary.famixRep.getAbsolutePath();
16
+
17
+ const sourceFile = node.getSourceFile();
18
+ let parts: string[] = [];
19
+ let currentNode: Node | undefined = node;
20
+
21
+ while (currentNode && !Node.isSourceFile(currentNode)) {
22
+ const { line, column } = sourceFile.getLineAndColumnAtPos(currentNode.getStart());
23
+ const lc = `${line}:${column}`;
24
+ if (Node.isClassDeclaration(currentNode) ||
25
+ Node.isClassExpression(currentNode) ||
26
+ Node.isInterfaceDeclaration(currentNode) ||
27
+ Node.isFunctionDeclaration(currentNode) ||
28
+ Node.isMethodDeclaration(currentNode) ||
29
+ Node.isModuleDeclaration(currentNode) ||
30
+ Node.isVariableDeclaration(currentNode) ||
31
+ Node.isGetAccessorDeclaration(currentNode) ||
32
+ Node.isSetAccessorDeclaration(currentNode) ||
33
+ Node.isIdentifier(currentNode)) {
34
+ let name = Node.isIdentifier(currentNode) ? currentNode.getText()
35
+ : getNameOfNode(currentNode) /* currentNode.getName() */ || 'Unnamed_' + currentNode.getKindName() + `(${lc})`;
36
+ parts.unshift(name);
37
+ } else if (Node.isArrowFunction(currentNode) ||
38
+ Node.isBlock(currentNode) ||
39
+ Node.isForInStatement(currentNode) ||
40
+ Node.isForOfStatement(currentNode) ||
41
+ Node.isForStatement(currentNode) ||
42
+ Node.isCatchClause(currentNode)) {
43
+ parts.unshift(`${currentNode.getKindName()}(${lc})`);
44
+ } else if (Node.isConstructorDeclaration(currentNode)) {
45
+ parts.unshift(`constructor`);
46
+ } else {
47
+ // For other kinds, you might want to handle them specifically or ignore
48
+ //console.log(`Ignoring node kind: ${currentNode.getKindName()}`);
49
+ }
50
+ currentNode = currentNode.getParent();
51
+ }
52
+
53
+
54
+
55
+ // Prepend the relative path of the source file
56
+ const relativePath = entityDictionary.convertToRelativePath(
57
+ path.normalize(sourceFile.getFilePath()),
58
+ absolutePathProject).replace(/\\/sg, "/");
59
+ parts.unshift(`{${relativePath}}`);
60
+ const fqn = parts.join(".") + `[${node.getKindName()}]`; // disambiguate
61
+
62
+ logger.debug(fqn);
63
+ return fqn;
64
+ }
65
+
66
+
67
+ export function getUniqueFQN(node: Node): string | undefined {
68
+ const absolutePathProject = entityDictionary.famixRep.getAbsolutePath();
69
+ let parts: string[] = [];
70
+
71
+ if (node instanceof SourceFile) {
72
+ return entityDictionary.convertToRelativePath(path.normalize(node.getFilePath()), absolutePathProject).replace(/\\/g, "/");
73
+ }
74
+
75
+ while (node) {
76
+ if (Node.isSourceFile(node)) {
77
+ const relativePath = entityDictionary.convertToRelativePath(path.normalize(node.getFilePath()), absolutePathProject).replace(/\\/g, "/");
78
+ parts.unshift(relativePath); // Add file path at the start
79
+ break;
80
+ } else if (node.getSymbol()) {
81
+ const name = node.getSymbol()!.getName();
82
+ // For anonymous nodes, use kind and position as unique identifiers
83
+ const identifier = name !== "__computed" ? name : `${node.getKindName()}_${node.getStartLinePos()}`;
84
+ parts.unshift(identifier);
85
+ }
86
+ node = node.getParent();
87
+ }
88
+
89
+ return parts.join("::");
90
+ }
91
+
4
92
 
5
93
  /**
6
94
  * Gets the fully qualified name of a node, if it has one
7
95
  * @param node A node
8
96
  * @returns The fully qualified name of the node, or undefined if it doesn't have one
9
97
  */
10
- export function getFQN(node: ts.Node): string {
98
+ export function oldGetFQN(node: Node): string {
11
99
  const absolutePathProject = entityDictionary.famixRep.getAbsolutePath();
12
100
 
13
- if (node instanceof ts.SourceFile) {
101
+ if (node instanceof SourceFile) {
14
102
  return entityDictionary.convertToRelativePath(path.normalize(node.getFilePath()),
15
103
  absolutePathProject).replace(/\\/sg, "/");
16
104
  }
@@ -67,7 +155,7 @@ export function getFQN(node: ts.Node): string {
67
155
  * @param a A node
68
156
  * @returns The name of the node, or an empty string if it doesn't have one
69
157
  */
70
- export function getNameOfNode(a: ts.Node<ts.ts.Node>): string {
158
+ export function getNameOfNode(a: Node): string {
71
159
  switch (a.getKind()) {
72
160
  case ts.SyntaxKind.SourceFile:
73
161
  return a.asKind(ts.SyntaxKind.SourceFile)?.getBaseName();
@@ -76,10 +164,18 @@ export function getNameOfNode(a: ts.Node<ts.ts.Node>): string {
76
164
  return a.asKind(ts.SyntaxKind.ModuleDeclaration)?.getName();
77
165
 
78
166
  case ts.SyntaxKind.ClassDeclaration:
79
- return a.asKind(ts.SyntaxKind.ClassDeclaration)?.getName();
167
+ if (a.asKind(ts.SyntaxKind.ClassDeclaration).getTypeParameters().length>0){
168
+ return a.asKind(ts.SyntaxKind.ClassDeclaration)?.getName()+getParameters(a);
169
+ } else {
170
+ return a.asKind(ts.SyntaxKind.ClassDeclaration)?.getName();
171
+ }
80
172
 
81
173
  case ts.SyntaxKind.InterfaceDeclaration:
82
- return a.asKind(ts.SyntaxKind.InterfaceDeclaration)?.getName();
174
+ if (a.asKind(ts.SyntaxKind.InterfaceDeclaration).getTypeParameters().length>0){
175
+ return a.asKind(ts.SyntaxKind.InterfaceDeclaration)?.getName()+getParameters(a);
176
+ } else {
177
+ return a.asKind(ts.SyntaxKind.InterfaceDeclaration)?.getName();
178
+ }
83
179
 
84
180
  case ts.SyntaxKind.PropertyDeclaration:
85
181
  return a.asKind(ts.SyntaxKind.PropertyDeclaration)?.getName();
@@ -88,7 +184,11 @@ export function getNameOfNode(a: ts.Node<ts.ts.Node>): string {
88
184
  return a.asKind(ts.SyntaxKind.PropertySignature)?.getName();
89
185
 
90
186
  case ts.SyntaxKind.MethodDeclaration:
91
- return a.asKind(ts.SyntaxKind.MethodDeclaration)?.getName();
187
+ if (a.asKind(ts.SyntaxKind.MethodDeclaration).getTypeParameters().length>0){
188
+ return a.asKind(ts.SyntaxKind.MethodDeclaration)?.getName()+getParameters(a);
189
+ } else {
190
+ return a.asKind(ts.SyntaxKind.MethodDeclaration)?.getName();
191
+ }
92
192
 
93
193
  case ts.SyntaxKind.MethodSignature:
94
194
  return a.asKind(ts.SyntaxKind.MethodSignature)?.getName();
@@ -100,7 +200,11 @@ export function getNameOfNode(a: ts.Node<ts.ts.Node>): string {
100
200
  return a.asKind(ts.SyntaxKind.SetAccessor)?.getName();
101
201
 
102
202
  case ts.SyntaxKind.FunctionDeclaration:
103
- return a.asKind(ts.SyntaxKind.FunctionDeclaration)?.getName();
203
+ if (a.asKind(ts.SyntaxKind.FunctionDeclaration).getTypeParameters().length>0){
204
+ return a.asKind(ts.SyntaxKind.FunctionDeclaration)?.getName()+getParameters(a);
205
+ } else {
206
+ return a.asKind(ts.SyntaxKind.FunctionDeclaration)?.getName();
207
+ }
104
208
 
105
209
  case ts.SyntaxKind.FunctionExpression:
106
210
  return (a.asKind(ts.SyntaxKind.FunctionExpression)?.getName()) ? a.asKind(ts.SyntaxKind.FunctionExpression)?.getName() : "anonymous";
@@ -133,4 +237,22 @@ export function getNameOfNode(a: ts.Node<ts.ts.Node>): string {
133
237
  // ancestor hasn't got a useful name
134
238
  return "";
135
239
  }
136
- }
240
+ }
241
+
242
+ /**
243
+ * Gets the name of a node, if it has one
244
+ * @param a A node
245
+ * @returns The name of the node, or an empty string if it doesn't have one
246
+ */
247
+ export function getParameters(a: Node): string {
248
+ switch (a.getKind()) {
249
+ case ts.SyntaxKind.ClassDeclaration:
250
+ return "<" + a.asKind(ts.SyntaxKind.ClassDeclaration)?.getTypeParameters().map(tp => tp.getName()).join(", ") + ">";
251
+ case ts.SyntaxKind.InterfaceDeclaration:
252
+ return "<" + a.asKind(ts.SyntaxKind.InterfaceDeclaration)?.getTypeParameters().map(tp => tp.getName()).join(", ") + ">";
253
+ case ts.SyntaxKind.MethodDeclaration:
254
+ return "<" + a.asKind(ts.SyntaxKind.MethodDeclaration)?.getTypeParameters().map(tp => tp.getName()).join(", ") + ">";
255
+ case ts.SyntaxKind.FunctionDeclaration:
256
+ return "<" + a.asKind(ts.SyntaxKind.FunctionDeclaration)?.getTypeParameters().map(tp => tp.getName()).join(", ") + ">";
257
+ }
258
+ }
@@ -1,5 +1,5 @@
1
1
  import { FamixBaseElement } from "./famix_base_element";
2
- import { Class, Interface, Namespace, Variable, Method, Function as FamixFunctionEntity, Type, NamedEntity, ScriptEntity, Module, SourceLanguage } from "./model/famix";
2
+ import { Class, Interface, Variable, Method, ArrowFunction, Function as FamixFunctionEntity, Type, NamedEntity, ScriptEntity, Module, SourceLanguage } from "./model/famix";
3
3
  // 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, ImportEqualsDeclaration } from "ts-morph";
4
4
  import * as Famix from "./model/famix";
5
5
  import { TSMorphObjectType } from "../../../famix_functions/EntityDictionary";
@@ -10,7 +10,7 @@ export class FamixRepository {
10
10
  private elements = new Set<FamixBaseElement>(); // All Famix elements
11
11
  private famixClasses = new Set<Class>(); // All Famix classes
12
12
  private famixInterfaces = new Set<Interface>(); // All Famix interfaces
13
- private famixNamespaces = new Set<Namespace>(); // All Famix namespaces
13
+ private famixModules = new Set<Module>(); // All Famix namespaces
14
14
  private famixMethods = new Set<Method>(); // All Famix methods
15
15
  private famixVariables = new Set<Variable>(); // All Famix variables
16
16
  private famixFunctions = new Set<FamixFunctionEntity>(); // All Famix functions
@@ -139,16 +139,16 @@ export class FamixRepository {
139
139
  * @param name A namespace name
140
140
  * @returns The Famix namespace corresponding to the name or undefined if it doesn't exist
141
141
  */
142
- public _getFamixNamespace(fullyQualifiedName: string): Namespace | undefined {
143
- return Array.from(this.famixNamespaces.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
142
+ public _getFamixModule(fullyQualifiedName: string): Module | undefined {
143
+ return Array.from(this.famixModules.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
144
144
  }
145
145
 
146
146
  /**
147
147
  * Gets all Famix namespaces
148
148
  * @returns All Famix namespaces
149
149
  */
150
- public _getFamixNamespaces(): Set<Namespace> {
151
- return new Set(Array.from(this.famixNamespaces.values()));
150
+ public _getFamixModules(): Set<Module> {
151
+ return new Set(Array.from(this.famixModules.values()));
152
152
  }
153
153
 
154
154
  /**
@@ -212,13 +212,13 @@ export class FamixRepository {
212
212
  this.famixClasses.add(element);
213
213
  } else if (element instanceof Interface) {
214
214
  this.famixInterfaces.add(element);
215
- } else if (element instanceof Namespace) {
216
- this.famixNamespaces.add(element);
215
+ } else if (element instanceof Module) {
216
+ this.famixModules.add(element);
217
217
  } else if (element instanceof Variable) {
218
218
  this.famixVariables.add(element);
219
219
  } else if (element instanceof Method) {
220
220
  this.famixMethods.add(element);
221
- } else if (element instanceof FamixFunctionEntity) {
221
+ } else if (element instanceof FamixFunctionEntity || element instanceof ArrowFunction) {
222
222
  this.famixFunctions.add(element);
223
223
  } else if (element instanceof ScriptEntity || element instanceof Module) {
224
224
  this.famixFiles.add(element);
@@ -1,9 +1,9 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
2
  import { StructuralEntity } from "./structural_entity";
3
- import { Association } from "./association";
4
3
  import { ContainerEntity } from "./container_entity";
4
+ import { Entity } from "./entity";
5
5
 
6
- export class Access extends Association {
6
+ export class Access extends Entity {
7
7
 
8
8
  private accessor: ContainerEntity;
9
9
 
@@ -35,7 +35,7 @@ export class Alias extends NamedEntity {
35
35
 
36
36
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
37
37
  super.addPropertiesToExporter(exporter);
38
- exporter.addProperty("parentEntity", this.getParentEntity());
38
+ exporter.addProperty("parentType", this.getParentEntity());
39
39
  exporter.addProperty("aliasedEntity", this.getAliasedEntity());
40
40
  }
41
41
  }
@@ -0,0 +1,15 @@
1
+ import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
+ import { BehavioralEntity } from "./behavioral_entity";
3
+
4
+ export class ArrowFunction extends BehavioralEntity {
5
+
6
+ public getJSON(): string {
7
+ const json: FamixJSONExporter = new FamixJSONExporter("ArrowFunction", this);
8
+ this.addPropertiesToExporter(json);
9
+ return json.getJSON();
10
+ }
11
+
12
+ public addPropertiesToExporter(exporter: FamixJSONExporter): void {
13
+ super.addPropertiesToExporter(exporter);
14
+ }
15
+ }
@@ -7,16 +7,6 @@ import { ParameterType } from "./parameter_type";
7
7
 
8
8
  export class BehavioralEntity extends ContainerEntity {
9
9
 
10
- private isGeneric: boolean;
11
-
12
- public getIsGeneric(): boolean {
13
- return this.isGeneric;
14
- }
15
-
16
- public setIsGeneric(isGeneric: boolean): void {
17
- this.isGeneric = isGeneric;
18
- }
19
-
20
10
  private signature: string;
21
11
 
22
12
  public getSignature(): string {
@@ -74,19 +64,22 @@ export class BehavioralEntity extends ContainerEntity {
74
64
  declaredType.addBehavioralEntityWithDeclaredType(this);
75
65
  }
76
66
 
77
- private typeParameters: Set<ParameterType> = new Set();
67
+ private genericParameters: Set<ParameterType> = new Set();
78
68
 
79
- public getParameterTypes(): Set<ParameterType> {
80
- return this.typeParameters;
69
+ public getGenericParameters(): Set<ParameterType> {
70
+ return this.genericParameters;
81
71
  }
82
72
 
83
- public addParameterType(typeParameter: ParameterType): void {
84
- if (!this.typeParameters.has(typeParameter)) {
85
- this.typeParameters.add(typeParameter);
86
- typeParameter.setParentGeneric(this);
73
+ public addGenericParameter(genericParameter: ParameterType): void {
74
+ if (!this.genericParameters.has(genericParameter)) {
75
+ this.genericParameters.add(genericParameter);
76
+ genericParameter.setParentGeneric(this);
87
77
  }
88
78
  }
89
79
 
80
+ clearGenericParameters(): void {
81
+ this.genericParameters.clear();
82
+ }
90
83
 
91
84
  public getJSON(): string {
92
85
  const json: FamixJSONExporter = new FamixJSONExporter("BehavioralEntity", this);
@@ -96,12 +89,12 @@ export class BehavioralEntity extends ContainerEntity {
96
89
 
97
90
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
98
91
  super.addPropertiesToExporter(exporter);
99
- exporter.addProperty("isGeneric", this.getIsGeneric());
100
92
  exporter.addProperty("signature", this.getSignature());
101
93
  exporter.addProperty("parameters", this.getParameters());
102
94
  exporter.addProperty("numberOfParameters", this.getNumberOfParameters());
103
95
  exporter.addProperty("incomingInvocations", this.getIncomingInvocations());
104
96
  exporter.addProperty("declaredType", this.getDeclaredType());
105
- exporter.addProperty("typeParameters", this.getParameterTypes());
97
+ /* don't add the property here, since it doesn't apply to all subclasses */
98
+ // exporter.addProperty("genericParameters", this.getGenericParameters());
106
99
  }
107
100
  }
@@ -44,7 +44,7 @@ export class Comment extends SourcedEntity {
44
44
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
45
45
  super.addPropertiesToExporter(exporter);
46
46
  exporter.addProperty("isJSDoc", this.getIsJSDoc());
47
- exporter.addProperty("container", this.getContainer());
47
+ exporter.addProperty("commentedEntity", this.getContainer());
48
48
  exporter.addProperty("content", this.getContent());
49
49
  }
50
50
  }
@@ -0,0 +1,42 @@
1
+ import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
+ import { Entity } from "./entity";
3
+ import { ParametricClass } from "./parametric_class";
4
+ import { ParametricFunction } from "./parametric_function";
5
+ import { ParametricInterface } from "./parametric_interface";
6
+ import { ParametricMethod } from "./parametric_method";
7
+
8
+ export class Concretisation extends Entity {
9
+
10
+ private genericEntity: ParametricClass | ParametricInterface | ParametricFunction | ParametricMethod;
11
+
12
+ public getGenericEntity(): ParametricClass | ParametricInterface | ParametricFunction | ParametricMethod {
13
+ return this.genericEntity;
14
+ }
15
+
16
+ public setGenericEntity(genericEntity: ParametricClass | ParametricInterface | ParametricFunction | ParametricMethod): void {
17
+ this.genericEntity = genericEntity;
18
+ }
19
+
20
+ private concreteEntity: ParametricClass | ParametricInterface | ParametricFunction | ParametricMethod;
21
+
22
+ public getConcreteEntity(): ParametricClass | ParametricInterface | ParametricFunction | ParametricMethod {
23
+ return this.concreteEntity;
24
+ }
25
+
26
+ public setConcreteEntity(concreteEntity: ParametricClass | ParametricInterface | ParametricFunction | ParametricMethod): void {
27
+ this.concreteEntity = concreteEntity;
28
+ }
29
+
30
+ public getJSON(): string {
31
+ const json: FamixJSONExporter = new FamixJSONExporter("Concretisation", this);
32
+ this.addPropertiesToExporter(json);
33
+ return json.getJSON();
34
+ }
35
+
36
+ public addPropertiesToExporter(exporter: FamixJSONExporter): void {
37
+ super.addPropertiesToExporter(exporter);
38
+ exporter.addProperty("genericEntity", this.getGenericEntity());
39
+ exporter.addProperty("concreteEntity", this.getConcreteEntity());
40
+ }
41
+
42
+ }
@@ -150,16 +150,16 @@ export class ContainerEntity extends NamedEntity {
150
150
 
151
151
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
152
152
  super.addPropertiesToExporter(exporter);
153
- exporter.addProperty("parentBehaviouralEntity", this.getParentContainerEntity());
154
- exporter.addProperty("childrenContainerEntities", this.getChildrenContainerEntities());
153
+ // exporter.addProperty("parentBehaviouralEntity", this.getParentContainerEntity());
154
+ // exporter.addProperty("childrenContainerEntities", this.getChildrenContainerEntities());
155
155
  exporter.addProperty("cyclomaticComplexity", this.getCyclomaticComplexity());
156
156
  exporter.addProperty("numberOfStatements", this.getNumberOfStatements());
157
- exporter.addProperty("outgoingReferences", this.getOutgoingReferences());
157
+ // exporter.addProperty("outgoingReferences", this.getOutgoingReferences()); /* derived ?*/
158
158
  exporter.addProperty("numberOfLinesOfCode", this.getNumberOfLinesOfCode());
159
- exporter.addProperty("outgoingInvocations", this.getOutgoingInvocations());
160
- exporter.addProperty("accesses", this.getAccesses());
159
+ // exporter.addProperty("outgoingInvocations", this.getOutgoingInvocations()); /* derived ?*/
160
+ // exporter.addProperty("accesses", this.getAccesses()); /* derived ?*/
161
161
  exporter.addProperty("types", this.getTypes());
162
162
  exporter.addProperty("functions", this.getFunctions());
163
- exporter.addProperty("variables", this.getVariables());
163
+ exporter.addProperty("localVariables", this.getVariables());
164
164
  }
165
165
  }
@@ -33,7 +33,7 @@ export class Decorator extends NamedEntity {
33
33
 
34
34
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
35
35
  super.addPropertiesToExporter(exporter);
36
- exporter.addProperty("decoratorExpression", this.getDecoratorExpression());
36
+ exporter.addProperty("expression", this.getDecoratorExpression());
37
37
  exporter.addProperty("decoratedEntity", this.getDecoratedEntity());
38
38
  }
39
39
  }
@@ -26,6 +26,6 @@ export class Enum extends Type {
26
26
 
27
27
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
28
28
  super.addPropertiesToExporter(exporter);
29
- exporter.addProperty("values", this.getValues());
29
+ exporter.addProperty("enumValues", this.getValues());
30
30
  }
31
31
  }
@@ -24,6 +24,6 @@ export class EnumValue extends StructuralEntity {
24
24
 
25
25
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
26
26
  super.addPropertiesToExporter(exporter);
27
- exporter.addProperty("parentEntity", this.getParentEntity());
27
+ exporter.addProperty("parentEnum", this.getParentEntity());
28
28
  }
29
29
  }
@@ -1,9 +1,9 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { Association } from "./association";
2
+ import { Entity } from "./entity";
3
3
  import { Module } from "./module";
4
4
  import { NamedEntity } from "./named_entity";
5
5
 
6
- export class ImportClause extends Association {
6
+ export class ImportClause extends Entity {
7
7
 
8
8
  private importingEntity: Module;
9
9
 
@@ -48,6 +48,7 @@ export class ImportClause extends Association {
48
48
  super.addPropertiesToExporter(exporter);
49
49
  exporter.addProperty("importingEntity", this.getImportingEntity());
50
50
  exporter.addProperty("importedEntity", this.getImportedEntity());
51
- exporter.addProperty("moduleSpecifier", this.getModuleSpecifier());
51
+ // unknown property below
52
+ // exporter.addProperty("moduleSpecifier", this.getModuleSpecifier());
52
53
  }
53
54
  }
@@ -1,11 +1,11 @@
1
1
  export { Access } from "./access";
2
2
  export { Accessor } from "./accessor";
3
3
  export { Alias } from "./alias";
4
- export { Association } from "./association";
5
4
  export { BehavioralEntity } from "./behavioral_entity";
6
5
  export { Class } from "./class";
7
6
  export { Comment } from "./comment";
8
7
  export { ContainerEntity } from "./container_entity";
8
+ export { Concretisation } from "./concretisation";
9
9
  export { Decorator } from "./decorator";
10
10
  export { Entity } from "./entity";
11
11
  export { EnumValue } from "./enum_value";
@@ -21,12 +21,10 @@ export { Invocation } from "./invocation";
21
21
  export { Method } from "./method";
22
22
  export { Module } from "./module";
23
23
  export { NamedEntity } from "./named_entity";
24
- export { Namespace } from "./namespace";
25
24
  export { ParameterType } from "./parameter_type";
26
25
  export { Parameter } from "./parameter";
27
- export { ParameterizableClass } from "./parameterizable_class";
28
- export { ParameterizableInterface } from "./parameterizable_interface";
29
- export { ParameterizedType } from "./parameterized_type";
26
+ export { ParametricClass } from "./parametric_class";
27
+ export { ParametricInterface } from "./parametric_interface";
30
28
  export { PrimitiveType } from "./primitive_type";
31
29
  export { Reference } from "./reference";
32
30
  export { ScopingEntity } from "./scoping_entity";
@@ -38,3 +36,8 @@ export { StructuralEntity } from "./structural_entity";
38
36
  export { TextAnchor } from "./text_anchor";
39
37
  export { Type } from "./type";
40
38
  export { Variable } from "./variable";
39
+ export { ParametricFunction } from "./parametric_function";
40
+ export { ParametricMethod } from "./parametric_method";
41
+ export { ArrowFunction } from "./arrowFunction";
42
+ export { ParametricArrowFunction } from "./parametric_arrow_function";
43
+ export { ParameterConcretisation } from "./parameterConcretisation";
@@ -64,8 +64,8 @@ export class IndexedFileAnchor extends SourceAnchor {
64
64
  super.addPropertiesToExporter(exporter);
65
65
  exporter.addProperty("startPos", this.getStartPos());
66
66
  exporter.addProperty("endPos", this.getEndPos());
67
- exporter.addProperty("startLine", this.getStartLine());
68
- exporter.addProperty("endLine", this.getEndLine());
67
+ // exporter.addProperty("startLine", this.getStartLine());
68
+ // exporter.addProperty("endLine", this.getEndLine());
69
69
  exporter.addProperty("fileName", this.getFileName());
70
70
  }
71
71
  }
@@ -1,9 +1,9 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { Association } from "./association";
3
2
  import { Class } from "./class";
3
+ import { Entity } from "./entity";
4
4
  import { Interface } from "./interface";
5
5
 
6
- export class Inheritance extends Association {
6
+ export class Inheritance extends Entity {
7
7
 
8
8
  private superclass: Class | Interface;
9
9
 
@@ -27,7 +27,6 @@ export class Inheritance extends Association {
27
27
  subclass.addSuperInheritance(this);
28
28
  }
29
29
 
30
-
31
30
  public getJSON(): string {
32
31
  const json: FamixJSONExporter = new FamixJSONExporter("Inheritance", this);
33
32
  this.addPropertiesToExporter(json);
@@ -39,4 +38,4 @@ export class Inheritance extends Association {
39
38
  exporter.addProperty("superclass", this.getSuperclass());
40
39
  exporter.addProperty("subclass", this.getSubclass());
41
40
  }
42
- }
41
+ }
@@ -67,7 +67,7 @@ export class Interface extends Type {
67
67
 
68
68
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
69
69
  super.addPropertiesToExporter(exporter);
70
- exporter.addProperty("properties", this.getProperties());
70
+ exporter.addProperty("attributes", this.getProperties());
71
71
  exporter.addProperty("methods", this.getMethods());
72
72
  exporter.addProperty("superInheritances", this.getSuperInheritances());
73
73
  exporter.addProperty("subInheritances", this.getSubInheritances());
@@ -1,10 +1,10 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
2
  import { NamedEntity } from "./named_entity";
3
- import { Association } from "./association";
4
3
  import { BehavioralEntity } from "./behavioral_entity";
5
4
  import { ContainerEntity } from "./container_entity";
5
+ import { Entity } from "./entity";
6
6
 
7
- export class Invocation extends Association {
7
+ export class Invocation extends Entity {
8
8
 
9
9
  private candidates: Set<BehavioralEntity> = new Set();
10
10
 
@@ -85,7 +85,7 @@ export class Method extends BehavioralEntity {
85
85
 
86
86
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
87
87
  super.addPropertiesToExporter(exporter);
88
- exporter.addProperty("parentEntity", this.getParentEntity());
88
+ exporter.addProperty("parentType", this.getParentEntity());
89
89
  exporter.addProperty("kind", this.getKind());
90
90
  exporter.addProperty("isAbstract", this.getIsAbstract());
91
91
  exporter.addProperty("isClassSide", this.getIsClassSide());