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