ts2famix 1.3.1 → 1.4.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 (40) hide show
  1. package/dist/analyze.js +37 -27
  2. package/dist/analyze_functions/process_functions.js +723 -0
  3. package/dist/famix_functions/EntityDictionary.js +798 -0
  4. package/dist/famix_functions/helpers_creation.js +97 -0
  5. package/dist/fqn.js +106 -95
  6. package/dist/lib/famix/src/famix_base_element.js +8 -4
  7. package/dist/lib/famix/src/famix_repository.js +32 -15
  8. package/dist/lib/ts-complex/cyclomatic-service.js +2 -3
  9. package/doc-uml/metamodel-full.svg +1 -0
  10. package/doc-uml/metamodel.svg +1 -0
  11. package/package.json +1 -1
  12. package/plantuml.jar +0 -0
  13. package/src/analyze.ts +46 -29
  14. package/src/analyze_functions/process_functions.ts +838 -0
  15. package/src/famix_functions/EntityDictionary.ts +915 -0
  16. package/src/famix_functions/helpers_creation.ts +77 -0
  17. package/src/fqn.ts +101 -92
  18. package/src/lib/famix/src/famix_base_element.ts +9 -5
  19. package/src/lib/famix/src/famix_repository.ts +45 -23
  20. package/src/lib/ts-complex/cyclomatic-service.ts +2 -4
  21. package/src/ts2famix-cli.ts +1 -0
  22. package/dist/analyze_functions/processAccesses.js +0 -56
  23. package/dist/analyze_functions/processFiles.js +0 -554
  24. package/dist/analyze_functions/processImportClauses.js +0 -88
  25. package/dist/analyze_functions/processInheritances.js +0 -74
  26. package/dist/analyze_functions/processInvocations.js +0 -50
  27. package/dist/famix_functions/famix_functions.js +0 -523
  28. package/dist/famix_functions/famix_functions_associations.js +0 -238
  29. package/dist/famix_functions/famix_functions_index.js +0 -135
  30. package/dist/famix_functions/famix_functions_types.js +0 -115
  31. package/docs/.gitkeep +0 -0
  32. package/src/analyze_functions/processAccesses.ts +0 -58
  33. package/src/analyze_functions/processFiles.ts +0 -667
  34. package/src/analyze_functions/processImportClauses.ts +0 -95
  35. package/src/analyze_functions/processInheritances.ts +0 -85
  36. package/src/analyze_functions/processInvocations.ts +0 -52
  37. package/src/famix_functions/famix_functions.ts +0 -562
  38. package/src/famix_functions/famix_functions_associations.ts +0 -242
  39. package/src/famix_functions/famix_functions_index.ts +0 -120
  40. package/src/famix_functions/famix_functions_types.ts +0 -106
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.findTypeAncestor = exports.findAncestor = exports.computeSignature = exports.getSubTypeName = exports.indexOfSplitArray = void 0;
27
+ const Famix = __importStar(require("../lib/famix/src/model/famix"));
28
+ const analyze_1 = require("../analyze");
29
+ const ts_morph_1 = require("ts-morph");
30
+ /**
31
+ * This function works like indexOf, but it works with arrays of grapheme clusters.
32
+ * @param targetArray
33
+ */
34
+ function indexOfSplitArray(params) {
35
+ const { searchArray, targetArray, start = 0 } = params;
36
+ for (let i = start; i <= searchArray.length - targetArray.length; i++) {
37
+ let found = true;
38
+ for (let j = 0; j < targetArray.length; j++) {
39
+ if (searchArray[i + j] !== targetArray[j]) {
40
+ found = false;
41
+ break;
42
+ }
43
+ }
44
+ if (found) {
45
+ return i; // Return the index where the target array was found
46
+ }
47
+ }
48
+ return -1; // Return -1 if the target array was not found in the search array
49
+ }
50
+ exports.indexOfSplitArray = indexOfSplitArray;
51
+ function getSubTypeName(fmxNamedEntity) {
52
+ const name = fmxNamedEntity instanceof Famix.Class ? 'Class' :
53
+ fmxNamedEntity instanceof Famix.Interface ? 'Interface' :
54
+ fmxNamedEntity instanceof Famix.Function ? 'Function' :
55
+ fmxNamedEntity instanceof Famix.Enum ? 'Enum' :
56
+ fmxNamedEntity instanceof Famix.EnumValue ? 'EnumValue' :
57
+ fmxNamedEntity instanceof Famix.Alias ? 'Alias' :
58
+ fmxNamedEntity instanceof Famix.Variable ? 'Variable' :
59
+ fmxNamedEntity instanceof Famix.Type ? 'Type' :
60
+ fmxNamedEntity instanceof Famix.Method ? 'Method' :
61
+ fmxNamedEntity instanceof Famix.Decorator ? 'Decorator' :
62
+ fmxNamedEntity instanceof Famix.Accessor ? 'Accessor' :
63
+ fmxNamedEntity instanceof Famix.Parameter ? 'Parameter' :
64
+ fmxNamedEntity instanceof Famix.Property ? 'Property' :
65
+ 'NamedEntity';
66
+ analyze_1.logger.debug(`${fmxNamedEntity.getName()} is of type ${name}`);
67
+ return name;
68
+ }
69
+ exports.getSubTypeName = getSubTypeName;
70
+ /**
71
+ * Gets the signature of a method or a function
72
+ * @param text A method or a function source code
73
+ * @returns The signature of the method or the function
74
+ */
75
+ function computeSignature(text) {
76
+ const endSignatureText = text.indexOf("{");
77
+ return text.substring(0, endSignatureText).trim();
78
+ }
79
+ exports.computeSignature = computeSignature;
80
+ /**
81
+ * Finds the ancestor of a node
82
+ * @param node A node
83
+ * @returns The ancestor of the node
84
+ */
85
+ function findAncestor(node) {
86
+ return node.getAncestors().find(a => a.getKind() === ts_morph_1.SyntaxKind.MethodDeclaration || a.getKind() === ts_morph_1.SyntaxKind.Constructor || a.getKind() === ts_morph_1.SyntaxKind.FunctionDeclaration || a.getKind() === ts_morph_1.SyntaxKind.FunctionExpression || a.getKind() === ts_morph_1.SyntaxKind.ModuleDeclaration || a.getKind() === ts_morph_1.SyntaxKind.SourceFile || a.getKindName() === "GetAccessor" || a.getKindName() === "SetAccessor" || a.getKind() === ts_morph_1.SyntaxKind.ClassDeclaration);
87
+ }
88
+ exports.findAncestor = findAncestor;
89
+ /**
90
+ * Finds the ancestor of a ts-morph element
91
+ * @param element A ts-morph element
92
+ * @returns The ancestor of the ts-morph element
93
+ */
94
+ function findTypeAncestor(element) {
95
+ return element.getAncestors().find(a => a.getKind() === ts_morph_1.SyntaxKind.MethodDeclaration || a.getKind() === ts_morph_1.SyntaxKind.Constructor || a.getKind() === ts_morph_1.SyntaxKind.MethodSignature || a.getKind() === ts_morph_1.SyntaxKind.FunctionDeclaration || a.getKind() === ts_morph_1.SyntaxKind.FunctionExpression || a.getKind() === ts_morph_1.SyntaxKind.ModuleDeclaration || a.getKind() === ts_morph_1.SyntaxKind.SourceFile || a.getKindName() === "GetAccessor" || a.getKindName() === "SetAccessor" || a.getKind() === ts_morph_1.SyntaxKind.ClassDeclaration || a.getKind() === ts_morph_1.SyntaxKind.InterfaceDeclaration);
96
+ }
97
+ exports.findTypeAncestor = findTypeAncestor;
package/dist/fqn.js CHANGED
@@ -22,105 +22,116 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
25
28
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.FQNFunctions = void 0;
29
+ exports.getNameOfNode = exports.getFQN = void 0;
27
30
  const ts = __importStar(require("ts-morph"));
31
+ const analyze_1 = require("./analyze");
32
+ const path_1 = __importDefault(require("path"));
28
33
  /**
29
- * This class is used to get the fully qualified name of a node
34
+ * Gets the fully qualified name of a node, if it has one
35
+ * @param node A node
36
+ * @returns The fully qualified name of the node, or undefined if it doesn't have one
30
37
  */
31
- class FQNFunctions {
32
- /**
33
- * Gets the fully qualified name of a node, if it has one
34
- * @param node A node
35
- * @returns The fully qualified name of the node, or undefined if it doesn't have one
36
- */
37
- getFQN(node) {
38
- if (node instanceof ts.SourceFile) {
39
- return `"${node.getFilePath()}"`;
40
- }
41
- const symbol = node.getSymbol();
42
- if (!symbol) {
43
- return undefined;
44
- }
45
- const declarations = symbol.getDeclarations();
46
- if (!declarations) {
47
- return undefined;
48
- }
49
- const sourceFile = declarations[0].getSourceFile();
50
- if (!sourceFile) {
51
- return undefined;
52
- }
53
- const sourceFilePath = sourceFile.getFilePath();
54
- const sourceFileDirectory = sourceFilePath.substring(0, sourceFilePath.lastIndexOf("/"));
55
- const qualifiedNameParts = [];
56
- const nodeName = this.getNameOfNode(node);
57
- if (nodeName)
58
- qualifiedNameParts.push(nodeName);
59
- const ancestors = node.getAncestors();
60
- ancestors.forEach(a => {
61
- const partName = this.getNameOfNode(a);
62
- if (partName)
63
- qualifiedNameParts.push(partName);
64
- });
65
- if (qualifiedNameParts.length > 0) {
66
- return `"${sourceFileDirectory}/${qualifiedNameParts.pop()}".${qualifiedNameParts.reverse().join(".")}`;
67
- }
68
- else {
69
- return undefined;
70
- }
38
+ function getFQN(node) {
39
+ const absolutePathProject = analyze_1.entityDictionary.famixRep.getAbsolutePath();
40
+ if (node instanceof ts.SourceFile) {
41
+ return analyze_1.entityDictionary.convertToRelativePath(path_1.default.normalize(node.getFilePath()), absolutePathProject).replace(/\\/sg, "/");
42
+ }
43
+ const symbol = node.getSymbol();
44
+ if (!symbol) {
45
+ return undefined;
46
+ }
47
+ const declarations = symbol.getDeclarations();
48
+ if (!declarations) {
49
+ return undefined;
50
+ }
51
+ const sourceFile = declarations[0].getSourceFile();
52
+ if (!sourceFile) {
53
+ return undefined;
54
+ }
55
+ const absolutePath = path_1.default.normalize(sourceFile.getFilePath());
56
+ const positionNodeModules = absolutePath.indexOf('node_modules');
57
+ let pathInProject = "";
58
+ if (positionNodeModules !== -1) {
59
+ const pathFromNodeModules = absolutePath.substring(positionNodeModules);
60
+ pathInProject = pathFromNodeModules;
61
+ }
62
+ else {
63
+ pathInProject = analyze_1.entityDictionary.convertToRelativePath(absolutePath, absolutePathProject).replace(/\\/g, "/");
71
64
  }
72
- /**
73
- * Gets the name of a node, if it has one
74
- * @param a A node
75
- * @returns The name of the node, or an empty string if it doesn't have one
76
- */
77
- getNameOfNode(a) {
78
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
79
- switch (a.getKind()) {
80
- case ts.SyntaxKind.SourceFile:
81
- return (_a = a.asKind(ts.SyntaxKind.SourceFile)) === null || _a === void 0 ? void 0 : _a.getBaseName();
82
- case ts.SyntaxKind.ModuleDeclaration:
83
- return (_b = a.asKind(ts.SyntaxKind.ModuleDeclaration)) === null || _b === void 0 ? void 0 : _b.getName();
84
- case ts.SyntaxKind.ClassDeclaration:
85
- return (_c = a.asKind(ts.SyntaxKind.ClassDeclaration)) === null || _c === void 0 ? void 0 : _c.getName();
86
- case ts.SyntaxKind.InterfaceDeclaration:
87
- return (_d = a.asKind(ts.SyntaxKind.InterfaceDeclaration)) === null || _d === void 0 ? void 0 : _d.getName();
88
- case ts.SyntaxKind.PropertyDeclaration:
89
- return (_e = a.asKind(ts.SyntaxKind.PropertyDeclaration)) === null || _e === void 0 ? void 0 : _e.getName();
90
- case ts.SyntaxKind.PropertySignature:
91
- return (_f = a.asKind(ts.SyntaxKind.PropertySignature)) === null || _f === void 0 ? void 0 : _f.getName();
92
- case ts.SyntaxKind.MethodDeclaration:
93
- return (_g = a.asKind(ts.SyntaxKind.MethodDeclaration)) === null || _g === void 0 ? void 0 : _g.getName();
94
- case ts.SyntaxKind.MethodSignature:
95
- return (_h = a.asKind(ts.SyntaxKind.MethodSignature)) === null || _h === void 0 ? void 0 : _h.getName();
96
- case ts.SyntaxKind.GetAccessor:
97
- return (_j = a.asKind(ts.SyntaxKind.GetAccessor)) === null || _j === void 0 ? void 0 : _j.getName();
98
- case ts.SyntaxKind.SetAccessor:
99
- return (_k = a.asKind(ts.SyntaxKind.SetAccessor)) === null || _k === void 0 ? void 0 : _k.getName();
100
- case ts.SyntaxKind.FunctionDeclaration:
101
- return (_l = a.asKind(ts.SyntaxKind.FunctionDeclaration)) === null || _l === void 0 ? void 0 : _l.getName();
102
- case ts.SyntaxKind.FunctionExpression:
103
- return ((_m = a.asKind(ts.SyntaxKind.FunctionExpression)) === null || _m === void 0 ? void 0 : _m.getName()) ? (_o = a.asKind(ts.SyntaxKind.FunctionExpression)) === null || _o === void 0 ? void 0 : _o.getName() : "anonymous";
104
- case ts.SyntaxKind.Parameter:
105
- return (_p = a.asKind(ts.SyntaxKind.Parameter)) === null || _p === void 0 ? void 0 : _p.getName();
106
- case ts.SyntaxKind.VariableDeclaration:
107
- return (_q = a.asKind(ts.SyntaxKind.VariableDeclaration)) === null || _q === void 0 ? void 0 : _q.getName();
108
- case ts.SyntaxKind.Decorator:
109
- return "@" + ((_r = a.asKind(ts.SyntaxKind.Decorator)) === null || _r === void 0 ? void 0 : _r.getName());
110
- case ts.SyntaxKind.TypeParameter:
111
- return (_s = a.asKind(ts.SyntaxKind.TypeParameter)) === null || _s === void 0 ? void 0 : _s.getName();
112
- case ts.SyntaxKind.EnumDeclaration:
113
- return (_t = a.asKind(ts.SyntaxKind.EnumDeclaration)) === null || _t === void 0 ? void 0 : _t.getName();
114
- case ts.SyntaxKind.EnumMember:
115
- return (_u = a.asKind(ts.SyntaxKind.EnumMember)) === null || _u === void 0 ? void 0 : _u.getName();
116
- case ts.SyntaxKind.TypeAliasDeclaration:
117
- return (_v = a.asKind(ts.SyntaxKind.TypeAliasDeclaration)) === null || _v === void 0 ? void 0 : _v.getName();
118
- case ts.SyntaxKind.Constructor:
119
- return "constructor";
120
- default:
121
- // ancestor hasn't got a useful name
122
- return "";
123
- }
65
+ const qualifiedNameParts = [];
66
+ const nodeName = this.getNameOfNode(node);
67
+ if (nodeName)
68
+ qualifiedNameParts.push(nodeName);
69
+ const ancestors = node.getAncestors();
70
+ ancestors.forEach(a => {
71
+ const partName = this.getNameOfNode(a);
72
+ if (partName)
73
+ qualifiedNameParts.push(partName);
74
+ });
75
+ qualifiedNameParts.pop();
76
+ if (qualifiedNameParts.length > 0) {
77
+ return `{${pathInProject}}.${qualifiedNameParts.reverse().join(".")}`;
78
+ }
79
+ else {
80
+ return undefined;
81
+ }
82
+ }
83
+ exports.getFQN = getFQN;
84
+ /**
85
+ * Gets the name of a node, if it has one
86
+ * @param a A node
87
+ * @returns The name of the node, or an empty string if it doesn't have one
88
+ */
89
+ function getNameOfNode(a) {
90
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
91
+ switch (a.getKind()) {
92
+ case ts.SyntaxKind.SourceFile:
93
+ return (_a = a.asKind(ts.SyntaxKind.SourceFile)) === null || _a === void 0 ? void 0 : _a.getBaseName();
94
+ case ts.SyntaxKind.ModuleDeclaration:
95
+ return (_b = a.asKind(ts.SyntaxKind.ModuleDeclaration)) === null || _b === void 0 ? void 0 : _b.getName();
96
+ case ts.SyntaxKind.ClassDeclaration:
97
+ return (_c = a.asKind(ts.SyntaxKind.ClassDeclaration)) === null || _c === void 0 ? void 0 : _c.getName();
98
+ case ts.SyntaxKind.InterfaceDeclaration:
99
+ return (_d = a.asKind(ts.SyntaxKind.InterfaceDeclaration)) === null || _d === void 0 ? void 0 : _d.getName();
100
+ case ts.SyntaxKind.PropertyDeclaration:
101
+ return (_e = a.asKind(ts.SyntaxKind.PropertyDeclaration)) === null || _e === void 0 ? void 0 : _e.getName();
102
+ case ts.SyntaxKind.PropertySignature:
103
+ return (_f = a.asKind(ts.SyntaxKind.PropertySignature)) === null || _f === void 0 ? void 0 : _f.getName();
104
+ case ts.SyntaxKind.MethodDeclaration:
105
+ return (_g = a.asKind(ts.SyntaxKind.MethodDeclaration)) === null || _g === void 0 ? void 0 : _g.getName();
106
+ case ts.SyntaxKind.MethodSignature:
107
+ return (_h = a.asKind(ts.SyntaxKind.MethodSignature)) === null || _h === void 0 ? void 0 : _h.getName();
108
+ case ts.SyntaxKind.GetAccessor:
109
+ return (_j = a.asKind(ts.SyntaxKind.GetAccessor)) === null || _j === void 0 ? void 0 : _j.getName();
110
+ case ts.SyntaxKind.SetAccessor:
111
+ return (_k = a.asKind(ts.SyntaxKind.SetAccessor)) === null || _k === void 0 ? void 0 : _k.getName();
112
+ case ts.SyntaxKind.FunctionDeclaration:
113
+ return (_l = a.asKind(ts.SyntaxKind.FunctionDeclaration)) === null || _l === void 0 ? void 0 : _l.getName();
114
+ case ts.SyntaxKind.FunctionExpression:
115
+ return ((_m = a.asKind(ts.SyntaxKind.FunctionExpression)) === null || _m === void 0 ? void 0 : _m.getName()) ? (_o = a.asKind(ts.SyntaxKind.FunctionExpression)) === null || _o === void 0 ? void 0 : _o.getName() : "anonymous";
116
+ case ts.SyntaxKind.Parameter:
117
+ return (_p = a.asKind(ts.SyntaxKind.Parameter)) === null || _p === void 0 ? void 0 : _p.getName();
118
+ case ts.SyntaxKind.VariableDeclaration:
119
+ return (_q = a.asKind(ts.SyntaxKind.VariableDeclaration)) === null || _q === void 0 ? void 0 : _q.getName();
120
+ case ts.SyntaxKind.Decorator:
121
+ return "@" + ((_r = a.asKind(ts.SyntaxKind.Decorator)) === null || _r === void 0 ? void 0 : _r.getName());
122
+ case ts.SyntaxKind.TypeParameter:
123
+ return (_s = a.asKind(ts.SyntaxKind.TypeParameter)) === null || _s === void 0 ? void 0 : _s.getName();
124
+ case ts.SyntaxKind.EnumDeclaration:
125
+ return (_t = a.asKind(ts.SyntaxKind.EnumDeclaration)) === null || _t === void 0 ? void 0 : _t.getName();
126
+ case ts.SyntaxKind.EnumMember:
127
+ return (_u = a.asKind(ts.SyntaxKind.EnumMember)) === null || _u === void 0 ? void 0 : _u.getName();
128
+ case ts.SyntaxKind.TypeAliasDeclaration:
129
+ return (_v = a.asKind(ts.SyntaxKind.TypeAliasDeclaration)) === null || _v === void 0 ? void 0 : _v.getName();
130
+ case ts.SyntaxKind.Constructor:
131
+ return "constructor";
132
+ default:
133
+ // ancestor hasn't got a useful name
134
+ return "";
124
135
  }
125
136
  }
126
- exports.FQNFunctions = FQNFunctions;
137
+ exports.getNameOfNode = getNameOfNode;
@@ -1,13 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FamixBaseElement = void 0;
4
+ const analyze_1 = require("../../../analyze");
5
+ // import { FamixRepository } from "./famix_repository";
4
6
  class FamixBaseElement {
5
- constructor(repo) {
6
- repo.addElement(this);
7
+ // constructor(repo: FamixRepository) {
8
+ // repo.addElement(this);
9
+ // }
10
+ constructor() {
7
11
  }
8
- // @ts-ignore
9
- // tslint:disable-next-line:no-empty
12
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
13
  addPropertiesToExporter(exporter) {
14
+ analyze_1.logger.debug("addPropertiesToExporter not implemented for " + this.constructor.name + `(${exporter})`);
11
15
  }
12
16
  }
13
17
  exports.FamixBaseElement = FamixBaseElement;
@@ -16,7 +16,21 @@ class FamixRepository {
16
16
  this.famixFunctions = new Set(); // All Famix functions
17
17
  this.famixFiles = new Set(); // All Famix files
18
18
  this.idCounter = 1; // Id counter
19
- this.addElement(new famix_1.SourceLanguage(this)); // add the source language entity (TypeScript)
19
+ this.absolutePath = "";
20
+ this.fmxElementObjectMap = new Map();
21
+ this.addElement(new famix_1.SourceLanguage()); // add the source language entity (TypeScript)
22
+ }
23
+ setFmxElementObjectMap(fmxElementObjectMap) {
24
+ this.fmxElementObjectMap = fmxElementObjectMap;
25
+ }
26
+ getFmxElementObjectMap() {
27
+ return this.fmxElementObjectMap;
28
+ }
29
+ getAbsolutePath() {
30
+ return this.absolutePath;
31
+ }
32
+ setAbsolutePath(path) {
33
+ this.absolutePath = path;
20
34
  }
21
35
  /**
22
36
  * Gets a Famix entity by id
@@ -41,6 +55,9 @@ class FamixRepository {
41
55
  if (arg0.format === "json") {
42
56
  return this.getJSON();
43
57
  }
58
+ else {
59
+ throw new Error("Unsupported format");
60
+ }
44
61
  }
45
62
  // Only for tests
46
63
  /**
@@ -63,48 +80,48 @@ class FamixRepository {
63
80
  * @param name A class name
64
81
  * @returns The Famix class corresponding to the name or undefined if it doesn't exist
65
82
  */
66
- _getFamixClass(name) {
67
- return Array.from(this.famixClasses.values()).find(ns => ns.getName() === name);
83
+ _getFamixClass(fullyQualifiedName) {
84
+ return Array.from(this.famixClasses.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
68
85
  }
69
86
  /**
70
87
  * Gets a Famix interface by name
71
88
  * @param name An interface name
72
89
  * @returns The Famix interface corresponding to the name or undefined if it doesn't exist
73
90
  */
74
- _getFamixInterface(name) {
75
- return Array.from(this.famixInterfaces.values()).find(ns => ns.getName() === name);
91
+ _getFamixInterface(fullyQualifiedName) {
92
+ return Array.from(this.famixInterfaces.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
76
93
  }
77
94
  /**
78
95
  * Gets a Famix method by name
79
96
  * @param name A method name
80
97
  * @returns The Famix method corresponding to the name or undefined if it doesn't exist
81
98
  */
82
- _getFamixMethod(name) {
83
- return Array.from(this.famixMethods.values()).find(ns => ns.getName() === name);
99
+ _getFamixMethod(fullyQualifiedName) {
100
+ return Array.from(this.famixMethods.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
84
101
  }
85
102
  /**
86
103
  * Gets a Famix function by name
87
104
  * @param name A function name
88
105
  * @returns The Famix function corresponding to the name or undefined if it doesn't exist
89
106
  */
90
- _getFamixFunction(name) {
91
- return Array.from(this.famixFunctions.values()).find(ns => ns.getName() === name);
107
+ _getFamixFunction(fullyQualifiedName) {
108
+ return Array.from(this.famixFunctions.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
92
109
  }
93
110
  /**
94
111
  * Gets a Famix variable by name
95
112
  * @param name A variable name
96
113
  * @returns The Famix variable corresponding to the name or undefined if it doesn't exist
97
114
  */
98
- _getFamixVariable(name) {
99
- return Array.from(this.famixVariables.values()).find(v => v.getName() === name);
115
+ _getFamixVariable(fullyQualifiedName) {
116
+ return Array.from(this.famixVariables.values()).find(v => v.getFullyQualifiedName() === fullyQualifiedName);
100
117
  }
101
118
  /**
102
119
  * Gets a Famix namespace by name
103
120
  * @param name A namespace name
104
121
  * @returns The Famix namespace corresponding to the name or undefined if it doesn't exist
105
122
  */
106
- _getFamixNamespace(name) {
107
- return Array.from(this.famixNamespaces.values()).find(ns => ns.getName() === name);
123
+ _getFamixNamespace(fullyQualifiedName) {
124
+ return Array.from(this.famixNamespaces.values()).find(ns => ns.getFullyQualifiedName() === fullyQualifiedName);
108
125
  }
109
126
  /**
110
127
  * Gets all Famix namespaces
@@ -118,8 +135,8 @@ class FamixRepository {
118
135
  * @param name A file name
119
136
  * @returns The Famix file corresponding to the name or undefined if it doesn't exist
120
137
  */
121
- _getFamixFile(name) {
122
- return Array.from(this.famixFiles.values()).find(ns => ns.getName() === name);
138
+ _getFamixFile(fullyQualifiedName) {
139
+ return Array.from(this.famixFiles.values()).find(ns => ns.getName() === fullyQualifiedName);
123
140
  }
124
141
  /**
125
142
  * Gets all Famix files
@@ -17,10 +17,9 @@ exports.calculate = void 0;
17
17
  const typescript_1 = require("typescript");
18
18
  const tsutils_1 = require("tsutils");
19
19
  const fs_1 = require("fs");
20
- const { isIdentifier } = require('typescript');
21
20
  const getNodeName = (node) => {
22
21
  const { name, pos, end } = node;
23
- const key = name !== undefined && isIdentifier(name) ? name.text : JSON.stringify({ pos, end });
22
+ const key = name !== undefined && (0, typescript_1.isIdentifier)(name) ? name.text : JSON.stringify({ pos, end });
24
23
  return key;
25
24
  };
26
25
  const increasesComplexity = (node) => {
@@ -77,7 +76,7 @@ const calculate = (filePath) => {
77
76
  throw new Error(`File "${filePath}" does not exists`);
78
77
  }
79
78
  const sourceText = (0, fs_1.readFileSync)(filePath).toString();
80
- const source = (0, typescript_1.createSourceFile)(filePath, sourceText, isIdentifier.ES2015);
79
+ const source = (0, typescript_1.createSourceFile)(filePath, sourceText, typescript_1.ScriptTarget.ES2015);
81
80
  return calculateFromSource(source);
82
81
  };
83
82
  exports.calculate = calculate;
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="206px" preserveAspectRatio="none" style="width:303px;height:206px;background:#FFFFFF;" version="1.1" viewBox="0 0 303 206" width="303px" zoomAndPan="magnify"><defs/><g><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="261" x="5" y="19">Dot Executable: /opt/local/bin/dot</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="237" x="5" y="35.2969">Dot executable does not exist</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="291" x="5" y="51.5938">Cannot find Graphviz. You should try</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="67.8906">&#160;</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="79" x="5" y="84.1875">@startuml</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="57" x="5" y="100.4844">testdot</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="72" x="5" y="116.7813">@enduml</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="133.0781">&#160;</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="17" x="10" y="149.375">or</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="165.6719">&#160;</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="227" x="5" y="181.9688">java -jar plantuml.jar -testdot</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="198.2656">&#160;</text><!--SRC=[xHpBSjmsykwlu96koAuzRZ5RIicIx9eaihGUnJviRRau78p4DOUS9KYj5Dl_ldWsq423CtOYUX_nGHwYdsW0_G10Lat9UNRU3lNmaB7xWRLhdhqij_NzYvApyuPjMJja7vzaujztDspuSNdvEdzQP7pew_P6DvVhzLNVxLW_r8nVT-VtkwuVM9ypywFG32MfXGaETrszVlBvIQKKM7PZNx6Vo_PcB6yOA6BqqkAVSOMqLer2Kf4jsV2NfTVuSAmLQiijmoeApPUOMdOYHIywX9fpN_93aI6WxSeZM-YqswgXiAP1EbWBrVp7vLbN5TcgwnfMjg3KGWEaNWZ47IYazVlrhEhQeQnRgIaI309EBOAoQup2VPGKjqYaw70qZgUwFJGnTv20SgO1qZqvQQlRhazCOAQNKyg6PhMbBMWHQ3wpzdCTk8nm7Yw7SKLDGzbEpq852GZHXE2UWGjaxc2DwqPdHX-91qXffi5aLAlF-1op5e-zEQd1rgbW165qqv0RFeLTpaZ8cWaBzsoDdM4HE4SGUaQYksvZ0fuaE4piJBFhXFEkgikXxjffLzSAQE6ZWsQl1KHg5i6uWKMaQ1HsFRkhkv7JpAyCD2K0u2IRcOpuMiG_lYih5qYNLRSJ4h09TsBKsq62v6Zx6Awx3aLDh1Y9OwGqpxdS4-gfxJ_47co1whPkra9XC9XPuF3ibhX3iOiyH1BAGrEkECDZuOPaDZFqzMu8h43EWdRShbX_kVbPc8TVRgxLuj2DhlCnZjJPn-8qrWHtjEeitkbjsPULw11FAk5G9dJmaDAiPngBYsuzDlvQz8R6348t3ZUTaBdOIXPc5kg7qwOSkJSHBp6g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tthE519jPt_SomRNzdlC_Un2fVJV9y5dtIGZLVbS6iNX2M3F4gp1tmf42Q5GEQBLjSL79QZR3rZct9i1Wto89-nERhsJZYRw-uDQqevrQKcURdYNJCEIAsZp6yLJagcVLwTP39Gk0QDwuZWqsd-cQRtWKARD4Eo13Sb_Ce0fJjmv1oa-YZZepy7f94kKkzjQF3RgJDFZNBeGQt1he4PfB14uL2lJxjHPt9U2VoC6XceD7vBrY-hu9X3_jLSmygPOlxqInIKbQxNUQAAH-2TPw185vqTI7al7XRh7FcoS4xIL5_w1GUQgzuYaDjEVvB-PjFrst9mVk1pqCVtwhC3JNWPY5v58RPrY_bmQ_RGGBazJBpQPRAFNdK2PAuicIGDoWqWDmN19At62GYzF7pVgE2b6l21J7QI3qvWWTXLd9FKGSKPaoS_LUQwM-zJaVGr11VtZbhQENttNbTeIfqJBh1VzjtMLhVYRo0xUfVVqEj3c4CvUBxWVTtMqeD88g4dQ-GN0LZZTrVu5RsaZsmzvVPxe-zlXfD_pxOV_WeMwxrNq7LGDD4Hxwr9PQLhuietSRTZzpInwoROoSGBbZkmBrkyaU9BC7TevKPcYx9iUwiMJ_v09bPMoyl3RX6qdv-KvbNCp0l_nAU7dQlLpnyjtUVi4L_92X6Y3xcIxldPQjniM6_sLuNHTQlP1M6R-ZwbwKEERI-tIlowVd9o_Hi0]--></g></svg>
@@ -0,0 +1 @@
1
+ <?xml version="1.0" encoding="us-ascii" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" contentStyleType="text/css" height="206px" preserveAspectRatio="none" style="width:303px;height:206px;background:#FFFFFF;" version="1.1" viewBox="0 0 303 206" width="303px" zoomAndPan="magnify"><defs/><g><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="261" x="5" y="19">Dot Executable: /opt/local/bin/dot</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="237" x="5" y="35.2969">Dot executable does not exist</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="291" x="5" y="51.5938">Cannot find Graphviz. You should try</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="67.8906">&#160;</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="79" x="5" y="84.1875">@startuml</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="57" x="5" y="100.4844">testdot</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="72" x="5" y="116.7813">@enduml</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="133.0781">&#160;</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="17" x="10" y="149.375">or</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="165.6719">&#160;</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="227" x="5" y="181.9688">java -jar plantuml.jar -testdot</text><text fill="#33FF02" font-family="sans-serif" font-size="14" font-weight="bold" lengthAdjust="spacing" textLength="5" x="5" y="198.2656">&#160;</text><!--SRC=[xHpBSjouyUwlO6vqhUpACSLDQKkMPDVihYp5exKFgPIBmy58Z3daX20LARR_FNWsq423C_Qkw3pM1tc8Vg81z0C0-OUwhPfnpJB-eMxvS_FqV3TkcoTLKtAUdRT3FJnax7vWxPfdByjjVV-YvEoyOLlM3jd79vduzzqD6tvSNhxEdnOP7_gwlT7DvNfzrNSxrWyruzVT-VskwmVMvypyA3H3IMfXWiDTLw-VV3OABBknhzZFPNipbZSC535wQV7Fk49QgqOXgSYMRFZpqcjyEDOAjUMMOHM5vajCBJkHeXSTGisvB_cX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sdt7vlzFtDSFBlsVR3Ny5YlVSAkWwA9ZhYlJMfh7HDNFacxdRidYPstGGxcNZ1SWVsPOitKdm9vWwjtCXiKPPjRzNYoH_8nCfgUNdOBOBsyvFIl8gPUU6V-FImSxNw-QEb-vmzuYjP8KBq8LVIFJzRZPiDwyt-gZ2wRZMx86nJtwSqVSYnxULMYL_NJqwkVmC0]--></g></svg>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts2famix",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "A TypeScript to JSON importer for Moose 10.",
5
5
  "main": "dist/ts2famix-cli.js",
6
6
  "scripts": {
package/plantuml.jar ADDED
Binary file
package/src/analyze.ts CHANGED
@@ -1,31 +1,28 @@
1
1
  import { Project } from "ts-morph";
2
2
  import * as fs from 'fs';
3
3
  import { FamixRepository } from "./lib/famix/src/famix_repository";
4
- import { FamixFunctions } from "./famix_functions/famix_functions";
5
- import { ProcessFiles } from "./analyze_functions/processFiles";
6
- import { ProcessAccesses } from "./analyze_functions/processAccesses";
7
- import { ProcessInvocations } from "./analyze_functions/processInvocations";
8
- import { ProcessInheritances } from "./analyze_functions/processInheritances";
9
- import { ProcessImportClauses } from "./analyze_functions/processImportClauses";
10
-
11
4
  import { Logger } from "tslog";
5
+ import * as processFunctions from "./analyze_functions/process_functions";
6
+ import { EntityDictionary } from "./famix_functions/EntityDictionary";
7
+ import path from "path";
12
8
 
13
9
  export const logger = new Logger({ name: "ts2famix", minLevel: 3});
14
10
  export const config = { "expectGraphemes": false };
11
+ export const entityDictionary = new EntityDictionary();
15
12
 
16
13
  /**
17
14
  * This class is used to build a Famix model from a TypeScript source code
18
15
  */
19
16
  export class Importer {
20
17
 
21
- private project = new Project(); // The project containing the source files to analyze
22
- private famixFunctions = new FamixFunctions(); // FamixFunctions object, it contains all the functions needed to create Famix entities
23
- private processFiles = new ProcessFiles(this.famixFunctions); // ProcessFiles object, it contains all the functions needed to process the source files
24
- private processAccesses = new ProcessAccesses(this.famixFunctions); // ProcessAccesses object, it contains all the functions needed to process the accesses
25
- private processInvocations = new ProcessInvocations(this.famixFunctions); // ProcessInvocations object, it contains all the functions needed to process the invocations
26
- private processInheritances = new ProcessInheritances(this.famixFunctions); // ProcessInheritances object, it contains all the functions needed to process the inheritances
27
- private processImportClauses = new ProcessImportClauses(this.famixFunctions); // ProcessImportClauses object, it contains all the functions needed to process the import clauses
28
-
18
+ private project = new Project(
19
+ {
20
+ compilerOptions: {
21
+ baseUrl: "./test_src"
22
+ }
23
+ }
24
+ ); // The project containing the source files to analyze
25
+
29
26
  /**
30
27
  * Main method
31
28
  * @param paths An array of paths to the source files to analyze
@@ -36,9 +33,12 @@ export class Importer {
36
33
  // try {
37
34
  logger.debug(`famixRepFromPaths: paths: ${paths}`);
38
35
  this.project.addSourceFilesAtPaths(paths);
36
+
37
+ initFamixRep(this.project);
38
+
39
39
  this.processEntities(this.project);
40
40
 
41
- const famixRep = this.famixFunctions.getFamixRepository();
41
+ const famixRep = entityDictionary.famixRep;
42
42
  // }
43
43
  // catch (error) {
44
44
  // logger.error(`> ERROR: got exception ${error}. Exiting...`);
@@ -51,18 +51,19 @@ export class Importer {
51
51
  }
52
52
 
53
53
  private processEntities(project) {
54
- this.processFiles.processFiles(project.getSourceFiles());
55
- const accesses = this.processFiles.getAccesses();
56
- const methodsAndFunctionsWithId = this.processFiles.getMethodsAndFunctionsWithId();
57
- const classes = this.processFiles.getClasses();
58
- const interfaces = this.processFiles.getInterfaces();
59
- const modules = this.processFiles.getModules();
60
- const exports = this.processFiles.getExports();
61
-
62
- this.processImportClauses.processImportClauses(modules, exports);
63
- this.processAccesses.processAccesses(accesses);
64
- this.processInvocations.processInvocations(methodsAndFunctionsWithId);
65
- this.processInheritances.processInheritances(classes, interfaces);
54
+ processFunctions.processFiles(project.getSourceFiles());
55
+ const accesses = processFunctions.accessMap;
56
+ const methodsAndFunctionsWithId = processFunctions.methodsAndFunctionsWithId;
57
+ const classes = processFunctions.classes;
58
+ const interfaces = processFunctions.interfaces;
59
+ const modules = processFunctions.modules;
60
+ const exports = processFunctions.exportedMap;
61
+
62
+ processFunctions.processImportClausesForImportEqualsDeclarations(project.getSourceFiles(), exports);
63
+ processFunctions.processImportClausesForModules(modules, exports);
64
+ processFunctions.processAccesses(accesses);
65
+ processFunctions.processInvocations(methodsAndFunctionsWithId);
66
+ processFunctions.processInheritances(classes, interfaces);
66
67
  }
67
68
 
68
69
  /**
@@ -92,9 +93,25 @@ export class Importer {
92
93
  //const sourceFileNames = project.getSourceFiles().map(f => f.getFilePath()) as Array<string>;
93
94
 
94
95
  //const famixRep = this.famixRepFromPaths(sourceFileNames);
96
+
97
+ initFamixRep(project);
98
+
95
99
  this.processEntities(project);
96
100
 
97
- return this.famixFunctions.getFamixRepository();
101
+ return entityDictionary.famixRep;
98
102
  }
99
103
 
100
104
  }
105
+
106
+ function initFamixRep(project :Project ): void {
107
+
108
+ // get compiler options
109
+ const compilerOptions = project.getCompilerOptions();
110
+
111
+ // get baseUrl
112
+ const baseUrl = compilerOptions.baseUrl;
113
+
114
+ const absoluteBaseUrl = path.resolve(baseUrl);
115
+
116
+ entityDictionary.famixRep.setAbsolutePath(path.normalize(absoluteBaseUrl));
117
+ }