ts2famix 2.0.0 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (212) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +29 -60
  3. package/dist/analyze.js +1 -1
  4. package/dist/analyze_functions/process_functions.js +49 -43
  5. package/dist/famix_functions/EntityDictionary.js +309 -182
  6. package/dist/famix_functions/helpers_creation.js +36 -5
  7. package/dist/fqn.js +76 -114
  8. package/dist/lib/famix/famix_JSON_exporter.js +55 -0
  9. package/dist/lib/famix/famix_base_element.js +18 -0
  10. package/dist/lib/famix/famix_repository.js +224 -0
  11. package/dist/lib/famix/{src/index.js → index.js} +1 -1
  12. package/dist/lib/famix/model/famix/access.js +40 -0
  13. package/dist/lib/famix/model/famix/accessor.js +17 -0
  14. package/dist/lib/famix/model/famix/alias.js +33 -0
  15. package/dist/lib/famix/model/famix/arrow_function.js +17 -0
  16. package/dist/lib/famix/model/famix/behavioral_entity.js +79 -0
  17. package/dist/lib/famix/model/famix/class.js +71 -0
  18. package/dist/lib/famix/model/famix/comment.js +39 -0
  19. package/dist/lib/famix/model/famix/concretisation.js +31 -0
  20. package/dist/lib/famix/model/famix/container_entity.js +126 -0
  21. package/dist/lib/famix/model/famix/decorator.js +32 -0
  22. package/dist/lib/famix/model/famix/entity.js +17 -0
  23. package/dist/lib/famix/model/famix/enum.js +31 -0
  24. package/dist/lib/famix/model/famix/enum_value.js +25 -0
  25. package/dist/lib/famix/model/famix/function.js +17 -0
  26. package/dist/lib/famix/model/famix/import_clause.js +41 -0
  27. package/dist/lib/famix/{src/model → model}/famix/index.js +6 -10
  28. package/dist/lib/famix/model/famix/indexed_file_anchor.js +38 -0
  29. package/dist/lib/famix/model/famix/inheritance.js +33 -0
  30. package/dist/lib/famix/model/famix/interface.js +64 -0
  31. package/dist/lib/famix/model/famix/invocation.js +54 -0
  32. package/dist/lib/famix/model/famix/method.js +67 -0
  33. package/dist/lib/famix/model/famix/module.js +60 -0
  34. package/dist/lib/famix/model/famix/named_entity.js +78 -0
  35. package/dist/lib/famix/model/famix/parameter.js +25 -0
  36. package/dist/lib/famix/model/famix/parameter_concretisation.js +44 -0
  37. package/dist/lib/famix/model/famix/parameter_type.js +45 -0
  38. package/dist/lib/famix/model/famix/parametric_arrow_function.js +31 -0
  39. package/dist/lib/famix/model/famix/parametric_class.js +44 -0
  40. package/dist/lib/famix/model/famix/parametric_function.js +31 -0
  41. package/dist/lib/famix/model/famix/parametric_interface.js +44 -0
  42. package/dist/lib/famix/model/famix/parametric_method.js +31 -0
  43. package/dist/lib/famix/model/famix/primitive_type.js +17 -0
  44. package/dist/lib/famix/model/famix/property.js +73 -0
  45. package/dist/lib/famix/model/famix/reference.js +33 -0
  46. package/dist/lib/famix/model/famix/scoping_entity.js +36 -0
  47. package/dist/lib/famix/model/famix/script_entity.js +29 -0
  48. package/dist/lib/famix/model/famix/source_anchor.js +27 -0
  49. package/dist/lib/famix/model/famix/source_language.js +35 -0
  50. package/dist/lib/famix/model/famix/sourced_entity.js +60 -0
  51. package/dist/lib/famix/model/famix/structural_entity.js +39 -0
  52. package/dist/lib/famix/model/famix/type.js +73 -0
  53. package/dist/lib/famix/model/famix/variable.js +24 -0
  54. package/dist/lib/ts-complex/cyclomatic-service.js +2 -2
  55. package/dist/refactorer/refactor-getter-setter.js +142 -0
  56. package/dist/ts2famix-cli-wrapper.js +29 -3
  57. package/dist/ts2famix-cli.js +1 -1
  58. package/doc-uml/famix-typescript-model.puml +390 -341
  59. package/doc-uml/famix-typescript-model.svg +1 -1
  60. package/package.json +26 -9
  61. package/src/analyze.ts +2 -2
  62. package/src/analyze_functions/process_functions.ts +49 -44
  63. package/src/famix_functions/EntityDictionary.ts +345 -216
  64. package/src/famix_functions/helpers_creation.ts +36 -4
  65. package/src/fqn.ts +76 -125
  66. package/src/lib/famix/famix_JSON_exporter.ts +56 -0
  67. package/src/lib/famix/famix_base_element.ts +22 -0
  68. package/src/lib/famix/famix_repository.ts +243 -0
  69. package/src/lib/famix/model/famix/access.ts +50 -0
  70. package/src/lib/famix/model/famix/alias.ts +39 -0
  71. package/src/lib/famix/model/famix/behavioral_entity.ts +97 -0
  72. package/src/lib/famix/model/famix/class.ts +85 -0
  73. package/src/lib/famix/model/famix/comment.ts +47 -0
  74. package/src/lib/famix/model/famix/concretisation.ts +40 -0
  75. package/src/lib/famix/model/famix/container_entity.ts +160 -0
  76. package/src/lib/famix/model/famix/decorator.ts +37 -0
  77. package/src/lib/famix/model/famix/enum.ts +30 -0
  78. package/src/lib/famix/model/famix/enum_value.ts +28 -0
  79. package/src/lib/famix/model/famix/import_clause.ts +51 -0
  80. package/src/lib/famix/{src/model → model}/famix/index.ts +2 -4
  81. package/src/lib/famix/model/famix/indexed_file_anchor.ts +46 -0
  82. package/src/lib/famix/model/famix/inheritance.ts +40 -0
  83. package/src/lib/famix/model/famix/interface.ts +75 -0
  84. package/src/lib/famix/model/famix/invocation.ts +65 -0
  85. package/src/lib/famix/model/famix/method.ts +89 -0
  86. package/src/lib/famix/model/famix/module.ts +71 -0
  87. package/src/lib/famix/model/famix/named_entity.ts +95 -0
  88. package/src/lib/famix/{src/model → model}/famix/parameter.ts +11 -12
  89. package/src/lib/famix/model/famix/parameter_concretisation.ts +51 -0
  90. package/src/lib/famix/model/famix/parameter_type.ts +58 -0
  91. package/src/lib/famix/model/famix/parametric_arrow_function.ts +32 -0
  92. package/src/lib/famix/model/famix/parametric_class.ts +49 -0
  93. package/src/lib/famix/model/famix/parametric_function.ts +32 -0
  94. package/src/lib/famix/model/famix/parametric_interface.ts +49 -0
  95. package/src/lib/famix/model/famix/parametric_method.ts +32 -0
  96. package/src/lib/famix/model/famix/primitive_type.ts +15 -0
  97. package/src/lib/famix/model/famix/property.ts +94 -0
  98. package/src/lib/famix/model/famix/reference.ts +40 -0
  99. package/src/lib/famix/model/famix/scoping_entity.ts +35 -0
  100. package/src/lib/famix/model/famix/script_entity.ts +34 -0
  101. package/src/lib/famix/model/famix/source_anchor.ts +30 -0
  102. package/src/lib/famix/model/famix/source_language.ts +35 -0
  103. package/src/lib/famix/model/famix/sourced_entity.ts +70 -0
  104. package/src/lib/famix/model/famix/structural_entity.ts +43 -0
  105. package/src/lib/famix/model/famix/type.ts +87 -0
  106. package/src/lib/famix/model/famix/variable.ts +27 -0
  107. package/src/lib/famix/package.json +1 -1
  108. package/src/lib/ts-complex/cyclomatic-service.ts +10 -10
  109. package/src/refactorer/refactor-getter-setter.ts +140 -0
  110. package/src/ts2famix-cli-wrapper.ts +6 -2
  111. package/src/ts2famix-cli.ts +1 -1
  112. package/tsconfig.check-tests.json +14 -0
  113. package/tsconfig.json +70 -68
  114. package/dist/famix2puml.js +0 -126
  115. package/dist/lib/famix/src/famix_JSON_exporter.js +0 -55
  116. package/dist/lib/famix/src/famix_base_element.js +0 -18
  117. package/dist/lib/famix/src/famix_repository.js +0 -223
  118. package/dist/lib/famix/src/model/famix/access.js +0 -40
  119. package/dist/lib/famix/src/model/famix/accessor.js +0 -17
  120. package/dist/lib/famix/src/model/famix/alias.js +0 -33
  121. package/dist/lib/famix/src/model/famix/arrowFunction.js +0 -17
  122. package/dist/lib/famix/src/model/famix/behavioral_entity.js +0 -79
  123. package/dist/lib/famix/src/model/famix/class.js +0 -71
  124. package/dist/lib/famix/src/model/famix/comment.js +0 -39
  125. package/dist/lib/famix/src/model/famix/concretisation.js +0 -31
  126. package/dist/lib/famix/src/model/famix/container_entity.js +0 -126
  127. package/dist/lib/famix/src/model/famix/decorator.js +0 -32
  128. package/dist/lib/famix/src/model/famix/entity.js +0 -17
  129. package/dist/lib/famix/src/model/famix/enum.js +0 -31
  130. package/dist/lib/famix/src/model/famix/enum_value.js +0 -25
  131. package/dist/lib/famix/src/model/famix/function.js +0 -17
  132. package/dist/lib/famix/src/model/famix/implicit_variable.js +0 -17
  133. package/dist/lib/famix/src/model/famix/import_clause.js +0 -41
  134. package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +0 -52
  135. package/dist/lib/famix/src/model/famix/inheritance.js +0 -33
  136. package/dist/lib/famix/src/model/famix/interface.js +0 -64
  137. package/dist/lib/famix/src/model/famix/invocation.js +0 -54
  138. package/dist/lib/famix/src/model/famix/method.js +0 -67
  139. package/dist/lib/famix/src/model/famix/module.js +0 -84
  140. package/dist/lib/famix/src/model/famix/named_entity.js +0 -78
  141. package/dist/lib/famix/src/model/famix/parameter.js +0 -25
  142. package/dist/lib/famix/src/model/famix/parameterConcretisation.js +0 -44
  143. package/dist/lib/famix/src/model/famix/parameter_type.js +0 -45
  144. package/dist/lib/famix/src/model/famix/parametric_arrow_function.js +0 -31
  145. package/dist/lib/famix/src/model/famix/parametric_class.js +0 -44
  146. package/dist/lib/famix/src/model/famix/parametric_function.js +0 -31
  147. package/dist/lib/famix/src/model/famix/parametric_interface.js +0 -44
  148. package/dist/lib/famix/src/model/famix/parametric_method.js +0 -31
  149. package/dist/lib/famix/src/model/famix/primitive_type.js +0 -17
  150. package/dist/lib/famix/src/model/famix/property.js +0 -126
  151. package/dist/lib/famix/src/model/famix/reference.js +0 -33
  152. package/dist/lib/famix/src/model/famix/scoping_entity.js +0 -37
  153. package/dist/lib/famix/src/model/famix/script_entity.js +0 -29
  154. package/dist/lib/famix/src/model/famix/source_anchor.js +0 -27
  155. package/dist/lib/famix/src/model/famix/source_language.js +0 -35
  156. package/dist/lib/famix/src/model/famix/sourced_entity.js +0 -60
  157. package/dist/lib/famix/src/model/famix/structural_entity.js +0 -39
  158. package/dist/lib/famix/src/model/famix/text_anchor.js +0 -38
  159. package/dist/lib/famix/src/model/famix/type.js +0 -73
  160. package/dist/lib/famix/src/model/famix/variable.js +0 -24
  161. package/jest.config-old.ts +0 -199
  162. package/src/famix2puml.ts +0 -119
  163. package/src/lib/famix/package-lock.json +0 -301
  164. package/src/lib/famix/readme.md +0 -5
  165. package/src/lib/famix/src/famix_JSON_exporter.ts +0 -56
  166. package/src/lib/famix/src/famix_base_element.ts +0 -22
  167. package/src/lib/famix/src/famix_repository.ts +0 -243
  168. package/src/lib/famix/src/model/famix/access.ts +0 -53
  169. package/src/lib/famix/src/model/famix/alias.ts +0 -41
  170. package/src/lib/famix/src/model/famix/behavioral_entity.ts +0 -100
  171. package/src/lib/famix/src/model/famix/class.ts +0 -86
  172. package/src/lib/famix/src/model/famix/comment.ts +0 -50
  173. package/src/lib/famix/src/model/famix/concretisation.ts +0 -42
  174. package/src/lib/famix/src/model/famix/container_entity.ts +0 -165
  175. package/src/lib/famix/src/model/famix/decorator.ts +0 -39
  176. package/src/lib/famix/src/model/famix/enum.ts +0 -31
  177. package/src/lib/famix/src/model/famix/enum_value.ts +0 -29
  178. package/src/lib/famix/src/model/famix/implicit_variable.ts +0 -15
  179. package/src/lib/famix/src/model/famix/import_clause.ts +0 -54
  180. package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +0 -71
  181. package/src/lib/famix/src/model/famix/inheritance.ts +0 -41
  182. package/src/lib/famix/src/model/famix/interface.ts +0 -75
  183. package/src/lib/famix/src/model/famix/invocation.ts +0 -68
  184. package/src/lib/famix/src/model/famix/method.ts +0 -96
  185. package/src/lib/famix/src/model/famix/module.ts +0 -97
  186. package/src/lib/famix/src/model/famix/named_entity.ts +0 -98
  187. package/src/lib/famix/src/model/famix/parameterConcretisation.ts +0 -54
  188. package/src/lib/famix/src/model/famix/parameter_type.ts +0 -60
  189. package/src/lib/famix/src/model/famix/parametric_arrow_function.ts +0 -32
  190. package/src/lib/famix/src/model/famix/parametric_class.ts +0 -49
  191. package/src/lib/famix/src/model/famix/parametric_function.ts +0 -32
  192. package/src/lib/famix/src/model/famix/parametric_interface.ts +0 -49
  193. package/src/lib/famix/src/model/famix/parametric_method.ts +0 -32
  194. package/src/lib/famix/src/model/famix/primitive_type.ts +0 -15
  195. package/src/lib/famix/src/model/famix/property.ts +0 -152
  196. package/src/lib/famix/src/model/famix/reference.ts +0 -42
  197. package/src/lib/famix/src/model/famix/scoping_entity.ts +0 -36
  198. package/src/lib/famix/src/model/famix/script_entity.ts +0 -36
  199. package/src/lib/famix/src/model/famix/source_anchor.ts +0 -31
  200. package/src/lib/famix/src/model/famix/source_language.ts +0 -36
  201. package/src/lib/famix/src/model/famix/sourced_entity.ts +0 -73
  202. package/src/lib/famix/src/model/famix/structural_entity.ts +0 -44
  203. package/src/lib/famix/src/model/famix/text_anchor.ts +0 -49
  204. package/src/lib/famix/src/model/famix/type.ts +0 -89
  205. package/src/lib/famix/src/model/famix/variable.ts +0 -28
  206. package/src/lib/famix/tsconfig.json +0 -27
  207. package/src/lib/famix/tslint.json +0 -15
  208. /package/src/lib/famix/{src/index.ts → index.ts} +0 -0
  209. /package/src/lib/famix/{src/model → model}/famix/accessor.ts +0 -0
  210. /package/src/lib/famix/{src/model/famix/arrowFunction.ts → model/famix/arrow_function.ts} +0 -0
  211. /package/src/lib/famix/{src/model → model}/famix/entity.ts +0 -0
  212. /package/src/lib/famix/{src/model → model}/famix/function.ts +0 -0
@@ -1,199 +0,0 @@
1
- /*
2
- * For a detailed explanation regarding each configuration property and type check, visit:
3
- * https://jestjs.io/docs/configuration
4
- */
5
-
6
- export default {
7
- // All imported modules in your tests should be mocked automatically
8
- // automock: false,
9
-
10
- // Stop running tests after `n` failures
11
- // bail: 0,
12
-
13
- // The directory where Jest should store its cached dependency information
14
- // cacheDirectory: "",
15
-
16
- // Automatically clear mock calls and instances between every test
17
- // clearMocks: false,
18
-
19
- // Indicates whether the coverage information should be collected while executing the test
20
- collectCoverage: false,
21
-
22
- // An array of glob patterns indicating a set of files for which coverage information should be collected
23
- // collectCoverageFrom: undefined,
24
-
25
- // The directory where Jest should output its coverage files
26
- coverageDirectory: "coverage",
27
-
28
- // An array of regexp pattern strings used to skip coverage collection
29
- // coveragePathIgnorePatterns: [
30
- // "\\\\node_modules\\\\"
31
- // ],
32
-
33
- // Indicates which provider should be used to instrument code for coverage
34
- coverageProvider: "babel",
35
-
36
- // A list of reporter names that Jest uses when writing coverage reports
37
- // coverageReporters: [
38
- // "json",
39
- // "text",
40
- // "lcov",
41
- // "clover"
42
- // ],
43
-
44
- // An object that configures minimum threshold enforcement for coverage results
45
- // coverageThreshold: undefined,
46
-
47
- // A path to a custom dependency extractor
48
- // dependencyExtractor: undefined,
49
-
50
- // Make calling deprecated APIs throw helpful error messages
51
- // errorOnDeprecated: false,
52
-
53
- // Force coverage collection from ignored files using an array of glob patterns
54
- // forceCoverageMatch: [],
55
-
56
- // A path to a module which exports an async function that is triggered once before all test suites
57
- // globalSetup: undefined,
58
-
59
- // A path to a module which exports an async function that is triggered once after all test suites
60
- // globalTeardown: undefined,
61
-
62
- // A set of global variables that need to be available in all test environments
63
- // globals: {},
64
-
65
- // The maximum amount of workers used to run your tests. Can be specified as % or a number. E.g. maxWorkers: 10% will use 10% of your CPU amount + 1 as the maximum worker number. maxWorkers: 2 will use a maximum of 2 workers.
66
- // maxWorkers: 1,
67
-
68
- // An array of directory names to be searched recursively up from the requiring module's location
69
- // moduleDirectories: [
70
- // "node_modules"
71
- // ],
72
-
73
- // An array of file extensions your modules use
74
- // moduleFileExtensions: [
75
- // "js",
76
- // "jsx",
77
- // "ts",
78
- // "tsx",
79
- // "json",
80
- // "node"
81
- // ],
82
-
83
- // A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
84
- // moduleNameMapper: {},
85
-
86
- // An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
87
- // modulePathIgnorePatterns: [],
88
-
89
- // Activates notifications for test results
90
- // notify: false,
91
-
92
- // An enum that specifies notification mode. Requires { notify: true }
93
- // notifyMode: "failure-change",
94
-
95
- // A preset that is used as a base for Jest's configuration
96
- // preset: undefined,
97
-
98
- // Run tests from one or more projects
99
- // projects: undefined,
100
-
101
- // Use this configuration option to add custom reporters to Jest
102
- // reporters: undefined,
103
-
104
- // Automatically reset mock state between every test
105
- // resetMocks: false,
106
-
107
- // Reset the module registry before running each individual test
108
- // resetModules: false,
109
-
110
- // A path to a custom resolver
111
- // resolver: undefined,
112
-
113
- // Automatically restore mock state between every test
114
- // restoreMocks: false,
115
-
116
- // The root directory that Jest should scan for tests and modules within
117
- // rootDir: undefined,
118
-
119
- // A list of paths to directories that Jest should use to search for files in
120
- // roots: [
121
- // "<rootDir>"
122
- // ],
123
-
124
- // Allows you to use a custom runner instead of Jest's default test runner
125
- // runner: "jest-runner",
126
-
127
- // The paths to modules that run some code to configure or set up the testing environment before each test
128
- // setupFiles: [],
129
-
130
- // A list of paths to modules that run some code to configure or set up the testing framework before each test
131
- // setupFilesAfterEnv: [],
132
-
133
- // The number of seconds after which a test is considered as slow and reported as such in the results.
134
- // slowTestThreshold: 5,
135
-
136
- // A list of paths to snapshot serializer modules Jest should use for snapshot testing
137
- // snapshotSerializers: [],
138
-
139
- // The test environment that will be used for testing
140
- testEnvironment: "jest-environment-node",
141
-
142
- // Options that will be passed to the testEnvironment
143
- // testEnvironmentOptions: {},
144
-
145
- // Adds a location field to test results
146
- // testLocationInResults: false,
147
-
148
- // The glob patterns Jest uses to detect test files
149
- // testMatch: [
150
- // "**/__tests__/**/*.[jt]s?(x)",
151
- // "**/?(*.)+(spec|test).[tj]s?(x)"
152
- // ],
153
-
154
- // An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
155
- // testPathIgnorePatterns: [
156
- // "\\\\node_modules\\\\"
157
- // ],
158
-
159
- // The regexp pattern or array of patterns that Jest uses to detect test files
160
- // testRegex: [],
161
-
162
- // This option allows the use of a custom results processor
163
- // testResultsProcessor: undefined,
164
-
165
- // This option allows use of a custom test runner
166
- // testRunner: "jest-circus/runner",
167
-
168
- // This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
169
- // testURL: "http://localhost",
170
-
171
- // Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
172
- // timers: "real",
173
-
174
- // A map from regular expressions to paths to transformers
175
- // transform: undefined,
176
- transform: {
177
- "^.+\\.tsx?$": ["ts-jest", {
178
- isolatedModules: true
179
- }]
180
- },
181
-
182
- // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
183
- // transformIgnorePatterns: [
184
- // "\\\\node_modules\\\\",
185
- // "\\.pnp\\.[^\\\\]+$"
186
- // ],
187
-
188
- // An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
189
- // unmockedModulePathPatterns: undefined,
190
-
191
- // Indicates whether each individual test should be reported during the run
192
- verbose: true,
193
-
194
- // An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
195
- // watchPathIgnorePatterns: [],
196
-
197
- // Whether to use watchman for file crawling
198
- // watchman: true,
199
- };
package/src/famix2puml.ts DELETED
@@ -1,119 +0,0 @@
1
- import * as fs from 'fs';
2
- import yargs from 'yargs';
3
-
4
- const argv = yargs
5
- .example('ts-node src/famix2puml.ts -i JSONModels/projectName.json -o PUMLModels/projectName.puml', 'creates a PlantUML class diagram from a JSON-format model of a typescript project')
6
- .alias('i', 'input')
7
- .nargs('i', 1)
8
- .alias('o', 'output')
9
- .nargs('o', 1)
10
- .demandOption('input').demandOption('output').parseSync();
11
-
12
- const INHERITANCE_LINK_COLOR = 'blue';
13
-
14
- // approximation for code completion
15
- interface FamixTypeScriptElement {
16
- FM3: string
17
- name: string
18
- id?: string
19
- }
20
-
21
- interface Association {
22
- from: string;
23
- to: string;
24
- name: string;
25
- }
26
-
27
- const jsonFileName = argv.input as string;
28
- const pumlFileName = (argv.output as string).substring((argv.output as string).indexOf("/")+1, (argv.output as string).lastIndexOf('.'));
29
- const parsedModel: Array<FamixTypeScriptElement> = JSON.parse(fs.readFileSync(jsonFileName, 'utf-8'));
30
- const classNameMap = new Map<string, string>();
31
- const associations = new Array<Association>();
32
-
33
- // maps all class names to their id
34
- parsedModel.forEach(element => {
35
- // map has id as key and unique (plantuml) class name
36
- classNameMap.set(element.id, uniqueElementName(element));
37
- const nameWithoutPrefix = element.FM3.split('.')[1];
38
- // special case association
39
- if (nameWithoutPrefix.endsWith('Inheritance')) {
40
- const subclass = element['subclass'].ref;
41
- const superclass = element['superclass'].ref;
42
- associations.push({ from: subclass, to: superclass, name: nameWithoutPrefix });
43
- }
44
- });
45
-
46
- // generates plantuml
47
- let plantUMLOutString = `@startuml ${pumlFileName}
48
- skinparam style strictuml
49
- title Object diagram for ${jsonFileName}
50
- `;
51
- parsedModel.forEach(element => {
52
- plantUMLOutString += `${toPlantUML(element)}\n`;
53
- });
54
-
55
- // creates associations
56
- associations.forEach(association => {
57
- // inheritance is a special case, show it in UML even though it doesn't make 100% sense in object diagrams
58
- const isInheritance = association.name.startsWith('Inheritance');
59
- if (isInheritance) {
60
- plantUMLOutString += `${classNameMap.get(association.from)} --|> ${classNameMap.get(association.to)} #line:${INHERITANCE_LINK_COLOR}\n`;
61
- } else {
62
- plantUMLOutString += `${classNameMap.get(association.from)} ..> "${association.name}" ${classNameMap.get(association.to)}\n`;
63
- }
64
- });
65
-
66
- plantUMLOutString += '@enduml';
67
-
68
- // writes to output file
69
- fs.writeFile(argv.output as string, plantUMLOutString, (err) => {
70
- if (err) { throw err; }
71
- });
72
-
73
- function uniqueElementName(element: FamixTypeScriptElement): string {
74
- return `${element.FM3}${element.id}`;
75
- }
76
-
77
- function toPlantUML(element: FamixTypeScriptElement) {
78
- let plantUMLString = '';
79
- const optionalName = element.name || '';
80
- const nameWithoutPrefix = element.FM3.split('.')[1];
81
- plantUMLString += `object "${optionalName}:${nameWithoutPrefix}" as ${uniqueElementName(element)} {\n`;
82
- plantUMLString += `id = ${element.id}\n`;
83
- plantUMLString += propertiesToPlantUML(element);
84
- plantUMLString += '}\n';
85
- return plantUMLString;
86
- }
87
-
88
- function propertiesToPlantUML(element: FamixTypeScriptElement) {
89
- let plantUMLString = '';
90
- for (const property in element) {
91
- const attribute = element[property];
92
- const isOneToManyReference = typeof attribute !== 'string' && attribute.length; // array but not a string
93
-
94
- switch (property) {
95
- // ignores these properties
96
- case 'subclass':
97
- case 'superclass':
98
- case 'FM3':
99
- case 'id':
100
- case 'name':
101
- break;
102
-
103
- default:
104
- if (isOneToManyReference) {
105
- attribute.forEach((composite, index) => {
106
- associations.push({ from: element.id, to: composite.ref, name: `${property}[${index}]` });
107
- });
108
- } else if (typeof attribute === 'object') {
109
- associations.push({ from: element.id, to: attribute.ref, name: property });
110
- } else { // typeof string, boolean, number, etc
111
- // treats it as a simple attribute
112
- plantUMLString += `${property} = ${element[property]}\n`;
113
- }
114
-
115
- break;
116
- }
117
- }
118
- return plantUMLString;
119
- }
@@ -1,301 +0,0 @@
1
- {
2
- "name": "famix",
3
- "version": "1.0.0",
4
- "lockfileVersion": 1,
5
- "requires": true,
6
- "dependencies": {
7
- "@babel/code-frame": {
8
- "version": "7.5.5",
9
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
10
- "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
11
- "dev": true,
12
- "requires": {
13
- "@babel/highlight": "^7.0.0"
14
- }
15
- },
16
- "@babel/highlight": {
17
- "version": "7.5.0",
18
- "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.5.0.tgz",
19
- "integrity": "sha512-7dV4eu9gBxoM0dAnj/BCFDW9LFU0zvTrkq0ugM7pnHEgguOEeOz1so2ZghEdzviYzQEED0r4EAgpsBChKy1TRQ==",
20
- "dev": true,
21
- "requires": {
22
- "chalk": "^2.0.0",
23
- "esutils": "^2.0.2",
24
- "js-tokens": "^4.0.0"
25
- }
26
- },
27
- "ansi-styles": {
28
- "version": "3.2.1",
29
- "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz",
30
- "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==",
31
- "dev": true,
32
- "requires": {
33
- "color-convert": "^1.9.0"
34
- }
35
- },
36
- "argparse": {
37
- "version": "1.0.10",
38
- "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
39
- "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
40
- "dev": true,
41
- "requires": {
42
- "sprintf-js": "~1.0.2"
43
- }
44
- },
45
- "balanced-match": {
46
- "version": "1.0.0",
47
- "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
48
- "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=",
49
- "dev": true
50
- },
51
- "brace-expansion": {
52
- "version": "1.1.11",
53
- "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
54
- "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
55
- "dev": true,
56
- "requires": {
57
- "balanced-match": "^1.0.0",
58
- "concat-map": "0.0.1"
59
- }
60
- },
61
- "builtin-modules": {
62
- "version": "1.1.1",
63
- "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz",
64
- "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=",
65
- "dev": true
66
- },
67
- "chalk": {
68
- "version": "2.4.2",
69
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
70
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
71
- "dev": true,
72
- "requires": {
73
- "ansi-styles": "^3.2.1",
74
- "escape-string-regexp": "^1.0.5",
75
- "supports-color": "^5.3.0"
76
- }
77
- },
78
- "color-convert": {
79
- "version": "1.9.3",
80
- "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz",
81
- "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==",
82
- "dev": true,
83
- "requires": {
84
- "color-name": "1.1.3"
85
- }
86
- },
87
- "color-name": {
88
- "version": "1.1.3",
89
- "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
90
- "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
91
- "dev": true
92
- },
93
- "commander": {
94
- "version": "2.20.1",
95
- "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.1.tgz",
96
- "integrity": "sha512-cCuLsMhJeWQ/ZpsFTbE765kvVfoeSddc4nU3up4fV+fDBcfUXnbITJ+JzhkdjzOqhURjZgujxaioam4RM9yGUg==",
97
- "dev": true
98
- },
99
- "concat-map": {
100
- "version": "0.0.1",
101
- "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
102
- "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=",
103
- "dev": true
104
- },
105
- "diff": {
106
- "version": "4.0.1",
107
- "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.1.tgz",
108
- "integrity": "sha512-s2+XdvhPCOF01LRQBC8hf4vhbVmI2CGS5aZnxLJlT5FtdhPCDFq80q++zK2KlrVorVDdL5BOGZ/VfLrVtYNF+Q==",
109
- "dev": true
110
- },
111
- "escape-string-regexp": {
112
- "version": "1.0.5",
113
- "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
114
- "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=",
115
- "dev": true
116
- },
117
- "esprima": {
118
- "version": "4.0.1",
119
- "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
120
- "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
121
- "dev": true
122
- },
123
- "esutils": {
124
- "version": "2.0.3",
125
- "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
126
- "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
127
- "dev": true
128
- },
129
- "fs.realpath": {
130
- "version": "1.0.0",
131
- "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
132
- "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=",
133
- "dev": true
134
- },
135
- "glob": {
136
- "version": "7.1.4",
137
- "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
138
- "integrity": "sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A==",
139
- "dev": true,
140
- "requires": {
141
- "fs.realpath": "^1.0.0",
142
- "inflight": "^1.0.4",
143
- "inherits": "2",
144
- "minimatch": "^3.0.4",
145
- "once": "^1.3.0",
146
- "path-is-absolute": "^1.0.0"
147
- }
148
- },
149
- "has-flag": {
150
- "version": "3.0.0",
151
- "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
152
- "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=",
153
- "dev": true
154
- },
155
- "inflight": {
156
- "version": "1.0.6",
157
- "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
158
- "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=",
159
- "dev": true,
160
- "requires": {
161
- "once": "^1.3.0",
162
- "wrappy": "1"
163
- }
164
- },
165
- "inherits": {
166
- "version": "2.0.4",
167
- "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
168
- "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
169
- "dev": true
170
- },
171
- "js-tokens": {
172
- "version": "4.0.0",
173
- "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
174
- "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==",
175
- "dev": true
176
- },
177
- "js-yaml": {
178
- "version": "3.13.1",
179
- "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.13.1.tgz",
180
- "integrity": "sha512-YfbcO7jXDdyj0DGxYVSlSeQNHbD7XPWvrVWeVUujrQEoZzWJIRrCPoyk6kL6IAjAG2IolMK4T0hNUe0HOUs5Jw==",
181
- "dev": true,
182
- "requires": {
183
- "argparse": "^1.0.7",
184
- "esprima": "^4.0.0"
185
- }
186
- },
187
- "minimatch": {
188
- "version": "3.0.4",
189
- "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz",
190
- "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==",
191
- "dev": true,
192
- "requires": {
193
- "brace-expansion": "^1.1.7"
194
- }
195
- },
196
- "minimist": {
197
- "version": "0.0.8",
198
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
199
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
200
- "dev": true
201
- },
202
- "once": {
203
- "version": "1.4.0",
204
- "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
205
- "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=",
206
- "dev": true,
207
- "requires": {
208
- "wrappy": "1"
209
- }
210
- },
211
- "path-is-absolute": {
212
- "version": "1.0.1",
213
- "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
214
- "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=",
215
- "dev": true
216
- },
217
- "path-parse": {
218
- "version": "1.0.6",
219
- "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz",
220
- "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==",
221
- "dev": true
222
- },
223
- "resolve": {
224
- "version": "1.12.0",
225
- "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz",
226
- "integrity": "sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==",
227
- "dev": true,
228
- "requires": {
229
- "path-parse": "^1.0.6"
230
- }
231
- },
232
- "semver": {
233
- "version": "5.7.1",
234
- "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz",
235
- "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==",
236
- "dev": true
237
- },
238
- "sprintf-js": {
239
- "version": "1.0.3",
240
- "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
241
- "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=",
242
- "dev": true
243
- },
244
- "supports-color": {
245
- "version": "5.5.0",
246
- "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
247
- "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
248
- "dev": true,
249
- "requires": {
250
- "has-flag": "^3.0.0"
251
- }
252
- },
253
- "tslib": {
254
- "version": "1.10.0",
255
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",
256
- "integrity": "sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==",
257
- "dev": true
258
- },
259
- "tslint": {
260
- "version": "5.20.0",
261
- "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.20.0.tgz",
262
- "integrity": "sha512-2vqIvkMHbnx8acMogAERQ/IuINOq6DFqgF8/VDvhEkBqQh/x6SP0Y+OHnKth9/ZcHQSroOZwUQSN18v8KKF0/g==",
263
- "dev": true,
264
- "requires": {
265
- "@babel/code-frame": "^7.0.0",
266
- "builtin-modules": "^1.1.1",
267
- "chalk": "^2.3.0",
268
- "commander": "^2.12.1",
269
- "diff": "^4.0.1",
270
- "glob": "^7.1.1",
271
- "js-yaml": "^3.13.1",
272
- "minimatch": "^3.0.4",
273
- "resolve": "^1.3.2",
274
- "semver": "^5.3.0",
275
- "tslib": "^1.8.0",
276
- "tsutils": "^2.29.0"
277
- }
278
- },
279
- "tsutils": {
280
- "version": "2.29.0",
281
- "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz",
282
- "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==",
283
- "dev": true,
284
- "requires": {
285
- "tslib": "^1.8.1"
286
- }
287
- },
288
- "typescript": {
289
- "version": "3.6.3",
290
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",
291
- "integrity": "sha512-N7bceJL1CtRQ2RiG0AQME13ksR7DiuQh/QehubYcghzv20tnh+MQnQIuJddTmsbqYj+dztchykemz0zFzlvdQw==",
292
- "dev": true
293
- },
294
- "wrappy": {
295
- "version": "1.0.2",
296
- "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
297
- "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=",
298
- "dev": true
299
- }
300
- }
301
- }
@@ -1,5 +0,0 @@
1
- # FAMIX model in typescript
2
-
3
- FAMIX is a family of metamodels to represent source code.
4
-
5
- Learn more about the MSE file format and the FAMIX model https://www.researchgate.net/publication/265428652
@@ -1,56 +0,0 @@
1
- import { FamixBaseElement } from "./famix_base_element";
2
-
3
- /**
4
- * This class is used to export Famix elements to JSON
5
- */
6
- export class FamixJSONExporter {
7
-
8
- private element: FamixBaseElement; // A Famix element to export
9
- private bufferArray: any = {}; // A buffer to store the properties of the Famix element
10
- private FamixPrefix = "FamixTypeScript"; // Prefix of the Famix element
11
-
12
- /**
13
- * Constructor of the FamixJSONExporter class
14
- * @param packageClass Name of a Famix class
15
- * @param element A Famix element to export, this element is an instance of the class named "packageClass"
16
- */
17
- constructor(packageClass: string, element: FamixBaseElement) {
18
- this.element = element;
19
- this.bufferArray["FM3"] = this.FamixPrefix + "." + packageClass;
20
- this.bufferArray["id"] = this.element.id;
21
- }
22
-
23
- /**
24
- * Adds a property to the Famix element
25
- * @param name Name of the property
26
- * @param prop A property
27
- */
28
- public addProperty(name: string, prop: unknown): void {
29
- if (prop instanceof Set) {
30
- const valueArray: Array<unknown> = [];
31
- for (const value of Array.from(prop.values())) {
32
- if (value instanceof FamixBaseElement) {
33
- valueArray.push({ "ref": value.id });
34
- }
35
- else {
36
- valueArray.push(value);
37
- }
38
- }
39
- this.bufferArray[name] = valueArray;
40
- }
41
- else if (prop instanceof FamixBaseElement) {
42
- this.bufferArray[name] = { "ref": prop.id };
43
- }
44
- else if (prop !== undefined && !(prop instanceof Set)) {
45
- this.bufferArray[name] = prop;
46
- }
47
- }
48
-
49
- /**
50
- * Gets a JSON representation of the Famix element
51
- * @returns A JSON representation of the Famix element
52
- */
53
- public getJSON(): string {
54
- return JSON.stringify(this.bufferArray);
55
- }
56
- }