@swagger-api/apidom-parser-adapter-json 1.0.0-beta.9 → 1.0.0-rc.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/CHANGELOG.md +178 -0
- package/dist/apidom-parser-adapter-json.browser.js +12970 -12509
- package/dist/apidom-parser-adapter-json.browser.min.js +1 -1
- package/package.json +7 -7
- package/src/syntactic-analysis/TreeCursorSyntaxNode.cjs +8 -4
- package/src/syntactic-analysis/TreeCursorSyntaxNode.mjs +8 -4
- package/src/syntactic-analysis/direct/visitors/CstVisitor.cjs +1 -17
- package/src/syntactic-analysis/direct/visitors/CstVisitor.mjs +2 -18
- package/src/syntactic-analysis/indirect/visitors/CstVisitor.cjs +25 -63
- package/src/syntactic-analysis/indirect/visitors/CstVisitor.mjs +26 -64
- package/src/syntactic-analysis/indirect/visitors/JsonAstVisitor.cjs +1 -6
- package/src/syntactic-analysis/indirect/visitors/JsonAstVisitor.mjs +2 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swagger-api/apidom-parser-adapter-json",
|
|
3
|
-
"version": "1.0.0-
|
|
3
|
+
"version": "1.0.0-rc.0",
|
|
4
4
|
"description": "Parser adapter for parsing JSON documents into base namespace.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"author": "Vladimir Gorej",
|
|
53
53
|
"license": "Apache-2.0",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@babel/runtime-corejs3": "^7.
|
|
56
|
-
"@swagger-api/apidom-ast": "^1.0.0-
|
|
57
|
-
"@swagger-api/apidom-core": "^1.0.0-
|
|
58
|
-
"@swagger-api/apidom-error": "^1.0.0-
|
|
55
|
+
"@babel/runtime-corejs3": "^7.26.10",
|
|
56
|
+
"@swagger-api/apidom-ast": "^1.0.0-rc.0",
|
|
57
|
+
"@swagger-api/apidom-core": "^1.0.0-rc.0",
|
|
58
|
+
"@swagger-api/apidom-error": "^1.0.0-rc.0",
|
|
59
59
|
"@types/ramda": "~0.30.0",
|
|
60
60
|
"ramda": "~0.30.0",
|
|
61
61
|
"ramda-adjunct": "^5.0.0",
|
|
62
|
-
"tree-sitter": "=0.
|
|
62
|
+
"tree-sitter": "=0.21.1",
|
|
63
63
|
"tree-sitter-json": "=0.24.8",
|
|
64
64
|
"web-tree-sitter": "=0.24.5"
|
|
65
65
|
},
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
"README.md",
|
|
78
78
|
"CHANGELOG.md"
|
|
79
79
|
],
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "af4b6e0fcae489477729581c52036725ac57a412"
|
|
81
81
|
}
|
|
@@ -4,9 +4,11 @@ exports.__esModule = true;
|
|
|
4
4
|
exports.default = void 0;
|
|
5
5
|
class TreeCursorSyntaxNode {
|
|
6
6
|
type;
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
startPositionRow;
|
|
8
|
+
startPositionColumn;
|
|
9
9
|
startIndex;
|
|
10
|
+
endPositionRow;
|
|
11
|
+
endPositionColumn;
|
|
10
12
|
endIndex;
|
|
11
13
|
text;
|
|
12
14
|
isNamed;
|
|
@@ -16,9 +18,11 @@ class TreeCursorSyntaxNode {
|
|
|
16
18
|
children = [];
|
|
17
19
|
constructor(cursor) {
|
|
18
20
|
this.type = cursor.nodeType;
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
21
|
+
this.startPositionRow = cursor.startPosition.row;
|
|
22
|
+
this.startPositionColumn = cursor.startPosition.column;
|
|
21
23
|
this.startIndex = cursor.startIndex;
|
|
24
|
+
this.endPositionRow = cursor.endPosition.row;
|
|
25
|
+
this.endPositionColumn = cursor.endPosition.column;
|
|
22
26
|
this.endIndex = cursor.endIndex;
|
|
23
27
|
this.text = cursor.nodeText;
|
|
24
28
|
this.isNamed = cursor.nodeIsNamed;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
class TreeCursorSyntaxNode {
|
|
2
2
|
type;
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
startPositionRow;
|
|
4
|
+
startPositionColumn;
|
|
5
5
|
startIndex;
|
|
6
|
+
endPositionRow;
|
|
7
|
+
endPositionColumn;
|
|
6
8
|
endIndex;
|
|
7
9
|
text;
|
|
8
10
|
isNamed;
|
|
@@ -12,9 +14,11 @@ class TreeCursorSyntaxNode {
|
|
|
12
14
|
children = [];
|
|
13
15
|
constructor(cursor) {
|
|
14
16
|
this.type = cursor.nodeType;
|
|
15
|
-
this.
|
|
16
|
-
this.
|
|
17
|
+
this.startPositionRow = cursor.startPosition.row;
|
|
18
|
+
this.startPositionColumn = cursor.startPosition.column;
|
|
17
19
|
this.startIndex = cursor.startIndex;
|
|
20
|
+
this.endPositionRow = cursor.endPosition.row;
|
|
21
|
+
this.endPositionColumn = cursor.endPosition.column;
|
|
18
22
|
this.endIndex = cursor.endIndex;
|
|
19
23
|
this.text = cursor.nodeText;
|
|
20
24
|
this.isNamed = cursor.nodeIsNamed;
|
|
@@ -8,13 +8,6 @@ var _TreeCursorSyntaxNode = _interopRequireDefault(require("../../TreeCursorSynt
|
|
|
8
8
|
/* eslint-disable no-underscore-dangle */
|
|
9
9
|
|
|
10
10
|
class CstVisitor {
|
|
11
|
-
static toPosition(node) {
|
|
12
|
-
const start = new _apidomCore.ArrayElement([node.startPosition.row, node.startPosition.column, node.startIndex]);
|
|
13
|
-
const end = new _apidomCore.ArrayElement([node.endPosition.row, node.endPosition.column, node.endIndex]);
|
|
14
|
-
start.classes.push('position');
|
|
15
|
-
end.classes.push('position');
|
|
16
|
-
return [start, end];
|
|
17
|
-
}
|
|
18
11
|
sourceMap = false;
|
|
19
12
|
annotations;
|
|
20
13
|
ParseResultElement = {
|
|
@@ -144,16 +137,7 @@ class CstVisitor {
|
|
|
144
137
|
if (!this.sourceMap) {
|
|
145
138
|
return;
|
|
146
139
|
}
|
|
147
|
-
|
|
148
|
-
const position = CstVisitor.toPosition(node);
|
|
149
|
-
if (position !== null) {
|
|
150
|
-
const [start, end] = position;
|
|
151
|
-
sourceMap.push(start);
|
|
152
|
-
sourceMap.push(end);
|
|
153
|
-
}
|
|
154
|
-
// @ts-ignore
|
|
155
|
-
sourceMap.astNode = node;
|
|
156
|
-
element.meta.set('sourceMap', sourceMap);
|
|
140
|
+
(0, _apidomCore.assignSourceMap)(element, node);
|
|
157
141
|
}
|
|
158
142
|
}
|
|
159
143
|
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import { BooleanElement, NullElement, NumberElement, ParseResultElement,
|
|
1
|
+
import { BooleanElement, NullElement, NumberElement, ParseResultElement, MemberElement, ObjectElement, ArrayElement, StringElement, AnnotationElement, isPrimitiveElement, assignSourceMap } from '@swagger-api/apidom-core';
|
|
2
2
|
import TreeCursorSyntaxNode from "../../TreeCursorSyntaxNode.mjs";
|
|
3
3
|
/* eslint-disable no-underscore-dangle */
|
|
4
4
|
class CstVisitor {
|
|
5
|
-
static toPosition(node) {
|
|
6
|
-
const start = new ArrayElement([node.startPosition.row, node.startPosition.column, node.startIndex]);
|
|
7
|
-
const end = new ArrayElement([node.endPosition.row, node.endPosition.column, node.endIndex]);
|
|
8
|
-
start.classes.push('position');
|
|
9
|
-
end.classes.push('position');
|
|
10
|
-
return [start, end];
|
|
11
|
-
}
|
|
12
5
|
sourceMap = false;
|
|
13
6
|
annotations;
|
|
14
7
|
ParseResultElement = {
|
|
@@ -138,16 +131,7 @@ class CstVisitor {
|
|
|
138
131
|
if (!this.sourceMap) {
|
|
139
132
|
return;
|
|
140
133
|
}
|
|
141
|
-
|
|
142
|
-
const position = CstVisitor.toPosition(node);
|
|
143
|
-
if (position !== null) {
|
|
144
|
-
const [start, end] = position;
|
|
145
|
-
sourceMap.push(start);
|
|
146
|
-
sourceMap.push(end);
|
|
147
|
-
}
|
|
148
|
-
// @ts-ignore
|
|
149
|
-
sourceMap.astNode = node;
|
|
150
|
-
element.meta.set('sourceMap', sourceMap);
|
|
134
|
+
assignSourceMap(element, node);
|
|
151
135
|
}
|
|
152
136
|
}
|
|
153
137
|
|
|
@@ -4,6 +4,7 @@ var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequ
|
|
|
4
4
|
exports.__esModule = true;
|
|
5
5
|
exports.keyMap = exports.default = void 0;
|
|
6
6
|
var _apidomAst = require("@swagger-api/apidom-ast");
|
|
7
|
+
var _apidomCore = require("@swagger-api/apidom-core");
|
|
7
8
|
var _TreeCursorSyntaxNode = _interopRequireDefault(require("../../TreeCursorSyntaxNode.cjs"));
|
|
8
9
|
const keyMap = exports.keyMap = {
|
|
9
10
|
document: ['children'],
|
|
@@ -18,30 +19,12 @@ const keyMap = exports.keyMap = {
|
|
|
18
19
|
/* eslint-disable class-methods-use-this */
|
|
19
20
|
|
|
20
21
|
class CstVisitor {
|
|
21
|
-
static toPosition(node) {
|
|
22
|
-
const start = new _apidomAst.Point({
|
|
23
|
-
row: node.startPosition.row,
|
|
24
|
-
column: node.startPosition.column,
|
|
25
|
-
char: node.startIndex
|
|
26
|
-
});
|
|
27
|
-
const end = new _apidomAst.Point({
|
|
28
|
-
row: node.endPosition.row,
|
|
29
|
-
column: node.endPosition.column,
|
|
30
|
-
char: node.endIndex
|
|
31
|
-
});
|
|
32
|
-
return new _apidomAst.Position({
|
|
33
|
-
start,
|
|
34
|
-
end
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
22
|
document = {
|
|
38
23
|
enter: node => {
|
|
39
|
-
|
|
40
|
-
return new _apidomAst.JsonDocument({
|
|
24
|
+
return new _apidomAst.JsonDocument((0, _apidomCore.assignSourceMap)({
|
|
41
25
|
children: node.children,
|
|
42
|
-
position,
|
|
43
26
|
isMissing: node.isMissing
|
|
44
|
-
});
|
|
27
|
+
}, node));
|
|
45
28
|
},
|
|
46
29
|
leave: document => {
|
|
47
30
|
return new _apidomAst.ParseResult({
|
|
@@ -52,114 +35,93 @@ class CstVisitor {
|
|
|
52
35
|
enter(node) {
|
|
53
36
|
// anonymous literals from CST transformed into AST literal nodes
|
|
54
37
|
if (node instanceof _TreeCursorSyntaxNode.default && !node.isNamed) {
|
|
55
|
-
const position = CstVisitor.toPosition(node);
|
|
56
38
|
const value = node.type || node.text;
|
|
57
39
|
const {
|
|
58
40
|
isMissing
|
|
59
41
|
} = node;
|
|
60
|
-
return new _apidomAst.Literal({
|
|
42
|
+
return new _apidomAst.Literal((0, _apidomCore.assignSourceMap)({
|
|
61
43
|
value,
|
|
62
|
-
position,
|
|
63
44
|
isMissing
|
|
64
|
-
});
|
|
45
|
+
}, node));
|
|
65
46
|
}
|
|
66
47
|
return undefined;
|
|
67
48
|
}
|
|
68
49
|
object(node) {
|
|
69
|
-
|
|
70
|
-
return new _apidomAst.JsonObject({
|
|
50
|
+
return new _apidomAst.JsonObject((0, _apidomCore.assignSourceMap)({
|
|
71
51
|
children: node.children,
|
|
72
|
-
position,
|
|
73
52
|
isMissing: node.isMissing
|
|
74
|
-
});
|
|
53
|
+
}, node));
|
|
75
54
|
}
|
|
76
55
|
pair(node) {
|
|
77
|
-
const position = CstVisitor.toPosition(node);
|
|
78
56
|
const children = node.children.slice(1);
|
|
79
57
|
const {
|
|
80
58
|
keyNode
|
|
81
59
|
} = node;
|
|
82
|
-
const key = new _apidomAst.JsonKey({
|
|
60
|
+
const key = new _apidomAst.JsonKey((0, _apidomCore.assignSourceMap)({
|
|
83
61
|
children: (keyNode == null ? void 0 : keyNode.children) || [],
|
|
84
|
-
position: keyNode != null ? CstVisitor.toPosition(keyNode) : undefined,
|
|
85
62
|
isMissing: keyNode != null ? keyNode.isMissing : false
|
|
86
|
-
});
|
|
87
|
-
return new _apidomAst.JsonProperty({
|
|
63
|
+
}, keyNode));
|
|
64
|
+
return new _apidomAst.JsonProperty((0, _apidomCore.assignSourceMap)({
|
|
88
65
|
children: [key, ...children],
|
|
89
|
-
position,
|
|
90
66
|
isMissing: node.isMissing
|
|
91
|
-
});
|
|
67
|
+
}, node));
|
|
92
68
|
}
|
|
93
69
|
array(node) {
|
|
94
|
-
|
|
95
|
-
return new _apidomAst.JsonArray({
|
|
70
|
+
return new _apidomAst.JsonArray((0, _apidomCore.assignSourceMap)({
|
|
96
71
|
children: node.children,
|
|
97
|
-
position,
|
|
98
72
|
isMissing: node.isMissing
|
|
99
|
-
});
|
|
73
|
+
}, node));
|
|
100
74
|
}
|
|
101
75
|
string(node) {
|
|
102
|
-
const position = CstVisitor.toPosition(node);
|
|
103
76
|
const content = new _apidomAst.JsonStringContent({
|
|
104
77
|
value: JSON.parse(node.text)
|
|
105
78
|
});
|
|
106
|
-
return new _apidomAst.JsonString({
|
|
79
|
+
return new _apidomAst.JsonString((0, _apidomCore.assignSourceMap)({
|
|
107
80
|
children: [content],
|
|
108
|
-
position,
|
|
109
81
|
isMissing: node.isMissing
|
|
110
|
-
});
|
|
82
|
+
}, node));
|
|
111
83
|
}
|
|
112
84
|
number(node) {
|
|
113
|
-
const position = CstVisitor.toPosition(node);
|
|
114
85
|
const value = node.text;
|
|
115
|
-
return new _apidomAst.JsonNumber({
|
|
86
|
+
return new _apidomAst.JsonNumber((0, _apidomCore.assignSourceMap)({
|
|
116
87
|
value,
|
|
117
|
-
position,
|
|
118
88
|
isMissing: node.isMissing
|
|
119
|
-
});
|
|
89
|
+
}, node));
|
|
120
90
|
}
|
|
121
91
|
|
|
122
92
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
123
93
|
null(node) {
|
|
124
|
-
const position = CstVisitor.toPosition(node);
|
|
125
94
|
const value = node.text;
|
|
126
|
-
return new _apidomAst.JsonNull({
|
|
95
|
+
return new _apidomAst.JsonNull((0, _apidomCore.assignSourceMap)({
|
|
127
96
|
value,
|
|
128
|
-
position,
|
|
129
97
|
isMissing: node.isMissing
|
|
130
|
-
});
|
|
98
|
+
}, node));
|
|
131
99
|
}
|
|
132
100
|
|
|
133
101
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
134
102
|
true(node) {
|
|
135
|
-
const position = CstVisitor.toPosition(node);
|
|
136
103
|
const value = node.text;
|
|
137
|
-
return new _apidomAst.JsonTrue({
|
|
104
|
+
return new _apidomAst.JsonTrue((0, _apidomCore.assignSourceMap)({
|
|
138
105
|
value,
|
|
139
|
-
position,
|
|
140
106
|
isMissing: node.isMissing
|
|
141
|
-
});
|
|
107
|
+
}, node));
|
|
142
108
|
}
|
|
143
109
|
|
|
144
110
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
145
111
|
false(node) {
|
|
146
|
-
const position = CstVisitor.toPosition(node);
|
|
147
112
|
const value = node.text;
|
|
148
|
-
return new _apidomAst.JsonFalse({
|
|
113
|
+
return new _apidomAst.JsonFalse((0, _apidomCore.assignSourceMap)({
|
|
149
114
|
value,
|
|
150
|
-
position,
|
|
151
115
|
isMissing: node.isMissing
|
|
152
|
-
});
|
|
116
|
+
}, node));
|
|
153
117
|
}
|
|
154
118
|
ERROR(node, key, parent, path) {
|
|
155
|
-
const
|
|
156
|
-
const errorNode = new _apidomAst.Error({
|
|
119
|
+
const errorNode = new _apidomAst.Error((0, _apidomCore.assignSourceMap)({
|
|
157
120
|
children: node.children,
|
|
158
|
-
position,
|
|
159
121
|
isUnexpected: !node.hasError,
|
|
160
122
|
isMissing: node.isMissing,
|
|
161
123
|
value: node.text
|
|
162
|
-
});
|
|
124
|
+
}, node));
|
|
163
125
|
if (path.length === 0) {
|
|
164
126
|
return new _apidomAst.ParseResult({
|
|
165
127
|
children: [errorNode]
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { JsonArray, JsonDocument, JsonFalse, JsonNull, JsonNumber, JsonObject, JsonKey, JsonProperty, JsonString, JsonStringContent, JsonTrue, ParseResult,
|
|
1
|
+
import { JsonArray, JsonDocument, JsonFalse, JsonNull, JsonNumber, JsonObject, JsonKey, JsonProperty, JsonString, JsonStringContent, JsonTrue, ParseResult, Literal, Error } from '@swagger-api/apidom-ast';
|
|
2
|
+
import { assignSourceMap } from '@swagger-api/apidom-core';
|
|
2
3
|
import TreeCursorSyntaxNode from "../../TreeCursorSyntaxNode.mjs";
|
|
3
4
|
export const keyMap = {
|
|
4
5
|
document: ['children'],
|
|
@@ -13,30 +14,12 @@ export const keyMap = {
|
|
|
13
14
|
/* eslint-disable class-methods-use-this */
|
|
14
15
|
|
|
15
16
|
class CstVisitor {
|
|
16
|
-
static toPosition(node) {
|
|
17
|
-
const start = new Point({
|
|
18
|
-
row: node.startPosition.row,
|
|
19
|
-
column: node.startPosition.column,
|
|
20
|
-
char: node.startIndex
|
|
21
|
-
});
|
|
22
|
-
const end = new Point({
|
|
23
|
-
row: node.endPosition.row,
|
|
24
|
-
column: node.endPosition.column,
|
|
25
|
-
char: node.endIndex
|
|
26
|
-
});
|
|
27
|
-
return new Position({
|
|
28
|
-
start,
|
|
29
|
-
end
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
17
|
document = {
|
|
33
18
|
enter: node => {
|
|
34
|
-
|
|
35
|
-
return new JsonDocument({
|
|
19
|
+
return new JsonDocument(assignSourceMap({
|
|
36
20
|
children: node.children,
|
|
37
|
-
position,
|
|
38
21
|
isMissing: node.isMissing
|
|
39
|
-
});
|
|
22
|
+
}, node));
|
|
40
23
|
},
|
|
41
24
|
leave: document => {
|
|
42
25
|
return new ParseResult({
|
|
@@ -47,114 +30,93 @@ class CstVisitor {
|
|
|
47
30
|
enter(node) {
|
|
48
31
|
// anonymous literals from CST transformed into AST literal nodes
|
|
49
32
|
if (node instanceof TreeCursorSyntaxNode && !node.isNamed) {
|
|
50
|
-
const position = CstVisitor.toPosition(node);
|
|
51
33
|
const value = node.type || node.text;
|
|
52
34
|
const {
|
|
53
35
|
isMissing
|
|
54
36
|
} = node;
|
|
55
|
-
return new Literal({
|
|
37
|
+
return new Literal(assignSourceMap({
|
|
56
38
|
value,
|
|
57
|
-
position,
|
|
58
39
|
isMissing
|
|
59
|
-
});
|
|
40
|
+
}, node));
|
|
60
41
|
}
|
|
61
42
|
return undefined;
|
|
62
43
|
}
|
|
63
44
|
object(node) {
|
|
64
|
-
|
|
65
|
-
return new JsonObject({
|
|
45
|
+
return new JsonObject(assignSourceMap({
|
|
66
46
|
children: node.children,
|
|
67
|
-
position,
|
|
68
47
|
isMissing: node.isMissing
|
|
69
|
-
});
|
|
48
|
+
}, node));
|
|
70
49
|
}
|
|
71
50
|
pair(node) {
|
|
72
|
-
const position = CstVisitor.toPosition(node);
|
|
73
51
|
const children = node.children.slice(1);
|
|
74
52
|
const {
|
|
75
53
|
keyNode
|
|
76
54
|
} = node;
|
|
77
|
-
const key = new JsonKey({
|
|
55
|
+
const key = new JsonKey(assignSourceMap({
|
|
78
56
|
children: (keyNode === null || keyNode === void 0 ? void 0 : keyNode.children) || [],
|
|
79
|
-
position: keyNode != null ? CstVisitor.toPosition(keyNode) : undefined,
|
|
80
57
|
isMissing: keyNode != null ? keyNode.isMissing : false
|
|
81
|
-
});
|
|
82
|
-
return new JsonProperty({
|
|
58
|
+
}, keyNode));
|
|
59
|
+
return new JsonProperty(assignSourceMap({
|
|
83
60
|
children: [key, ...children],
|
|
84
|
-
position,
|
|
85
61
|
isMissing: node.isMissing
|
|
86
|
-
});
|
|
62
|
+
}, node));
|
|
87
63
|
}
|
|
88
64
|
array(node) {
|
|
89
|
-
|
|
90
|
-
return new JsonArray({
|
|
65
|
+
return new JsonArray(assignSourceMap({
|
|
91
66
|
children: node.children,
|
|
92
|
-
position,
|
|
93
67
|
isMissing: node.isMissing
|
|
94
|
-
});
|
|
68
|
+
}, node));
|
|
95
69
|
}
|
|
96
70
|
string(node) {
|
|
97
|
-
const position = CstVisitor.toPosition(node);
|
|
98
71
|
const content = new JsonStringContent({
|
|
99
72
|
value: JSON.parse(node.text)
|
|
100
73
|
});
|
|
101
|
-
return new JsonString({
|
|
74
|
+
return new JsonString(assignSourceMap({
|
|
102
75
|
children: [content],
|
|
103
|
-
position,
|
|
104
76
|
isMissing: node.isMissing
|
|
105
|
-
});
|
|
77
|
+
}, node));
|
|
106
78
|
}
|
|
107
79
|
number(node) {
|
|
108
|
-
const position = CstVisitor.toPosition(node);
|
|
109
80
|
const value = node.text;
|
|
110
|
-
return new JsonNumber({
|
|
81
|
+
return new JsonNumber(assignSourceMap({
|
|
111
82
|
value,
|
|
112
|
-
position,
|
|
113
83
|
isMissing: node.isMissing
|
|
114
|
-
});
|
|
84
|
+
}, node));
|
|
115
85
|
}
|
|
116
86
|
|
|
117
87
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
118
88
|
null(node) {
|
|
119
|
-
const position = CstVisitor.toPosition(node);
|
|
120
89
|
const value = node.text;
|
|
121
|
-
return new JsonNull({
|
|
90
|
+
return new JsonNull(assignSourceMap({
|
|
122
91
|
value,
|
|
123
|
-
position,
|
|
124
92
|
isMissing: node.isMissing
|
|
125
|
-
});
|
|
93
|
+
}, node));
|
|
126
94
|
}
|
|
127
95
|
|
|
128
96
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
129
97
|
true(node) {
|
|
130
|
-
const position = CstVisitor.toPosition(node);
|
|
131
98
|
const value = node.text;
|
|
132
|
-
return new JsonTrue({
|
|
99
|
+
return new JsonTrue(assignSourceMap({
|
|
133
100
|
value,
|
|
134
|
-
position,
|
|
135
101
|
isMissing: node.isMissing
|
|
136
|
-
});
|
|
102
|
+
}, node));
|
|
137
103
|
}
|
|
138
104
|
|
|
139
105
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
140
106
|
false(node) {
|
|
141
|
-
const position = CstVisitor.toPosition(node);
|
|
142
107
|
const value = node.text;
|
|
143
|
-
return new JsonFalse({
|
|
108
|
+
return new JsonFalse(assignSourceMap({
|
|
144
109
|
value,
|
|
145
|
-
position,
|
|
146
110
|
isMissing: node.isMissing
|
|
147
|
-
});
|
|
111
|
+
}, node));
|
|
148
112
|
}
|
|
149
113
|
ERROR(node, key, parent, path) {
|
|
150
|
-
const
|
|
151
|
-
const errorNode = new Error({
|
|
114
|
+
const errorNode = new Error(assignSourceMap({
|
|
152
115
|
children: node.children,
|
|
153
|
-
position,
|
|
154
116
|
isUnexpected: !node.hasError,
|
|
155
117
|
isMissing: node.isMissing,
|
|
156
118
|
value: node.text
|
|
157
|
-
});
|
|
119
|
+
}, node));
|
|
158
120
|
if (path.length === 0) {
|
|
159
121
|
return new ParseResult({
|
|
160
122
|
children: [errorNode]
|
|
@@ -166,12 +166,7 @@ class JsonAstVisitor {
|
|
|
166
166
|
if (!this.sourceMap) {
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
// @ts-ignore
|
|
171
|
-
sourceMap.position = node.position;
|
|
172
|
-
// @ts-ignore
|
|
173
|
-
sourceMap.astNode = node;
|
|
174
|
-
element.meta.set('sourceMap', sourceMap);
|
|
169
|
+
(0, _apidomCore.assignSourceMap)(element, node);
|
|
175
170
|
}
|
|
176
171
|
}
|
|
177
172
|
var _default = exports.default = JsonAstVisitor;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JsonArray, JsonDocument, JsonObject, JsonProperty, ParseResult, Error, isNode as isCSTNode, getNodeType as getCSTNodeType } from '@swagger-api/apidom-ast';
|
|
2
|
-
import { ParseResultElement, ObjectElement,
|
|
2
|
+
import { ParseResultElement, ObjectElement, MemberElement, ArrayElement, BooleanElement, NullElement, NumberElement, StringElement, AnnotationElement, isParseResultElement, isPrimitiveElement, isElement, keyMap as keyMapApiDOM, getNodeType as getNodeTypeApiDOM, assignSourceMap } from '@swagger-api/apidom-core';
|
|
3
3
|
export const keyMap = {
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
[ParseResult.type]: ['children'],
|
|
@@ -161,12 +161,7 @@ class JsonAstVisitor {
|
|
|
161
161
|
if (!this.sourceMap) {
|
|
162
162
|
return;
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
// @ts-ignore
|
|
166
|
-
sourceMap.position = node.position;
|
|
167
|
-
// @ts-ignore
|
|
168
|
-
sourceMap.astNode = node;
|
|
169
|
-
element.meta.set('sourceMap', sourceMap);
|
|
164
|
+
assignSourceMap(element, node);
|
|
170
165
|
}
|
|
171
166
|
}
|
|
172
167
|
export default JsonAstVisitor;
|