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,25 +1,36 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _DefaultScanner_instances, _DefaultScanner_setTextPos, _DefaultScanner_error, _DefaultScanner_isWhiteSpaceSingleLine, _DefaultScanner_isAtMultiLineCommentEnd, _DefaultScanner_scanHashCommentTrivia, _DefaultScanner_scanSingleLineCommentTrivia, _DefaultScanner_scanMultiLineCommentTrivia, _DefaultScanner_scanHtml, _DefaultScanner_scanString, _DefaultScanner_scanNumber, _DefaultScanner_getIdentifierToken, _DefaultScanner_speculationHelper;
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isLineBreak = exports.skipTrivia = exports.isIdentifierStart = exports.DefaultScanner = exports.getTextAsToken = exports.getTokenAsText = void 0;
9
+ exports.DefaultScanner = void 0;
10
+ exports.getTokenAsText = getTokenAsText;
11
+ exports.getTextAsToken = getTextAsToken;
12
+ exports.isIdentifierStart = isIdentifierStart;
13
+ exports.skipTrivia = skipTrivia;
14
+ exports.isLineBreak = isLineBreak;
4
15
  const core_js_1 = require("./core.js");
5
- const types_js_1 = require("./types.js");
6
16
  const util_js_1 = require("./service/util.js");
17
+ const types_js_1 = require("./types.js");
7
18
  const textToToken = (0, core_js_1.createMapFromTemplate)({
8
- "digraph": types_js_1.SyntaxKind.DigraphKeyword,
9
- "graph": types_js_1.SyntaxKind.GraphKeyword,
10
- "edge": types_js_1.SyntaxKind.EdgeKeyword,
11
- "node": types_js_1.SyntaxKind.NodeKeyword,
12
- "strict": types_js_1.SyntaxKind.StrictKeyword,
13
- "subgraph": types_js_1.SyntaxKind.SubgraphKeyword,
14
- "n": types_js_1.SyntaxKind.CompassNorthToken,
15
- "ne": types_js_1.SyntaxKind.CompassNorthEastToken,
16
- "e": types_js_1.SyntaxKind.CompassEastToken,
17
- "se": types_js_1.SyntaxKind.CompassSouthEastToken,
18
- "s": types_js_1.SyntaxKind.CompassSouthToken,
19
- "sw": types_js_1.SyntaxKind.CompassSouthWestToken,
20
- "w": types_js_1.SyntaxKind.CompassWestToken,
21
- "nw": types_js_1.SyntaxKind.CompassNorthWestToken,
22
- "c": types_js_1.SyntaxKind.CompassCenterToken,
19
+ digraph: types_js_1.SyntaxKind.DigraphKeyword,
20
+ graph: types_js_1.SyntaxKind.GraphKeyword,
21
+ edge: types_js_1.SyntaxKind.EdgeKeyword,
22
+ node: types_js_1.SyntaxKind.NodeKeyword,
23
+ strict: types_js_1.SyntaxKind.StrictKeyword,
24
+ subgraph: types_js_1.SyntaxKind.SubgraphKeyword,
25
+ n: types_js_1.SyntaxKind.CompassNorthToken,
26
+ ne: types_js_1.SyntaxKind.CompassNorthEastToken,
27
+ e: types_js_1.SyntaxKind.CompassEastToken,
28
+ se: types_js_1.SyntaxKind.CompassSouthEastToken,
29
+ s: types_js_1.SyntaxKind.CompassSouthToken,
30
+ sw: types_js_1.SyntaxKind.CompassSouthWestToken,
31
+ w: types_js_1.SyntaxKind.CompassWestToken,
32
+ nw: types_js_1.SyntaxKind.CompassNorthWestToken,
33
+ c: types_js_1.SyntaxKind.CompassCenterToken,
23
34
  "+": types_js_1.SyntaxKind.PlusToken,
24
35
  "=": types_js_1.SyntaxKind.EqualsToken,
25
36
  "->": types_js_1.SyntaxKind.DirectedEdgeOp,
@@ -30,7 +41,7 @@ const textToToken = (0, core_js_1.createMapFromTemplate)({
30
41
  "]": types_js_1.SyntaxKind.CloseBracketToken,
31
42
  ";": types_js_1.SyntaxKind.SemicolonToken,
32
43
  ":": types_js_1.SyntaxKind.ColonToken,
33
- "_": types_js_1.SyntaxKind.UnderscoreToken,
44
+ _: types_js_1.SyntaxKind.UnderscoreToken,
34
45
  ",": types_js_1.SyntaxKind.CommaToken,
35
46
  "<": types_js_1.SyntaxKind.LessThan,
36
47
  ">": types_js_1.SyntaxKind.GreaterThan,
@@ -46,29 +57,21 @@ const tokenToText = makeReverseMap(textToToken);
46
57
  function getTokenAsText(token) {
47
58
  return tokenToText.get(token);
48
59
  }
49
- exports.getTokenAsText = getTokenAsText;
50
60
  function getTextAsToken(token) {
51
61
  return textToToken.get(token);
52
62
  }
53
- exports.getTextAsToken = getTextAsToken;
54
63
  class DefaultScanner {
64
+ constructor() {
65
+ _DefaultScanner_instances.add(this);
66
+ }
55
67
  setText(newText, start = 0, length) {
56
68
  this.text = newText || "";
57
69
  this.end = length === undefined ? this.text.length : start + length;
58
- this.setTextPos(start || 0);
70
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_setTextPos).call(this, start || 0);
59
71
  }
60
72
  setErrorCallback(cb) {
61
73
  this.onError = cb;
62
74
  }
63
- setTextPos(textPos) {
64
- console.assert(textPos >= 0);
65
- this.pos = textPos;
66
- this.startPos = textPos;
67
- this.tokenPos = textPos;
68
- this.token = types_js_1.SyntaxKind.Unknown;
69
- this.tokenValue = undefined;
70
- this.tokenFlags = 0;
71
- }
72
75
  scan(skipTrivia = true) {
73
76
  this.startPos = this.pos;
74
77
  this.tokenFlags = 0;
@@ -76,7 +79,7 @@ class DefaultScanner {
76
79
  while (true) {
77
80
  this.tokenPos = this.pos;
78
81
  if (this.pos >= this.end) {
79
- return this.token = types_js_1.SyntaxKind.EndOfFileToken;
82
+ return (this.token = types_js_1.SyntaxKind.EndOfFileToken);
80
83
  }
81
84
  let ch = this.text.charCodeAt(this.pos);
82
85
  switch (ch) {
@@ -87,15 +90,15 @@ class DefaultScanner {
87
90
  this.pos++;
88
91
  continue;
89
92
  }
90
- if (ch === 13
91
- && this.pos + 1 < this.end
92
- && this.text.charCodeAt(this.pos + 1) === 10) {
93
+ if (ch === 13 &&
94
+ this.pos + 1 < this.end &&
95
+ this.text.charCodeAt(this.pos + 1) === 10) {
93
96
  this.pos += 2;
94
97
  }
95
98
  else {
96
99
  this.pos++;
97
100
  }
98
- return this.token = types_js_1.SyntaxKind.NewLineTrivia;
101
+ return (this.token = types_js_1.SyntaxKind.NewLineTrivia);
99
102
  case 9:
100
103
  case 11:
101
104
  case 12:
@@ -104,58 +107,59 @@ class DefaultScanner {
104
107
  this.pos++;
105
108
  continue;
106
109
  }
107
- while (this.pos < this.end && this.isWhiteSpaceSingleLine(this.text.charCodeAt(this.pos)))
110
+ while (this.pos < this.end &&
111
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_isWhiteSpaceSingleLine).call(this, this.text.charCodeAt(this.pos)))
108
112
  this.pos++;
109
- return this.token = types_js_1.SyntaxKind.WhitespaceTrivia;
113
+ return (this.token = types_js_1.SyntaxKind.WhitespaceTrivia);
110
114
  case 35: {
111
- const content = this.scanHashCommentTrivia(skipTrivia);
115
+ const content = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanHashCommentTrivia).call(this, skipTrivia);
112
116
  if (skipTrivia)
113
117
  continue;
114
118
  this.tokenValue = content;
115
- return this.token = types_js_1.SyntaxKind.HashCommentTrivia;
119
+ return (this.token = types_js_1.SyntaxKind.HashCommentTrivia);
116
120
  }
117
121
  case 47: {
118
122
  if (this.pos + 1 < this.end) {
119
123
  const nextChar = this.text.charCodeAt(this.pos + 1);
120
124
  switch (nextChar) {
121
125
  case 47: {
122
- const commentContent = this.scanSingleLineCommentTrivia(skipTrivia);
126
+ const commentContent = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanSingleLineCommentTrivia).call(this, skipTrivia);
123
127
  if (skipTrivia)
124
128
  continue;
125
129
  this.tokenValue = commentContent;
126
- return this.token = types_js_1.SyntaxKind.SingleLineCommentTrivia;
130
+ return (this.token = types_js_1.SyntaxKind.SingleLineCommentTrivia);
127
131
  }
128
132
  case 42: {
129
- const commentContent = this.scanMultiLineCommentTrivia(skipTrivia);
133
+ const commentContent = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanMultiLineCommentTrivia).call(this, skipTrivia);
130
134
  if (skipTrivia)
131
135
  continue;
132
136
  this.tokenValue = commentContent;
133
- return this.token = types_js_1.SyntaxKind.MultiLineCommentTrivia;
137
+ return (this.token = types_js_1.SyntaxKind.MultiLineCommentTrivia);
134
138
  }
135
139
  }
136
140
  }
137
- 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);
141
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_error).call(this, '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);
138
142
  ++this.pos;
139
143
  break;
140
144
  }
141
145
  case 123:
142
146
  this.pos++;
143
- return this.token = types_js_1.SyntaxKind.OpenBraceToken;
147
+ return (this.token = types_js_1.SyntaxKind.OpenBraceToken);
144
148
  case 125:
145
149
  this.pos++;
146
- return this.token = types_js_1.SyntaxKind.CloseBraceToken;
150
+ return (this.token = types_js_1.SyntaxKind.CloseBraceToken);
147
151
  case 91:
148
152
  this.pos++;
149
- return this.token = types_js_1.SyntaxKind.OpenBracketToken;
153
+ return (this.token = types_js_1.SyntaxKind.OpenBracketToken);
150
154
  case 93:
151
155
  this.pos++;
152
- return this.token = types_js_1.SyntaxKind.CloseBracketToken;
156
+ return (this.token = types_js_1.SyntaxKind.CloseBracketToken);
153
157
  case 43:
154
158
  this.pos++;
155
- return this.token = types_js_1.SyntaxKind.PlusToken;
159
+ return (this.token = types_js_1.SyntaxKind.PlusToken);
156
160
  case 61:
157
161
  this.pos++;
158
- return this.token = types_js_1.SyntaxKind.EqualsToken;
162
+ return (this.token = types_js_1.SyntaxKind.EqualsToken);
159
163
  case 48:
160
164
  case 49:
161
165
  case 50:
@@ -167,15 +171,17 @@ class DefaultScanner {
167
171
  case 56:
168
172
  case 57:
169
173
  case 46:
170
- this.tokenValue = this.scanNumber();
171
- return this.token = types_js_1.SyntaxKind.NumericIdentifier;
174
+ this.tokenValue = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanNumber).call(this);
175
+ return (this.token = types_js_1.SyntaxKind.NumericIdentifier);
172
176
  case 45: {
173
177
  const nextChar = this.text.charCodeAt(this.pos + 1);
174
178
  switch (nextChar) {
175
179
  case 45:
176
- return this.pos += 2, this.token = types_js_1.SyntaxKind.UndirectedEdgeOp;
180
+ this.pos += 2;
181
+ return (this.token = types_js_1.SyntaxKind.UndirectedEdgeOp);
177
182
  case 62:
178
- return this.pos += 2, this.token = types_js_1.SyntaxKind.DirectedEdgeOp;
183
+ this.pos += 2;
184
+ return (this.token = types_js_1.SyntaxKind.DirectedEdgeOp);
179
185
  case 48:
180
186
  case 49:
181
187
  case 50:
@@ -187,301 +193,297 @@ class DefaultScanner {
187
193
  case 56:
188
194
  case 57:
189
195
  case 46:
190
- this.tokenValue = this.scanNumber();
191
- return this.token = types_js_1.SyntaxKind.NumericIdentifier;
192
- default:
196
+ this.tokenValue = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanNumber).call(this);
197
+ return (this.token = types_js_1.SyntaxKind.NumericIdentifier);
198
+ default: {
193
199
  const chr = this.text.charAt(this.pos + 1);
194
- this.error(`Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`, 0);
200
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_error).call(this, `Unexpected "${chr}". Did you mean to define an edge? Depending on the type of graph you are defining, use "->" or "--".`, 0);
195
201
  break;
202
+ }
196
203
  }
197
204
  this.pos++;
198
205
  break;
199
206
  }
200
207
  case 95:
201
208
  this.pos++;
202
- return this.token = types_js_1.SyntaxKind.UnderscoreToken;
209
+ return (this.token = types_js_1.SyntaxKind.UnderscoreToken);
203
210
  case 59:
204
211
  this.pos++;
205
- return this.token = types_js_1.SyntaxKind.SemicolonToken;
212
+ return (this.token = types_js_1.SyntaxKind.SemicolonToken);
206
213
  case 58:
207
214
  this.pos++;
208
- return this.token = types_js_1.SyntaxKind.ColonToken;
215
+ return (this.token = types_js_1.SyntaxKind.ColonToken);
209
216
  case 44:
210
217
  this.pos++;
211
- return this.token = types_js_1.SyntaxKind.CommaToken;
218
+ return (this.token = types_js_1.SyntaxKind.CommaToken);
212
219
  case 60:
213
- this.tokenValue = this.scanHtml();
214
- return this.token = types_js_1.SyntaxKind.HtmlIdentifier;
220
+ this.tokenValue = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanHtml).call(this);
221
+ return (this.token = types_js_1.SyntaxKind.HtmlIdentifier);
215
222
  case 34:
216
- this.tokenValue = this.scanString();
217
- return this.token = types_js_1.SyntaxKind.StringLiteral;
218
- default:
219
- {
220
- if (isIdentifierStart(ch)) {
221
- this.pos++;
222
- while (this.pos < this.end && isIdentifierPart(ch = this.text.charCodeAt(this.pos)))
223
- this.pos++;
224
- const value = this.text.substring(this.tokenPos, this.pos);
225
- this.tokenValue = value;
226
- return this.token = this.getIdentifierToken(value);
227
- }
228
- if (this.isWhiteSpaceSingleLine(ch)) {
223
+ this.tokenValue = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_scanString).call(this);
224
+ return (this.token = types_js_1.SyntaxKind.StringLiteral);
225
+ default: {
226
+ if (isIdentifierStart(ch)) {
227
+ this.pos++;
228
+ while (this.pos < this.end &&
229
+ isIdentifierPart((ch = this.text.charCodeAt(this.pos))))
229
230
  this.pos++;
230
- continue;
231
- }
232
- const chr = this.text.charAt(this.pos);
233
- this.error(`Unexpected "${chr}". Did you mean to start an identifier? Node names cannot start with "${chr}".`, 0);
231
+ const value = this.text.substring(this.tokenPos, this.pos);
232
+ this.tokenValue = value;
233
+ return (this.token = __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_getIdentifierToken).call(this, value));
234
+ }
235
+ if (__classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_isWhiteSpaceSingleLine).call(this, ch)) {
234
236
  this.pos++;
235
- break;
237
+ continue;
236
238
  }
239
+ const chr = this.text.charAt(this.pos);
240
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_error).call(this, `Unexpected "${chr}". Did you mean to start an identifier? Node names cannot start with "${chr}".`, 0);
241
+ this.pos++;
242
+ break;
243
+ }
237
244
  }
238
245
  }
239
246
  }
240
- error(message, sub, category = types_js_1.DiagnosticCategory.Error, errPos = this.pos, length = 0) {
241
- const cb = this.onError;
242
- if (cb) {
243
- const posSave = this.pos;
244
- this.pos = errPos;
245
- cb(message, category, sub, length);
246
- this.pos = posSave;
247
- }
248
- }
249
- isWhiteSpaceSingleLine(ch) {
250
- return ch === 32 ||
251
- ch === 9 ||
252
- ch === 11 ||
253
- ch === 12 ||
254
- ch === 160 ||
255
- ch === 133 ||
256
- ch === 5760 ||
257
- ch >= 8192 && ch <= 8203 ||
258
- ch === 8239 ||
259
- ch === 8287 ||
260
- ch === 12288 ||
261
- ch === 65279;
247
+ lookAhead(callback) {
248
+ return __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_speculationHelper).call(this, callback, true);
262
249
  }
263
- isAtMultiLineCommentEnd(pos) {
264
- return pos + 1 < this.end
265
- && this.text.charCodeAt(pos) === 42
266
- && this.text.charCodeAt(pos + 1) === 47;
250
+ tryScan(callback) {
251
+ return __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_speculationHelper).call(this, callback, false);
267
252
  }
268
- scanHashCommentTrivia(skip) {
269
- ++this.pos;
270
- const start = this.pos;
271
- while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
272
- this.pos++;
273
- return skip ? undefined : this.text.substring(start, this.pos);
253
+ }
254
+ exports.DefaultScanner = DefaultScanner;
255
+ _DefaultScanner_instances = new WeakSet(), _DefaultScanner_setTextPos = function _DefaultScanner_setTextPos(textPos) {
256
+ console.assert(textPos >= 0);
257
+ this.pos = textPos;
258
+ this.startPos = textPos;
259
+ this.tokenPos = textPos;
260
+ this.token = types_js_1.SyntaxKind.Unknown;
261
+ this.tokenValue = undefined;
262
+ this.tokenFlags = 0;
263
+ }, _DefaultScanner_error = function _DefaultScanner_error(message, sub, category = types_js_1.DiagnosticCategory.Error, errPos = this.pos, length = 0) {
264
+ const cb = this.onError;
265
+ if (cb) {
266
+ const posSave = this.pos;
267
+ this.pos = errPos;
268
+ cb(message, category, sub, length);
269
+ this.pos = posSave;
274
270
  }
275
- scanSingleLineCommentTrivia(skip) {
271
+ }, _DefaultScanner_isWhiteSpaceSingleLine = function _DefaultScanner_isWhiteSpaceSingleLine(ch) {
272
+ return (ch === 32 ||
273
+ ch === 9 ||
274
+ ch === 11 ||
275
+ ch === 12 ||
276
+ ch === 160 ||
277
+ ch === 133 ||
278
+ ch === 5760 ||
279
+ (ch >= 8192 && ch <= 8203) ||
280
+ ch === 8239 ||
281
+ ch === 8287 ||
282
+ ch === 12288 ||
283
+ ch === 65279);
284
+ }, _DefaultScanner_isAtMultiLineCommentEnd = function _DefaultScanner_isAtMultiLineCommentEnd(pos) {
285
+ return (pos + 1 < this.end &&
286
+ this.text.charCodeAt(pos) === 42 &&
287
+ this.text.charCodeAt(pos + 1) === 47);
288
+ }, _DefaultScanner_scanHashCommentTrivia = function _DefaultScanner_scanHashCommentTrivia(skip) {
289
+ ++this.pos;
290
+ const start = this.pos;
291
+ while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
292
+ this.pos++;
293
+ return skip ? undefined : this.text.substring(start, this.pos);
294
+ }, _DefaultScanner_scanSingleLineCommentTrivia = function _DefaultScanner_scanSingleLineCommentTrivia(skip) {
295
+ this.pos += 2;
296
+ const start = this.pos;
297
+ while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
298
+ this.pos++;
299
+ return skip ? undefined : this.text.substring(start, this.pos);
300
+ }, _DefaultScanner_scanMultiLineCommentTrivia = function _DefaultScanner_scanMultiLineCommentTrivia(skip) {
301
+ this.pos += 2;
302
+ const start = this.pos;
303
+ while (this.pos < this.end && !__classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_isAtMultiLineCommentEnd).call(this, this.pos))
304
+ this.pos++;
305
+ const commentEnd = this.pos;
306
+ if (__classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_isAtMultiLineCommentEnd).call(this, this.pos)) {
276
307
  this.pos += 2;
277
- const start = this.pos;
278
- while (this.pos < this.end && !isLineBreak(this.text.charCodeAt(this.pos)))
279
- this.pos++;
280
- return skip ? undefined : this.text.substring(start, this.pos);
281
308
  }
282
- scanMultiLineCommentTrivia(skip) {
283
- this.pos += 2;
284
- const start = this.pos;
285
- while (this.pos < this.end && !this.isAtMultiLineCommentEnd(this.pos))
309
+ return skip ? undefined : this.text.substring(start, commentEnd);
310
+ }, _DefaultScanner_scanHtml = function _DefaultScanner_scanHtml() {
311
+ const htmlOpen = this.text.charCodeAt(this.pos);
312
+ this.pos++;
313
+ let result = "";
314
+ const start = this.pos;
315
+ let subTagsLevel = 0;
316
+ while (true) {
317
+ if (this.pos >= this.end) {
318
+ result += this.text.substring(start, this.pos);
319
+ this.tokenFlags |= 2;
320
+ this.isUnterminated = true;
321
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_error).call(this, "Unterminated html literal", 1);
322
+ break;
323
+ }
324
+ const ch = this.text.charCodeAt(this.pos);
325
+ if (ch === 60) {
326
+ ++subTagsLevel;
286
327
  this.pos++;
287
- const commentEnd = this.pos;
288
- if (this.isAtMultiLineCommentEnd(this.pos)) {
289
- this.pos += 2;
328
+ continue;
290
329
  }
291
- return skip ? undefined : this.text.substring(start, commentEnd);
292
- }
293
- scanHtml() {
294
- const htmlOpen = this.text.charCodeAt(this.pos);
295
- this.pos++;
296
- let result = "";
297
- let start = this.pos;
298
- let subTagsLevel = 0;
299
- while (true) {
300
- if (this.pos >= this.end) {
330
+ if (ch === 62) {
331
+ this.pos++;
332
+ console.assert(subTagsLevel >= 0);
333
+ if (subTagsLevel === 0) {
301
334
  result += this.text.substring(start, this.pos);
302
- this.tokenFlags |= 2;
303
- this.isUnterminated = true;
304
- this.error("Unterminated html literal", 1);
305
335
  break;
306
336
  }
307
- const ch = this.text.charCodeAt(this.pos);
308
- if (ch === 60) {
309
- ++subTagsLevel;
310
- this.pos++;
311
- continue;
337
+ --subTagsLevel;
338
+ continue;
339
+ }
340
+ this.pos++;
341
+ }
342
+ return result;
343
+ }, _DefaultScanner_scanString = function _DefaultScanner_scanString(allowEscapes = true) {
344
+ const quote = this.text.charCodeAt(this.pos);
345
+ this.pos++;
346
+ let result = "";
347
+ const start = this.pos;
348
+ let hasBackslash = false;
349
+ while (true) {
350
+ if (this.pos >= this.end) {
351
+ result += this.text.substring(start, this.pos);
352
+ this.tokenFlags |= 2;
353
+ this.isUnterminated = true;
354
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_error).call(this, "Unterminated string", 1);
355
+ break;
356
+ }
357
+ const ch = this.text.charCodeAt(this.pos);
358
+ if (ch === 92) {
359
+ hasBackslash = true;
360
+ }
361
+ else {
362
+ if (hasBackslash) {
363
+ hasBackslash = false;
312
364
  }
313
- if (ch === 62) {
314
- this.pos++;
315
- console.assert(subTagsLevel >= 0);
316
- if (subTagsLevel === 0) {
365
+ else {
366
+ if (ch === quote) {
317
367
  result += this.text.substring(start, this.pos);
368
+ this.pos++;
318
369
  break;
319
370
  }
320
- else {
321
- --subTagsLevel;
322
- continue;
371
+ if (isLineBreak(ch)) {
372
+ result += this.text.substring(start, this.pos);
373
+ this.tokenFlags |= 2;
374
+ this.isUnterminated = true;
375
+ __classPrivateFieldGet(this, _DefaultScanner_instances, "m", _DefaultScanner_error).call(this, "Unterminated string", 1);
376
+ break;
323
377
  }
324
378
  }
325
- this.pos++;
326
379
  }
327
- return result;
328
- }
329
- scanString(allowEscapes = true) {
330
- const quote = this.text.charCodeAt(this.pos);
331
380
  this.pos++;
332
- let result = "";
333
- let start = this.pos;
334
- let hasBackslash = false;
335
- while (true) {
336
- if (this.pos >= this.end) {
337
- result += this.text.substring(start, this.pos);
338
- this.tokenFlags |= 2;
339
- this.isUnterminated = true;
340
- this.error("Unterminated string", 1);
381
+ }
382
+ const removedEscapes = result.replace(/\\"/g, '"').replace(/\\(\r?\n)/g, "$1");
383
+ return removedEscapes;
384
+ }, _DefaultScanner_scanNumber = function _DefaultScanner_scanNumber() {
385
+ let result = "";
386
+ let hadDot = false;
387
+ let hadMinus = false;
388
+ const start = this.pos;
389
+ while (true) {
390
+ const ch = this.text.charCodeAt(this.pos);
391
+ switch (ch) {
392
+ case 48:
393
+ case 49:
394
+ case 50:
395
+ case 51:
396
+ case 52:
397
+ case 53:
398
+ case 54:
399
+ case 55:
400
+ case 56:
401
+ case 57:
341
402
  break;
342
- }
343
- const ch = this.text.charCodeAt(this.pos);
344
- if (ch === 92) {
345
- hasBackslash = true;
346
- }
347
- else {
348
- if (hasBackslash) {
349
- hasBackslash = false;
350
- }
351
- else {
352
- if (ch === quote) {
353
- result += this.text.substring(start, this.pos);
354
- this.pos++;
355
- break;
356
- }
357
- else if (isLineBreak(ch)) {
358
- result += this.text.substring(start, this.pos);
359
- this.tokenFlags |= 2;
360
- this.isUnterminated = true;
361
- this.error("Unterminated string", 1);
362
- break;
363
- }
403
+ case 46:
404
+ if (hadDot) {
405
+ result += this.text.substring(start, this.pos);
406
+ return result;
364
407
  }
365
- }
366
- this.pos++;
367
- }
368
- const removedEscapes = result
369
- .replace(/\\"/g, '"')
370
- .replace(/\\(\r?\n)/g, '$1');
371
- return removedEscapes;
372
- }
373
- scanNumber() {
374
- let result = "";
375
- let hadDot = false;
376
- let hadMinus = false;
377
- const start = this.pos;
378
- while (true) {
379
- const ch = this.text.charCodeAt(this.pos);
380
- switch (ch) {
381
- case 48:
382
- case 49:
383
- case 50:
384
- case 51:
385
- case 52:
386
- case 53:
387
- case 54:
388
- case 55:
389
- case 56:
390
- case 57:
391
- break;
392
- case 46:
393
- if (hadDot) {
394
- result += this.text.substring(start, this.pos);
395
- return result;
396
- }
397
- hadDot = true;
398
- hadMinus = true;
399
- break;
400
- case 45:
401
- if (this.pos !== start || hadMinus) {
402
- result += this.text.substring(start, this.pos);
403
- return result;
404
- }
405
- hadMinus = true;
406
- break;
407
- default:
408
+ hadDot = true;
409
+ hadMinus = true;
410
+ break;
411
+ case 45:
412
+ if (this.pos !== start || hadMinus) {
408
413
  result += this.text.substring(start, this.pos);
409
414
  return result;
410
- }
411
- ++this.pos;
415
+ }
416
+ hadMinus = true;
417
+ break;
418
+ default:
419
+ result += this.text.substring(start, this.pos);
420
+ return result;
412
421
  }
422
+ ++this.pos;
413
423
  }
414
- getIdentifierToken(tokenValue) {
415
- const len = tokenValue.length;
416
- if (len >= 4 && len <= 8) {
417
- const ch = tokenValue.charCodeAt(0);
418
- if ((ch >= 97 && ch <= 122)
419
- || (ch >= 65 && ch <= 90)) {
420
- const lowerCaseToken = tokenValue.toLowerCase();
421
- const t = textToToken.get(lowerCaseToken);
422
- if (t !== undefined) {
423
- this.token = t;
424
- return t;
425
- }
424
+ }, _DefaultScanner_getIdentifierToken = function _DefaultScanner_getIdentifierToken(tokenValue) {
425
+ const len = tokenValue.length;
426
+ if (len >= 4 && len <= 8) {
427
+ const ch = tokenValue.charCodeAt(0);
428
+ if ((ch >= 97 && ch <= 122) ||
429
+ (ch >= 65 && ch <= 90)) {
430
+ const lowerCaseToken = tokenValue.toLowerCase();
431
+ const t = textToToken.get(lowerCaseToken);
432
+ if (t !== undefined) {
433
+ this.token = t;
434
+ return t;
426
435
  }
427
436
  }
428
- return this.token = types_js_1.SyntaxKind.TextIdentifier;
429
- }
430
- lookAhead(callback) {
431
- return this.speculationHelper(callback, true);
432
- }
433
- tryScan(callback) {
434
- return this.speculationHelper(callback, false);
435
437
  }
436
- speculationHelper(callback, isLookahead) {
437
- const savePos = this.pos;
438
- const saveStartPos = this.startPos;
439
- const saveTokenPos = this.tokenPos;
440
- const saveToken = this.token;
441
- const saveTokenValue = this.tokenValue;
442
- const saveTokenFlags = this.tokenFlags;
443
- const result = callback();
444
- if (!result || isLookahead) {
445
- this.pos = savePos;
446
- this.startPos = saveStartPos;
447
- this.tokenPos = saveTokenPos;
448
- this.token = saveToken;
449
- this.tokenValue = saveTokenValue;
450
- this.tokenFlags = saveTokenFlags;
451
- }
452
- return result;
438
+ return (this.token = types_js_1.SyntaxKind.TextIdentifier);
439
+ }, _DefaultScanner_speculationHelper = function _DefaultScanner_speculationHelper(callback, isLookahead) {
440
+ const savePos = this.pos;
441
+ const saveStartPos = this.startPos;
442
+ const saveTokenPos = this.tokenPos;
443
+ const saveToken = this.token;
444
+ const saveTokenValue = this.tokenValue;
445
+ const saveTokenFlags = this.tokenFlags;
446
+ const result = callback();
447
+ if (!result || isLookahead) {
448
+ this.pos = savePos;
449
+ this.startPos = saveStartPos;
450
+ this.tokenPos = saveTokenPos;
451
+ this.token = saveToken;
452
+ this.tokenValue = saveTokenValue;
453
+ this.tokenFlags = saveTokenFlags;
453
454
  }
454
- }
455
- exports.DefaultScanner = DefaultScanner;
455
+ return result;
456
+ };
456
457
  function isIdentifierPartOf(ch, idType) {
457
458
  switch (idType) {
458
459
  case types_js_1.SyntaxKind.TextIdentifier:
459
- return ch === 95
460
- || 65 <= ch && ch <= 90
461
- || 97 <= ch && ch <= 122
462
- || 48 <= ch && ch <= 57;
460
+ return (ch === 95 ||
461
+ (65 <= ch && ch <= 90) ||
462
+ (97 <= ch && ch <= 122) ||
463
+ (48 <= ch && ch <= 57));
463
464
  case types_js_1.SyntaxKind.HtmlIdentifier:
464
- return ch === 95
465
- || ch === 60
466
- || ch === 61
467
- || ch === 34
468
- || 65 <= ch && ch <= 90
469
- || 97 <= ch && ch <= 122
470
- || 48 <= ch && ch <= 57;
465
+ return (ch === 95 ||
466
+ ch === 60 ||
467
+ ch === 61 ||
468
+ ch === 34 ||
469
+ (65 <= ch && ch <= 90) ||
470
+ (97 <= ch && ch <= 122) ||
471
+ (48 <= ch && ch <= 57));
471
472
  case types_js_1.SyntaxKind.StringLiteral:
472
- return ch === 95
473
- || ch === 92
474
- || ch === 60
475
- || ch === 61
476
- || ch === 34
477
- || 65 <= ch && ch <= 90
478
- || 97 <= ch && ch <= 122
479
- || 48 <= ch && ch <= 57;
473
+ return (ch === 95 ||
474
+ ch === 92 ||
475
+ ch === 60 ||
476
+ ch === 61 ||
477
+ ch === 34 ||
478
+ (65 <= ch && ch <= 90) ||
479
+ (97 <= ch && ch <= 122) ||
480
+ (48 <= ch && ch <= 57));
480
481
  case types_js_1.SyntaxKind.NumericIdentifier:
481
- return ch === 45
482
- || ch === 46
483
- || 48 <= ch && ch <= 57;
484
- default: return (0, util_js_1.assertNever)(idType);
482
+ return (ch === 45 ||
483
+ ch === 46 ||
484
+ (48 <= ch && ch <= 57));
485
+ default:
486
+ return (0, util_js_1.assertNever)(idType);
485
487
  }
486
488
  }
487
489
  function getIdentifierStart(ch) {
@@ -489,32 +491,31 @@ function getIdentifierStart(ch) {
489
491
  return types_js_1.SyntaxKind.HtmlIdentifier;
490
492
  if (ch === 34)
491
493
  return types_js_1.SyntaxKind.StringLiteral;
492
- if (ch === 95
493
- || 65 <= ch && ch <= 90
494
- || 97 <= ch && ch <= 122)
494
+ if (ch === 95 ||
495
+ (65 <= ch && ch <= 90) ||
496
+ (97 <= ch && ch <= 122))
495
497
  return types_js_1.SyntaxKind.TextIdentifier;
496
- if (ch === 45
497
- || ch === 46
498
- || 48 <= ch && ch <= 57)
498
+ if (ch === 45 ||
499
+ ch === 46 ||
500
+ (48 <= ch && ch <= 57))
499
501
  return types_js_1.SyntaxKind.NumericIdentifier;
500
502
  return undefined;
501
503
  }
502
504
  function isIdentifierStart(ch) {
503
- return ch >= 65 && ch <= 90
504
- || ch >= 97 && ch <= 122
505
- || ch >= 48 && ch <= 57
506
- || ch === 95
507
- || ch === 60
508
- || ch === 34;
505
+ return ((ch >= 65 && ch <= 90) ||
506
+ (ch >= 97 && ch <= 122) ||
507
+ (ch >= 48 && ch <= 57) ||
508
+ ch === 95 ||
509
+ ch === 60 ||
510
+ ch === 34);
509
511
  }
510
- exports.isIdentifierStart = isIdentifierStart;
511
512
  function isIdentifierPart(ch) {
512
- return ch >= 65 && ch <= 90
513
- || ch >= 97 && ch <= 122
514
- || ch >= 48 && ch <= 57
515
- || ch === 36
516
- || ch === 95
517
- || ch > 127;
513
+ return ((ch >= 65 && ch <= 90) ||
514
+ (ch >= 97 && ch <= 122) ||
515
+ (ch >= 48 && ch <= 57) ||
516
+ ch === 36 ||
517
+ ch === 95 ||
518
+ ch > 127);
518
519
  }
519
520
  function skipTrivia(text, pos) {
520
521
  while (true) {
@@ -556,7 +557,8 @@ function skipTrivia(text, pos) {
556
557
  case 42: {
557
558
  pos += 2;
558
559
  while (pos < text.length) {
559
- if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
560
+ if (text.charCodeAt(pos) === 42 &&
561
+ text.charCodeAt(pos + 1) === 47) {
560
562
  pos += 2;
561
563
  break;
562
564
  }
@@ -571,10 +573,7 @@ function skipTrivia(text, pos) {
571
573
  return pos;
572
574
  }
573
575
  }
574
- exports.skipTrivia = skipTrivia;
575
576
  function isLineBreak(ch) {
576
- return ch === 10
577
- || ch === 13;
577
+ return ch === 10 || ch === 13;
578
578
  }
579
- exports.isLineBreak = isLineBreak;
580
579
  //# sourceMappingURL=scanner.js.map