dot-language-support 2.2.2 → 2.2.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.
- package/.github/workflows/CD.yml +4 -1
- package/.github/workflows/CI.yml +4 -1
- package/.github/workflows/auto-merge.yaml +1 -1
- package/biome.json +50 -0
- package/lib/cjs/binder.d.ts +1 -1
- package/lib/cjs/binder.js +2 -5
- package/lib/cjs/checker.d.ts +1 -1
- package/lib/cjs/checker.js +34 -30
- package/lib/cjs/core.js +2 -3
- package/lib/cjs/error.js +3 -5
- package/lib/cjs/parser.d.ts +4 -61
- package/lib/cjs/parser.js +580 -616
- package/lib/cjs/scanner.d.ts +2 -13
- package/lib/cjs/scanner.js +316 -317
- package/lib/cjs/service/codeAction.d.ts +3 -3
- package/lib/cjs/service/codeAction.js +28 -32
- package/lib/cjs/service/colorProvider.d.ts +3 -3
- package/lib/cjs/service/colorProvider.js +13 -24
- package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
- package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +5 -6
- package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +3 -3
- package/lib/cjs/service/command/ChangeEdgeOpCommand.js +5 -8
- package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
- package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +12 -13
- package/lib/cjs/service/command/RemoveSemicolons.d.ts +4 -4
- package/lib/cjs/service/command/RemoveSemicolons.js +8 -11
- package/lib/cjs/service/command/common.d.ts +4 -4
- package/lib/cjs/service/command/common.js +12 -10
- package/lib/cjs/service/completion.d.ts +2 -2
- package/lib/cjs/service/completion.js +17 -18
- package/lib/cjs/service/hover.d.ts +2 -2
- package/lib/cjs/service/hover.js +12 -16
- package/lib/cjs/service/languageFacts.js +1 -6
- package/lib/cjs/service/reference.d.ts +2 -2
- package/lib/cjs/service/reference.js +4 -8
- package/lib/cjs/service/rename.d.ts +3 -3
- package/lib/cjs/service/rename.js +10 -8
- package/lib/cjs/service/service.d.ts +3 -3
- package/lib/cjs/service/service.js +7 -8
- package/lib/cjs/service/util.d.ts +1 -1
- package/lib/cjs/service/util.js +10 -13
- package/lib/cjs/service/validation.d.ts +3 -3
- package/lib/cjs/service/validation.js +1 -2
- package/lib/cjs/tester.js +1 -1
- package/lib/cjs/visitor.d.ts +1 -1
- package/lib/cjs/visitor.js +32 -34
- package/lib/esm/binder.d.ts +1 -1
- package/lib/esm/binder.js +1 -3
- package/lib/esm/checker.d.ts +1 -1
- package/lib/esm/checker.js +21 -16
- package/lib/esm/core.js +1 -1
- package/lib/esm/error.js +1 -3
- package/lib/esm/parser.d.ts +4 -61
- package/lib/esm/parser.js +320 -306
- package/lib/esm/scanner.d.ts +2 -13
- package/lib/esm/scanner.js +153 -152
- package/lib/esm/service/codeAction.d.ts +3 -3
- package/lib/esm/service/codeAction.js +26 -29
- package/lib/esm/service/colorProvider.d.ts +3 -3
- package/lib/esm/service/colorProvider.js +11 -21
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
- package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +4 -4
- package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +3 -3
- package/lib/esm/service/command/ChangeEdgeOpCommand.js +3 -5
- package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
- package/lib/esm/service/command/ConsolidateDescendantsCommand.js +11 -11
- package/lib/esm/service/command/RemoveSemicolons.d.ts +4 -4
- package/lib/esm/service/command/RemoveSemicolons.js +6 -8
- package/lib/esm/service/command/common.d.ts +4 -4
- package/lib/esm/service/command/common.js +7 -4
- package/lib/esm/service/completion.d.ts +2 -2
- package/lib/esm/service/completion.js +16 -16
- package/lib/esm/service/hover.d.ts +2 -2
- package/lib/esm/service/hover.js +8 -14
- package/lib/esm/service/languageFacts.js +1 -6
- package/lib/esm/service/reference.d.ts +2 -2
- package/lib/esm/service/reference.js +3 -6
- package/lib/esm/service/rename.d.ts +3 -3
- package/lib/esm/service/rename.js +9 -6
- package/lib/esm/service/service.d.ts +3 -3
- package/lib/esm/service/service.js +7 -7
- package/lib/esm/service/util.d.ts +1 -1
- package/lib/esm/service/util.js +5 -7
- package/lib/esm/service/validation.d.ts +3 -3
- package/lib/esm/service/validation.js +1 -1
- package/lib/esm/tester.js +1 -1
- package/lib/esm/visitor.d.ts +1 -1
- package/lib/esm/visitor.js +32 -33
- package/package.json +15 -10
package/lib/esm/scanner.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DiagnosticCategory, ScanError, SyntaxKind, TokenFlags } from "./types.js";
|
|
2
2
|
export interface Scanner {
|
|
3
3
|
readonly end: number;
|
|
4
4
|
readonly pos: number;
|
|
@@ -19,6 +19,7 @@ export declare function getTokenAsText(token: SyntaxKind): string | undefined;
|
|
|
19
19
|
export declare function getTextAsToken(token: string): SyntaxKind | undefined;
|
|
20
20
|
export type ErrorCallback = (message: string, category: DiagnosticCategory, sub: ScanError, length: number) => void;
|
|
21
21
|
export declare class DefaultScanner implements Scanner {
|
|
22
|
+
#private;
|
|
22
23
|
end: number;
|
|
23
24
|
pos: number;
|
|
24
25
|
startPos: number;
|
|
@@ -31,21 +32,9 @@ export declare class DefaultScanner implements Scanner {
|
|
|
31
32
|
onError: ErrorCallback | null;
|
|
32
33
|
setText(newText?: string, start?: number, length?: number): void;
|
|
33
34
|
setErrorCallback(cb: ErrorCallback | null): void;
|
|
34
|
-
private setTextPos;
|
|
35
35
|
scan(skipTrivia?: boolean): SyntaxKind;
|
|
36
|
-
private error;
|
|
37
|
-
private isWhiteSpaceSingleLine;
|
|
38
|
-
private isAtMultiLineCommentEnd;
|
|
39
|
-
private scanHashCommentTrivia;
|
|
40
|
-
private scanSingleLineCommentTrivia;
|
|
41
|
-
private scanMultiLineCommentTrivia;
|
|
42
|
-
private scanHtml;
|
|
43
|
-
private scanString;
|
|
44
|
-
private scanNumber;
|
|
45
|
-
private getIdentifierToken;
|
|
46
36
|
lookAhead<T extends SyntaxKind>(callback: () => T): T;
|
|
47
37
|
tryScan<T extends SyntaxKind>(callback: () => T): T;
|
|
48
|
-
private speculationHelper;
|
|
49
38
|
}
|
|
50
39
|
export declare function isIdentifierStart(ch: number): boolean;
|
|
51
40
|
export declare function skipTrivia(text: string, pos: number): number;
|
package/lib/esm/scanner.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { createMapFromTemplate } from "./core.js";
|
|
2
|
-
import { SyntaxKind, DiagnosticCategory } from "./types.js";
|
|
3
2
|
import { assertNever } from "./service/util.js";
|
|
3
|
+
import { DiagnosticCategory, SyntaxKind } from "./types.js";
|
|
4
4
|
const textToToken = createMapFromTemplate({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
5
|
+
digraph: SyntaxKind.DigraphKeyword,
|
|
6
|
+
graph: SyntaxKind.GraphKeyword,
|
|
7
|
+
edge: SyntaxKind.EdgeKeyword,
|
|
8
|
+
node: SyntaxKind.NodeKeyword,
|
|
9
|
+
strict: SyntaxKind.StrictKeyword,
|
|
10
|
+
subgraph: SyntaxKind.SubgraphKeyword,
|
|
11
|
+
n: SyntaxKind.CompassNorthToken,
|
|
12
|
+
ne: SyntaxKind.CompassNorthEastToken,
|
|
13
|
+
e: SyntaxKind.CompassEastToken,
|
|
14
|
+
se: SyntaxKind.CompassSouthEastToken,
|
|
15
|
+
s: SyntaxKind.CompassSouthToken,
|
|
16
|
+
sw: SyntaxKind.CompassSouthWestToken,
|
|
17
|
+
w: SyntaxKind.CompassWestToken,
|
|
18
|
+
nw: SyntaxKind.CompassNorthWestToken,
|
|
19
|
+
c: SyntaxKind.CompassCenterToken,
|
|
20
20
|
"+": SyntaxKind.PlusToken,
|
|
21
21
|
"=": SyntaxKind.EqualsToken,
|
|
22
22
|
"->": SyntaxKind.DirectedEdgeOp,
|
|
@@ -27,7 +27,7 @@ const textToToken = createMapFromTemplate({
|
|
|
27
27
|
"]": SyntaxKind.CloseBracketToken,
|
|
28
28
|
";": SyntaxKind.SemicolonToken,
|
|
29
29
|
":": SyntaxKind.ColonToken,
|
|
30
|
-
|
|
30
|
+
_: SyntaxKind.UnderscoreToken,
|
|
31
31
|
",": SyntaxKind.CommaToken,
|
|
32
32
|
"<": SyntaxKind.LessThan,
|
|
33
33
|
">": SyntaxKind.GreaterThan,
|
|
@@ -60,12 +60,12 @@ export class DefaultScanner {
|
|
|
60
60
|
setText(newText, start = 0, length) {
|
|
61
61
|
this.text = newText || "";
|
|
62
62
|
this.end = length === undefined ? this.text.length : start + length;
|
|
63
|
-
this
|
|
63
|
+
this.#setTextPos(start || 0);
|
|
64
64
|
}
|
|
65
65
|
setErrorCallback(cb) {
|
|
66
66
|
this.onError = cb;
|
|
67
67
|
}
|
|
68
|
-
setTextPos(textPos) {
|
|
68
|
+
#setTextPos(textPos) {
|
|
69
69
|
console.assert(textPos >= 0);
|
|
70
70
|
this.pos = textPos;
|
|
71
71
|
this.startPos = textPos;
|
|
@@ -81,7 +81,7 @@ export class DefaultScanner {
|
|
|
81
81
|
while (true) {
|
|
82
82
|
this.tokenPos = this.pos;
|
|
83
83
|
if (this.pos >= this.end) {
|
|
84
|
-
return this.token = SyntaxKind.EndOfFileToken;
|
|
84
|
+
return (this.token = SyntaxKind.EndOfFileToken);
|
|
85
85
|
}
|
|
86
86
|
let ch = this.text.charCodeAt(this.pos);
|
|
87
87
|
switch (ch) {
|
|
@@ -92,15 +92,15 @@ export class DefaultScanner {
|
|
|
92
92
|
this.pos++;
|
|
93
93
|
continue;
|
|
94
94
|
}
|
|
95
|
-
if (ch === 13
|
|
96
|
-
|
|
97
|
-
|
|
95
|
+
if (ch === 13 &&
|
|
96
|
+
this.pos + 1 < this.end &&
|
|
97
|
+
this.text.charCodeAt(this.pos + 1) === 10) {
|
|
98
98
|
this.pos += 2;
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
101
|
this.pos++;
|
|
102
102
|
}
|
|
103
|
-
return this.token = SyntaxKind.NewLineTrivia;
|
|
103
|
+
return (this.token = SyntaxKind.NewLineTrivia);
|
|
104
104
|
case 9:
|
|
105
105
|
case 11:
|
|
106
106
|
case 12:
|
|
@@ -109,58 +109,59 @@ export class DefaultScanner {
|
|
|
109
109
|
this.pos++;
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
|
-
while (this.pos < this.end &&
|
|
112
|
+
while (this.pos < this.end &&
|
|
113
|
+
this.#isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos)))
|
|
113
114
|
this.pos++;
|
|
114
|
-
return this.token = SyntaxKind.WhitespaceTrivia;
|
|
115
|
+
return (this.token = SyntaxKind.WhitespaceTrivia);
|
|
115
116
|
case 35: {
|
|
116
|
-
const content = this
|
|
117
|
+
const content = this.#scanHashCommentTrivia(skipTrivia);
|
|
117
118
|
if (skipTrivia)
|
|
118
119
|
continue;
|
|
119
120
|
this.tokenValue = content;
|
|
120
|
-
return this.token = SyntaxKind.HashCommentTrivia;
|
|
121
|
+
return (this.token = SyntaxKind.HashCommentTrivia);
|
|
121
122
|
}
|
|
122
123
|
case 47: {
|
|
123
124
|
if (this.pos + 1 < this.end) {
|
|
124
125
|
const nextChar = this.text.charCodeAt(this.pos + 1);
|
|
125
126
|
switch (nextChar) {
|
|
126
127
|
case 47: {
|
|
127
|
-
const commentContent = this
|
|
128
|
+
const commentContent = this.#scanSingleLineCommentTrivia(skipTrivia);
|
|
128
129
|
if (skipTrivia)
|
|
129
130
|
continue;
|
|
130
131
|
this.tokenValue = commentContent;
|
|
131
|
-
return this.token = SyntaxKind.SingleLineCommentTrivia;
|
|
132
|
+
return (this.token = SyntaxKind.SingleLineCommentTrivia);
|
|
132
133
|
}
|
|
133
134
|
case 42: {
|
|
134
|
-
const commentContent = this
|
|
135
|
+
const commentContent = this.#scanMultiLineCommentTrivia(skipTrivia);
|
|
135
136
|
if (skipTrivia)
|
|
136
137
|
continue;
|
|
137
138
|
this.tokenValue = commentContent;
|
|
138
|
-
return this.token = SyntaxKind.MultiLineCommentTrivia;
|
|
139
|
+
return (this.token = SyntaxKind.MultiLineCommentTrivia);
|
|
139
140
|
}
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
this
|
|
143
|
+
this.#error('Unexpected "/". Did you mean to start a comment like "/*" or "//"? If you wanted to use it as an identifier, put it in double quotes.', 0);
|
|
143
144
|
++this.pos;
|
|
144
145
|
break;
|
|
145
146
|
}
|
|
146
147
|
case 123:
|
|
147
148
|
this.pos++;
|
|
148
|
-
return this.token = SyntaxKind.OpenBraceToken;
|
|
149
|
+
return (this.token = SyntaxKind.OpenBraceToken);
|
|
149
150
|
case 125:
|
|
150
151
|
this.pos++;
|
|
151
|
-
return this.token = SyntaxKind.CloseBraceToken;
|
|
152
|
+
return (this.token = SyntaxKind.CloseBraceToken);
|
|
152
153
|
case 91:
|
|
153
154
|
this.pos++;
|
|
154
|
-
return this.token = SyntaxKind.OpenBracketToken;
|
|
155
|
+
return (this.token = SyntaxKind.OpenBracketToken);
|
|
155
156
|
case 93:
|
|
156
157
|
this.pos++;
|
|
157
|
-
return this.token = SyntaxKind.CloseBracketToken;
|
|
158
|
+
return (this.token = SyntaxKind.CloseBracketToken);
|
|
158
159
|
case 43:
|
|
159
160
|
this.pos++;
|
|
160
|
-
return this.token = SyntaxKind.PlusToken;
|
|
161
|
+
return (this.token = SyntaxKind.PlusToken);
|
|
161
162
|
case 61:
|
|
162
163
|
this.pos++;
|
|
163
|
-
return this.token = SyntaxKind.EqualsToken;
|
|
164
|
+
return (this.token = SyntaxKind.EqualsToken);
|
|
164
165
|
case 48:
|
|
165
166
|
case 49:
|
|
166
167
|
case 50:
|
|
@@ -172,15 +173,17 @@ export class DefaultScanner {
|
|
|
172
173
|
case 56:
|
|
173
174
|
case 57:
|
|
174
175
|
case 46:
|
|
175
|
-
this.tokenValue = this
|
|
176
|
-
return this.token = SyntaxKind.NumericIdentifier;
|
|
176
|
+
this.tokenValue = this.#scanNumber();
|
|
177
|
+
return (this.token = SyntaxKind.NumericIdentifier);
|
|
177
178
|
case 45: {
|
|
178
179
|
const nextChar = this.text.charCodeAt(this.pos + 1);
|
|
179
180
|
switch (nextChar) {
|
|
180
181
|
case 45:
|
|
181
|
-
|
|
182
|
+
this.pos += 2;
|
|
183
|
+
return (this.token = SyntaxKind.UndirectedEdgeOp);
|
|
182
184
|
case 62:
|
|
183
|
-
|
|
185
|
+
this.pos += 2;
|
|
186
|
+
return (this.token = SyntaxKind.DirectedEdgeOp);
|
|
184
187
|
case 48:
|
|
185
188
|
case 49:
|
|
186
189
|
case 50:
|
|
@@ -192,57 +195,58 @@ export class DefaultScanner {
|
|
|
192
195
|
case 56:
|
|
193
196
|
case 57:
|
|
194
197
|
case 46:
|
|
195
|
-
this.tokenValue = this
|
|
196
|
-
return this.token = SyntaxKind.NumericIdentifier;
|
|
197
|
-
default:
|
|
198
|
+
this.tokenValue = this.#scanNumber();
|
|
199
|
+
return (this.token = SyntaxKind.NumericIdentifier);
|
|
200
|
+
default: {
|
|
198
201
|
const chr = this.text.charAt(this.pos + 1);
|
|
199
|
-
this
|
|
202
|
+
this.#error(`Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`, 0);
|
|
200
203
|
break;
|
|
204
|
+
}
|
|
201
205
|
}
|
|
202
206
|
this.pos++;
|
|
203
207
|
break;
|
|
204
208
|
}
|
|
205
209
|
case 95:
|
|
206
210
|
this.pos++;
|
|
207
|
-
return this.token = SyntaxKind.UnderscoreToken;
|
|
211
|
+
return (this.token = SyntaxKind.UnderscoreToken);
|
|
208
212
|
case 59:
|
|
209
213
|
this.pos++;
|
|
210
|
-
return this.token = SyntaxKind.SemicolonToken;
|
|
214
|
+
return (this.token = SyntaxKind.SemicolonToken);
|
|
211
215
|
case 58:
|
|
212
216
|
this.pos++;
|
|
213
|
-
return this.token = SyntaxKind.ColonToken;
|
|
217
|
+
return (this.token = SyntaxKind.ColonToken);
|
|
214
218
|
case 44:
|
|
215
219
|
this.pos++;
|
|
216
|
-
return this.token = SyntaxKind.CommaToken;
|
|
220
|
+
return (this.token = SyntaxKind.CommaToken);
|
|
217
221
|
case 60:
|
|
218
|
-
this.tokenValue = this
|
|
219
|
-
return this.token = SyntaxKind.HtmlIdentifier;
|
|
222
|
+
this.tokenValue = this.#scanHtml();
|
|
223
|
+
return (this.token = SyntaxKind.HtmlIdentifier);
|
|
220
224
|
case 34:
|
|
221
|
-
this.tokenValue = this
|
|
222
|
-
return this.token = SyntaxKind.StringLiteral;
|
|
223
|
-
default:
|
|
224
|
-
{
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
this.pos++;
|
|
229
|
-
const value = this.text.substring(this.tokenPos, this.pos);
|
|
230
|
-
this.tokenValue = value;
|
|
231
|
-
return this.token = this.getIdentifierToken(value);
|
|
232
|
-
}
|
|
233
|
-
if (this.isWhiteSpaceSingleLine(ch)) {
|
|
225
|
+
this.tokenValue = this.#scanString();
|
|
226
|
+
return (this.token = SyntaxKind.StringLiteral);
|
|
227
|
+
default: {
|
|
228
|
+
if (isIdentifierStart(ch)) {
|
|
229
|
+
this.pos++;
|
|
230
|
+
while (this.pos < this.end &&
|
|
231
|
+
isIdentifierPart((ch = this.text.charCodeAt(this.pos))))
|
|
234
232
|
this.pos++;
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
233
|
+
const value = this.text.substring(this.tokenPos, this.pos);
|
|
234
|
+
this.tokenValue = value;
|
|
235
|
+
return (this.token = this.#getIdentifierToken(value));
|
|
236
|
+
}
|
|
237
|
+
if (this.#isWhiteSpaceSingleLine(ch)) {
|
|
239
238
|
this.pos++;
|
|
240
|
-
|
|
239
|
+
continue;
|
|
241
240
|
}
|
|
241
|
+
const chr = this.text.charAt(this.pos);
|
|
242
|
+
this.#error(`Unexpected "${chr}". Did you mean to start an identifier? Node names cannot start with "${chr}".`, 0);
|
|
243
|
+
this.pos++;
|
|
244
|
+
break;
|
|
245
|
+
}
|
|
242
246
|
}
|
|
243
247
|
}
|
|
244
248
|
}
|
|
245
|
-
error(message, sub, category = DiagnosticCategory.Error, errPos = this.pos, length = 0) {
|
|
249
|
+
#error(message, sub, category = DiagnosticCategory.Error, errPos = this.pos, length = 0) {
|
|
246
250
|
const cb = this.onError;
|
|
247
251
|
if (cb) {
|
|
248
252
|
const posSave = this.pos;
|
|
@@ -251,62 +255,62 @@ export class DefaultScanner {
|
|
|
251
255
|
this.pos = posSave;
|
|
252
256
|
}
|
|
253
257
|
}
|
|
254
|
-
isWhiteSpaceSingleLine(ch) {
|
|
255
|
-
return ch === 32 ||
|
|
258
|
+
#isWhiteSpaceSingleLine(ch) {
|
|
259
|
+
return (ch === 32 ||
|
|
256
260
|
ch === 9 ||
|
|
257
261
|
ch === 11 ||
|
|
258
262
|
ch === 12 ||
|
|
259
263
|
ch === 160 ||
|
|
260
264
|
ch === 133 ||
|
|
261
265
|
ch === 5760 ||
|
|
262
|
-
ch >= 8192 && ch <= 8203 ||
|
|
266
|
+
(ch >= 8192 && ch <= 8203) ||
|
|
263
267
|
ch === 8239 ||
|
|
264
268
|
ch === 8287 ||
|
|
265
269
|
ch === 12288 ||
|
|
266
|
-
ch === 65279;
|
|
270
|
+
ch === 65279);
|
|
267
271
|
}
|
|
268
|
-
isAtMultiLineCommentEnd(pos) {
|
|
269
|
-
return pos + 1 < this.end
|
|
270
|
-
|
|
271
|
-
|
|
272
|
+
#isAtMultiLineCommentEnd(pos) {
|
|
273
|
+
return (pos + 1 < this.end &&
|
|
274
|
+
this.text.charCodeAt(pos) === 42 &&
|
|
275
|
+
this.text.charCodeAt(pos + 1) === 47);
|
|
272
276
|
}
|
|
273
|
-
scanHashCommentTrivia(skip) {
|
|
277
|
+
#scanHashCommentTrivia(skip) {
|
|
274
278
|
++this.pos;
|
|
275
279
|
const start = this.pos;
|
|
276
280
|
while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
|
|
277
281
|
this.pos++;
|
|
278
282
|
return skip ? undefined : this.text.substring(start, this.pos);
|
|
279
283
|
}
|
|
280
|
-
scanSingleLineCommentTrivia(skip) {
|
|
284
|
+
#scanSingleLineCommentTrivia(skip) {
|
|
281
285
|
this.pos += 2;
|
|
282
286
|
const start = this.pos;
|
|
283
287
|
while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
|
|
284
288
|
this.pos++;
|
|
285
289
|
return skip ? undefined : this.text.substring(start, this.pos);
|
|
286
290
|
}
|
|
287
|
-
scanMultiLineCommentTrivia(skip) {
|
|
291
|
+
#scanMultiLineCommentTrivia(skip) {
|
|
288
292
|
this.pos += 2;
|
|
289
293
|
const start = this.pos;
|
|
290
|
-
while (this.pos < this.end && !this
|
|
294
|
+
while (this.pos < this.end && !this.#isAtMultiLineCommentEnd(this.pos))
|
|
291
295
|
this.pos++;
|
|
292
296
|
const commentEnd = this.pos;
|
|
293
|
-
if (this
|
|
297
|
+
if (this.#isAtMultiLineCommentEnd(this.pos)) {
|
|
294
298
|
this.pos += 2;
|
|
295
299
|
}
|
|
296
300
|
return skip ? undefined : this.text.substring(start, commentEnd);
|
|
297
301
|
}
|
|
298
|
-
scanHtml() {
|
|
302
|
+
#scanHtml() {
|
|
299
303
|
const htmlOpen = this.text.charCodeAt(this.pos);
|
|
300
304
|
this.pos++;
|
|
301
305
|
let result = "";
|
|
302
|
-
|
|
306
|
+
const start = this.pos;
|
|
303
307
|
let subTagsLevel = 0;
|
|
304
308
|
while (true) {
|
|
305
309
|
if (this.pos >= this.end) {
|
|
306
310
|
result += this.text.substring(start, this.pos);
|
|
307
311
|
this.tokenFlags |= 2;
|
|
308
312
|
this.isUnterminated = true;
|
|
309
|
-
this
|
|
313
|
+
this.#error("Unterminated html literal", 1);
|
|
310
314
|
break;
|
|
311
315
|
}
|
|
312
316
|
const ch = this.text.charCodeAt(this.pos);
|
|
@@ -322,27 +326,25 @@ export class DefaultScanner {
|
|
|
322
326
|
result += this.text.substring(start, this.pos);
|
|
323
327
|
break;
|
|
324
328
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
continue;
|
|
328
|
-
}
|
|
329
|
+
--subTagsLevel;
|
|
330
|
+
continue;
|
|
329
331
|
}
|
|
330
332
|
this.pos++;
|
|
331
333
|
}
|
|
332
334
|
return result;
|
|
333
335
|
}
|
|
334
|
-
scanString(allowEscapes = true) {
|
|
336
|
+
#scanString(allowEscapes = true) {
|
|
335
337
|
const quote = this.text.charCodeAt(this.pos);
|
|
336
338
|
this.pos++;
|
|
337
339
|
let result = "";
|
|
338
|
-
|
|
340
|
+
const start = this.pos;
|
|
339
341
|
let hasBackslash = false;
|
|
340
342
|
while (true) {
|
|
341
343
|
if (this.pos >= this.end) {
|
|
342
344
|
result += this.text.substring(start, this.pos);
|
|
343
345
|
this.tokenFlags |= 2;
|
|
344
346
|
this.isUnterminated = true;
|
|
345
|
-
this
|
|
347
|
+
this.#error("Unterminated string", 1);
|
|
346
348
|
break;
|
|
347
349
|
}
|
|
348
350
|
const ch = this.text.charCodeAt(this.pos);
|
|
@@ -359,23 +361,21 @@ export class DefaultScanner {
|
|
|
359
361
|
this.pos++;
|
|
360
362
|
break;
|
|
361
363
|
}
|
|
362
|
-
|
|
364
|
+
if (isLineBreak(ch)) {
|
|
363
365
|
result += this.text.substring(start, this.pos);
|
|
364
366
|
this.tokenFlags |= 2;
|
|
365
367
|
this.isUnterminated = true;
|
|
366
|
-
this
|
|
368
|
+
this.#error("Unterminated string", 1);
|
|
367
369
|
break;
|
|
368
370
|
}
|
|
369
371
|
}
|
|
370
372
|
}
|
|
371
373
|
this.pos++;
|
|
372
374
|
}
|
|
373
|
-
const removedEscapes = result
|
|
374
|
-
.replace(/\\"/g, '"')
|
|
375
|
-
.replace(/\\(\r?\n)/g, '$1');
|
|
375
|
+
const removedEscapes = result.replace(/\\"/g, '"').replace(/\\(\r?\n)/g, "$1");
|
|
376
376
|
return removedEscapes;
|
|
377
377
|
}
|
|
378
|
-
scanNumber() {
|
|
378
|
+
#scanNumber() {
|
|
379
379
|
let result = "";
|
|
380
380
|
let hadDot = false;
|
|
381
381
|
let hadMinus = false;
|
|
@@ -416,12 +416,12 @@ export class DefaultScanner {
|
|
|
416
416
|
++this.pos;
|
|
417
417
|
}
|
|
418
418
|
}
|
|
419
|
-
getIdentifierToken(tokenValue) {
|
|
419
|
+
#getIdentifierToken(tokenValue) {
|
|
420
420
|
const len = tokenValue.length;
|
|
421
421
|
if (len >= 4 && len <= 8) {
|
|
422
422
|
const ch = tokenValue.charCodeAt(0);
|
|
423
|
-
if ((ch >= 97 && ch <= 122)
|
|
424
|
-
|
|
423
|
+
if ((ch >= 97 && ch <= 122) ||
|
|
424
|
+
(ch >= 65 && ch <= 90)) {
|
|
425
425
|
const lowerCaseToken = tokenValue.toLowerCase();
|
|
426
426
|
const t = textToToken.get(lowerCaseToken);
|
|
427
427
|
if (t !== undefined) {
|
|
@@ -430,15 +430,15 @@ export class DefaultScanner {
|
|
|
430
430
|
}
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
|
-
return this.token = SyntaxKind.TextIdentifier;
|
|
433
|
+
return (this.token = SyntaxKind.TextIdentifier);
|
|
434
434
|
}
|
|
435
435
|
lookAhead(callback) {
|
|
436
|
-
return this
|
|
436
|
+
return this.#speculationHelper(callback, true);
|
|
437
437
|
}
|
|
438
438
|
tryScan(callback) {
|
|
439
|
-
return this
|
|
439
|
+
return this.#speculationHelper(callback, false);
|
|
440
440
|
}
|
|
441
|
-
speculationHelper(callback, isLookahead) {
|
|
441
|
+
#speculationHelper(callback, isLookahead) {
|
|
442
442
|
const savePos = this.pos;
|
|
443
443
|
const saveStartPos = this.startPos;
|
|
444
444
|
const saveTokenPos = this.tokenPos;
|
|
@@ -460,32 +460,33 @@ export class DefaultScanner {
|
|
|
460
460
|
function isIdentifierPartOf(ch, idType) {
|
|
461
461
|
switch (idType) {
|
|
462
462
|
case SyntaxKind.TextIdentifier:
|
|
463
|
-
return ch === 95
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
463
|
+
return (ch === 95 ||
|
|
464
|
+
(65 <= ch && ch <= 90) ||
|
|
465
|
+
(97 <= ch && ch <= 122) ||
|
|
466
|
+
(48 <= ch && ch <= 57));
|
|
467
467
|
case SyntaxKind.HtmlIdentifier:
|
|
468
|
-
return ch === 95
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
468
|
+
return (ch === 95 ||
|
|
469
|
+
ch === 60 ||
|
|
470
|
+
ch === 61 ||
|
|
471
|
+
ch === 34 ||
|
|
472
|
+
(65 <= ch && ch <= 90) ||
|
|
473
|
+
(97 <= ch && ch <= 122) ||
|
|
474
|
+
(48 <= ch && ch <= 57));
|
|
475
475
|
case SyntaxKind.StringLiteral:
|
|
476
|
-
return ch === 95
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
476
|
+
return (ch === 95 ||
|
|
477
|
+
ch === 92 ||
|
|
478
|
+
ch === 60 ||
|
|
479
|
+
ch === 61 ||
|
|
480
|
+
ch === 34 ||
|
|
481
|
+
(65 <= ch && ch <= 90) ||
|
|
482
|
+
(97 <= ch && ch <= 122) ||
|
|
483
|
+
(48 <= ch && ch <= 57));
|
|
484
484
|
case SyntaxKind.NumericIdentifier:
|
|
485
|
-
return ch === 45
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
default:
|
|
485
|
+
return (ch === 45 ||
|
|
486
|
+
ch === 46 ||
|
|
487
|
+
(48 <= ch && ch <= 57));
|
|
488
|
+
default:
|
|
489
|
+
return assertNever(idType);
|
|
489
490
|
}
|
|
490
491
|
}
|
|
491
492
|
function getIdentifierStart(ch) {
|
|
@@ -493,31 +494,31 @@ function getIdentifierStart(ch) {
|
|
|
493
494
|
return SyntaxKind.HtmlIdentifier;
|
|
494
495
|
if (ch === 34)
|
|
495
496
|
return SyntaxKind.StringLiteral;
|
|
496
|
-
if (ch === 95
|
|
497
|
-
|
|
498
|
-
|
|
497
|
+
if (ch === 95 ||
|
|
498
|
+
(65 <= ch && ch <= 90) ||
|
|
499
|
+
(97 <= ch && ch <= 122))
|
|
499
500
|
return SyntaxKind.TextIdentifier;
|
|
500
|
-
if (ch === 45
|
|
501
|
-
|
|
502
|
-
|
|
501
|
+
if (ch === 45 ||
|
|
502
|
+
ch === 46 ||
|
|
503
|
+
(48 <= ch && ch <= 57))
|
|
503
504
|
return SyntaxKind.NumericIdentifier;
|
|
504
505
|
return undefined;
|
|
505
506
|
}
|
|
506
507
|
export function isIdentifierStart(ch) {
|
|
507
|
-
return ch >= 65 && ch <= 90
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
508
|
+
return ((ch >= 65 && ch <= 90) ||
|
|
509
|
+
(ch >= 97 && ch <= 122) ||
|
|
510
|
+
(ch >= 48 && ch <= 57) ||
|
|
511
|
+
ch === 95 ||
|
|
512
|
+
ch === 60 ||
|
|
513
|
+
ch === 34);
|
|
513
514
|
}
|
|
514
515
|
function isIdentifierPart(ch) {
|
|
515
|
-
return ch >= 65 && ch <= 90
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
516
|
+
return ((ch >= 65 && ch <= 90) ||
|
|
517
|
+
(ch >= 97 && ch <= 122) ||
|
|
518
|
+
(ch >= 48 && ch <= 57) ||
|
|
519
|
+
ch === 36 ||
|
|
520
|
+
ch === 95 ||
|
|
521
|
+
ch > 127);
|
|
521
522
|
}
|
|
522
523
|
export function skipTrivia(text, pos) {
|
|
523
524
|
while (true) {
|
|
@@ -559,7 +560,8 @@ export function skipTrivia(text, pos) {
|
|
|
559
560
|
case 42: {
|
|
560
561
|
pos += 2;
|
|
561
562
|
while (pos < text.length) {
|
|
562
|
-
if (text.charCodeAt(pos) === 42 &&
|
|
563
|
+
if (text.charCodeAt(pos) === 42 &&
|
|
564
|
+
text.charCodeAt(pos + 1) === 47) {
|
|
563
565
|
pos += 2;
|
|
564
566
|
break;
|
|
565
567
|
}
|
|
@@ -575,7 +577,6 @@ export function skipTrivia(text, pos) {
|
|
|
575
577
|
}
|
|
576
578
|
}
|
|
577
579
|
export function isLineBreak(ch) {
|
|
578
|
-
return ch === 10
|
|
579
|
-
|| ch === 13;
|
|
580
|
+
return ch === 10 || ch === 13;
|
|
580
581
|
}
|
|
581
582
|
//# sourceMappingURL=scanner.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as lst from "vscode-languageserver-types";
|
|
2
|
-
import { DocumentLike, SourceFile
|
|
3
|
-
import { ExecutableCommand } from "./command/common.js";
|
|
2
|
+
import { type CommandApplication, type DocumentLike, type SourceFile } from "../index.js";
|
|
3
|
+
import { type ExecutableCommand } from "./command/common.js";
|
|
4
4
|
export declare function getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, _context?: lst.CodeActionContext): lst.Command[] | undefined;
|
|
5
5
|
export declare const enum CommandIds {
|
|
6
6
|
ChangeEdgeOp = "DOT.changeEdgeOp",
|
|
@@ -9,4 +9,4 @@ export declare const enum CommandIds {
|
|
|
9
9
|
RemoveSemicolons = "DOT.removeSemicolons"
|
|
10
10
|
}
|
|
11
11
|
export declare function getAvailableCommands(): string[];
|
|
12
|
-
export declare function executeCommand(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand): CommandApplication | undefined;
|
|
12
|
+
export declare function executeCommand(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;
|