ts2famix 1.0.10 → 1.0.12

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 (138) hide show
  1. package/.eslintrc.json +24 -24
  2. package/LICENSE +23 -23
  3. package/README.md +109 -109
  4. package/jest.config-old.ts +199 -199
  5. package/package.json +47 -47
  6. package/src/analyze.ts +94 -94
  7. package/src/analyze_functions/processAccesses.ts +57 -50
  8. package/src/analyze_functions/processFiles.ts +669 -660
  9. package/src/analyze_functions/processImportClauses.ts +77 -77
  10. package/src/analyze_functions/processInheritances.ts +84 -84
  11. package/src/analyze_functions/processInvocations.ts +51 -51
  12. package/src/famix2puml.ts +119 -119
  13. package/src/famix_functions/famix_functions.ts +559 -555
  14. package/src/famix_functions/famix_functions_associations.ts +215 -215
  15. package/src/famix_functions/famix_functions_index.ts +44 -44
  16. package/src/famix_functions/famix_functions_types.ts +105 -100
  17. package/src/generate_uml.sh +16 -16
  18. package/src/lib/famix/License.md +22 -22
  19. package/src/lib/famix/package-lock.json +301 -301
  20. package/src/lib/famix/package.json +27 -27
  21. package/src/lib/famix/readme.md +4 -4
  22. package/src/lib/famix/src/famix_JSON_exporter.ts +56 -56
  23. package/src/lib/famix/src/famix_base_element.ts +18 -18
  24. package/src/lib/famix/src/famix_repository.ts +199 -199
  25. package/src/lib/famix/src/index.ts +8 -8
  26. package/src/lib/famix/src/model/famix/access.ts +53 -53
  27. package/src/lib/famix/src/model/famix/accessor.ts +15 -15
  28. package/src/lib/famix/src/model/famix/alias.ts +41 -41
  29. package/src/lib/famix/src/model/famix/association.ts +44 -44
  30. package/src/lib/famix/src/model/famix/behavioral_entity.ts +107 -107
  31. package/src/lib/famix/src/model/famix/c_source_language.ts +15 -15
  32. package/src/lib/famix/src/model/famix/class.ts +86 -86
  33. package/src/lib/famix/src/model/famix/comment.ts +50 -50
  34. package/src/lib/famix/src/model/famix/container_entity.ts +165 -165
  35. package/src/lib/famix/src/model/famix/custom_source_language.ts +27 -27
  36. package/src/lib/famix/src/model/famix/decorator.ts +39 -39
  37. package/src/lib/famix/src/model/famix/entity.ts +15 -15
  38. package/src/lib/famix/src/model/famix/enum.ts +31 -31
  39. package/src/lib/famix/src/model/famix/enum_value.ts +29 -29
  40. package/src/lib/famix/src/model/famix/function.ts +15 -15
  41. package/src/lib/famix/src/model/famix/implicit_variable.ts +15 -15
  42. package/src/lib/famix/src/model/famix/import_clause.ts +53 -53
  43. package/src/lib/famix/src/model/famix/index.ts +42 -42
  44. package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +49 -49
  45. package/src/lib/famix/src/model/famix/inheritance.ts +42 -42
  46. package/src/lib/famix/src/model/famix/interface.ts +75 -75
  47. package/src/lib/famix/src/model/famix/invocation.ts +68 -68
  48. package/src/lib/famix/src/model/famix/method.ts +96 -96
  49. package/src/lib/famix/src/model/famix/module.ts +31 -31
  50. package/src/lib/famix/src/model/famix/named_entity.ts +98 -98
  51. package/src/lib/famix/src/model/famix/namespace.ts +28 -28
  52. package/src/lib/famix/src/model/famix/parameter.ts +29 -29
  53. package/src/lib/famix/src/model/famix/parameterizable_class.ts +31 -31
  54. package/src/lib/famix/src/model/famix/parameterizable_interface.ts +31 -31
  55. package/src/lib/famix/src/model/famix/parameterized_type.ts +40 -40
  56. package/src/lib/famix/src/model/famix/primitive_type.ts +15 -15
  57. package/src/lib/famix/src/model/famix/property.ts +54 -54
  58. package/src/lib/famix/src/model/famix/reference.ts +42 -42
  59. package/src/lib/famix/src/model/famix/scoping_entity.ts +31 -31
  60. package/src/lib/famix/src/model/famix/script_entity.ts +38 -38
  61. package/src/lib/famix/src/model/famix/source_anchor.ts +31 -31
  62. package/src/lib/famix/src/model/famix/source_language.ts +31 -31
  63. package/src/lib/famix/src/model/famix/sourced_entity.ts +70 -70
  64. package/src/lib/famix/src/model/famix/structural_entity.ts +44 -44
  65. package/src/lib/famix/src/model/famix/text_anchor.ts +49 -49
  66. package/src/lib/famix/src/model/famix/type.ts +88 -88
  67. package/src/lib/famix/src/model/famix/type_parameter.ts +33 -33
  68. package/src/lib/famix/src/model/famix/variable.ts +28 -28
  69. package/src/lib/famix/tsconfig.json +26 -26
  70. package/src/lib/famix/tslint.json +14 -14
  71. package/src/lib/ts-complex/cyclomatic-service.ts +85 -85
  72. package/src/ts2famix-cli.ts +39 -39
  73. package/tsconfig.json +69 -69
  74. package/dist/analyze.js +0 -102
  75. package/dist/analyze_functions/processAccesses.js +0 -47
  76. package/dist/analyze_functions/processFiles.js +0 -540
  77. package/dist/analyze_functions/processImportClauses.js +0 -70
  78. package/dist/analyze_functions/processInheritances.js +0 -73
  79. package/dist/analyze_functions/processInvocations.js +0 -49
  80. package/dist/famix2puml.js +0 -125
  81. package/dist/famix_functions/famix_functions.js +0 -513
  82. package/dist/famix_functions/famix_functions_associations.js +0 -205
  83. package/dist/famix_functions/famix_functions_index.js +0 -62
  84. package/dist/famix_functions/famix_functions_types.js +0 -110
  85. package/dist/fqn.js +0 -126
  86. package/dist/fqp_implementation.js +0 -73
  87. package/dist/lib/famix/src/famix_JSON_exporter.js +0 -54
  88. package/dist/lib/famix/src/famix_base_element.js +0 -13
  89. package/dist/lib/famix/src/famix_repository.js +0 -187
  90. package/dist/lib/famix/src/index.js +0 -30
  91. package/dist/lib/famix/src/model/famix/access.js +0 -39
  92. package/dist/lib/famix/src/model/famix/accessor.js +0 -16
  93. package/dist/lib/famix/src/model/famix/alias.js +0 -32
  94. package/dist/lib/famix/src/model/famix/association.js +0 -36
  95. package/dist/lib/famix/src/model/famix/behavioral_entity.js +0 -81
  96. package/dist/lib/famix/src/model/famix/c_source_language.js +0 -16
  97. package/dist/lib/famix/src/model/famix/class.js +0 -70
  98. package/dist/lib/famix/src/model/famix/comment.js +0 -38
  99. package/dist/lib/famix/src/model/famix/container_entity.js +0 -125
  100. package/dist/lib/famix/src/model/famix/custom_source_language.js +0 -23
  101. package/dist/lib/famix/src/model/famix/decorator.js +0 -31
  102. package/dist/lib/famix/src/model/famix/entity.js +0 -16
  103. package/dist/lib/famix/src/model/famix/enum.js +0 -30
  104. package/dist/lib/famix/src/model/famix/enum_value.js +0 -24
  105. package/dist/lib/famix/src/model/famix/function.js +0 -16
  106. package/dist/lib/famix/src/model/famix/implicit_variable.js +0 -16
  107. package/dist/lib/famix/src/model/famix/import_clause.js +0 -39
  108. package/dist/lib/famix/src/model/famix/index.js +0 -87
  109. package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +0 -37
  110. package/dist/lib/famix/src/model/famix/inheritance.js +0 -32
  111. package/dist/lib/famix/src/model/famix/interface.js +0 -63
  112. package/dist/lib/famix/src/model/famix/invocation.js +0 -53
  113. package/dist/lib/famix/src/model/famix/method.js +0 -66
  114. package/dist/lib/famix/src/model/famix/module.js +0 -30
  115. package/dist/lib/famix/src/model/famix/named_entity.js +0 -77
  116. package/dist/lib/famix/src/model/famix/namespace.js +0 -24
  117. package/dist/lib/famix/src/model/famix/parameter.js +0 -24
  118. package/dist/lib/famix/src/model/famix/parameterizable_class.js +0 -30
  119. package/dist/lib/famix/src/model/famix/parameterizable_interface.js +0 -30
  120. package/dist/lib/famix/src/model/famix/parameterized_type.js +0 -36
  121. package/dist/lib/famix/src/model/famix/primitive_type.js +0 -16
  122. package/dist/lib/famix/src/model/famix/property.js +0 -44
  123. package/dist/lib/famix/src/model/famix/reference.js +0 -32
  124. package/dist/lib/famix/src/model/famix/scoping_entity.js +0 -30
  125. package/dist/lib/famix/src/model/famix/script_entity.js +0 -30
  126. package/dist/lib/famix/src/model/famix/source_anchor.js +0 -26
  127. package/dist/lib/famix/src/model/famix/source_language.js +0 -30
  128. package/dist/lib/famix/src/model/famix/sourced_entity.js +0 -55
  129. package/dist/lib/famix/src/model/famix/structural_entity.js +0 -38
  130. package/dist/lib/famix/src/model/famix/text_anchor.js +0 -37
  131. package/dist/lib/famix/src/model/famix/type.js +0 -71
  132. package/dist/lib/famix/src/model/famix/type_parameter.js +0 -24
  133. package/dist/lib/famix/src/model/famix/variable.js +0 -23
  134. package/dist/lib/ts-complex/cyclomatic-service.js +0 -83
  135. package/dist/ts2famix-cli.js +0 -63
  136. package/dist/ts2famix-tsconfig.js +0 -53
  137. package/metrics.ts +0 -23
  138. package/src/fqp_implementation.ts +0 -66
@@ -1,49 +1,49 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { SourceAnchor } from "./source_anchor";
3
-
4
- export class TextAnchor extends SourceAnchor {
5
-
6
- private startPos: number;
7
-
8
- public getStartPos(): number {
9
- return this.startPos;
10
- }
11
-
12
- public setStartPos(startPos: number): void {
13
- this.startPos = startPos;
14
- }
15
-
16
- private endPos: number;
17
-
18
- public getEndPos(): number {
19
- return this.endPos;
20
- }
21
-
22
- public setEndPos(endPos: number): void {
23
- this.endPos = endPos;
24
- }
25
-
26
- private fileName: string;
27
-
28
- public getFileName(): string {
29
- return this.fileName;
30
- }
31
-
32
- public setFileName(fileName: string): void {
33
- this.fileName = fileName;
34
- }
35
-
36
-
37
- public getJSON(): string {
38
- const mse: FamixJSONExporter = new FamixJSONExporter("TextAnchor", this);
39
- this.addPropertiesToExporter(mse);
40
- return mse.getJSON();
41
- }
42
-
43
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
44
- super.addPropertiesToExporter(exporter);
45
- exporter.addProperty("startPos", this.getStartPos());
46
- exporter.addProperty("endPos", this.getEndPos());
47
- exporter.addProperty("fileName", this.getFileName());
48
- }
49
- }
1
+ import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
+ import { SourceAnchor } from "./source_anchor";
3
+
4
+ export class TextAnchor extends SourceAnchor {
5
+
6
+ private startPos: number;
7
+
8
+ public getStartPos(): number {
9
+ return this.startPos;
10
+ }
11
+
12
+ public setStartPos(startPos: number): void {
13
+ this.startPos = startPos;
14
+ }
15
+
16
+ private endPos: number;
17
+
18
+ public getEndPos(): number {
19
+ return this.endPos;
20
+ }
21
+
22
+ public setEndPos(endPos: number): void {
23
+ this.endPos = endPos;
24
+ }
25
+
26
+ private fileName: string;
27
+
28
+ public getFileName(): string {
29
+ return this.fileName;
30
+ }
31
+
32
+ public setFileName(fileName: string): void {
33
+ this.fileName = fileName;
34
+ }
35
+
36
+
37
+ public getJSON(): string {
38
+ const mse: FamixJSONExporter = new FamixJSONExporter("TextAnchor", this);
39
+ this.addPropertiesToExporter(mse);
40
+ return mse.getJSON();
41
+ }
42
+
43
+ public addPropertiesToExporter(exporter: FamixJSONExporter): void {
44
+ super.addPropertiesToExporter(exporter);
45
+ exporter.addProperty("startPos", this.getStartPos());
46
+ exporter.addProperty("endPos", this.getEndPos());
47
+ exporter.addProperty("fileName", this.getFileName());
48
+ }
49
+ }
@@ -1,88 +1,88 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { StructuralEntity } from "./structural_entity";
3
- import { ContainerEntity } from "./container_entity";
4
- import { Reference } from "./reference";
5
- import { BehavioralEntity } from "./behavioral_entity";
6
- import { Alias } from "./alias";
7
-
8
- export class Type extends ContainerEntity {
9
-
10
- private container: ContainerEntity;
11
-
12
- public getContainer(): ContainerEntity {
13
- return this.container;
14
- }
15
-
16
- public setContainer(container: ContainerEntity): void {
17
- this.container = container;
18
- container.addType(this);
19
- }
20
-
21
- private typeAliases: Set<Alias> = new Set();
22
-
23
- public getTypeAliases(): Set<Alias> {
24
- return this.typeAliases;
25
- }
26
-
27
- public addTypeAlias(typeAlias: Alias): void {
28
- if (!this.typeAliases.has(typeAlias)) {
29
- this.typeAliases.add(typeAlias);
30
- typeAlias.setAliasedEntity(this);
31
- }
32
- }
33
-
34
- private structuresWithDeclaredType: Set<StructuralEntity> = new Set();
35
-
36
- public getStructuresWithDeclaredType(): Set<StructuralEntity> {
37
- return this.structuresWithDeclaredType;
38
- }
39
-
40
- public addStructureWithDeclaredType(structureWithDeclaredType: StructuralEntity): void {
41
- if (!this.structuresWithDeclaredType.has(structureWithDeclaredType)) {
42
- this.structuresWithDeclaredType.add(structureWithDeclaredType);
43
- structureWithDeclaredType.setDeclaredType(this);
44
- }
45
- }
46
-
47
- private behavioralEntitiesWithDeclaredType: Set<BehavioralEntity> = new Set();
48
-
49
- public getBehavioralEntitiesWithDeclaredType(): Set<BehavioralEntity> {
50
- return this.behavioralEntitiesWithDeclaredType;
51
- }
52
-
53
- public addBehavioralEntityWithDeclaredType(behavioralEntityWithDeclaredType: BehavioralEntity): void {
54
- if (!this.behavioralEntitiesWithDeclaredType.has(behavioralEntityWithDeclaredType)) {
55
- this.behavioralEntitiesWithDeclaredType.add(behavioralEntityWithDeclaredType);
56
- behavioralEntityWithDeclaredType.setDeclaredType(this);
57
- }
58
- }
59
-
60
- private incomingReferences: Set<Reference> = new Set();
61
-
62
- public getIncomingReferences(): Set<Reference> {
63
- return this.incomingReferences;
64
- }
65
-
66
- public addIncomingReference(incomingReference: Reference): void {
67
- if (!this.incomingReferences.has(incomingReference)) {
68
- this.incomingReferences.add(incomingReference);
69
- incomingReference.setTarget(this);
70
- }
71
- }
72
-
73
-
74
- public getJSON(): string {
75
- const mse: FamixJSONExporter = new FamixJSONExporter("Type", this);
76
- this.addPropertiesToExporter(mse);
77
- return mse.getJSON();
78
- }
79
-
80
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
81
- super.addPropertiesToExporter(exporter);
82
- exporter.addProperty("container", this.getContainer());
83
- exporter.addProperty("typeAliases", this.getTypeAliases());
84
- exporter.addProperty("structuresWithDeclaredType", this.getStructuresWithDeclaredType());
85
- exporter.addProperty("behavioralEntitiesWithDeclaredType", this.getBehavioralEntitiesWithDeclaredType());
86
- exporter.addProperty("incomingReferences", this.getIncomingReferences());
87
- }
88
- }
1
+ import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
+ import { StructuralEntity } from "./structural_entity";
3
+ import { ContainerEntity } from "./container_entity";
4
+ import { Reference } from "./reference";
5
+ import { BehavioralEntity } from "./behavioral_entity";
6
+ import { Alias } from "./alias";
7
+
8
+ export class Type extends ContainerEntity {
9
+
10
+ private container: ContainerEntity;
11
+
12
+ public getContainer(): ContainerEntity {
13
+ return this.container;
14
+ }
15
+
16
+ public setContainer(container: ContainerEntity): void {
17
+ this.container = container;
18
+ container.addType(this);
19
+ }
20
+
21
+ private typeAliases: Set<Alias> = new Set();
22
+
23
+ public getTypeAliases(): Set<Alias> {
24
+ return this.typeAliases;
25
+ }
26
+
27
+ public addTypeAlias(typeAlias: Alias): void {
28
+ if (!this.typeAliases.has(typeAlias)) {
29
+ this.typeAliases.add(typeAlias);
30
+ typeAlias.setAliasedEntity(this);
31
+ }
32
+ }
33
+
34
+ private structuresWithDeclaredType: Set<StructuralEntity> = new Set();
35
+
36
+ public getStructuresWithDeclaredType(): Set<StructuralEntity> {
37
+ return this.structuresWithDeclaredType;
38
+ }
39
+
40
+ public addStructureWithDeclaredType(structureWithDeclaredType: StructuralEntity): void {
41
+ if (!this.structuresWithDeclaredType.has(structureWithDeclaredType)) {
42
+ this.structuresWithDeclaredType.add(structureWithDeclaredType);
43
+ structureWithDeclaredType.setDeclaredType(this);
44
+ }
45
+ }
46
+
47
+ private behavioralEntitiesWithDeclaredType: Set<BehavioralEntity> = new Set();
48
+
49
+ public getBehavioralEntitiesWithDeclaredType(): Set<BehavioralEntity> {
50
+ return this.behavioralEntitiesWithDeclaredType;
51
+ }
52
+
53
+ public addBehavioralEntityWithDeclaredType(behavioralEntityWithDeclaredType: BehavioralEntity): void {
54
+ if (!this.behavioralEntitiesWithDeclaredType.has(behavioralEntityWithDeclaredType)) {
55
+ this.behavioralEntitiesWithDeclaredType.add(behavioralEntityWithDeclaredType);
56
+ behavioralEntityWithDeclaredType.setDeclaredType(this);
57
+ }
58
+ }
59
+
60
+ private incomingReferences: Set<Reference> = new Set();
61
+
62
+ public getIncomingReferences(): Set<Reference> {
63
+ return this.incomingReferences;
64
+ }
65
+
66
+ public addIncomingReference(incomingReference: Reference): void {
67
+ if (!this.incomingReferences.has(incomingReference)) {
68
+ this.incomingReferences.add(incomingReference);
69
+ incomingReference.setTarget(this);
70
+ }
71
+ }
72
+
73
+
74
+ public getJSON(): string {
75
+ const mse: FamixJSONExporter = new FamixJSONExporter("Type", this);
76
+ this.addPropertiesToExporter(mse);
77
+ return mse.getJSON();
78
+ }
79
+
80
+ public addPropertiesToExporter(exporter: FamixJSONExporter): void {
81
+ super.addPropertiesToExporter(exporter);
82
+ exporter.addProperty("container", this.getContainer());
83
+ exporter.addProperty("typeAliases", this.getTypeAliases());
84
+ exporter.addProperty("structuresWithDeclaredType", this.getStructuresWithDeclaredType());
85
+ exporter.addProperty("behavioralEntitiesWithDeclaredType", this.getBehavioralEntitiesWithDeclaredType());
86
+ exporter.addProperty("incomingReferences", this.getIncomingReferences());
87
+ }
88
+ }
@@ -1,33 +1,33 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { Type } from "./type";
3
- import { ParameterizableClass } from "./parameterizable_class";
4
- import { ParameterizableInterface } from "./parameterizable_interface";
5
- import { Method } from "./method";
6
- import { Function } from "./function";
7
- import { Accessor } from "./accessor";
8
-
9
- export class TypeParameter extends Type {
10
-
11
- private parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | Function;
12
-
13
- public getParentGeneric(): ParameterizableClass | ParameterizableInterface | Method | Accessor | Function {
14
- return this.parentGeneric;
15
- }
16
-
17
- public setParentGeneric(parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | Function): void {
18
- this.parentGeneric = parentGeneric;
19
- parentGeneric.addTypeParameter(this);
20
- }
21
-
22
-
23
- public getJSON(): string {
24
- const mse: FamixJSONExporter = new FamixJSONExporter("TypeParameter", this);
25
- this.addPropertiesToExporter(mse);
26
- return mse.getJSON();
27
- }
28
-
29
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
30
- super.addPropertiesToExporter(exporter);
31
- exporter.addProperty("parentGeneric", this.getParentGeneric());
32
- }
33
- }
1
+ import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
+ import { Type } from "./type";
3
+ import { ParameterizableClass } from "./parameterizable_class";
4
+ import { ParameterizableInterface } from "./parameterizable_interface";
5
+ import { Method } from "./method";
6
+ import { Function } from "./function";
7
+ import { Accessor } from "./accessor";
8
+
9
+ export class TypeParameter extends Type {
10
+
11
+ private parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | Function;
12
+
13
+ public getParentGeneric(): ParameterizableClass | ParameterizableInterface | Method | Accessor | Function {
14
+ return this.parentGeneric;
15
+ }
16
+
17
+ public setParentGeneric(parentGeneric: ParameterizableClass | ParameterizableInterface | Method | Accessor | Function): void {
18
+ this.parentGeneric = parentGeneric;
19
+ parentGeneric.addTypeParameter(this);
20
+ }
21
+
22
+
23
+ public getJSON(): string {
24
+ const mse: FamixJSONExporter = new FamixJSONExporter("TypeParameter", this);
25
+ this.addPropertiesToExporter(mse);
26
+ return mse.getJSON();
27
+ }
28
+
29
+ public addPropertiesToExporter(exporter: FamixJSONExporter): void {
30
+ super.addPropertiesToExporter(exporter);
31
+ exporter.addProperty("parentGeneric", this.getParentGeneric());
32
+ }
33
+ }
@@ -1,28 +1,28 @@
1
- import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
- import { ContainerEntity } from "./container_entity";
3
- import { StructuralEntity } from "./structural_entity";
4
-
5
- export class Variable extends StructuralEntity {
6
-
7
- private parentContainerEntity: ContainerEntity;
8
-
9
- public getParentContainerEntity(): ContainerEntity {
10
- return this.parentContainerEntity;
11
- }
12
-
13
- public setParentContainerEntity(parentContainerEntity: ContainerEntity): void {
14
- this.parentContainerEntity = parentContainerEntity;
15
- }
16
-
17
-
18
- public getJSON(): string {
19
- const mse: FamixJSONExporter = new FamixJSONExporter("Variable", this);
20
- this.addPropertiesToExporter(mse);
21
- return mse.getJSON();
22
- }
23
-
24
- public addPropertiesToExporter(exporter: FamixJSONExporter): void {
25
- super.addPropertiesToExporter(exporter);
26
- exporter.addProperty("parentContainerEntity", this.getParentContainerEntity());
27
- }
28
- }
1
+ import { FamixJSONExporter } from "../../famix_JSON_exporter";
2
+ import { ContainerEntity } from "./container_entity";
3
+ import { StructuralEntity } from "./structural_entity";
4
+
5
+ export class Variable extends StructuralEntity {
6
+
7
+ private parentContainerEntity: ContainerEntity;
8
+
9
+ public getParentContainerEntity(): ContainerEntity {
10
+ return this.parentContainerEntity;
11
+ }
12
+
13
+ public setParentContainerEntity(parentContainerEntity: ContainerEntity): void {
14
+ this.parentContainerEntity = parentContainerEntity;
15
+ }
16
+
17
+
18
+ public getJSON(): string {
19
+ const mse: FamixJSONExporter = new FamixJSONExporter("Variable", this);
20
+ this.addPropertiesToExporter(mse);
21
+ return mse.getJSON();
22
+ }
23
+
24
+ public addPropertiesToExporter(exporter: FamixJSONExporter): void {
25
+ super.addPropertiesToExporter(exporter);
26
+ exporter.addProperty("parentContainerEntity", this.getParentContainerEntity());
27
+ }
28
+ }
@@ -1,27 +1,27 @@
1
- {
2
- "compilerOptions": {
3
- "module": "commonjs",
4
- "outDir": "dist",
5
- "incremental": true,
6
- "pretty": true,
7
- "noFallthroughCasesInSwitch": true,
8
- "noImplicitReturns": true,
9
- "noUnusedParameters": true,
10
- "noUnusedLocals": true,
11
- "noImplicitAny": true,
12
- "declaration": true,
13
- "strictNullChecks": true,
14
- "strictFunctionTypes": true,
15
- "alwaysStrict": true,
16
- "target": "es2017",
17
- "sourceMap": true,
18
- "lib": ["es6"]
19
- },
20
- "filesGlob": [
21
- "./**/*.ts"
22
- ],
23
- "exclude": [
24
- "node_modules",
25
- "dist"
26
- ]
1
+ {
2
+ "compilerOptions": {
3
+ "module": "commonjs",
4
+ "outDir": "dist",
5
+ "incremental": true,
6
+ "pretty": true,
7
+ "noFallthroughCasesInSwitch": true,
8
+ "noImplicitReturns": true,
9
+ "noUnusedParameters": true,
10
+ "noUnusedLocals": true,
11
+ "noImplicitAny": true,
12
+ "declaration": true,
13
+ "strictNullChecks": true,
14
+ "strictFunctionTypes": true,
15
+ "alwaysStrict": true,
16
+ "target": "es2017",
17
+ "sourceMap": true,
18
+ "lib": ["es6"]
19
+ },
20
+ "filesGlob": [
21
+ "./**/*.ts"
22
+ ],
23
+ "exclude": [
24
+ "node_modules",
25
+ "dist"
26
+ ]
27
27
  }
@@ -1,15 +1,15 @@
1
- {
2
- "defaultSeverity": "error",
3
- "extends": [
4
- "tslint:recommended"
5
- ],
6
- "jsRules": {},
7
- "rules": {
8
- "member-ordering": false,
9
- "no-consecutive-blank-lines": false,
10
- "ordered-imports": false,
11
- "ban-types": false,
12
- "max-line-length": false
13
- },
14
- "rulesDirectory": []
1
+ {
2
+ "defaultSeverity": "error",
3
+ "extends": [
4
+ "tslint:recommended"
5
+ ],
6
+ "jsRules": {},
7
+ "rules": {
8
+ "member-ordering": false,
9
+ "no-consecutive-blank-lines": false,
10
+ "ordered-imports": false,
11
+ "ban-types": false,
12
+ "max-line-length": false
13
+ },
14
+ "rulesDirectory": []
15
15
  }
@@ -1,85 +1,85 @@
1
- /*
2
- Portions of this file:
3
-
4
- MIT License
5
-
6
- Copyright (c) 2018 Anand Undavia
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- */
14
-
15
- import { forEachChild, SyntaxKind, createSourceFile } from 'typescript';
16
- import { isFunctionWithBody } from 'tsutils';
17
- import { existsSync, readFileSync } from 'fs';
18
-
19
- const { isIdentifier } = require('typescript');
20
-
21
- const getNodeName = (node) => {
22
- const { name, pos, end } = node;
23
- const key = name !== undefined && isIdentifier(name) ? name.text : JSON.stringify({ pos, end });
24
- return key;
25
- };
26
-
27
- const increasesComplexity = (node) => {
28
- /* eslint-disable indent */
29
- switch (node.kind) {
30
- case SyntaxKind.CaseClause:
31
- return node.statements.length > 0;
32
- case SyntaxKind.CatchClause:
33
- case SyntaxKind.ConditionalExpression:
34
- case SyntaxKind.DoStatement:
35
- case SyntaxKind.ForStatement:
36
- case SyntaxKind.ForInStatement:
37
- case SyntaxKind.ForOfStatement:
38
- case SyntaxKind.IfStatement:
39
- case SyntaxKind.WhileStatement:
40
- return true;
41
-
42
- case SyntaxKind.BinaryExpression:
43
- switch (node.operatorToken.kind) {
44
- case SyntaxKind.BarBarToken:
45
- case SyntaxKind.AmpersandAmpersandToken:
46
- return true;
47
- default:
48
- return false;
49
- }
50
-
51
- default:
52
- return false;
53
- }
54
- /* eslint-enable indent */
55
- };
56
-
57
- const calculateFromSource = (ctx) => {
58
- let complexity = 0;
59
- const output = {};
60
- forEachChild(ctx, function cb(node) {
61
- if (isFunctionWithBody(node)) {
62
- const old = complexity;
63
- complexity = 1;
64
- forEachChild(node, cb);
65
- const name = getNodeName(node)?.toString();
66
- output[name] = complexity;
67
- complexity = old;
68
- } else {
69
- if (increasesComplexity(node)) {
70
- complexity += 1;
71
- }
72
- forEachChild(node, cb);
73
- }
74
- });
75
- return output;
76
- };
77
-
78
- export const calculate = (filePath) => {
79
- if (!existsSync(filePath)) {
80
- throw new Error(`File "${filePath}" does not exists`);
81
- }
82
- const sourceText = readFileSync(filePath).toString();
83
- const source = createSourceFile(filePath, sourceText, isIdentifier.ES2015);
84
- return calculateFromSource(source);
85
- };
1
+ /*
2
+ Portions of this file:
3
+
4
+ MIT License
5
+
6
+ Copyright (c) 2018 Anand Undavia
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ */
14
+
15
+ import { forEachChild, SyntaxKind, createSourceFile } from 'typescript';
16
+ import { isFunctionWithBody } from 'tsutils';
17
+ import { existsSync, readFileSync } from 'fs';
18
+
19
+ const { isIdentifier } = require('typescript');
20
+
21
+ const getNodeName = (node) => {
22
+ const { name, pos, end } = node;
23
+ const key = name !== undefined && isIdentifier(name) ? name.text : JSON.stringify({ pos, end });
24
+ return key;
25
+ };
26
+
27
+ const increasesComplexity = (node) => {
28
+ /* eslint-disable indent */
29
+ switch (node.kind) {
30
+ case SyntaxKind.CaseClause:
31
+ return node.statements.length > 0;
32
+ case SyntaxKind.CatchClause:
33
+ case SyntaxKind.ConditionalExpression:
34
+ case SyntaxKind.DoStatement:
35
+ case SyntaxKind.ForStatement:
36
+ case SyntaxKind.ForInStatement:
37
+ case SyntaxKind.ForOfStatement:
38
+ case SyntaxKind.IfStatement:
39
+ case SyntaxKind.WhileStatement:
40
+ return true;
41
+
42
+ case SyntaxKind.BinaryExpression:
43
+ switch (node.operatorToken.kind) {
44
+ case SyntaxKind.BarBarToken:
45
+ case SyntaxKind.AmpersandAmpersandToken:
46
+ return true;
47
+ default:
48
+ return false;
49
+ }
50
+
51
+ default:
52
+ return false;
53
+ }
54
+ /* eslint-enable indent */
55
+ };
56
+
57
+ const calculateFromSource = (ctx) => {
58
+ let complexity = 0;
59
+ const output = {};
60
+ forEachChild(ctx, function cb(node) {
61
+ if (isFunctionWithBody(node)) {
62
+ const old = complexity;
63
+ complexity = 1;
64
+ forEachChild(node, cb);
65
+ const name = getNodeName(node)?.toString();
66
+ output[name] = complexity;
67
+ complexity = old;
68
+ } else {
69
+ if (increasesComplexity(node)) {
70
+ complexity += 1;
71
+ }
72
+ forEachChild(node, cb);
73
+ }
74
+ });
75
+ return output;
76
+ };
77
+
78
+ export const calculate = (filePath) => {
79
+ if (!existsSync(filePath)) {
80
+ throw new Error(`File "${filePath}" does not exists`);
81
+ }
82
+ const sourceText = readFileSync(filePath).toString();
83
+ const source = createSourceFile(filePath, sourceText, isIdentifier.ES2015);
84
+ return calculateFromSource(source);
85
+ };