ts2famix 1.1.0 → 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
@@ -78,9 +78,9 @@ export class Method extends BehavioralEntity {
78
78
 
79
79
 
80
80
  public getJSON(): string {
81
- const mse: FamixJSONExporter = new FamixJSONExporter("Method", this);
82
- this.addPropertiesToExporter(mse);
83
- return mse.getJSON();
81
+ const json: FamixJSONExporter = new FamixJSONExporter("Method", this);
82
+ this.addPropertiesToExporter(json);
83
+ return json.getJSON();
84
84
  }
85
85
 
86
86
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -19,9 +19,9 @@ export class Module extends ScriptEntity {
19
19
  }
20
20
 
21
21
  public getJSON(): string {
22
- const mse: FamixJSONExporter = new FamixJSONExporter("Module", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
22
+ const json: FamixJSONExporter = new FamixJSONExporter("Module", this);
23
+ this.addPropertiesToExporter(json);
24
+ return json.getJSON();
25
25
  }
26
26
 
27
27
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -81,15 +81,15 @@ export class NamedEntity extends SourcedEntity {
81
81
 
82
82
 
83
83
  public getJSON(): string {
84
- const mse: FamixJSONExporter = new FamixJSONExporter("NamedEntity", this);
85
- this.addPropertiesToExporter(mse);
86
- return mse.getJSON();
84
+ const json: FamixJSONExporter = new FamixJSONExporter("NamedEntity", this);
85
+ this.addPropertiesToExporter(json);
86
+ return json.getJSON();
87
87
  }
88
88
 
89
89
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
90
90
  super.addPropertiesToExporter(exporter);
91
91
  exporter.addProperty("fullyQualifiedName", this.getFullyQualifiedName());
92
- exporter.addProperty("receivedInvocations", this.getReceivedInvocations());
92
+ exporter.addProperty("incomingInvocations", this.getReceivedInvocations());
93
93
  exporter.addProperty("incomingImports", this.getIncomingImports());
94
94
  exporter.addProperty("name", this.getName());
95
95
  exporter.addProperty("aliases", this.getAliases());
@@ -16,9 +16,9 @@ export class Namespace extends ScopingEntity {
16
16
 
17
17
 
18
18
  public getJSON(): string {
19
- const mse: FamixJSONExporter = new FamixJSONExporter("Namespace", this);
20
- this.addPropertiesToExporter(mse);
21
- return mse.getJSON();
19
+ const json: FamixJSONExporter = new FamixJSONExporter("Namespace", this);
20
+ this.addPropertiesToExporter(json);
21
+ return json.getJSON();
22
22
  }
23
23
 
24
24
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -17,9 +17,9 @@ export class Parameter extends StructuralEntity {
17
17
 
18
18
 
19
19
  public getJSON(): string {
20
- const mse: FamixJSONExporter = new FamixJSONExporter("Parameter", this);
21
- this.addPropertiesToExporter(mse);
22
- return mse.getJSON();
20
+ const json: FamixJSONExporter = new FamixJSONExporter("Parameter", this);
21
+ this.addPropertiesToExporter(json);
22
+ return json.getJSON();
23
23
  }
24
24
 
25
25
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -3,27 +3,27 @@ import { Type } from "./type";
3
3
  import { ParameterizableClass } from "./parameterizable_class";
4
4
  import { ParameterizableInterface } from "./parameterizable_interface";
5
5
  import { Method } from "./method";
6
- import { Function } from "./function";
6
+ import { Function as FamixFunction } from "./function";
7
7
  import { Accessor } from "./accessor";
8
8
 
9
- export class TypeParameter extends Type {
9
+ export class ParameterType extends Type {
10
10
 
11
- private parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | Function;
11
+ private parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | FamixFunction;
12
12
 
13
- public getParentGeneric(): ParameterizableClass | ParameterizableInterface | Method | Accessor | Function {
13
+ public getParentGeneric(): ParameterizableClass | ParameterizableInterface | Method | Accessor | FamixFunction {
14
14
  return this.parentGeneric;
15
15
  }
16
16
 
17
- public setParentGeneric(parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | Function): void {
17
+ public setParentGeneric(parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | FamixFunction): void {
18
18
  this.parentGeneric = parentGeneric;
19
- parentGeneric.addTypeParameter(this);
19
+ parentGeneric.addParameterType(this);
20
20
  }
21
21
 
22
22
 
23
23
  public getJSON(): string {
24
- const mse: FamixJSONExporter = new FamixJSONExporter("TypeParameter", this);
25
- this.addPropertiesToExporter(mse);
26
- return mse.getJSON();
24
+ const json: FamixJSONExporter = new FamixJSONExporter("ParameterType", this);
25
+ this.addPropertiesToExporter(json);
26
+ return json.getJSON();
27
27
  }
28
28
 
29
29
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -1,31 +1,31 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
2
  import { Class } from "./class";
3
- import { TypeParameter } from "./type_parameter";
3
+ import { ParameterType } from "./parameter_type";
4
4
 
5
5
  export class ParameterizableClass extends Class {
6
6
 
7
- private typeParameters: Set<TypeParameter> = new Set();
7
+ private parameterTypes: Set<ParameterType> = new Set();
8
8
 
9
- public getTypeParameters(): Set<TypeParameter> {
10
- return this.typeParameters;
9
+ public getParameterTypes(): Set<ParameterType> {
10
+ return this.parameterTypes;
11
11
  }
12
12
 
13
- public addTypeParameter(typeParameter: TypeParameter): void {
14
- if (!this.typeParameters.has(typeParameter)) {
15
- this.typeParameters.add(typeParameter);
16
- typeParameter.setParentGeneric(this);
13
+ public addParameterType(parameterType: ParameterType): void {
14
+ if (!this.parameterTypes.has(parameterType)) {
15
+ this.parameterTypes.add(parameterType);
16
+ parameterType.setParentGeneric(this);
17
17
  }
18
18
  }
19
19
 
20
20
 
21
21
  public getJSON(): string {
22
- const mse: FamixJSONExporter = new FamixJSONExporter("ParameterizableClass", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
22
+ const json: FamixJSONExporter = new FamixJSONExporter("ParameterizableClass", this);
23
+ this.addPropertiesToExporter(json);
24
+ return json.getJSON();
25
25
  }
26
26
 
27
27
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
28
28
  super.addPropertiesToExporter(exporter);
29
- exporter.addProperty("typeParameters", this.getTypeParameters());
29
+ exporter.addProperty("parameterTypes", this.getParameterTypes());
30
30
  }
31
31
  }
@@ -1,31 +1,31 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
2
  import { Interface } from "./interface";
3
- import { TypeParameter } from "./type_parameter";
3
+ import { ParameterType } from "./parameter_type";
4
4
 
5
5
  export class ParameterizableInterface extends Interface {
6
6
 
7
- private typeParameters: Set<TypeParameter> = new Set();
7
+ private parameterTypes: Set<ParameterType> = new Set();
8
8
 
9
- public getTypeParameters(): Set<TypeParameter> {
10
- return this.typeParameters;
9
+ public getParameterTypes(): Set<ParameterType> {
10
+ return this.parameterTypes;
11
11
  }
12
12
 
13
- public addTypeParameter(typeParameter: TypeParameter): void {
14
- if (!this.typeParameters.has(typeParameter)) {
15
- this.typeParameters.add(typeParameter);
16
- typeParameter.setParentGeneric(this);
13
+ public addParameterType(parameterType: ParameterType): void {
14
+ if (!this.parameterTypes.has(parameterType)) {
15
+ this.parameterTypes.add(parameterType);
16
+ parameterType.setParentGeneric(this);
17
17
  }
18
18
  }
19
19
 
20
20
 
21
21
  public getJSON(): string {
22
- const mse: FamixJSONExporter = new FamixJSONExporter("ParameterizableInterface", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
22
+ const json: FamixJSONExporter = new FamixJSONExporter("ParameterizableInterface", this);
23
+ this.addPropertiesToExporter(json);
24
+ return json.getJSON();
25
25
  }
26
26
 
27
27
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
28
28
  super.addPropertiesToExporter(exporter);
29
- exporter.addProperty("typeParameters", this.getTypeParameters());
29
+ exporter.addProperty("parameterTypes", this.getParameterTypes());
30
30
  }
31
31
  }
@@ -27,9 +27,9 @@ export class ParameterizedType extends Type {
27
27
 
28
28
 
29
29
  public getJSON(): string {
30
- const mse: FamixJSONExporter = new FamixJSONExporter("ParameterizedType", this);
31
- this.addPropertiesToExporter(mse);
32
- return mse.getJSON();
30
+ const json: FamixJSONExporter = new FamixJSONExporter("ParameterizedType", this);
31
+ this.addPropertiesToExporter(json);
32
+ return json.getJSON();
33
33
  }
34
34
 
35
35
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -4,9 +4,9 @@ import { Type } from "./type";
4
4
  export class PrimitiveType extends Type {
5
5
 
6
6
  public getJSON(): string {
7
- const mse: FamixJSONExporter = new FamixJSONExporter("PrimitiveType", this);
8
- this.addPropertiesToExporter(mse);
9
- return mse.getJSON();
7
+ const json: FamixJSONExporter = new FamixJSONExporter("PrimitiveType", this);
8
+ this.addPropertiesToExporter(json);
9
+ return json.getJSON();
10
10
  }
11
11
 
12
12
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -40,9 +40,9 @@ export class Property extends StructuralEntity {
40
40
 
41
41
 
42
42
  public getJSON(): string {
43
- const mse: FamixJSONExporter = new FamixJSONExporter("Property", this);
44
- this.addPropertiesToExporter(mse);
45
- return mse.getJSON();
43
+ const json: FamixJSONExporter = new FamixJSONExporter("Property", this);
44
+ this.addPropertiesToExporter(json);
45
+ return json.getJSON();
46
46
  }
47
47
 
48
48
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -29,9 +29,9 @@ export class Reference extends Association {
29
29
 
30
30
 
31
31
  public getJSON(): string {
32
- const mse: FamixJSONExporter = new FamixJSONExporter("Reference", this);
33
- this.addPropertiesToExporter(mse);
34
- return mse.getJSON();
32
+ const json: FamixJSONExporter = new FamixJSONExporter("Reference", this);
33
+ this.addPropertiesToExporter(json);
34
+ return json.getJSON();
35
35
  }
36
36
 
37
37
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -1,6 +1,7 @@
1
1
  import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
2
  import { ContainerEntity } from "./container_entity";
3
3
  import { Namespace } from "./namespace";
4
+ import { logger } from "../../../../../analyze";
4
5
 
5
6
  export class ScopingEntity extends ContainerEntity {
6
7
 
@@ -12,19 +13,19 @@ export class ScopingEntity extends ContainerEntity {
12
13
 
13
14
  public addNamespace(childNamespace: Namespace): void {
14
15
  if (!this.childrenNamespaces.has(childNamespace)) {
15
- console.info("Adding namespace " + childNamespace.getName() + " to " + this.getName());
16
+ logger.debug("Adding namespace " + childNamespace.getName() + " to " + this.getName());
16
17
  this.childrenNamespaces.add(childNamespace);
17
18
  childNamespace.setParentScope(this);
18
19
  } else {
19
- console.info("Namespace " + childNamespace.getName() + " already added to " + this.getName());
20
+ logger.debug("Namespace " + childNamespace.getName() + " already added to " + this.getName());
20
21
  }
21
22
  }
22
23
 
23
24
 
24
25
  public getJSON(): string {
25
- const mse: FamixJSONExporter = new FamixJSONExporter("ScopingEntity", this);
26
- this.addPropertiesToExporter(mse);
27
- return mse.getJSON();
26
+ const json: FamixJSONExporter = new FamixJSONExporter("ScopingEntity", this);
27
+ this.addPropertiesToExporter(json);
28
+ return json.getJSON();
28
29
  }
29
30
 
30
31
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -25,9 +25,9 @@ export class ScriptEntity extends ScopingEntity {
25
25
 
26
26
 
27
27
  public getJSON(): string {
28
- const mse: FamixJSONExporter = new FamixJSONExporter("ScriptEntity", this);
29
- this.addPropertiesToExporter(mse);
30
- return mse.getJSON();
28
+ const json: FamixJSONExporter = new FamixJSONExporter("ScriptEntity", this);
29
+ this.addPropertiesToExporter(json);
30
+ return json.getJSON();
31
31
  }
32
32
 
33
33
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -19,9 +19,9 @@ export class SourceAnchor extends Entity {
19
19
 
20
20
 
21
21
  public getJSON(): string {
22
- const mse: FamixJSONExporter = new FamixJSONExporter("SourceAnchor", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
22
+ const json: FamixJSONExporter = new FamixJSONExporter("SourceAnchor", this);
23
+ this.addPropertiesToExporter(json);
24
+ return json.getJSON();
25
25
  }
26
26
 
27
27
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -6,6 +6,11 @@ export class SourceLanguage extends Entity {
6
6
 
7
7
  private sourcedEntities: Set<SourcedEntity> = new Set();
8
8
 
9
+ // name of the source language
10
+ get name(): string {
11
+ return "TypeScript";
12
+ }
13
+
9
14
  public getSourcedEntities(): Set<SourcedEntity> {
10
15
  return this.sourcedEntities;
11
16
  }
@@ -19,13 +24,14 @@ export class SourceLanguage extends Entity {
19
24
 
20
25
 
21
26
  public getJSON(): string {
22
- const mse: FamixJSONExporter = new FamixJSONExporter("SourceLanguage", this);
23
- this.addPropertiesToExporter(mse);
24
- return mse.getJSON();
27
+ const json: FamixJSONExporter = new FamixJSONExporter("SourceLanguage", this);
28
+ this.addPropertiesToExporter(json);
29
+ return json.getJSON();
25
30
  }
26
31
 
27
32
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
28
33
  super.addPropertiesToExporter(exporter);
34
+ exporter.addProperty("name", this.name);
29
35
  exporter.addProperty("sourcedEntities", this.getSourcedEntities());
30
36
  }
31
37
  }
@@ -3,6 +3,7 @@ import { SourceLanguage } from "./source_language";
3
3
  import { Entity } from "./entity";
4
4
  import { Comment } from "./comment";
5
5
  import { SourceAnchor } from "./source_anchor";
6
+ import { logger } from "../../../../../analyze";
6
7
 
7
8
  export class SourcedEntity extends Entity {
8
9
 
@@ -39,6 +40,8 @@ export class SourcedEntity extends Entity {
39
40
  if (!this.comments.has(comment)) {
40
41
  this.comments.add(comment);
41
42
  comment.setContainer(this);
43
+ } else {
44
+ logger.warn("WARNING: adding comment that is already in comments: " + comment.getJSON() + " to " + this.getJSON());
42
45
  }
43
46
  }
44
47
 
@@ -55,9 +58,9 @@ export class SourcedEntity extends Entity {
55
58
 
56
59
 
57
60
  public getJSON(): string {
58
- const mse: FamixJSONExporter = new FamixJSONExporter("SourcedEntity", this);
59
- this.addPropertiesToExporter(mse);
60
- return mse.getJSON();
61
+ const json: FamixJSONExporter = new FamixJSONExporter("SourcedEntity", this);
62
+ this.addPropertiesToExporter(json);
63
+ return json.getJSON();
61
64
  }
62
65
 
63
66
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -31,9 +31,9 @@ export class StructuralEntity extends NamedEntity {
31
31
 
32
32
 
33
33
  public getJSON(): string {
34
- const mse: FamixJSONExporter = new FamixJSONExporter("StructuralEntity", this);
35
- this.addPropertiesToExporter(mse);
36
- return mse.getJSON();
34
+ const json: FamixJSONExporter = new FamixJSONExporter("StructuralEntity", this);
35
+ this.addPropertiesToExporter(json);
36
+ return json.getJSON();
37
37
  }
38
38
 
39
39
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -35,9 +35,9 @@ export class TextAnchor extends SourceAnchor {
35
35
 
36
36
 
37
37
  public getJSON(): string {
38
- const mse: FamixJSONExporter = new FamixJSONExporter("TextAnchor", this);
39
- this.addPropertiesToExporter(mse);
40
- return mse.getJSON();
38
+ const json: FamixJSONExporter = new FamixJSONExporter("TextAnchor", this);
39
+ this.addPropertiesToExporter(json);
40
+ return json.getJSON();
41
41
  }
42
42
 
43
43
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -72,9 +72,9 @@ export class Type extends ContainerEntity {
72
72
 
73
73
 
74
74
  public getJSON(): string {
75
- const mse: FamixJSONExporter = new FamixJSONExporter("Type", this);
76
- this.addPropertiesToExporter(mse);
77
- return mse.getJSON();
75
+ const json: FamixJSONExporter = new FamixJSONExporter("Type", this);
76
+ this.addPropertiesToExporter(json);
77
+ return json.getJSON();
78
78
  }
79
79
 
80
80
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -16,9 +16,9 @@ export class Variable extends StructuralEntity {
16
16
 
17
17
 
18
18
  public getJSON(): string {
19
- const mse: FamixJSONExporter = new FamixJSONExporter("Variable", this);
20
- this.addPropertiesToExporter(mse);
21
- return mse.getJSON();
19
+ const json: FamixJSONExporter = new FamixJSONExporter("Variable", this);
20
+ this.addPropertiesToExporter(json);
21
+ return json.getJSON();
22
22
  }
23
23
 
24
24
  public addPropertiesToExporter(exporter: FamixJSONExporter): void {
@@ -4,6 +4,7 @@ import yargs from "yargs";
4
4
  import { Importer } from './analyze';
5
5
  import { FamixRepository } from "./lib/famix/src/famix_repository";
6
6
  import { Project } from "ts-morph";
7
+ import { config } from "./analyze";
7
8
 
8
9
  const argv = yargs
9
10
  .example(`ts2famix -i "path/to/project/**/*.ts" -o JSONModels/projectName.json`, 'Creates a JSON-format Famix model of typescript files.')
@@ -12,7 +13,20 @@ const argv = yargs
12
13
  .nargs('i', 1)
13
14
  .alias('o', 'output')
14
15
  .nargs('o', 1)
15
- .demandOption('input').demandOption('output').parseSync();
16
+ .alias('l', 'loglevel')
17
+ .nargs('l', 1)
18
+ .default('l', 3)
19
+ .describe('l', 'Set minimum logging level 0: silly, 1: trace, 2: debug, 3: info, 4: warn, 5: error, 6: fatal')
20
+ .boolean('graphemes')
21
+ .default('graphemes', false)
22
+ .describe('graphemes', 'Process graphemes (outside of the BMP) to avoid source anchor offset errors (due to performance issues, this is disabled by default)')
23
+ .demandOption('input')
24
+ .demandOption('output')
25
+ .parseSync();
26
+
27
+ import { logger } from './analyze';
28
+ logger.settings.minLevel = Number(argv.loglevel) as number;
29
+ config.expectGraphemes = argv.graphemes as boolean;
16
30
 
17
31
  const importer = new Importer();
18
32
  let famixRep: FamixRepository;
@@ -29,11 +43,11 @@ if ((argv.input as string).endsWith('tsconfig.json')) {
29
43
  famixRep = importer.famixRepFromPaths(paths);
30
44
  }
31
45
 
32
- const jsonOutput = famixRep.getJSON();
46
+ const jsonOutput = famixRep.export({format: "json"});
33
47
  const jsonFilePath = argv.output as string;
34
48
 
35
49
  fs.writeFile(jsonFilePath, jsonOutput, (err) => {
36
50
  if (err) { throw err; }
37
51
  });
38
52
 
39
- console.info(`Created: ${jsonFilePath}`);
53
+ logger.info(`Created: ${jsonFilePath}`);
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CSourceLanguage = void 0;
4
- const famix_JSON_exporter_1 = require("../../famix_JSON_exporter");
5
- const source_language_1 = require("./source_language");
6
- class CSourceLanguage extends source_language_1.SourceLanguage {
7
- getJSON() {
8
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("CSourceLanguage", this);
9
- this.addPropertiesToExporter(mse);
10
- return mse.getJSON();
11
- }
12
- addPropertiesToExporter(exporter) {
13
- super.addPropertiesToExporter(exporter);
14
- }
15
- }
16
- exports.CSourceLanguage = CSourceLanguage;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CustomSourceLanguage = void 0;
4
- const famix_JSON_exporter_1 = require("../../famix_JSON_exporter");
5
- const source_language_1 = require("./source_language");
6
- class CustomSourceLanguage extends source_language_1.SourceLanguage {
7
- getLanguageName() {
8
- return this.languageName;
9
- }
10
- setLanguageName(languageName) {
11
- this.languageName = languageName;
12
- }
13
- getJSON() {
14
- const mse = new famix_JSON_exporter_1.FamixJSONExporter("CustomSourceLanguage", this);
15
- this.addPropertiesToExporter(mse);
16
- return mse.getJSON();
17
- }
18
- addPropertiesToExporter(exporter) {
19
- super.addPropertiesToExporter(exporter);
20
- exporter.addProperty("languageName", this.getLanguageName());
21
- }
22
- }
23
- exports.CustomSourceLanguage = CustomSourceLanguage;
@@ -1,15 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { SourceLanguage } from "./source_language";
3
-
4
- export class CSourceLanguage extends SourceLanguage {
5
-
6
- public getJSON(): string {
7
- const mse: FamixJSONExporter = new FamixJSONExporter("CSourceLanguage", this);
8
- this.addPropertiesToExporter(mse);
9
- return mse.getJSON();
10
- }
11
-
12
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
13
- super.addPropertiesToExporter(exporter);
14
- }
15
- }
@@ -1,27 +0,0 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { SourceLanguage } from "./source_language";
3
-
4
- export class CustomSourceLanguage extends SourceLanguage {
5
-
6
- private languageName: string;
7
-
8
- public getLanguageName(): string {
9
- return this.languageName;
10
- }
11
-
12
- public setLanguageName(languageName: string): void {
13
- this.languageName = languageName;
14
- }
15
-
16
-
17
- public getJSON(): string {
18
- const mse: FamixJSONExporter = new FamixJSONExporter("CustomSourceLanguage", this);
19
- this.addPropertiesToExporter(mse);
20
- return mse.getJSON();
21
- }
22
-
23
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
24
- super.addPropertiesToExporter(exporter);
25
- exporter.addProperty("languageName", this.getLanguageName());
26
- }
27
- }