ts2famix 1.2.0 → 1.3.1
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.
- package/README.md +2 -2
- package/dist/famix_functions/famix_functions_index.js +7 -1
- package/dist/lib/famix/src/model/famix/class.js +1 -1
- package/dist/lib/famix/src/model/famix/indexed_file_anchor.js +14 -0
- package/package.json +4 -4
- package/src/famix_functions/famix_functions_index.ts +7 -1
- package/src/generate_uml.sh +3 -0
- package/src/lib/famix/src/model/famix/class.ts +1 -1
- package/src/lib/famix/src/model/famix/indexed_file_anchor.ts +22 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# FamixTypeScriptImporter
|
|
2
2
|
|
|
3
|
-
[](https://github.com/fuhrmanator/FamixTypeScriptImporter/actions/workflows/ci-nodejs.yml)
|
|
4
4
|
|
|
5
5
|
Create a [FamixTypeScript](https://github.com/fuhrmanator/FamixTypeScript) model in JSON of TypeScript files.
|
|
6
6
|
|
|
@@ -106,4 +106,4 @@ ts-node src/famix2puml.ts -i JSONModels/projectName.json -o PUMLModels/projectNa
|
|
|
106
106
|
|
|
107
107
|
The following was generated by CI using [tplant](https://github.com/bafolts/tplant), in a similar fashion described [here](https://modularmoose.org/posts/2021-07-19-automatic-metamodel-documentation-generation).
|
|
108
108
|
|
|
109
|
-

|
|
@@ -55,10 +55,12 @@ class FamixFunctionsIndex {
|
|
|
55
55
|
fmxIndexFileAnchor.setElement(famixElement);
|
|
56
56
|
if (sourceElement !== null) {
|
|
57
57
|
fmxIndexFileAnchor.setFileName(sourceElement.getSourceFile().getFilePath());
|
|
58
|
-
let sourceStart, sourceEnd;
|
|
58
|
+
let sourceStart, sourceEnd, sourceLineStart, sourceLineEnd;
|
|
59
59
|
if (!(sourceElement instanceof ts_morph_1.CommentRange)) {
|
|
60
60
|
sourceStart = sourceElement.getStart();
|
|
61
61
|
sourceEnd = sourceElement.getEnd();
|
|
62
|
+
sourceLineStart = sourceElement.getStartLineNumber();
|
|
63
|
+
sourceLineEnd = sourceElement.getEndLineNumber();
|
|
62
64
|
}
|
|
63
65
|
else {
|
|
64
66
|
sourceStart = sourceElement.getPos();
|
|
@@ -93,6 +95,10 @@ class FamixFunctionsIndex {
|
|
|
93
95
|
// note: the +1 is because the source anchor is 1-based, but ts-morph is 0-based
|
|
94
96
|
fmxIndexFileAnchor.setStartPos(sourceStart + 1);
|
|
95
97
|
fmxIndexFileAnchor.setEndPos(sourceEnd + 1);
|
|
98
|
+
if (!(sourceElement instanceof ts_morph_1.CommentRange)) {
|
|
99
|
+
fmxIndexFileAnchor.setStartLine(sourceLineStart);
|
|
100
|
+
fmxIndexFileAnchor.setEndLine(sourceLineEnd);
|
|
101
|
+
}
|
|
96
102
|
if (!(famixElement instanceof Famix.Association) && !(famixElement instanceof Famix.Comment) && !(sourceElement instanceof ts_morph_1.CommentRange) && !(sourceElement instanceof ts_morph_1.Identifier) && !(sourceElement instanceof ts_morph_1.ImportSpecifier) && !(sourceElement instanceof ts_morph_1.ExpressionWithTypeArguments)) {
|
|
97
103
|
famixElement.setFullyQualifiedName(this.FQNFunctions.getFQN(sourceElement));
|
|
98
104
|
}
|
|
@@ -61,7 +61,7 @@ class Class extends type_1.Type {
|
|
|
61
61
|
addPropertiesToExporter(exporter) {
|
|
62
62
|
super.addPropertiesToExporter(exporter);
|
|
63
63
|
exporter.addProperty("isAbstract", this.getIsAbstract());
|
|
64
|
-
exporter.addProperty("
|
|
64
|
+
exporter.addProperty("attributes", this.getProperties()); // Moose (10) codes them as attributes
|
|
65
65
|
exporter.addProperty("methods", this.getMethods());
|
|
66
66
|
exporter.addProperty("superInheritances", this.getSuperInheritances());
|
|
67
67
|
exporter.addProperty("subInheritances", this.getSubInheritances());
|
|
@@ -16,6 +16,18 @@ class IndexedFileAnchor extends source_anchor_1.SourceAnchor {
|
|
|
16
16
|
setEndPos(endPos) {
|
|
17
17
|
this.endPos = endPos;
|
|
18
18
|
}
|
|
19
|
+
getEndLine() {
|
|
20
|
+
return this.endLine;
|
|
21
|
+
}
|
|
22
|
+
setEndLine(sourceEndLine) {
|
|
23
|
+
this.endLine = sourceEndLine;
|
|
24
|
+
}
|
|
25
|
+
getStartLine() {
|
|
26
|
+
return this.startLine;
|
|
27
|
+
}
|
|
28
|
+
setStartLine(sourceStartLine) {
|
|
29
|
+
this.startLine = sourceStartLine;
|
|
30
|
+
}
|
|
19
31
|
getFileName() {
|
|
20
32
|
return this.fileName;
|
|
21
33
|
}
|
|
@@ -31,6 +43,8 @@ class IndexedFileAnchor extends source_anchor_1.SourceAnchor {
|
|
|
31
43
|
super.addPropertiesToExporter(exporter);
|
|
32
44
|
exporter.addProperty("startPos", this.getStartPos());
|
|
33
45
|
exporter.addProperty("endPos", this.getEndPos());
|
|
46
|
+
exporter.addProperty("startLine", this.getStartLine());
|
|
47
|
+
exporter.addProperty("endLine", this.getEndLine());
|
|
34
48
|
exporter.addProperty("fileName", this.getFileName());
|
|
35
49
|
}
|
|
36
50
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts2famix",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "A TypeScript to JSON importer for Moose 10.",
|
|
5
5
|
"main": "dist/ts2famix-cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -33,17 +33,17 @@
|
|
|
33
33
|
"@typescript-eslint/parser": "^7.0.1",
|
|
34
34
|
"eslint": "^8.56.0",
|
|
35
35
|
"jest": "^29.7.0",
|
|
36
|
-
"tplant": "
|
|
36
|
+
"tplant": "3.1.0",
|
|
37
37
|
"ts-jest": "^29.1.2",
|
|
38
38
|
"ts-node": "^10.9.2",
|
|
39
|
-
"typedoc": "^0.25.8"
|
|
40
|
-
"typescript": "^5.3.3"
|
|
39
|
+
"typedoc": "^0.25.8"
|
|
41
40
|
},
|
|
42
41
|
"dependencies": {
|
|
43
42
|
"grapheme-splitter": "^1.0.4",
|
|
44
43
|
"ts-morph": "^21.0.1",
|
|
45
44
|
"tslog": "^4.9.2",
|
|
46
45
|
"tsutils": "^3.21.0",
|
|
46
|
+
"typescript": "^5.3.3",
|
|
47
47
|
"yargs": "^17.7.2"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -33,10 +33,12 @@ export class FamixFunctionsIndex {
|
|
|
33
33
|
|
|
34
34
|
if (sourceElement !== null) {
|
|
35
35
|
fmxIndexFileAnchor.setFileName(sourceElement.getSourceFile().getFilePath());
|
|
36
|
-
let sourceStart, sourceEnd: number;
|
|
36
|
+
let sourceStart, sourceEnd, sourceLineStart, sourceLineEnd: number;
|
|
37
37
|
if (!(sourceElement instanceof CommentRange)) {
|
|
38
38
|
sourceStart = sourceElement.getStart();
|
|
39
39
|
sourceEnd = sourceElement.getEnd();
|
|
40
|
+
sourceLineStart = sourceElement.getStartLineNumber();
|
|
41
|
+
sourceLineEnd = sourceElement.getEndLineNumber();
|
|
40
42
|
} else {
|
|
41
43
|
sourceStart = sourceElement.getPos();
|
|
42
44
|
sourceEnd = sourceElement.getEnd();
|
|
@@ -71,6 +73,10 @@ export class FamixFunctionsIndex {
|
|
|
71
73
|
// note: the +1 is because the source anchor is 1-based, but ts-morph is 0-based
|
|
72
74
|
fmxIndexFileAnchor.setStartPos(sourceStart + 1);
|
|
73
75
|
fmxIndexFileAnchor.setEndPos(sourceEnd + 1);
|
|
76
|
+
if (!(sourceElement instanceof CommentRange)) {
|
|
77
|
+
fmxIndexFileAnchor.setStartLine(sourceLineStart);
|
|
78
|
+
fmxIndexFileAnchor.setEndLine(sourceLineEnd);
|
|
79
|
+
}
|
|
74
80
|
|
|
75
81
|
if (!(famixElement instanceof Famix.Association) && !(famixElement instanceof Famix.Comment) && !(sourceElement instanceof CommentRange) && !(sourceElement instanceof Identifier) && !(sourceElement instanceof ImportSpecifier) && !(sourceElement instanceof ExpressionWithTypeArguments)) {
|
|
76
82
|
(famixElement as Famix.NamedEntity).setFullyQualifiedName(this.FQNFunctions.getFQN(sourceElement));
|
package/src/generate_uml.sh
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
# Gets latest plantuml
|
|
3
3
|
rm -f plantuml.jar
|
|
4
4
|
wget --no-verbose https://downloads.sourceforge.net/project/plantuml/plantuml.jar
|
|
5
|
+
# echo the version
|
|
6
|
+
echo "PlantUML version: $(java -jar plantuml.jar -version)"
|
|
7
|
+
echo "tplant version: $(npx tplant --version)"
|
|
5
8
|
# Builds metamodel plantuml from TypeScript sources
|
|
6
9
|
npx tplant -i src/lib/famix/**/*.ts -o doc-metamodel/famix-typescript-model.puml
|
|
7
10
|
sed -i 's/@startuml/& metamodel/' doc-metamodel/famix-typescript-model.puml
|
|
@@ -78,7 +78,7 @@ export class Class extends Type {
|
|
|
78
78
|
public addPropertiesToExporter(exporter: FamixJSONExporter): void {
|
|
79
79
|
super.addPropertiesToExporter(exporter);
|
|
80
80
|
exporter.addProperty("isAbstract", this.getIsAbstract());
|
|
81
|
-
exporter.addProperty("
|
|
81
|
+
exporter.addProperty("attributes", this.getProperties()); // Moose (10) codes them as attributes
|
|
82
82
|
exporter.addProperty("methods", this.getMethods());
|
|
83
83
|
exporter.addProperty("superInheritances", this.getSuperInheritances());
|
|
84
84
|
exporter.addProperty("subInheritances", this.getSubInheritances());
|
|
@@ -23,6 +23,26 @@ export class IndexedFileAnchor extends SourceAnchor {
|
|
|
23
23
|
this.endPos = endPos;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
private endLine: number;
|
|
27
|
+
|
|
28
|
+
public getEndLine(): number {
|
|
29
|
+
return this.endLine;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public setEndLine(sourceEndLine: number) {
|
|
33
|
+
this.endLine = sourceEndLine;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
private startLine: number;
|
|
37
|
+
|
|
38
|
+
public getStartLine(): number {
|
|
39
|
+
return this.startLine;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public setStartLine(sourceStartLine: number) {
|
|
43
|
+
this.startLine = sourceStartLine;
|
|
44
|
+
}
|
|
45
|
+
|
|
26
46
|
private fileName: string;
|
|
27
47
|
|
|
28
48
|
public getFileName(): string {
|
|
@@ -44,6 +64,8 @@ export class IndexedFileAnchor extends SourceAnchor {
|
|
|
44
64
|
super.addPropertiesToExporter(exporter);
|
|
45
65
|
exporter.addProperty("startPos", this.getStartPos());
|
|
46
66
|
exporter.addProperty("endPos", this.getEndPos());
|
|
67
|
+
exporter.addProperty("startLine", this.getStartLine());
|
|
68
|
+
exporter.addProperty("endLine", this.getEndLine());
|
|
47
69
|
exporter.addProperty("fileName", this.getFileName());
|
|
48
70
|
}
|
|
49
71
|
}
|