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.
Files changed (212) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +29 -60
  3. package/dist/analyze.js +1 -1
  4. package/dist/analyze_functions/process_functions.js +49 -43
  5. package/dist/famix_functions/EntityDictionary.js +309 -182
  6. package/dist/famix_functions/helpers_creation.js +36 -5
  7. package/dist/fqn.js +76 -114
  8. package/dist/lib/famix/famix_JSON_exporter.js +55 -0
  9. package/dist/lib/famix/famix_base_element.js +18 -0
  10. package/dist/lib/famix/famix_repository.js +224 -0
  11. package/dist/lib/famix/{src/index.js → index.js} +1 -1
  12. package/dist/lib/famix/model/famix/access.js +40 -0
  13. package/dist/lib/famix/model/famix/accessor.js +17 -0
  14. package/dist/lib/famix/model/famix/alias.js +33 -0
  15. package/dist/lib/famix/model/famix/arrow_function.js +17 -0
  16. package/dist/lib/famix/model/famix/behavioral_entity.js +79 -0
  17. package/dist/lib/famix/model/famix/class.js +71 -0
  18. package/dist/lib/famix/model/famix/comment.js +39 -0
  19. package/dist/lib/famix/model/famix/concretisation.js +31 -0
  20. package/dist/lib/famix/model/famix/container_entity.js +126 -0
  21. package/dist/lib/famix/model/famix/decorator.js +32 -0
  22. package/dist/lib/famix/model/famix/entity.js +17 -0
  23. package/dist/lib/famix/model/famix/enum.js +31 -0
  24. package/dist/lib/famix/model/famix/enum_value.js +25 -0
  25. package/dist/lib/famix/model/famix/function.js +17 -0
  26. package/dist/lib/famix/model/famix/import_clause.js +41 -0
  27. package/dist/lib/famix/{src/model → model}/famix/index.js +6 -10
  28. package/dist/lib/famix/model/famix/indexed_file_anchor.js +38 -0
  29. package/dist/lib/famix/model/famix/inheritance.js +33 -0
  30. package/dist/lib/famix/model/famix/interface.js +64 -0
  31. package/dist/lib/famix/model/famix/invocation.js +54 -0
  32. package/dist/lib/famix/model/famix/method.js +67 -0
  33. package/dist/lib/famix/model/famix/module.js +60 -0
  34. package/dist/lib/famix/model/famix/named_entity.js +78 -0
  35. package/dist/lib/famix/model/famix/parameter.js +25 -0
  36. package/dist/lib/famix/model/famix/parameter_concretisation.js +44 -0
  37. package/dist/lib/famix/model/famix/parameter_type.js +45 -0
  38. package/dist/lib/famix/model/famix/parametric_arrow_function.js +31 -0
  39. package/dist/lib/famix/model/famix/parametric_class.js +44 -0
  40. package/dist/lib/famix/model/famix/parametric_function.js +31 -0
  41. package/dist/lib/famix/model/famix/parametric_interface.js +44 -0
  42. package/dist/lib/famix/model/famix/parametric_method.js +31 -0
  43. package/dist/lib/famix/model/famix/primitive_type.js +17 -0
  44. package/dist/lib/famix/model/famix/property.js +73 -0
  45. package/dist/lib/famix/model/famix/reference.js +33 -0
  46. package/dist/lib/famix/model/famix/scoping_entity.js +36 -0
  47. package/dist/lib/famix/model/famix/script_entity.js +29 -0
  48. package/dist/lib/famix/model/famix/source_anchor.js +27 -0
  49. package/dist/lib/famix/model/famix/source_language.js +35 -0
  50. package/dist/lib/famix/model/famix/sourced_entity.js +60 -0
  51. package/dist/lib/famix/model/famix/structural_entity.js +39 -0
  52. package/dist/lib/famix/model/famix/type.js +73 -0
  53. package/dist/lib/famix/model/famix/variable.js +24 -0
  54. package/dist/lib/ts-complex/cyclomatic-service.js +2 -2
  55. package/dist/refactorer/refactor-getter-setter.js +142 -0
  56. package/dist/ts2famix-cli-wrapper.js +29 -3
  57. package/dist/ts2famix-cli.js +1 -1
  58. package/doc-uml/famix-typescript-model.puml +390 -341
  59. package/doc-uml/famix-typescript-model.svg +1 -1
  60. package/package.json +8 -7
  61. package/src/analyze.ts +2 -2
  62. package/src/analyze_functions/process_functions.ts +49 -44
  63. package/src/famix_functions/EntityDictionary.ts +345 -216
  64. package/src/famix_functions/helpers_creation.ts +36 -4
  65. package/src/fqn.ts +76 -125
  66. package/src/lib/famix/famix_JSON_exporter.ts +56 -0
  67. package/src/lib/famix/famix_base_element.ts +22 -0
  68. package/src/lib/famix/famix_repository.ts +243 -0
  69. package/src/lib/famix/model/famix/access.ts +50 -0
  70. package/src/lib/famix/model/famix/alias.ts +39 -0
  71. package/src/lib/famix/model/famix/behavioral_entity.ts +97 -0
  72. package/src/lib/famix/model/famix/class.ts +85 -0
  73. package/src/lib/famix/model/famix/comment.ts +47 -0
  74. package/src/lib/famix/model/famix/concretisation.ts +40 -0
  75. package/src/lib/famix/model/famix/container_entity.ts +160 -0
  76. package/src/lib/famix/model/famix/decorator.ts +37 -0
  77. package/src/lib/famix/model/famix/enum.ts +30 -0
  78. package/src/lib/famix/model/famix/enum_value.ts +28 -0
  79. package/src/lib/famix/model/famix/import_clause.ts +51 -0
  80. package/src/lib/famix/{src/model → model}/famix/index.ts +2 -4
  81. package/src/lib/famix/model/famix/indexed_file_anchor.ts +46 -0
  82. package/src/lib/famix/model/famix/inheritance.ts +40 -0
  83. package/src/lib/famix/model/famix/interface.ts +75 -0
  84. package/src/lib/famix/model/famix/invocation.ts +65 -0
  85. package/src/lib/famix/model/famix/method.ts +89 -0
  86. package/src/lib/famix/model/famix/module.ts +71 -0
  87. package/src/lib/famix/model/famix/named_entity.ts +95 -0
  88. package/src/lib/famix/{src/model → model}/famix/parameter.ts +11 -12
  89. package/src/lib/famix/model/famix/parameter_concretisation.ts +51 -0
  90. package/src/lib/famix/model/famix/parameter_type.ts +58 -0
  91. package/src/lib/famix/model/famix/parametric_arrow_function.ts +32 -0
  92. package/src/lib/famix/model/famix/parametric_class.ts +49 -0
  93. package/src/lib/famix/model/famix/parametric_function.ts +32 -0
  94. package/src/lib/famix/model/famix/parametric_interface.ts +49 -0
  95. package/src/lib/famix/model/famix/parametric_method.ts +32 -0
  96. package/src/lib/famix/model/famix/primitive_type.ts +15 -0
  97. package/src/lib/famix/model/famix/property.ts +94 -0
  98. package/src/lib/famix/model/famix/reference.ts +40 -0
  99. package/src/lib/famix/model/famix/scoping_entity.ts +35 -0
  100. package/src/lib/famix/model/famix/script_entity.ts +34 -0
  101. package/src/lib/famix/model/famix/source_anchor.ts +30 -0
  102. package/src/lib/famix/model/famix/source_language.ts +35 -0
  103. package/src/lib/famix/model/famix/sourced_entity.ts +70 -0
  104. package/src/lib/famix/model/famix/structural_entity.ts +43 -0
  105. package/src/lib/famix/model/famix/type.ts +87 -0
  106. package/src/lib/famix/model/famix/variable.ts +27 -0
  107. package/src/lib/famix/package.json +1 -1
  108. package/src/lib/ts-complex/cyclomatic-service.ts +10 -10
  109. package/src/refactorer/refactor-getter-setter.ts +140 -0
  110. package/src/ts2famix-cli-wrapper.ts +6 -2
  111. package/src/ts2famix-cli.ts +1 -1
  112. package/tsconfig.check-tests.json +14 -0
  113. package/tsconfig.json +70 -68
  114. package/dist/famix2puml.js +0 -126
  115. package/dist/lib/famix/src/famix_JSON_exporter.js +0 -55
  116. package/dist/lib/famix/src/famix_base_element.js +0 -18
  117. package/dist/lib/famix/src/famix_repository.js +0 -223
  118. package/dist/lib/famix/src/model/famix/access.js +0 -40
  119. package/dist/lib/famix/src/model/famix/accessor.js +0 -17
  120. package/dist/lib/famix/src/model/famix/alias.js +0 -33
  121. package/dist/lib/famix/src/model/famix/arrowFunction.js +0 -17
  122. package/dist/lib/famix/src/model/famix/behavioral_entity.js +0 -79
  123. package/dist/lib/famix/src/model/famix/class.js +0 -71
  124. package/dist/lib/famix/src/model/famix/comment.js +0 -39
  125. package/dist/lib/famix/src/model/famix/concretisation.js +0 -31
  126. package/dist/lib/famix/src/model/famix/container_entity.js +0 -126
  127. package/dist/lib/famix/src/model/famix/decorator.js +0 -32
  128. package/dist/lib/famix/src/model/famix/entity.js +0 -17
  129. package/dist/lib/famix/src/model/famix/enum.js +0 -31
  130. package/dist/lib/famix/src/model/famix/enum_value.js +0 -25
  131. package/dist/lib/famix/src/model/famix/function.js +0 -17
  132. package/dist/lib/famix/src/model/famix/implicit_variable.js +0 -17
  133. package/dist/lib/famix/src/model/famix/import_clause.js +0 -41
  134. package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +0 -52
  135. package/dist/lib/famix/src/model/famix/inheritance.js +0 -33
  136. package/dist/lib/famix/src/model/famix/interface.js +0 -64
  137. package/dist/lib/famix/src/model/famix/invocation.js +0 -54
  138. package/dist/lib/famix/src/model/famix/method.js +0 -67
  139. package/dist/lib/famix/src/model/famix/module.js +0 -84
  140. package/dist/lib/famix/src/model/famix/named_entity.js +0 -78
  141. package/dist/lib/famix/src/model/famix/parameter.js +0 -25
  142. package/dist/lib/famix/src/model/famix/parameterConcretisation.js +0 -44
  143. package/dist/lib/famix/src/model/famix/parameter_type.js +0 -45
  144. package/dist/lib/famix/src/model/famix/parametric_arrow_function.js +0 -31
  145. package/dist/lib/famix/src/model/famix/parametric_class.js +0 -44
  146. package/dist/lib/famix/src/model/famix/parametric_function.js +0 -31
  147. package/dist/lib/famix/src/model/famix/parametric_interface.js +0 -44
  148. package/dist/lib/famix/src/model/famix/parametric_method.js +0 -31
  149. package/dist/lib/famix/src/model/famix/primitive_type.js +0 -17
  150. package/dist/lib/famix/src/model/famix/property.js +0 -126
  151. package/dist/lib/famix/src/model/famix/reference.js +0 -33
  152. package/dist/lib/famix/src/model/famix/scoping_entity.js +0 -37
  153. package/dist/lib/famix/src/model/famix/script_entity.js +0 -29
  154. package/dist/lib/famix/src/model/famix/source_anchor.js +0 -27
  155. package/dist/lib/famix/src/model/famix/source_language.js +0 -35
  156. package/dist/lib/famix/src/model/famix/sourced_entity.js +0 -60
  157. package/dist/lib/famix/src/model/famix/structural_entity.js +0 -39
  158. package/dist/lib/famix/src/model/famix/text_anchor.js +0 -38
  159. package/dist/lib/famix/src/model/famix/type.js +0 -73
  160. package/dist/lib/famix/src/model/famix/variable.js +0 -24
  161. package/jest.config-old.ts +0 -199
  162. package/src/famix2puml.ts +0 -119
  163. package/src/lib/famix/package-lock.json +0 -301
  164. package/src/lib/famix/readme.md +0 -5
  165. package/src/lib/famix/src/famix_JSON_exporter.ts +0 -56
  166. package/src/lib/famix/src/famix_base_element.ts +0 -22
  167. package/src/lib/famix/src/famix_repository.ts +0 -243
  168. package/src/lib/famix/src/model/famix/access.ts +0 -53
  169. package/src/lib/famix/src/model/famix/alias.ts +0 -41
  170. package/src/lib/famix/src/model/famix/behavioral_entity.ts +0 -100
  171. package/src/lib/famix/src/model/famix/class.ts +0 -86
  172. package/src/lib/famix/src/model/famix/comment.ts +0 -50
  173. package/src/lib/famix/src/model/famix/concretisation.ts +0 -42
  174. package/src/lib/famix/src/model/famix/container_entity.ts +0 -165
  175. package/src/lib/famix/src/model/famix/decorator.ts +0 -39
  176. package/src/lib/famix/src/model/famix/enum.ts +0 -31
  177. package/src/lib/famix/src/model/famix/enum_value.ts +0 -29
  178. package/src/lib/famix/src/model/famix/implicit_variable.ts +0 -15
  179. package/src/lib/famix/src/model/famix/import_clause.ts +0 -54
  180. package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +0 -71
  181. package/src/lib/famix/src/model/famix/inheritance.ts +0 -41
  182. package/src/lib/famix/src/model/famix/interface.ts +0 -75
  183. package/src/lib/famix/src/model/famix/invocation.ts +0 -68
  184. package/src/lib/famix/src/model/famix/method.ts +0 -96
  185. package/src/lib/famix/src/model/famix/module.ts +0 -97
  186. package/src/lib/famix/src/model/famix/named_entity.ts +0 -98
  187. package/src/lib/famix/src/model/famix/parameterConcretisation.ts +0 -54
  188. package/src/lib/famix/src/model/famix/parameter_type.ts +0 -60
  189. package/src/lib/famix/src/model/famix/parametric_arrow_function.ts +0 -32
  190. package/src/lib/famix/src/model/famix/parametric_class.ts +0 -49
  191. package/src/lib/famix/src/model/famix/parametric_function.ts +0 -32
  192. package/src/lib/famix/src/model/famix/parametric_interface.ts +0 -49
  193. package/src/lib/famix/src/model/famix/parametric_method.ts +0 -32
  194. package/src/lib/famix/src/model/famix/primitive_type.ts +0 -15
  195. package/src/lib/famix/src/model/famix/property.ts +0 -152
  196. package/src/lib/famix/src/model/famix/reference.ts +0 -42
  197. package/src/lib/famix/src/model/famix/scoping_entity.ts +0 -36
  198. package/src/lib/famix/src/model/famix/script_entity.ts +0 -36
  199. package/src/lib/famix/src/model/famix/source_anchor.ts +0 -31
  200. package/src/lib/famix/src/model/famix/source_language.ts +0 -36
  201. package/src/lib/famix/src/model/famix/sourced_entity.ts +0 -73
  202. package/src/lib/famix/src/model/famix/structural_entity.ts +0 -44
  203. package/src/lib/famix/src/model/famix/text_anchor.ts +0 -49
  204. package/src/lib/famix/src/model/famix/type.ts +0 -89
  205. package/src/lib/famix/src/model/famix/variable.ts +0 -28
  206. package/src/lib/famix/tsconfig.json +0 -27
  207. package/src/lib/famix/tslint.json +0 -15
  208. /package/src/lib/famix/{src/index.ts → index.ts} +0 -0
  209. /package/src/lib/famix/{src/model → model}/famix/accessor.ts +0 -0
  210. /package/src/lib/famix/{src/model/famix/arrowFunction.ts → model/famix/arrow_function.ts} +0 -0
  211. /package/src/lib/famix/{src/model → model}/famix/entity.ts +0 -0
  212. /package/src/lib/famix/{src/model → model}/famix/function.ts +0 -0
@@ -1,22 +0,0 @@
1
- import { logger } from "../../../analyze";
2
- import { FamixJSONExporter } from "./famix_JSON_exporter";
3
- // import { FamixRepository } from "./famix_repository";
4
-
5
- export abstract class FamixBaseElement {
6
-
7
- public id: number;
8
-
9
- // constructor(repo: FamixRepository) {
10
- // repo.addElement(this);
11
- // }
12
-
13
- constructor(){
14
- }
15
-
16
- public abstract getJSON(): string;
17
-
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
20
- logger.debug("addPropertiesToExporter not implemented for " + this.constructor.name + `(${exporter})`);
21
- }
22
- }
@@ -1,243 +0,0 @@
1
- import { FamixBaseElement } from "./famix_base_element";
2
- import { Class, Interface, Variable, Method, ArrowFunction, Function as FamixFunctionEntity, Type, NamedEntity, ScriptEntity, Module, SourceLanguage } from "./model/famix";
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
- import * as Famix from "./model/famix";
5
- import { TSMorphObjectType } from "../../../famix_functions/EntityDictionary";
6
- /**
7
- * This class is used to store all Famix elements
8
- */
9
- export class FamixRepository {
10
- private elements = new Set<FamixBaseElement>(); // All Famix elements
11
- private famixClasses = new Set<Class>(); // All Famix classes
12
- private famixInterfaces = new Set<Interface>(); // All Famix interfaces
13
- private famixModules = new Set<Module>(); // All Famix namespaces
14
- private famixMethods = new Set<Method>(); // All Famix methods
15
- private famixVariables = new Set<Variable>(); // All Famix variables
16
- private famixFunctions = new Set<FamixFunctionEntity>(); // All Famix functions
17
- private famixFiles = new Set<ScriptEntity | Module>(); // All Famix files
18
- private idCounter = 1; // Id counter
19
- private absolutePath: string = "";
20
- private fmxElementObjectMap = new Map<Famix.Entity,TSMorphObjectType>();
21
-
22
- constructor() {
23
- this.addElement(new SourceLanguage()); // add the source language entity (TypeScript)
24
- }
25
-
26
- public setFmxElementObjectMap(fmxElementObjectMap: Map<Famix.Entity,TSMorphObjectType>){
27
- this.fmxElementObjectMap = fmxElementObjectMap;
28
- }
29
-
30
- public getFmxElementObjectMap(){
31
- return this.fmxElementObjectMap;
32
- }
33
-
34
- public getAbsolutePath() : string {
35
- return this.absolutePath;
36
- }
37
-
38
- public setAbsolutePath( path: string ){
39
- this.absolutePath = path;
40
- }
41
-
42
- /**
43
- * Gets a Famix entity by id
44
- * @param id An id of a Famix entity
45
- * @returns The Famix entity corresponding to the id or undefined if it doesn't exist
46
- */
47
- public getFamixEntityById(id: number): FamixBaseElement | undefined {
48
- const entity = Array.from(this.elements.values()).find(e => e.id === id);
49
- return entity;
50
- }
51
-
52
- /**
53
- * Gets a Famix entity by fully qualified name
54
- * @param fullyQualifiedName A fully qualified name
55
- * @returns The Famix entity corresponding to the fully qualified name or undefined if it doesn't exist
56
- */
57
- public getFamixEntityByFullyQualifiedName(fullyQualifiedName: string): FamixBaseElement | undefined {
58
- const allEntities = Array.from(this.elements.values()).filter(e => e instanceof NamedEntity) as Array<NamedEntity>;
59
- const entity = allEntities.find(e => e.getFullyQualifiedName() === fullyQualifiedName);
60
- return entity;
61
- }
62
-
63
- export(arg0: { format: string; }) {
64
- if(arg0.format === "json") {
65
- return this.getJSON();
66
- } else {
67
- throw new Error("Unsupported format");
68
- }
69
- }
70
-
71
-
72
- // Only for tests
73
-
74
- /**
75
- * Gets all Famix entities
76
- * @returns All Famix entities
77
- */
78
- public _getAllEntities(): Set<FamixBaseElement> {
79
- return new Set(Array.from(this.elements.values()));
80
- }
81
-
82
- /**
83
- * Gets all Famix entities of a given type
84
- * @param theType A type of Famix entity
85
- * @returns All Famix entities of the given type
86
- */
87
- public _getAllEntitiesWithType(theType: string): Set<FamixBaseElement> {
88
- return new Set(Array.from(this.elements.values()).filter(e => (e as FamixBaseElement).constructor.name === theType));
89
- }
90
-
91
- /**
92
- * Gets a Famix class by name
93
- * @param name A class name
94
- * @returns The Famix class corresponding to the name or undefined if it doesn't exist
95
- */
96
- public _getFamixClass(fullyQualifiedName: string): Class | undefined {
97
- return Array.from(this.famixClasses.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
98
- }
99
-
100
- /**
101
- * Gets a Famix interface by name
102
- * @param name An interface name
103
- * @returns The Famix interface corresponding to the name or undefined if it doesn't exist
104
- */
105
- public _getFamixInterface(fullyQualifiedName: string): Interface | undefined {
106
- return Array.from(this.famixInterfaces.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
107
- }
108
-
109
- /**
110
- * Gets a Famix method by name
111
- * @param name A method name
112
- * @returns The Famix method corresponding to the name or undefined if it doesn't exist
113
- */
114
- public _getFamixMethod(fullyQualifiedName: string): Method | undefined {
115
- return Array.from(this.famixMethods.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
116
- }
117
-
118
- /**
119
- * Gets a Famix function by name
120
- * @param name A function name
121
- * @returns The Famix function corresponding to the name or undefined if it doesn't exist
122
- */
123
- public _getFamixFunction(fullyQualifiedName: string): FamixFunctionEntity | undefined {
124
- return Array.from(this.famixFunctions.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
125
- }
126
-
127
-
128
- /**
129
- * Gets a Famix variable by name
130
- * @param name A variable name
131
- * @returns The Famix variable corresponding to the name or undefined if it doesn't exist
132
- */
133
- public _getFamixVariable(fullyQualifiedName: string): Variable | undefined {
134
- return Array.from(this.famixVariables.values()).find(v => v.getFullyQualifiedName() === fullyQualifiedName);
135
- }
136
-
137
- /**
138
- * Gets a Famix namespace by name
139
- * @param name A namespace name
140
- * @returns The Famix namespace corresponding to the name or undefined if it doesn't exist
141
- */
142
- public _getFamixModule(fullyQualifiedName: string): Module | undefined {
143
- return Array.from(this.famixModules.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
144
- }
145
-
146
- /**
147
- * Gets all Famix namespaces
148
- * @returns All Famix namespaces
149
- */
150
- public _getFamixModules(): Set<Module> {
151
- return new Set(Array.from(this.famixModules.values()));
152
- }
153
-
154
- /**
155
- * Gets a Famix file by name
156
- * @param name A file name
157
- * @returns The Famix file corresponding to the name or undefined if it doesn't exist
158
- */
159
- public _getFamixFile(fullyQualifiedName: string): ScriptEntity | Module | undefined {
160
- return Array.from(this.famixFiles.values()).find(ns => ns.getName() === fullyQualifiedName);
161
- }
162
-
163
- /**
164
- * Gets all Famix files
165
- * @returns All Famix files
166
- */
167
- public _getFamixFiles(): Set<ScriptEntity | Module> {
168
- return new Set(Array.from(this.famixFiles.values()));
169
- }
170
-
171
- /**
172
- * Gets all method names as a set from a class
173
- * @param className A class name
174
- * @returns The set of class "className" method names
175
- */
176
- public _methodNamesAsSetFromClass(className: string): Set<string> {
177
- const theClass = this._getFamixClass(className) as Class;
178
- return new Set(Array.from(theClass.getMethods()).map(m => m.getName()));
179
- }
180
-
181
- /**
182
- * Gets all method parents as a set from a class
183
- * @param className A class name
184
- * @returns The set of class "className" method parents
185
- */
186
- public _methodParentsAsSetFromClass(className: string): Set<Type> {
187
- const theClass = this._getFamixClass(className) as Class;
188
- return new Set(Array.from(theClass.getMethods()).map(m => m.getParentEntity()));
189
- }
190
-
191
- /**
192
- * Gets the map of Famix element ids and their Famix element from a JSON model
193
- * @param model A JSON model
194
- * @returns The map of Famix element ids and their Famix element from the JSON model
195
- */
196
- public _initMapFromModel(model: string): Map<number, unknown> {
197
- const parsedModel: Array<FamixBaseElement> = JSON.parse(model);
198
- const idToElementMap: Map<number, unknown> = new Map();
199
- parsedModel.forEach(element => {
200
- idToElementMap.set(element.id, element);
201
- });
202
- return idToElementMap;
203
- }
204
-
205
-
206
- /**
207
- * Adds a Famix element to the repository
208
- * @param element A Famix element
209
- */
210
- public addElement(element: FamixBaseElement): void {
211
- if (element instanceof Class) {
212
- this.famixClasses.add(element);
213
- } else if (element instanceof Interface) {
214
- this.famixInterfaces.add(element);
215
- } else if (element instanceof Module) {
216
- this.famixModules.add(element);
217
- } else if (element instanceof Variable) {
218
- this.famixVariables.add(element);
219
- } else if (element instanceof Method) {
220
- this.famixMethods.add(element);
221
- } else if (element instanceof FamixFunctionEntity || element instanceof ArrowFunction) {
222
- this.famixFunctions.add(element);
223
- } else if (element instanceof ScriptEntity || element instanceof Module) {
224
- this.famixFiles.add(element);
225
- }
226
- this.elements.add(element);
227
- element.id = this.idCounter;
228
- this.idCounter++;
229
- }
230
-
231
- /**
232
- * Gets a JSON representation of the repository
233
- * @returns A JSON representation of the repository
234
- */
235
- public getJSON(): string {
236
- let ret = "[";
237
- for (const element of Array.from(this.elements.values())) {
238
- ret = ret + element.getJSON() + ",";
239
- }
240
- ret = ret.substring(0, ret.length - 1);
241
- return ret + "]";
242
- }
243
- }
@@ -1,53 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { StructuralEntity } from "./structural_entity";
3
- import { ContainerEntity } from "./container_entity";
4
- import { Entity } from "./entity";
5
-
6
- export class Access extends Entity {
7
-
8
- private accessor: ContainerEntity;
9
-
10
- public getAccessor(): ContainerEntity {
11
- return this.accessor;
12
- }
13
-
14
- public setAccessor(accessor: ContainerEntity): void {
15
- this.accessor = accessor;
16
- accessor.addAccess(this);
17
- }
18
-
19
- private variable: StructuralEntity;
20
-
21
- public getVariable(): StructuralEntity {
22
- return this.variable;
23
- }
24
-
25
- public setVariable(variable: StructuralEntity): void {
26
- this.variable = variable;
27
- variable.addIncomingAccess(this);
28
- }
29
-
30
- private isWrite: boolean;
31
-
32
- public getIsWrite(): boolean {
33
- return this.isWrite;
34
- }
35
-
36
- public setIsWrite(isWrite: boolean): void {
37
- this.isWrite = isWrite;
38
- }
39
-
40
-
41
- public getJSON(): string {
42
- const json: FamixJSONExporter = new FamixJSONExporter("Access", this);
43
- this.addPropertiesToExporter(json);
44
- return json.getJSON();
45
- }
46
-
47
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
48
- super.addPropertiesToExporter(exporter);
49
- exporter.addProperty("accessor", this.getAccessor());
50
- exporter.addProperty("variable", this.getVariable());
51
- exporter.addProperty("isWrite", this.getIsWrite());
52
- }
53
- }
@@ -1,41 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { NamedEntity } from "./named_entity";
3
- import { Type } from "./type";
4
-
5
- export class Alias extends NamedEntity {
6
-
7
- private parentEntity: NamedEntity;
8
-
9
- public getParentEntity(): NamedEntity {
10
- return this.parentEntity;
11
- }
12
-
13
- public setParentEntity(parentEntity: NamedEntity): void {
14
- this.parentEntity = parentEntity;
15
- parentEntity.addAlias(this);
16
- }
17
-
18
- private aliasedEntity: Type;
19
-
20
- public getAliasedEntity(): Type {
21
- return this.aliasedEntity;
22
- }
23
-
24
- public setAliasedEntity(aliasedEntity: Type): void {
25
- this.aliasedEntity = aliasedEntity;
26
- aliasedEntity.addTypeAlias(this);
27
- }
28
-
29
-
30
- public getJSON(): string {
31
- const json: FamixJSONExporter = new FamixJSONExporter("Alias", this);
32
- this.addPropertiesToExporter(json);
33
- return json.getJSON();
34
- }
35
-
36
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
37
- super.addPropertiesToExporter(exporter);
38
- exporter.addProperty("parentType", this.getParentEntity());
39
- exporter.addProperty("aliasedEntity", this.getAliasedEntity());
40
- }
41
- }
@@ -1,100 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { Type } from "./type";
3
- import { ContainerEntity } from "./container_entity";
4
- import { Parameter } from "./parameter";
5
- import { Invocation } from "./invocation";
6
- import { ParameterType } from "./parameter_type";
7
-
8
- export class BehavioralEntity extends ContainerEntity {
9
-
10
- private signature: string;
11
-
12
- public getSignature(): string {
13
- return this.signature;
14
- }
15
-
16
- public setSignature(signature: string): void {
17
- this.signature = signature;
18
- }
19
-
20
- private parameters: Set<Parameter> = new Set();
21
-
22
- public getParameters(): Set<Parameter> {
23
- return this.parameters;
24
- }
25
-
26
- public addParameter(parameter: Parameter): void {
27
- if (!this.parameters.has(parameter)) {
28
- this.parameters.add(parameter);
29
- parameter.setParentEntity(this);
30
- }
31
- }
32
-
33
- private numberOfParameters: number;
34
-
35
- public getNumberOfParameters(): number {
36
- return this.numberOfParameters;
37
- }
38
-
39
- public setNumberOfParameters(numberOfParameters: number): void {
40
- this.numberOfParameters = numberOfParameters;
41
- }
42
-
43
- private incomingInvocations: Set<Invocation> = new Set();
44
-
45
- public getIncomingInvocations(): Set<Invocation> {
46
- return this.incomingInvocations;
47
- }
48
-
49
- public addIncomingInvocation(incomingInvocation: Invocation): void {
50
- if (!this.incomingInvocations.has(incomingInvocation)) {
51
- this.incomingInvocations.add(incomingInvocation);
52
- incomingInvocation.addCandidate(this);
53
- }
54
- }
55
-
56
- private declaredType: Type;
57
-
58
- public getDeclaredType(): Type {
59
- return this.declaredType;
60
- }
61
-
62
- public setDeclaredType(declaredType: Type): void {
63
- this.declaredType = declaredType;
64
- declaredType.addBehavioralEntityWithDeclaredType(this);
65
- }
66
-
67
- private genericParameters: Set<ParameterType> = new Set();
68
-
69
- public getGenericParameters(): Set<ParameterType> {
70
- return this.genericParameters;
71
- }
72
-
73
- public addGenericParameter(genericParameter: ParameterType): void {
74
- if (!this.genericParameters.has(genericParameter)) {
75
- this.genericParameters.add(genericParameter);
76
- genericParameter.setParentGeneric(this);
77
- }
78
- }
79
-
80
- clearGenericParameters(): void {
81
- this.genericParameters.clear();
82
- }
83
-
84
- public getJSON(): string {
85
- const json: FamixJSONExporter = new FamixJSONExporter("BehavioralEntity", this);
86
- this.addPropertiesToExporter(json);
87
- return json.getJSON();
88
- }
89
-
90
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
91
- super.addPropertiesToExporter(exporter);
92
- exporter.addProperty("signature", this.getSignature());
93
- exporter.addProperty("parameters", this.getParameters());
94
- exporter.addProperty("numberOfParameters", this.getNumberOfParameters());
95
- exporter.addProperty("incomingInvocations", this.getIncomingInvocations());
96
- exporter.addProperty("declaredType", this.getDeclaredType());
97
- /* don't add the property here, since it doesn't apply to all subclasses */
98
- // exporter.addProperty("genericParameters", this.getGenericParameters());
99
- }
100
- }
@@ -1,86 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { Type } from "./type";
3
- import { Method } from "./method";
4
- import { Property } from "./property";
5
- import { Inheritance } from "./inheritance";
6
-
7
- export class Class extends Type {
8
-
9
- private isAbstract: boolean;
10
-
11
- public getIsAbstract(): boolean {
12
- return this.isAbstract;
13
- }
14
-
15
- public setIsAbstract(isAbstract: boolean): void {
16
- this.isAbstract = isAbstract;
17
- }
18
-
19
- private properties: Set<Property> = new Set();
20
-
21
- public getProperties(): Set<Property> {
22
- return this.properties;
23
- }
24
-
25
- public addProperty(property: Property): void {
26
- if (!this.properties.has(property)) {
27
- this.properties.add(property);
28
- property.setParentEntity(this);
29
- }
30
- }
31
-
32
- private methods: Set<Method> = new Set();
33
-
34
- public getMethods(): Set<Method> {
35
- return this.methods;
36
- }
37
-
38
- public addMethod(method: Method): void {
39
- if (!this.methods.has(method)) {
40
- this.methods.add(method);
41
- method.setParentEntity(this);
42
- }
43
- }
44
-
45
- private superInheritances: Set<Inheritance> = new Set();
46
-
47
- public getSuperInheritances(): Set<Inheritance> {
48
- return this.superInheritances;
49
- }
50
-
51
- public addSuperInheritance(superInheritance: Inheritance): void {
52
- if (!this.superInheritances.has(superInheritance)) {
53
- this.superInheritances.add(superInheritance);
54
- superInheritance.setSubclass(this);
55
- }
56
- }
57
-
58
- private subInheritances: Set<Inheritance> = new Set();
59
-
60
- public getSubInheritances(): Set<Inheritance> {
61
- return this.subInheritances;
62
- }
63
-
64
- public addSubInheritance(subInheritance: Inheritance): void {
65
- if (!this.subInheritances.has(subInheritance)) {
66
- this.subInheritances.add(subInheritance);
67
- subInheritance.setSuperclass(this);
68
- }
69
- }
70
-
71
-
72
- public getJSON(): string {
73
- const json: FamixJSONExporter = new FamixJSONExporter("Class", this);
74
- this.addPropertiesToExporter(json);
75
- return json.getJSON();
76
- }
77
-
78
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
79
- super.addPropertiesToExporter(exporter);
80
- exporter.addProperty("isAbstract", this.getIsAbstract());
81
- exporter.addProperty("attributes", this.getProperties()); // Moose (10) codes them as attributes
82
- exporter.addProperty("methods", this.getMethods());
83
- exporter.addProperty("superInheritances", this.getSuperInheritances());
84
- exporter.addProperty("subInheritances", this.getSubInheritances());
85
- }
86
- }
@@ -1,50 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { SourcedEntity } from "./sourced_entity";
3
-
4
- export class Comment extends SourcedEntity {
5
-
6
- private isJSDoc: boolean;
7
-
8
- public getIsJSDoc(): boolean {
9
- return this.isJSDoc;
10
- }
11
-
12
- public setIsJSDoc(isJSDoc: boolean): void {
13
- this.isJSDoc = isJSDoc;
14
- }
15
-
16
- private container: SourcedEntity;
17
-
18
- public getContainer(): SourcedEntity {
19
- return this.container;
20
- }
21
-
22
- public setContainer(container: SourcedEntity): void {
23
- this.container = container;
24
- container.addComment(this);
25
- }
26
-
27
- private content: string;
28
-
29
- public getContent(): string {
30
- return this.content;
31
- }
32
-
33
- public setContent(content: string): void {
34
- this.content = content;
35
- }
36
-
37
-
38
- public getJSON(): string {
39
- const json: FamixJSONExporter = new FamixJSONExporter("Comment", this);
40
- this.addPropertiesToExporter(json);
41
- return json.getJSON();
42
- }
43
-
44
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
45
- super.addPropertiesToExporter(exporter);
46
- exporter.addProperty("isJSDoc", this.getIsJSDoc());
47
- exporter.addProperty("commentedEntity", this.getContainer());
48
- exporter.addProperty("content", this.getContent());
49
- }
50
- }
@@ -1,42 +0,0 @@
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
- }