ts2famix 1.2.0 → 1.3.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # FamixTypeScriptImporter
2
2
 
3
- [![Node.js CI](https://github.com/maelpaul/FamixTypeScriptImporter/actions/workflows/node.js.yml/badge.svg)](https://github.com/maelpaul/FamixTypeScriptImporter/actions/workflows/node.js.yml)
3
+ [![Node.js CI](https://github.com/fuhrmanator/FamixTypeScriptImporter/actions/workflows/ci-nodejs.yml/badge.svg)](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
- ![FamixTypeScript API Metamodel](https://raw.githubusercontent.com/maelpaul/FamixTypeScriptImporter/v1/doc/metamodel.svg)
109
+ ![FamixTypeScript API Metamodel](https://raw.githubusercontent.com/fuhrmanator/FamixTypeScriptImporter/v1/doc/metamodel.svg)
@@ -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
  }
@@ -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.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "A TypeScript to JSON importer for Moose 10.",
5
5
  "main": "dist/ts2famix-cli.js",
6
6
  "scripts": {
@@ -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));
@@ -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
  }