dot-language-support 2.3.0 → 3.0.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 (109) hide show
  1. package/dist/index.d.ts +497 -0
  2. package/dist/index.js +3853 -0
  3. package/package.json +10 -11
  4. package/.github/dependabot.yml +0 -15
  5. package/.github/workflows/CD.yml +0 -37
  6. package/.github/workflows/CI.yml +0 -28
  7. package/.github/workflows/auto-merge.yaml +0 -26
  8. package/CITATION.cff +0 -14
  9. package/biome.json +0 -48
  10. package/lib/cjs/binder.d.ts +0 -2
  11. package/lib/cjs/binder.js +0 -297
  12. package/lib/cjs/checker.d.ts +0 -15
  13. package/lib/cjs/checker.js +0 -228
  14. package/lib/cjs/core.d.ts +0 -1
  15. package/lib/cjs/core.js +0 -13
  16. package/lib/cjs/error.d.ts +0 -3
  17. package/lib/cjs/error.js +0 -12
  18. package/lib/cjs/index.d.ts +0 -5
  19. package/lib/cjs/index.js +0 -22
  20. package/lib/cjs/parser.d.ts +0 -27
  21. package/lib/cjs/parser.js +0 -664
  22. package/lib/cjs/scanner.d.ts +0 -41
  23. package/lib/cjs/scanner.js +0 -578
  24. package/lib/cjs/service/codeAction.d.ts +0 -12
  25. package/lib/cjs/service/codeAction.js +0 -245
  26. package/lib/cjs/service/colorProvider.d.ts +0 -5
  27. package/lib/cjs/service/colorProvider.js +0 -91
  28. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  29. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -42
  30. package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  31. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +0 -67
  32. package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  33. package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +0 -87
  34. package/lib/cjs/service/command/RemoveSemicolons.d.ts +0 -10
  35. package/lib/cjs/service/command/RemoveSemicolons.js +0 -39
  36. package/lib/cjs/service/command/common.d.ts +0 -31
  37. package/lib/cjs/service/command/common.js +0 -33
  38. package/lib/cjs/service/completion.d.ts +0 -4
  39. package/lib/cjs/service/completion.js +0 -173
  40. package/lib/cjs/service/hover.d.ts +0 -4
  41. package/lib/cjs/service/hover.js +0 -142
  42. package/lib/cjs/service/languageFacts.d.ts +0 -683
  43. package/lib/cjs/service/languageFacts.js +0 -996
  44. package/lib/cjs/service/reference.d.ts +0 -5
  45. package/lib/cjs/service/reference.js +0 -67
  46. package/lib/cjs/service/rename.d.ts +0 -4
  47. package/lib/cjs/service/rename.js +0 -51
  48. package/lib/cjs/service/service.d.ts +0 -28
  49. package/lib/cjs/service/service.js +0 -38
  50. package/lib/cjs/service/util.d.ts +0 -11
  51. package/lib/cjs/service/util.js +0 -49
  52. package/lib/cjs/service/validation.d.ts +0 -4
  53. package/lib/cjs/service/validation.js +0 -23
  54. package/lib/cjs/tester.d.ts +0 -1
  55. package/lib/cjs/tester.js +0 -23
  56. package/lib/cjs/types.d.ts +0 -397
  57. package/lib/cjs/types.js +0 -74
  58. package/lib/cjs/visitor.d.ts +0 -2
  59. package/lib/cjs/visitor.js +0 -76
  60. package/lib/esm/binder.d.ts +0 -2
  61. package/lib/esm/binder.js +0 -294
  62. package/lib/esm/checker.d.ts +0 -15
  63. package/lib/esm/checker.js +0 -212
  64. package/lib/esm/core.d.ts +0 -1
  65. package/lib/esm/core.js +0 -10
  66. package/lib/esm/error.d.ts +0 -3
  67. package/lib/esm/error.js +0 -8
  68. package/lib/esm/index.d.ts +0 -5
  69. package/lib/esm/index.js +0 -6
  70. package/lib/esm/parser.d.ts +0 -27
  71. package/lib/esm/parser.js +0 -714
  72. package/lib/esm/scanner.d.ts +0 -41
  73. package/lib/esm/scanner.js +0 -581
  74. package/lib/esm/service/codeAction.d.ts +0 -12
  75. package/lib/esm/service/codeAction.js +0 -207
  76. package/lib/esm/service/colorProvider.d.ts +0 -5
  77. package/lib/esm/service/colorProvider.js +0 -54
  78. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +0 -10
  79. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +0 -38
  80. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +0 -10
  81. package/lib/esm/service/command/ChangeEdgeOpCommand.js +0 -30
  82. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +0 -10
  83. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +0 -83
  84. package/lib/esm/service/command/RemoveSemicolons.d.ts +0 -10
  85. package/lib/esm/service/command/RemoveSemicolons.js +0 -35
  86. package/lib/esm/service/command/common.d.ts +0 -31
  87. package/lib/esm/service/command/common.js +0 -25
  88. package/lib/esm/service/completion.d.ts +0 -4
  89. package/lib/esm/service/completion.js +0 -137
  90. package/lib/esm/service/hover.d.ts +0 -4
  91. package/lib/esm/service/hover.js +0 -135
  92. package/lib/esm/service/languageFacts.d.ts +0 -683
  93. package/lib/esm/service/languageFacts.js +0 -993
  94. package/lib/esm/service/reference.d.ts +0 -5
  95. package/lib/esm/service/reference.js +0 -63
  96. package/lib/esm/service/rename.d.ts +0 -4
  97. package/lib/esm/service/rename.js +0 -48
  98. package/lib/esm/service/service.d.ts +0 -28
  99. package/lib/esm/service/service.js +0 -35
  100. package/lib/esm/service/util.d.ts +0 -11
  101. package/lib/esm/service/util.js +0 -42
  102. package/lib/esm/service/validation.d.ts +0 -4
  103. package/lib/esm/service/validation.js +0 -20
  104. package/lib/esm/tester.d.ts +0 -1
  105. package/lib/esm/tester.js +0 -21
  106. package/lib/esm/types.d.ts +0 -397
  107. package/lib/esm/types.js +0 -71
  108. package/lib/esm/visitor.d.ts +0 -2
  109. package/lib/esm/visitor.js +0 -73
@@ -1,41 +0,0 @@
1
- import { DiagnosticCategory, ScanError, SyntaxKind, TokenFlags } from "./types.js";
2
- export interface Scanner {
3
- readonly end: number;
4
- readonly pos: number;
5
- readonly startPos: number;
6
- readonly tokenPos: number;
7
- readonly token: SyntaxKind;
8
- readonly tokenValue: string | undefined;
9
- readonly isUnterminated: boolean;
10
- readonly text: string;
11
- readonly onError: ErrorCallback | null;
12
- setText(newText?: string, start?: number, length?: number): void;
13
- setErrorCallback(cb: ErrorCallback): void;
14
- scan(skipTrivia: boolean): SyntaxKind;
15
- lookAhead(callback: () => SyntaxKind | boolean): SyntaxKind | boolean;
16
- tryScan(callback: () => SyntaxKind | boolean): SyntaxKind | boolean;
17
- }
18
- export declare function getTokenAsText(token: SyntaxKind): string | undefined;
19
- export declare function getTextAsToken(token: string): SyntaxKind | undefined;
20
- export type ErrorCallback = (message: string, category: DiagnosticCategory, sub: ScanError, length: number) => void;
21
- export declare class DefaultScanner implements Scanner {
22
- #private;
23
- end: number;
24
- pos: number;
25
- startPos: number;
26
- tokenPos: number;
27
- token: SyntaxKind;
28
- tokenValue: string | undefined;
29
- tokenFlags: TokenFlags;
30
- isUnterminated: boolean;
31
- text: string;
32
- onError: ErrorCallback | null;
33
- setText(newText?: string, start?: number, length?: number): void;
34
- setErrorCallback(cb: ErrorCallback | null): void;
35
- scan(skipTrivia?: boolean): SyntaxKind;
36
- lookAhead<T extends SyntaxKind>(callback: () => T): T;
37
- tryScan<T extends SyntaxKind>(callback: () => T): T;
38
- }
39
- export declare function isIdentifierStart(ch: number): boolean;
40
- export declare function skipTrivia(text: string, pos: number): number;
41
- export declare function isLineBreak(ch: number): boolean;
@@ -1,581 +0,0 @@
1
- import { createMapFromTemplate } from "./core.js";
2
- import { assertNever } from "./service/util.js";
3
- import { DiagnosticCategory, SyntaxKind } from "./types.js";
4
- const textToToken = createMapFromTemplate({
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
- "+": SyntaxKind.PlusToken,
21
- "=": SyntaxKind.EqualsToken,
22
- "->": SyntaxKind.DirectedEdgeOp,
23
- "--": SyntaxKind.UndirectedEdgeOp,
24
- "{": SyntaxKind.OpenBraceToken,
25
- "}": SyntaxKind.CloseBraceToken,
26
- "[": SyntaxKind.OpenBracketToken,
27
- "]": SyntaxKind.CloseBracketToken,
28
- ";": SyntaxKind.SemicolonToken,
29
- ":": SyntaxKind.ColonToken,
30
- _: SyntaxKind.UnderscoreToken,
31
- ",": SyntaxKind.CommaToken,
32
- "<": SyntaxKind.LessThan,
33
- ">": SyntaxKind.GreaterThan,
34
- });
35
- function makeReverseMap(source) {
36
- const result = new Map();
37
- source.forEach((value, key) => {
38
- result.set(value, key);
39
- });
40
- return result;
41
- }
42
- const tokenToText = makeReverseMap(textToToken);
43
- export function getTokenAsText(token) {
44
- return tokenToText.get(token);
45
- }
46
- export function getTextAsToken(token) {
47
- return textToToken.get(token);
48
- }
49
- export class DefaultScanner {
50
- end;
51
- pos;
52
- startPos;
53
- tokenPos;
54
- token;
55
- tokenValue;
56
- tokenFlags;
57
- isUnterminated;
58
- text;
59
- onError;
60
- setText(newText, start = 0, length) {
61
- this.text = newText || "";
62
- this.end = length === undefined ? this.text.length : start + length;
63
- this.#setTextPos(start || 0);
64
- }
65
- setErrorCallback(cb) {
66
- this.onError = cb;
67
- }
68
- #setTextPos(textPos) {
69
- console.assert(textPos >= 0);
70
- this.pos = textPos;
71
- this.startPos = textPos;
72
- this.tokenPos = textPos;
73
- this.token = SyntaxKind.Unknown;
74
- this.tokenValue = undefined;
75
- this.tokenFlags = 0;
76
- }
77
- scan(skipTrivia = true) {
78
- this.startPos = this.pos;
79
- this.tokenFlags = 0;
80
- this.isUnterminated = false;
81
- while (true) {
82
- this.tokenPos = this.pos;
83
- if (this.pos >= this.end) {
84
- return (this.token = SyntaxKind.EndOfFileToken);
85
- }
86
- let ch = this.text.charCodeAt(this.pos);
87
- switch (ch) {
88
- case 10:
89
- case 13:
90
- this.tokenFlags |= 4;
91
- if (skipTrivia) {
92
- this.pos++;
93
- continue;
94
- }
95
- if (ch === 13 &&
96
- this.pos + 1 < this.end &&
97
- this.text.charCodeAt(this.pos + 1) === 10) {
98
- this.pos += 2;
99
- }
100
- else {
101
- this.pos++;
102
- }
103
- return (this.token = SyntaxKind.NewLineTrivia);
104
- case 9:
105
- case 11:
106
- case 12:
107
- case 32:
108
- if (skipTrivia) {
109
- this.pos++;
110
- continue;
111
- }
112
- while (this.pos < this.end &&
113
- this.#isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos)))
114
- this.pos++;
115
- return (this.token = SyntaxKind.WhitespaceTrivia);
116
- case 35: {
117
- const content = this.#scanHashCommentTrivia(skipTrivia);
118
- if (skipTrivia)
119
- continue;
120
- this.tokenValue = content;
121
- return (this.token = SyntaxKind.HashCommentTrivia);
122
- }
123
- case 47: {
124
- if (this.pos + 1 < this.end) {
125
- const nextChar = this.text.charCodeAt(this.pos + 1);
126
- switch (nextChar) {
127
- case 47: {
128
- const commentContent = this.#scanSingleLineCommentTrivia(skipTrivia);
129
- if (skipTrivia)
130
- continue;
131
- this.tokenValue = commentContent;
132
- return (this.token = SyntaxKind.SingleLineCommentTrivia);
133
- }
134
- case 42: {
135
- const commentContent = this.#scanMultiLineCommentTrivia(skipTrivia);
136
- if (skipTrivia)
137
- continue;
138
- this.tokenValue = commentContent;
139
- return (this.token = SyntaxKind.MultiLineCommentTrivia);
140
- }
141
- }
142
- }
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);
144
- ++this.pos;
145
- break;
146
- }
147
- case 123:
148
- this.pos++;
149
- return (this.token = SyntaxKind.OpenBraceToken);
150
- case 125:
151
- this.pos++;
152
- return (this.token = SyntaxKind.CloseBraceToken);
153
- case 91:
154
- this.pos++;
155
- return (this.token = SyntaxKind.OpenBracketToken);
156
- case 93:
157
- this.pos++;
158
- return (this.token = SyntaxKind.CloseBracketToken);
159
- case 43:
160
- this.pos++;
161
- return (this.token = SyntaxKind.PlusToken);
162
- case 61:
163
- this.pos++;
164
- return (this.token = SyntaxKind.EqualsToken);
165
- case 48:
166
- case 49:
167
- case 50:
168
- case 51:
169
- case 52:
170
- case 53:
171
- case 54:
172
- case 55:
173
- case 56:
174
- case 57:
175
- case 46:
176
- this.tokenValue = this.#scanNumber();
177
- return (this.token = SyntaxKind.NumericIdentifier);
178
- case 45: {
179
- const nextChar = this.text.charCodeAt(this.pos + 1);
180
- switch (nextChar) {
181
- case 45:
182
- this.pos += 2;
183
- return (this.token = SyntaxKind.UndirectedEdgeOp);
184
- case 62:
185
- this.pos += 2;
186
- return (this.token = SyntaxKind.DirectedEdgeOp);
187
- case 48:
188
- case 49:
189
- case 50:
190
- case 51:
191
- case 52:
192
- case 53:
193
- case 54:
194
- case 55:
195
- case 56:
196
- case 57:
197
- case 46:
198
- this.tokenValue = this.#scanNumber();
199
- return (this.token = SyntaxKind.NumericIdentifier);
200
- default: {
201
- const chr = this.text.charAt(this.pos + 1);
202
- this.#error(`Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`, 0);
203
- break;
204
- }
205
- }
206
- this.pos++;
207
- break;
208
- }
209
- case 95:
210
- this.pos++;
211
- return (this.token = SyntaxKind.UnderscoreToken);
212
- case 59:
213
- this.pos++;
214
- return (this.token = SyntaxKind.SemicolonToken);
215
- case 58:
216
- this.pos++;
217
- return (this.token = SyntaxKind.ColonToken);
218
- case 44:
219
- this.pos++;
220
- return (this.token = SyntaxKind.CommaToken);
221
- case 60:
222
- this.tokenValue = this.#scanHtml();
223
- return (this.token = SyntaxKind.HtmlIdentifier);
224
- case 34:
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))))
232
- this.pos++;
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)) {
238
- this.pos++;
239
- continue;
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
- }
246
- }
247
- }
248
- }
249
- #error(message, sub, category = DiagnosticCategory.Error, errPos = this.pos, length = 0) {
250
- const cb = this.onError;
251
- if (cb) {
252
- const posSave = this.pos;
253
- this.pos = errPos;
254
- cb(message, category, sub, length);
255
- this.pos = posSave;
256
- }
257
- }
258
- #isWhiteSpaceSingleLine(ch) {
259
- return (ch === 32 ||
260
- ch === 9 ||
261
- ch === 11 ||
262
- ch === 12 ||
263
- ch === 160 ||
264
- ch === 133 ||
265
- ch === 5760 ||
266
- (ch >= 8192 && ch <= 8203) ||
267
- ch === 8239 ||
268
- ch === 8287 ||
269
- ch === 12288 ||
270
- ch === 65279);
271
- }
272
- #isAtMultiLineCommentEnd(pos) {
273
- return (pos + 1 < this.end &&
274
- this.text.charCodeAt(pos) === 42 &&
275
- this.text.charCodeAt(pos + 1) === 47);
276
- }
277
- #scanHashCommentTrivia(skip) {
278
- ++this.pos;
279
- const start = this.pos;
280
- while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
281
- this.pos++;
282
- return skip ? undefined : this.text.substring(start, this.pos);
283
- }
284
- #scanSingleLineCommentTrivia(skip) {
285
- this.pos += 2;
286
- const start = this.pos;
287
- while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
288
- this.pos++;
289
- return skip ? undefined : this.text.substring(start, this.pos);
290
- }
291
- #scanMultiLineCommentTrivia(skip) {
292
- this.pos += 2;
293
- const start = this.pos;
294
- while (this.pos < this.end && !this.#isAtMultiLineCommentEnd(this.pos))
295
- this.pos++;
296
- const commentEnd = this.pos;
297
- if (this.#isAtMultiLineCommentEnd(this.pos)) {
298
- this.pos += 2;
299
- }
300
- return skip ? undefined : this.text.substring(start, commentEnd);
301
- }
302
- #scanHtml() {
303
- this.pos++;
304
- let result = "";
305
- const start = this.pos;
306
- let subTagsLevel = 0;
307
- while (true) {
308
- if (this.pos >= this.end) {
309
- result += this.text.substring(start, this.pos);
310
- this.tokenFlags |= 2;
311
- this.isUnterminated = true;
312
- this.#error("Unterminated html literal", 1);
313
- break;
314
- }
315
- const ch = this.text.charCodeAt(this.pos);
316
- if (ch === 60) {
317
- ++subTagsLevel;
318
- this.pos++;
319
- continue;
320
- }
321
- if (ch === 62) {
322
- this.pos++;
323
- console.assert(subTagsLevel >= 0);
324
- if (subTagsLevel === 0) {
325
- result += this.text.substring(start, this.pos);
326
- break;
327
- }
328
- --subTagsLevel;
329
- continue;
330
- }
331
- this.pos++;
332
- }
333
- return result;
334
- }
335
- #scanString(allowEscapes = true) {
336
- const quote = this.text.charCodeAt(this.pos);
337
- this.pos++;
338
- let result = "";
339
- const start = this.pos;
340
- let hasBackslash = false;
341
- while (true) {
342
- if (this.pos >= this.end) {
343
- result += this.text.substring(start, this.pos);
344
- this.tokenFlags |= 2;
345
- this.isUnterminated = true;
346
- this.#error("Unterminated string", 1);
347
- break;
348
- }
349
- const ch = this.text.charCodeAt(this.pos);
350
- if (ch === 92) {
351
- hasBackslash = true;
352
- }
353
- else {
354
- if (hasBackslash) {
355
- hasBackslash = false;
356
- }
357
- else {
358
- if (ch === quote) {
359
- result += this.text.substring(start, this.pos);
360
- this.pos++;
361
- break;
362
- }
363
- if (isLineBreak(ch)) {
364
- result += this.text.substring(start, this.pos);
365
- this.tokenFlags |= 2;
366
- this.isUnterminated = true;
367
- this.#error("Unterminated string", 1);
368
- break;
369
- }
370
- }
371
- }
372
- this.pos++;
373
- }
374
- const removedEscapes = result.replace(/\\"/g, '"').replace(/\\(\r?\n)/g, "$1");
375
- return removedEscapes;
376
- }
377
- #scanNumber() {
378
- let result = "";
379
- let hadDot = false;
380
- let hadMinus = false;
381
- const start = this.pos;
382
- while (true) {
383
- const ch = this.text.charCodeAt(this.pos);
384
- switch (ch) {
385
- case 48:
386
- case 49:
387
- case 50:
388
- case 51:
389
- case 52:
390
- case 53:
391
- case 54:
392
- case 55:
393
- case 56:
394
- case 57:
395
- break;
396
- case 46:
397
- if (hadDot) {
398
- result += this.text.substring(start, this.pos);
399
- return result;
400
- }
401
- hadDot = true;
402
- hadMinus = true;
403
- break;
404
- case 45:
405
- if (this.pos !== start || hadMinus) {
406
- result += this.text.substring(start, this.pos);
407
- return result;
408
- }
409
- hadMinus = true;
410
- break;
411
- default:
412
- result += this.text.substring(start, this.pos);
413
- return result;
414
- }
415
- ++this.pos;
416
- }
417
- }
418
- #getIdentifierToken(tokenValue) {
419
- const len = tokenValue.length;
420
- if (len >= 4 && len <= 8) {
421
- const ch = tokenValue.charCodeAt(0);
422
- if ((ch >= 97 && ch <= 122) ||
423
- (ch >= 65 && ch <= 90)) {
424
- const lowerCaseToken = tokenValue.toLowerCase();
425
- const t = textToToken.get(lowerCaseToken);
426
- if (t !== undefined) {
427
- this.token = t;
428
- return t;
429
- }
430
- }
431
- }
432
- return (this.token = SyntaxKind.TextIdentifier);
433
- }
434
- lookAhead(callback) {
435
- return this.#speculationHelper(callback, true);
436
- }
437
- tryScan(callback) {
438
- return this.#speculationHelper(callback, false);
439
- }
440
- #speculationHelper(callback, isLookahead) {
441
- const savePos = this.pos;
442
- const saveStartPos = this.startPos;
443
- const saveTokenPos = this.tokenPos;
444
- const saveToken = this.token;
445
- const saveTokenValue = this.tokenValue;
446
- const saveTokenFlags = this.tokenFlags;
447
- const result = callback();
448
- if (!result || isLookahead) {
449
- this.pos = savePos;
450
- this.startPos = saveStartPos;
451
- this.tokenPos = saveTokenPos;
452
- this.token = saveToken;
453
- this.tokenValue = saveTokenValue;
454
- this.tokenFlags = saveTokenFlags;
455
- }
456
- return result;
457
- }
458
- }
459
- function isIdentifierPartOf(ch, idType) {
460
- switch (idType) {
461
- case SyntaxKind.TextIdentifier:
462
- return (ch === 95 ||
463
- (65 <= ch && ch <= 90) ||
464
- (97 <= ch && ch <= 122) ||
465
- (48 <= ch && ch <= 57));
466
- case SyntaxKind.HtmlIdentifier:
467
- return (ch === 95 ||
468
- ch === 60 ||
469
- ch === 61 ||
470
- ch === 34 ||
471
- (65 <= ch && ch <= 90) ||
472
- (97 <= ch && ch <= 122) ||
473
- (48 <= ch && ch <= 57));
474
- case SyntaxKind.StringLiteral:
475
- return (ch === 95 ||
476
- ch === 92 ||
477
- ch === 60 ||
478
- ch === 61 ||
479
- ch === 34 ||
480
- (65 <= ch && ch <= 90) ||
481
- (97 <= ch && ch <= 122) ||
482
- (48 <= ch && ch <= 57));
483
- case SyntaxKind.NumericIdentifier:
484
- return (ch === 45 ||
485
- ch === 46 ||
486
- (48 <= ch && ch <= 57));
487
- default:
488
- return assertNever(idType);
489
- }
490
- }
491
- function getIdentifierStart(ch) {
492
- if (ch === 60)
493
- return SyntaxKind.HtmlIdentifier;
494
- if (ch === 34)
495
- return SyntaxKind.StringLiteral;
496
- if (ch === 95 ||
497
- (65 <= ch && ch <= 90) ||
498
- (97 <= ch && ch <= 122))
499
- return SyntaxKind.TextIdentifier;
500
- if (ch === 45 ||
501
- ch === 46 ||
502
- (48 <= ch && ch <= 57))
503
- return SyntaxKind.NumericIdentifier;
504
- return undefined;
505
- }
506
- export function isIdentifierStart(ch) {
507
- return ((ch >= 65 && ch <= 90) ||
508
- (ch >= 97 && ch <= 122) ||
509
- (ch >= 48 && ch <= 57) ||
510
- ch === 95 ||
511
- ch === 60 ||
512
- ch === 34);
513
- }
514
- function isIdentifierPart(ch) {
515
- return ((ch >= 65 && ch <= 90) ||
516
- (ch >= 97 && ch <= 122) ||
517
- (ch >= 48 && ch <= 57) ||
518
- ch === 36 ||
519
- ch === 95 ||
520
- ch > 127);
521
- }
522
- export function skipTrivia(text, pos) {
523
- while (true) {
524
- const ch = text.charCodeAt(pos);
525
- switch (ch) {
526
- case 13:
527
- if (text.charCodeAt(pos + 1) === 10)
528
- ++pos;
529
- continue;
530
- case 10:
531
- case 9:
532
- case 11:
533
- case 12:
534
- case 32:
535
- ++pos;
536
- continue;
537
- case 35: {
538
- ++pos;
539
- while (pos < text.length) {
540
- if (isLineBreak(text.charCodeAt(pos)))
541
- break;
542
- ++pos;
543
- }
544
- continue;
545
- }
546
- case 47:
547
- if (pos + 1 < text.length) {
548
- const nextChar = text.charCodeAt(pos + 1);
549
- switch (nextChar) {
550
- case 47: {
551
- pos += 2;
552
- while (pos < text.length) {
553
- if (isLineBreak(text.charCodeAt(pos)))
554
- break;
555
- ++pos;
556
- }
557
- continue;
558
- }
559
- case 42: {
560
- pos += 2;
561
- while (pos < text.length) {
562
- if (text.charCodeAt(pos) === 42 &&
563
- text.charCodeAt(pos + 1) === 47) {
564
- pos += 2;
565
- break;
566
- }
567
- ++pos;
568
- }
569
- continue;
570
- }
571
- }
572
- }
573
- break;
574
- }
575
- return pos;
576
- }
577
- }
578
- export function isLineBreak(ch) {
579
- return ch === 10 || ch === 13;
580
- }
581
- //# sourceMappingURL=scanner.js.map
@@ -1,12 +0,0 @@
1
- import type * as lst from "vscode-languageserver-types";
2
- import { type CommandApplication, type DocumentLike, type SourceFile } from "../index.js";
3
- import { type ExecutableCommand } from "./command/common.js";
4
- export declare function getCodeActions(doc: DocumentLike, sourceFile: SourceFile, range: lst.Range, _context?: lst.CodeActionContext): lst.Command[] | undefined;
5
- export declare const enum CommandIds {
6
- ChangeEdgeOp = "DOT.changeEdgeOp",
7
- ConvertGraphType = "DOT.convertGraphType",
8
- ConsolidateDescendants = "DOT.consolidateDescendants",
9
- RemoveSemicolons = "DOT.removeSemicolons"
10
- }
11
- export declare function getAvailableCommands(): string[];
12
- export declare function executeCommand(doc: DocumentLike, sourceFile: SourceFile, cmd: ExecutableCommand<unknown[]>): CommandApplication | undefined;