ts2famix 1.0.17 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +3 -3
  2. package/dist/analyze.js +8 -5
  3. package/dist/analyze_functions/processAccesses.js +7 -6
  4. package/dist/analyze_functions/processFiles.js +43 -43
  5. package/dist/analyze_functions/processImportClauses.js +25 -7
  6. package/dist/analyze_functions/processInheritances.js +8 -7
  7. package/dist/analyze_functions/processInvocations.js +6 -5
  8. package/dist/famix_functions/famix_functions.js +19 -21
  9. package/dist/famix_functions/famix_functions_associations.js +29 -14
  10. package/dist/famix_functions/famix_functions_index.js +26 -15
  11. package/dist/famix_functions/famix_functions_types.js +2 -1
  12. package/dist/lib/famix/src/famix_repository.js +6 -0
  13. package/dist/lib/famix/src/model/famix/access.js +3 -3
  14. package/dist/lib/famix/src/model/famix/accessor.js +3 -3
  15. package/dist/lib/famix/src/model/famix/alias.js +3 -3
  16. package/dist/lib/famix/src/model/famix/association.js +3 -3
  17. package/dist/lib/famix/src/model/famix/behavioral_entity.js +6 -6
  18. package/dist/lib/famix/src/model/famix/class.js +3 -3
  19. package/dist/lib/famix/src/model/famix/comment.js +3 -3
  20. package/dist/lib/famix/src/model/famix/container_entity.js +3 -3
  21. package/dist/lib/famix/src/model/famix/decorator.js +3 -3
  22. package/dist/lib/famix/src/model/famix/entity.js +3 -3
  23. package/dist/lib/famix/src/model/famix/enum.js +3 -3
  24. package/dist/lib/famix/src/model/famix/enum_value.js +3 -3
  25. package/dist/lib/famix/src/model/famix/function.js +3 -3
  26. package/dist/lib/famix/src/model/famix/implicit_variable.js +3 -3
  27. package/dist/lib/famix/src/model/famix/import_clause.js +3 -3
  28. package/dist/lib/famix/src/model/famix/index.js +3 -7
  29. package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +3 -3
  30. package/dist/lib/famix/src/model/famix/inheritance.js +3 -3
  31. package/dist/lib/famix/src/model/famix/interface.js +3 -3
  32. package/dist/lib/famix/src/model/famix/invocation.js +3 -3
  33. package/dist/lib/famix/src/model/famix/method.js +3 -3
  34. package/dist/lib/famix/src/model/famix/module.js +3 -3
  35. package/dist/lib/famix/src/model/famix/named_entity.js +4 -4
  36. package/dist/lib/famix/src/model/famix/namespace.js +3 -3
  37. package/dist/lib/famix/src/model/famix/parameter.js +3 -3
  38. package/dist/lib/famix/src/model/famix/{type_parameter.js → parameter_type.js} +7 -7
  39. package/dist/lib/famix/src/model/famix/parameterizable_class.js +11 -11
  40. package/dist/lib/famix/src/model/famix/parameterizable_interface.js +11 -11
  41. package/dist/lib/famix/src/model/famix/parameterized_type.js +3 -3
  42. package/dist/lib/famix/src/model/famix/primitive_type.js +3 -3
  43. package/dist/lib/famix/src/model/famix/property.js +3 -3
  44. package/dist/lib/famix/src/model/famix/reference.js +3 -3
  45. package/dist/lib/famix/src/model/famix/scoping_entity.js +6 -5
  46. package/dist/lib/famix/src/model/famix/script_entity.js +3 -3
  47. package/dist/lib/famix/src/model/famix/source_anchor.js +3 -3
  48. package/dist/lib/famix/src/model/famix/source_language.js +8 -3
  49. package/dist/lib/famix/src/model/famix/sourced_entity.js +7 -3
  50. package/dist/lib/famix/src/model/famix/structural_entity.js +3 -3
  51. package/dist/lib/famix/src/model/famix/text_anchor.js +3 -3
  52. package/dist/lib/famix/src/model/famix/type.js +3 -3
  53. package/dist/lib/famix/src/model/famix/variable.js +3 -3
  54. package/dist/ts2famix-cli.js +16 -3
  55. package/package.json +14 -13
  56. package/src/analyze.ts +10 -4
  57. package/src/analyze_functions/processAccesses.ts +7 -6
  58. package/src/analyze_functions/processFiles.ts +44 -46
  59. package/src/analyze_functions/processImportClauses.ts +25 -7
  60. package/src/analyze_functions/processInheritances.ts +8 -7
  61. package/src/analyze_functions/processInvocations.ts +6 -5
  62. package/src/famix_functions/famix_functions.ts +20 -23
  63. package/src/famix_functions/famix_functions_associations.ts +32 -15
  64. package/src/famix_functions/famix_functions_index.ts +28 -18
  65. package/src/famix_functions/famix_functions_types.ts +2 -1
  66. package/src/generate_uml.sh +1 -0
  67. package/src/lib/famix/src/famix_repository.ts +12 -3
  68. package/src/lib/famix/src/model/famix/access.ts +3 -3
  69. package/src/lib/famix/src/model/famix/accessor.ts +3 -3
  70. package/src/lib/famix/src/model/famix/alias.ts +3 -3
  71. package/src/lib/famix/src/model/famix/association.ts +3 -3
  72. package/src/lib/famix/src/model/famix/behavioral_entity.ts +8 -8
  73. package/src/lib/famix/src/model/famix/class.ts +3 -3
  74. package/src/lib/famix/src/model/famix/comment.ts +3 -3
  75. package/src/lib/famix/src/model/famix/container_entity.ts +3 -3
  76. package/src/lib/famix/src/model/famix/decorator.ts +3 -3
  77. package/src/lib/famix/src/model/famix/entity.ts +3 -3
  78. package/src/lib/famix/src/model/famix/enum.ts +3 -3
  79. package/src/lib/famix/src/model/famix/enum_value.ts +3 -3
  80. package/src/lib/famix/src/model/famix/function.ts +3 -3
  81. package/src/lib/famix/src/model/famix/implicit_variable.ts +3 -3
  82. package/src/lib/famix/src/model/famix/import_clause.ts +3 -3
  83. package/src/lib/famix/src/model/famix/index.ts +40 -42
  84. package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +3 -3
  85. package/src/lib/famix/src/model/famix/inheritance.ts +3 -3
  86. package/src/lib/famix/src/model/famix/interface.ts +3 -3
  87. package/src/lib/famix/src/model/famix/invocation.ts +3 -3
  88. package/src/lib/famix/src/model/famix/method.ts +3 -3
  89. package/src/lib/famix/src/model/famix/module.ts +3 -3
  90. package/src/lib/famix/src/model/famix/named_entity.ts +4 -4
  91. package/src/lib/famix/src/model/famix/namespace.ts +3 -3
  92. package/src/lib/famix/src/model/famix/parameter.ts +3 -3
  93. package/src/lib/famix/src/model/famix/{type_parameter.ts → parameter_type.ts} +9 -9
  94. package/src/lib/famix/src/model/famix/parameterizable_class.ts +12 -12
  95. package/src/lib/famix/src/model/famix/parameterizable_interface.ts +12 -12
  96. package/src/lib/famix/src/model/famix/parameterized_type.ts +3 -3
  97. package/src/lib/famix/src/model/famix/primitive_type.ts +3 -3
  98. package/src/lib/famix/src/model/famix/property.ts +3 -3
  99. package/src/lib/famix/src/model/famix/reference.ts +3 -3
  100. package/src/lib/famix/src/model/famix/scoping_entity.ts +6 -5
  101. package/src/lib/famix/src/model/famix/script_entity.ts +3 -3
  102. package/src/lib/famix/src/model/famix/source_anchor.ts +3 -3
  103. package/src/lib/famix/src/model/famix/source_language.ts +9 -3
  104. package/src/lib/famix/src/model/famix/sourced_entity.ts +6 -3
  105. package/src/lib/famix/src/model/famix/structural_entity.ts +3 -3
  106. package/src/lib/famix/src/model/famix/text_anchor.ts +3 -3
  107. package/src/lib/famix/src/model/famix/type.ts +3 -3
  108. package/src/lib/famix/src/model/famix/variable.ts +3 -3
  109. package/src/ts2famix-cli.ts +17 -3
  110. package/dist/lib/famix/src/model/famix/c_source_language.js +0 -16
  111. package/dist/lib/famix/src/model/famix/custom_source_language.js +0 -23
  112. package/src/lib/famix/src/model/famix/c_source_language.ts +0 -15
  113. package/src/lib/famix/src/model/famix/custom_source_language.ts +0 -27
@@ -48,9 +48,9 @@ class Interface extends type_1.Type {
48
48
  }
49
49
  }
50
50
  getJSON() {
51
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Interface", this);
52
- this.addPropertiesToExporter(mse);
53
- return mse.getJSON();
51
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Interface", this);
52
+ this.addPropertiesToExporter(json);
53
+ return json.getJSON();
54
54
  }
55
55
  addPropertiesToExporter(exporter) {
56
56
  super.addPropertiesToExporter(exporter);
@@ -38,9 +38,9 @@ class Invocation extends association_1.Association {
38
38
  this.signature = signature;
39
39
  }
40
40
  getJSON() {
41
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Invocation", this);
42
- this.addPropertiesToExporter(mse);
43
- return mse.getJSON();
41
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Invocation", this);
42
+ this.addPropertiesToExporter(json);
43
+ return json.getJSON();
44
44
  }
45
45
  addPropertiesToExporter(exporter) {
46
46
  super.addPropertiesToExporter(exporter);
@@ -48,9 +48,9 @@ class Method extends behavioral_entity_1.BehavioralEntity {
48
48
  this.isProtected = isProtected;
49
49
  }
50
50
  getJSON() {
51
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Method", this);
52
- this.addPropertiesToExporter(mse);
53
- return mse.getJSON();
51
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Method", this);
52
+ this.addPropertiesToExporter(json);
53
+ return json.getJSON();
54
54
  }
55
55
  addPropertiesToExporter(exporter) {
56
56
  super.addPropertiesToExporter(exporter);
@@ -19,9 +19,9 @@ class Module extends script_entity_1.ScriptEntity {
19
19
  }
20
20
  }
21
21
  getJSON() {
22
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Module", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
22
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Module", this);
23
+ this.addPropertiesToExporter(json);
24
+ return json.getJSON();
25
25
  }
26
26
  addPropertiesToExporter(exporter) {
27
27
  super.addPropertiesToExporter(exporter);
@@ -60,14 +60,14 @@ class NamedEntity extends sourced_entity_1.SourcedEntity {
60
60
  }
61
61
  }
62
62
  getJSON() {
63
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("NamedEntity", this);
64
- this.addPropertiesToExporter(mse);
65
- return mse.getJSON();
63
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("NamedEntity", this);
64
+ this.addPropertiesToExporter(json);
65
+ return json.getJSON();
66
66
  }
67
67
  addPropertiesToExporter(exporter) {
68
68
  super.addPropertiesToExporter(exporter);
69
69
  exporter.addProperty("fullyQualifiedName", this.getFullyQualifiedName());
70
- exporter.addProperty("receivedInvocations", this.getReceivedInvocations());
70
+ exporter.addProperty("incomingInvocations", this.getReceivedInvocations());
71
71
  exporter.addProperty("incomingImports", this.getIncomingImports());
72
72
  exporter.addProperty("name", this.getName());
73
73
  exporter.addProperty("aliases", this.getAliases());
@@ -12,9 +12,9 @@ class Namespace extends scoping_entity_1.ScopingEntity {
12
12
  parentScope.addNamespace(this);
13
13
  }
14
14
  getJSON() {
15
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Namespace", this);
16
- this.addPropertiesToExporter(mse);
17
- return mse.getJSON();
15
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Namespace", this);
16
+ this.addPropertiesToExporter(json);
17
+ return json.getJSON();
18
18
  }
19
19
  addPropertiesToExporter(exporter) {
20
20
  super.addPropertiesToExporter(exporter);
@@ -12,9 +12,9 @@ class Parameter extends structural_entity_1.StructuralEntity {
12
12
  parentEntity.addParameter(this);
13
13
  }
14
14
  getJSON() {
15
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Parameter", this);
16
- this.addPropertiesToExporter(mse);
17
- return mse.getJSON();
15
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Parameter", this);
16
+ this.addPropertiesToExporter(json);
17
+ return json.getJSON();
18
18
  }
19
19
  addPropertiesToExporter(exporter) {
20
20
  super.addPropertiesToExporter(exporter);
@@ -1,24 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TypeParameter = void 0;
3
+ exports.ParameterType = void 0;
4
4
  const famix_JSON_exporter_1 = require("../../famix_JSON_exporter");
5
5
  const type_1 = require("./type");
6
- class TypeParameter extends type_1.Type {
6
+ class ParameterType extends type_1.Type {
7
7
  getParentGeneric() {
8
8
  return this.parentGeneric;
9
9
  }
10
10
  setParentGeneric(parentGeneric) {
11
11
  this.parentGeneric = parentGeneric;
12
- parentGeneric.addTypeParameter(this);
12
+ parentGeneric.addParameterType(this);
13
13
  }
14
14
  getJSON() {
15
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("TypeParameter", this);
16
- this.addPropertiesToExporter(mse);
17
- return mse.getJSON();
15
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("ParameterType", this);
16
+ this.addPropertiesToExporter(json);
17
+ return json.getJSON();
18
18
  }
19
19
  addPropertiesToExporter(exporter) {
20
20
  super.addPropertiesToExporter(exporter);
21
21
  exporter.addProperty("parentGeneric", this.getParentGeneric());
22
22
  }
23
23
  }
24
- exports.TypeParameter = TypeParameter;
24
+ exports.ParameterType = ParameterType;
@@ -6,25 +6,25 @@ const class_1 = require("./class");
6
6
  class ParameterizableClass extends class_1.Class {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this.typeParameters = new Set();
9
+ this.parameterTypes = new Set();
10
10
  }
11
- getTypeParameters() {
12
- return this.typeParameters;
11
+ getParameterTypes() {
12
+ return this.parameterTypes;
13
13
  }
14
- addTypeParameter(typeParameter) {
15
- if (!this.typeParameters.has(typeParameter)) {
16
- this.typeParameters.add(typeParameter);
17
- typeParameter.setParentGeneric(this);
14
+ addParameterType(parameterType) {
15
+ if (!this.parameterTypes.has(parameterType)) {
16
+ this.parameterTypes.add(parameterType);
17
+ parameterType.setParentGeneric(this);
18
18
  }
19
19
  }
20
20
  getJSON() {
21
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("ParameterizableClass", this);
22
- this.addPropertiesToExporter(mse);
23
- return mse.getJSON();
21
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("ParameterizableClass", this);
22
+ this.addPropertiesToExporter(json);
23
+ return json.getJSON();
24
24
  }
25
25
  addPropertiesToExporter(exporter) {
26
26
  super.addPropertiesToExporter(exporter);
27
- exporter.addProperty("typeParameters", this.getTypeParameters());
27
+ exporter.addProperty("parameterTypes", this.getParameterTypes());
28
28
  }
29
29
  }
30
30
  exports.ParameterizableClass = ParameterizableClass;
@@ -6,25 +6,25 @@ const interface_1 = require("./interface");
6
6
  class ParameterizableInterface extends interface_1.Interface {
7
7
  constructor() {
8
8
  super(...arguments);
9
- this.typeParameters = new Set();
9
+ this.parameterTypes = new Set();
10
10
  }
11
- getTypeParameters() {
12
- return this.typeParameters;
11
+ getParameterTypes() {
12
+ return this.parameterTypes;
13
13
  }
14
- addTypeParameter(typeParameter) {
15
- if (!this.typeParameters.has(typeParameter)) {
16
- this.typeParameters.add(typeParameter);
17
- typeParameter.setParentGeneric(this);
14
+ addParameterType(parameterType) {
15
+ if (!this.parameterTypes.has(parameterType)) {
16
+ this.parameterTypes.add(parameterType);
17
+ parameterType.setParentGeneric(this);
18
18
  }
19
19
  }
20
20
  getJSON() {
21
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("ParameterizableInterface", this);
22
- this.addPropertiesToExporter(mse);
23
- return mse.getJSON();
21
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("ParameterizableInterface", this);
22
+ this.addPropertiesToExporter(json);
23
+ return json.getJSON();
24
24
  }
25
25
  addPropertiesToExporter(exporter) {
26
26
  super.addPropertiesToExporter(exporter);
27
- exporter.addProperty("typeParameters", this.getTypeParameters());
27
+ exporter.addProperty("parameterTypes", this.getParameterTypes());
28
28
  }
29
29
  }
30
30
  exports.ParameterizableInterface = ParameterizableInterface;
@@ -23,9 +23,9 @@ class ParameterizedType extends type_1.Type {
23
23
  }
24
24
  }
25
25
  getJSON() {
26
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("ParameterizedType", this);
27
- this.addPropertiesToExporter(mse);
28
- return mse.getJSON();
26
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("ParameterizedType", this);
27
+ this.addPropertiesToExporter(json);
28
+ return json.getJSON();
29
29
  }
30
30
  addPropertiesToExporter(exporter) {
31
31
  super.addPropertiesToExporter(exporter);
@@ -5,9 +5,9 @@ const famix_JSON_exporter_1 = require("../../famix_JSON_exporter");
5
5
  const type_1 = require("./type");
6
6
  class PrimitiveType extends type_1.Type {
7
7
  getJSON() {
8
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("PrimitiveType", this);
9
- this.addPropertiesToExporter(mse);
10
- return mse.getJSON();
8
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("PrimitiveType", this);
9
+ this.addPropertiesToExporter(json);
10
+ return json.getJSON();
11
11
  }
12
12
  addPropertiesToExporter(exporter) {
13
13
  super.addPropertiesToExporter(exporter);
@@ -30,9 +30,9 @@ class Property extends structural_entity_1.StructuralEntity {
30
30
  }
31
31
  }
32
32
  getJSON() {
33
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Property", this);
34
- this.addPropertiesToExporter(mse);
35
- return mse.getJSON();
33
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Property", this);
34
+ this.addPropertiesToExporter(json);
35
+ return json.getJSON();
36
36
  }
37
37
  addPropertiesToExporter(exporter) {
38
38
  super.addPropertiesToExporter(exporter);
@@ -19,9 +19,9 @@ class Reference extends association_1.Association {
19
19
  target.addIncomingReference(this);
20
20
  }
21
21
  getJSON() {
22
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Reference", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
22
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Reference", this);
23
+ this.addPropertiesToExporter(json);
24
+ return json.getJSON();
25
25
  }
26
26
  addPropertiesToExporter(exporter) {
27
27
  super.addPropertiesToExporter(exporter);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ScopingEntity = void 0;
4
4
  const famix_JSON_exporter_1 = require("../../famix_JSON_exporter");
5
5
  const container_entity_1 = require("./container_entity");
6
+ const analyze_1 = require("../../../../../analyze");
6
7
  class ScopingEntity extends container_entity_1.ContainerEntity {
7
8
  constructor() {
8
9
  super(...arguments);
@@ -13,18 +14,18 @@ class ScopingEntity extends container_entity_1.ContainerEntity {
13
14
  }
14
15
  addNamespace(childNamespace) {
15
16
  if (!this.childrenNamespaces.has(childNamespace)) {
16
- console.info("Adding namespace " + childNamespace.getName() + " to " + this.getName());
17
+ analyze_1.logger.debug("Adding namespace " + childNamespace.getName() + " to " + this.getName());
17
18
  this.childrenNamespaces.add(childNamespace);
18
19
  childNamespace.setParentScope(this);
19
20
  }
20
21
  else {
21
- console.info("Namespace " + childNamespace.getName() + " already added to " + this.getName());
22
+ analyze_1.logger.debug("Namespace " + childNamespace.getName() + " already added to " + this.getName());
22
23
  }
23
24
  }
24
25
  getJSON() {
25
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("ScopingEntity", this);
26
- this.addPropertiesToExporter(mse);
27
- return mse.getJSON();
26
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("ScopingEntity", this);
27
+ this.addPropertiesToExporter(json);
28
+ return json.getJSON();
28
29
  }
29
30
  addPropertiesToExporter(exporter) {
30
31
  super.addPropertiesToExporter(exporter);
@@ -17,9 +17,9 @@ class ScriptEntity extends scoping_entity_1.ScopingEntity {
17
17
  this.numberOfCharacters = numberOfCharacters;
18
18
  }
19
19
  getJSON() {
20
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("ScriptEntity", this);
21
- this.addPropertiesToExporter(mse);
22
- return mse.getJSON();
20
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("ScriptEntity", this);
21
+ this.addPropertiesToExporter(json);
22
+ return json.getJSON();
23
23
  }
24
24
  addPropertiesToExporter(exporter) {
25
25
  super.addPropertiesToExporter(exporter);
@@ -14,9 +14,9 @@ class SourceAnchor extends entity_1.Entity {
14
14
  }
15
15
  }
16
16
  getJSON() {
17
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("SourceAnchor", this);
18
- this.addPropertiesToExporter(mse);
19
- return mse.getJSON();
17
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("SourceAnchor", this);
18
+ this.addPropertiesToExporter(json);
19
+ return json.getJSON();
20
20
  }
21
21
  addPropertiesToExporter(exporter) {
22
22
  super.addPropertiesToExporter(exporter);
@@ -8,6 +8,10 @@ class SourceLanguage extends entity_1.Entity {
8
8
  super(...arguments);
9
9
  this.sourcedEntities = new Set();
10
10
  }
11
+ // name of the source language
12
+ get name() {
13
+ return "TypeScript";
14
+ }
11
15
  getSourcedEntities() {
12
16
  return this.sourcedEntities;
13
17
  }
@@ -18,12 +22,13 @@ class SourceLanguage extends entity_1.Entity {
18
22
  }
19
23
  }
20
24
  getJSON() {
21
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("SourceLanguage", this);
22
- this.addPropertiesToExporter(mse);
23
- return mse.getJSON();
25
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("SourceLanguage", this);
26
+ this.addPropertiesToExporter(json);
27
+ return json.getJSON();
24
28
  }
25
29
  addPropertiesToExporter(exporter) {
26
30
  super.addPropertiesToExporter(exporter);
31
+ exporter.addProperty("name", this.name);
27
32
  exporter.addProperty("sourcedEntities", this.getSourcedEntities());
28
33
  }
29
34
  }
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SourcedEntity = void 0;
4
4
  const famix_JSON_exporter_1 = require("../../famix_JSON_exporter");
5
5
  const entity_1 = require("./entity");
6
+ const analyze_1 = require("../../../../../analyze");
6
7
  class SourcedEntity extends entity_1.Entity {
7
8
  constructor() {
8
9
  super(...arguments);
@@ -31,6 +32,9 @@ class SourcedEntity extends entity_1.Entity {
31
32
  this.comments.add(comment);
32
33
  comment.setContainer(this);
33
34
  }
35
+ else {
36
+ analyze_1.logger.warn("WARNING: adding comment that is already in comments: " + comment.getJSON() + " to " + this.getJSON());
37
+ }
34
38
  }
35
39
  getDeclaredSourceLanguage() {
36
40
  return this.declaredSourceLanguage;
@@ -40,9 +44,9 @@ class SourcedEntity extends entity_1.Entity {
40
44
  declaredSourceLanguage.addSourcedEntity(this);
41
45
  }
42
46
  getJSON() {
43
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("SourcedEntity", this);
44
- this.addPropertiesToExporter(mse);
45
- return mse.getJSON();
47
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("SourcedEntity", this);
48
+ this.addPropertiesToExporter(json);
49
+ return json.getJSON();
46
50
  }
47
51
  addPropertiesToExporter(exporter) {
48
52
  super.addPropertiesToExporter(exporter);
@@ -25,9 +25,9 @@ class StructuralEntity extends named_entity_1.NamedEntity {
25
25
  declaredType.addStructureWithDeclaredType(this);
26
26
  }
27
27
  getJSON() {
28
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("StructuralEntity", this);
29
- this.addPropertiesToExporter(mse);
30
- return mse.getJSON();
28
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("StructuralEntity", this);
29
+ this.addPropertiesToExporter(json);
30
+ return json.getJSON();
31
31
  }
32
32
  addPropertiesToExporter(exporter) {
33
33
  super.addPropertiesToExporter(exporter);
@@ -23,9 +23,9 @@ class TextAnchor extends source_anchor_1.SourceAnchor {
23
23
  this.fileName = fileName;
24
24
  }
25
25
  getJSON() {
26
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("TextAnchor", this);
27
- this.addPropertiesToExporter(mse);
28
- return mse.getJSON();
26
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("TextAnchor", this);
27
+ this.addPropertiesToExporter(json);
28
+ return json.getJSON();
29
29
  }
30
30
  addPropertiesToExporter(exporter) {
31
31
  super.addPropertiesToExporter(exporter);
@@ -55,9 +55,9 @@ class Type extends container_entity_1.ContainerEntity {
55
55
  }
56
56
  }
57
57
  getJSON() {
58
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Type", this);
59
- this.addPropertiesToExporter(mse);
60
- return mse.getJSON();
58
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Type", this);
59
+ this.addPropertiesToExporter(json);
60
+ return json.getJSON();
61
61
  }
62
62
  addPropertiesToExporter(exporter) {
63
63
  super.addPropertiesToExporter(exporter);
@@ -11,9 +11,9 @@ class Variable extends structural_entity_1.StructuralEntity {
11
11
  this.parentContainerEntity = parentContainerEntity;
12
12
  }
13
13
  getJSON() {
14
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("Variable", this);
15
- this.addPropertiesToExporter(mse);
16
- return mse.getJSON();
14
+ const json = new famix_JSON_exporter_1.FamixJSONExporter("Variable", this);
15
+ this.addPropertiesToExporter(json);
16
+ return json.getJSON();
17
17
  }
18
18
  addPropertiesToExporter(exporter) {
19
19
  super.addPropertiesToExporter(exporter);
@@ -31,6 +31,7 @@ const fs = __importStar(require("fs"));
31
31
  const yargs_1 = __importDefault(require("yargs"));
32
32
  const analyze_1 = require("./analyze");
33
33
  const ts_morph_1 = require("ts-morph");
34
+ const analyze_2 = require("./analyze");
34
35
  const argv = yargs_1.default
35
36
  .example(`ts2famix -i "path/to/project/**/*.ts" -o JSONModels/projectName.json`, 'Creates a JSON-format Famix model of typescript files.')
36
37
  .example(`ts2famix -i path/to/tsconfig.json -o JSONModels/projectName.json`, 'Creates a JSON-format model of a typescript project.')
@@ -38,7 +39,19 @@ const argv = yargs_1.default
38
39
  .nargs('i', 1)
39
40
  .alias('o', 'output')
40
41
  .nargs('o', 1)
41
- .demandOption('input').demandOption('output').parseSync();
42
+ .alias('l', 'loglevel')
43
+ .nargs('l', 1)
44
+ .default('l', 3)
45
+ .describe('l', 'Set minimum logging level 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal')
46
+ .boolean('graphemes')
47
+ .default('graphemes', false)
48
+ .describe('graphemes', 'Process graphemes (outside of the BMP) to avoid source anchor offset errors (due to performance issues, this is disabled by default)')
49
+ .demandOption('input')
50
+ .demandOption('output')
51
+ .parseSync();
52
+ const analyze_3 = require("./analyze");
53
+ analyze_3.logger.settings.minLevel = Number(argv.loglevel);
54
+ analyze_2.config.expectGraphemes = argv.graphemes;
42
55
  const importer = new analyze_1.Importer();
43
56
  let famixRep;
44
57
  if (argv.input.endsWith('tsconfig.json')) {
@@ -53,11 +66,11 @@ else {
53
66
  paths.push(argv.input);
54
67
  famixRep = importer.famixRepFromPaths(paths);
55
68
  }
56
- const jsonOutput = famixRep.getJSON();
69
+ const jsonOutput = famixRep.export({ format: "json" });
57
70
  const jsonFilePath = argv.output;
58
71
  fs.writeFile(jsonFilePath, jsonOutput, (err) => {
59
72
  if (err) {
60
73
  throw err;
61
74
  }
62
75
  });
63
- console.info(`Created: ${jsonFilePath}`);
76
+ analyze_3.logger.info(`Created: ${jsonFilePath}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts2famix",
3
- "version": "1.0.17",
3
+ "version": "1.2.0",
4
4
  "description": "A TypeScript to JSON importer for Moose 10.",
5
5
  "main": "dist/ts2famix-cli.js",
6
6
  "scripts": {
@@ -26,22 +26,23 @@
26
26
  },
27
27
  "license": "MIT",
28
28
  "devDependencies": {
29
- "@types/jest": "^29.5.5",
30
- "@types/node": "^20.6.3",
31
- "@types/yargs": "^17.0.24",
32
- "@typescript-eslint/eslint-plugin": "^6.7.2",
33
- "@typescript-eslint/parser": "^6.7.2",
34
- "eslint": "^8.49.0",
29
+ "@types/jest": "^29.5.12",
30
+ "@types/node": "^20.11.18",
31
+ "@types/yargs": "^17.0.32",
32
+ "@typescript-eslint/eslint-plugin": "^7.0.1",
33
+ "@typescript-eslint/parser": "^7.0.1",
34
+ "eslint": "^8.56.0",
35
35
  "jest": "^29.7.0",
36
- "tplant": "^3.1.2",
37
- "ts-jest": "^29.1.1",
38
- "ts-node": "^10.9.1",
39
- "typedoc": "^0.25.1",
40
- "typescript": "^5.2.2"
36
+ "tplant": "^3.1.3",
37
+ "ts-jest": "^29.1.2",
38
+ "ts-node": "^10.9.2",
39
+ "typedoc": "^0.25.8",
40
+ "typescript": "^5.3.3"
41
41
  },
42
42
  "dependencies": {
43
43
  "grapheme-splitter": "^1.0.4",
44
- "ts-morph": "^19.0.0",
44
+ "ts-morph": "^21.0.1",
45
+ "tslog": "^4.9.2",
45
46
  "tsutils": "^3.21.0",
46
47
  "yargs": "^17.7.2"
47
48
  }
package/src/analyze.ts CHANGED
@@ -8,6 +8,11 @@ import { ProcessInvocations } from "./analyze_functions/processInvocations";
8
8
  import { ProcessInheritances } from "./analyze_functions/processInheritances";
9
9
  import { ProcessImportClauses } from "./analyze_functions/processImportClauses";
10
10
 
11
+ import { Logger } from "tslog";
12
+
13
+ export const logger = new Logger({ name: "ts2famix", minLevel: 3});
14
+ export const config = { "expectGraphemes": false };
15
+
11
16
  /**
12
17
  * This class is used to build a Famix model from a TypeScript source code
13
18
  */
@@ -29,16 +34,16 @@ export class Importer {
29
34
  public famixRepFromPaths(paths: Array<string>): FamixRepository {
30
35
 
31
36
  // try {
32
- console.info(`famixRepFromPaths: paths: ${paths}`);
37
+ logger.debug(`famixRepFromPaths: paths: ${paths}`);
33
38
  this.project.addSourceFilesAtPaths(paths);
34
39
  this.processEntities(this.project);
35
40
 
36
41
  const famixRep = this.famixFunctions.getFamixRepository();
37
42
  // }
38
43
  // catch (error) {
39
- // console.error(`> ERROR: got exception ${error}. Exiting...`);
40
- // console.error(error.message);
41
- // console.error(error.stack);
44
+ // logger.error(`> ERROR: got exception ${error}. Exiting...`);
45
+ // logger.error(error.message);
46
+ // logger.error(error.stack);
42
47
  // process.exit(1);
43
48
  // }
44
49
 
@@ -91,4 +96,5 @@ export class Importer {
91
96
 
92
97
  return this.famixFunctions.getFamixRepository();
93
98
  }
99
+
94
100
  }
@@ -1,5 +1,6 @@
1
1
  import { Identifier, ParameterDeclaration, VariableDeclaration, PropertyDeclaration, EnumMember } from "ts-morph";
2
2
  import { FamixFunctions } from "../famix_functions/famix_functions";
3
+ import { logger } from "../analyze";
3
4
 
4
5
  /**
5
6
  * This class is used to build a Famix model for the accesses
@@ -21,14 +22,14 @@ export class ProcessAccesses {
21
22
  * @param accessMap A map of parameters, variables, properties and enum members with their id
22
23
  */
23
24
  public processAccesses(accessMap: Map<number, ParameterDeclaration | VariableDeclaration | PropertyDeclaration | EnumMember>): void {
24
- console.info(`processAccesses: Creating accesses:`);
25
+ logger.debug(`processAccesses: Creating accesses:`);
25
26
  accessMap.forEach((v, id) => {
26
- console.info(`processAccesses: Accesses to ${v.getName()}`);
27
+ logger.debug(`processAccesses: Accesses to ${v.getName()}`);
27
28
  try {
28
29
  const temp_nodes = v.findReferencesAsNodes() as Array<Identifier>;
29
30
  temp_nodes.forEach(node => this.processNodeForAccesses(node, id));
30
31
  } catch (error) {
31
- console.error(`> WARNING: got exception ${error}. Continuing...`);
32
+ logger.error(`> WARNING: got exception ${error}. Continuing...`);
32
33
  }
33
34
  });
34
35
  }
@@ -45,13 +46,13 @@ export class ProcessAccesses {
45
46
  // check for a node whose first ancestor is a property declaration and bail?
46
47
  // This may be a bug in ts-morph?
47
48
  if (n.getFirstAncestorOrThrow().getKindName() === "PropertyDeclaration") {
48
- console.info(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})'s first ancestor is a PropertyDeclaration. Skipping...`);
49
+ logger.debug(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})'s first ancestor is a PropertyDeclaration. Skipping...`);
49
50
  return;
50
51
  }
51
52
  this.famixFunctions.createFamixAccess(n, id);
52
- console.info(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})`);
53
+ logger.debug(`processNodeForAccesses: node kind: ${n.getKindName()}, ${n.getText()}, (${n.getType().getText()})`);
53
54
  } catch (error) {
54
- console.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol().getFullyQualifiedName()}. Continuing...`);
55
+ logger.error(`> WARNING: got exception ${error}. ScopeDeclaration invalid for ${n.getSymbol().getFullyQualifiedName()}. Continuing...`);
55
56
  }
56
57
  }
57
58
  }