dot-language-support 2.2.2 → 2.2.4

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 (89) hide show
  1. package/.github/workflows/CD.yml +5 -2
  2. package/.github/workflows/CI.yml +5 -2
  3. package/.github/workflows/auto-merge.yaml +1 -1
  4. package/biome.json +50 -0
  5. package/lib/cjs/binder.d.ts +1 -1
  6. package/lib/cjs/binder.js +2 -5
  7. package/lib/cjs/checker.d.ts +1 -1
  8. package/lib/cjs/checker.js +34 -30
  9. package/lib/cjs/core.js +2 -3
  10. package/lib/cjs/error.js +3 -5
  11. package/lib/cjs/parser.d.ts +4 -61
  12. package/lib/cjs/parser.js +580 -616
  13. package/lib/cjs/scanner.d.ts +2 -13
  14. package/lib/cjs/scanner.js +316 -317
  15. package/lib/cjs/service/codeAction.d.ts +3 -3
  16. package/lib/cjs/service/codeAction.js +45 -39
  17. package/lib/cjs/service/colorProvider.d.ts +3 -3
  18. package/lib/cjs/service/colorProvider.js +30 -31
  19. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
  20. package/lib/cjs/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +5 -6
  21. package/lib/cjs/service/command/ChangeEdgeOpCommand.d.ts +3 -3
  22. package/lib/cjs/service/command/ChangeEdgeOpCommand.js +22 -15
  23. package/lib/cjs/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
  24. package/lib/cjs/service/command/ConsolidateDescendantsCommand.js +12 -13
  25. package/lib/cjs/service/command/RemoveSemicolons.d.ts +4 -4
  26. package/lib/cjs/service/command/RemoveSemicolons.js +8 -11
  27. package/lib/cjs/service/command/common.d.ts +4 -4
  28. package/lib/cjs/service/command/common.js +12 -10
  29. package/lib/cjs/service/completion.d.ts +2 -2
  30. package/lib/cjs/service/completion.js +34 -25
  31. package/lib/cjs/service/hover.d.ts +2 -2
  32. package/lib/cjs/service/hover.js +12 -16
  33. package/lib/cjs/service/languageFacts.js +1 -6
  34. package/lib/cjs/service/reference.d.ts +2 -2
  35. package/lib/cjs/service/reference.js +4 -8
  36. package/lib/cjs/service/rename.d.ts +3 -3
  37. package/lib/cjs/service/rename.js +10 -8
  38. package/lib/cjs/service/service.d.ts +3 -3
  39. package/lib/cjs/service/service.js +7 -8
  40. package/lib/cjs/service/util.d.ts +1 -1
  41. package/lib/cjs/service/util.js +10 -13
  42. package/lib/cjs/service/validation.d.ts +3 -3
  43. package/lib/cjs/service/validation.js +1 -2
  44. package/lib/cjs/tester.js +1 -1
  45. package/lib/cjs/visitor.d.ts +1 -1
  46. package/lib/cjs/visitor.js +32 -34
  47. package/lib/esm/binder.d.ts +1 -1
  48. package/lib/esm/binder.js +1 -3
  49. package/lib/esm/checker.d.ts +1 -1
  50. package/lib/esm/checker.js +21 -16
  51. package/lib/esm/core.js +1 -1
  52. package/lib/esm/error.js +1 -3
  53. package/lib/esm/parser.d.ts +4 -61
  54. package/lib/esm/parser.js +320 -306
  55. package/lib/esm/scanner.d.ts +2 -13
  56. package/lib/esm/scanner.js +153 -152
  57. package/lib/esm/service/codeAction.d.ts +3 -3
  58. package/lib/esm/service/codeAction.js +26 -29
  59. package/lib/esm/service/colorProvider.d.ts +3 -3
  60. package/lib/esm/service/colorProvider.js +11 -21
  61. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.d.ts +4 -4
  62. package/lib/esm/service/command/ChangeAllOtherEdgeOpsAndFixGraphCommand.js +4 -4
  63. package/lib/esm/service/command/ChangeEdgeOpCommand.d.ts +3 -3
  64. package/lib/esm/service/command/ChangeEdgeOpCommand.js +3 -5
  65. package/lib/esm/service/command/ConsolidateDescendantsCommand.d.ts +4 -4
  66. package/lib/esm/service/command/ConsolidateDescendantsCommand.js +11 -11
  67. package/lib/esm/service/command/RemoveSemicolons.d.ts +4 -4
  68. package/lib/esm/service/command/RemoveSemicolons.js +6 -8
  69. package/lib/esm/service/command/common.d.ts +4 -4
  70. package/lib/esm/service/command/common.js +7 -4
  71. package/lib/esm/service/completion.d.ts +2 -2
  72. package/lib/esm/service/completion.js +16 -16
  73. package/lib/esm/service/hover.d.ts +2 -2
  74. package/lib/esm/service/hover.js +8 -14
  75. package/lib/esm/service/languageFacts.js +1 -6
  76. package/lib/esm/service/reference.d.ts +2 -2
  77. package/lib/esm/service/reference.js +3 -6
  78. package/lib/esm/service/rename.d.ts +3 -3
  79. package/lib/esm/service/rename.js +9 -6
  80. package/lib/esm/service/service.d.ts +3 -3
  81. package/lib/esm/service/service.js +7 -7
  82. package/lib/esm/service/util.d.ts +1 -1
  83. package/lib/esm/service/util.js +5 -7
  84. package/lib/esm/service/validation.d.ts +3 -3
  85. package/lib/esm/service/validation.js +1 -1
  86. package/lib/esm/tester.js +1 -1
  87. package/lib/esm/visitor.d.ts +1 -1
  88. package/lib/esm/visitor.js +32 -33
  89. package/package.json +15 -10
@@ -1,4 +1,4 @@
1
- import { SyntaxKind, TokenFlags, DiagnosticCategory, ScanError } from "./types.js";
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;
@@ -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
- "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,
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
- "_": SyntaxKind.UnderscoreToken,
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.setTextPos(start || 0);
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
- && this.pos + 1 < this.end
97
- && this.text.charCodeAt(this.pos + 1) === 10) {
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 && this.isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos)))
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.scanHashCommentTrivia(skipTrivia);
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.scanSingleLineCommentTrivia(skipTrivia);
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.scanMultiLineCommentTrivia(skipTrivia);
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.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
+ 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.scanNumber();
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
- return this.pos += 2, this.token = SyntaxKind.UndirectedEdgeOp;
182
+ this.pos += 2;
183
+ return (this.token = SyntaxKind.UndirectedEdgeOp);
182
184
  case 62:
183
- return this.pos += 2, this.token = SyntaxKind.DirectedEdgeOp;
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.scanNumber();
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.error(`Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`, 0);
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.scanHtml();
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.scanString();
222
- return this.token = SyntaxKind.StringLiteral;
223
- default:
224
- {
225
- if (isIdentifierStart(ch)) {
226
- this.pos++;
227
- while (this.pos < this.end && isIdentifierPart(ch = this.text.charCodeAt(this.pos)))
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
- continue;
236
- }
237
- const chr = this.text.charAt(this.pos);
238
- this.error(`Unexpected "${chr}". Did you mean to start an identifier? Node names cannot start with "${chr}".`, 0);
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
- break;
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
- && this.text.charCodeAt(pos) === 42
271
- && this.text.charCodeAt(pos + 1) === 47;
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.isAtMultiLineCommentEnd(this.pos))
294
+ while (this.pos < this.end && !this.#isAtMultiLineCommentEnd(this.pos))
291
295
  this.pos++;
292
296
  const commentEnd = this.pos;
293
- if (this.isAtMultiLineCommentEnd(this.pos)) {
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
- let start = this.pos;
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.error("Unterminated html literal", 1);
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
- else {
326
- --subTagsLevel;
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
- let start = this.pos;
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.error("Unterminated string", 1);
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
- else if (isLineBreak(ch)) {
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.error("Unterminated string", 1);
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
- || (ch >= 65 && ch <= 90)) {
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.speculationHelper(callback, true);
436
+ return this.#speculationHelper(callback, true);
437
437
  }
438
438
  tryScan(callback) {
439
- return this.speculationHelper(callback, false);
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
- || 65 <= ch && ch <= 90
465
- || 97 <= ch && ch <= 122
466
- || 48 <= ch && ch <= 57;
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
- || ch === 60
470
- || ch === 61
471
- || ch === 34
472
- || 65 <= ch && ch <= 90
473
- || 97 <= ch && ch <= 122
474
- || 48 <= ch && ch <= 57;
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
- || 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;
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
- || ch === 46
487
- || 48 <= ch && ch <= 57;
488
- default: return assertNever(idType);
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
- || 65 <= ch && ch <= 90
498
- || 97 <= ch && ch <= 122)
497
+ if (ch === 95 ||
498
+ (65 <= ch && ch <= 90) ||
499
+ (97 <= ch && ch <= 122))
499
500
  return SyntaxKind.TextIdentifier;
500
- if (ch === 45
501
- || ch === 46
502
- || 48 <= ch && ch <= 57)
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
- || ch >= 97 && ch <= 122
509
- || ch >= 48 && ch <= 57
510
- || ch === 95
511
- || ch === 60
512
- || ch === 34;
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
- || ch >= 97 && ch <= 122
517
- || ch >= 48 && ch <= 57
518
- || ch === 36
519
- || ch === 95
520
- || ch > 127;
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 && text.charCodeAt(pos + 1) === 47) {
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, CommandApplication } from "../index.js";
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;