vscode-css-languageservice 5.4.2 → 6.1.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 (83) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/beautify/beautify-css.js +11 -4
  4. package/lib/esm/cssLanguageService.d.ts +2 -1
  5. package/lib/esm/cssLanguageService.js +15 -17
  6. package/lib/esm/cssLanguageTypes.js +2 -2
  7. package/lib/esm/data/webCustomData.js +356 -232
  8. package/lib/esm/languageFacts/builtinData.js +15 -15
  9. package/lib/esm/languageFacts/colors.js +66 -69
  10. package/lib/esm/languageFacts/dataManager.js +38 -42
  11. package/lib/esm/languageFacts/dataProvider.js +17 -23
  12. package/lib/esm/languageFacts/entry.js +22 -23
  13. package/lib/esm/parser/cssErrors.js +5 -7
  14. package/lib/esm/parser/cssNodes.js +869 -1377
  15. package/lib/esm/parser/cssParser.js +419 -376
  16. package/lib/esm/parser/cssScanner.js +168 -175
  17. package/lib/esm/parser/cssSymbolScope.js +107 -137
  18. package/lib/esm/parser/lessParser.js +177 -202
  19. package/lib/esm/parser/lessScanner.js +22 -43
  20. package/lib/esm/parser/scssErrors.js +5 -7
  21. package/lib/esm/parser/scssParser.js +196 -208
  22. package/lib/esm/parser/scssScanner.js +33 -54
  23. package/lib/esm/services/cssCodeActions.js +36 -40
  24. package/lib/esm/services/cssCompletion.js +300 -395
  25. package/lib/esm/services/cssFolding.js +32 -35
  26. package/lib/esm/services/cssFormatter.js +22 -22
  27. package/lib/esm/services/cssHover.js +30 -33
  28. package/lib/esm/services/cssNavigation.js +260 -289
  29. package/lib/esm/services/cssSelectionRange.js +6 -6
  30. package/lib/esm/services/cssValidation.js +13 -16
  31. package/lib/esm/services/lessCompletion.js +351 -370
  32. package/lib/esm/services/lint.js +161 -175
  33. package/lib/esm/services/lintRules.js +20 -27
  34. package/lib/esm/services/lintUtil.js +19 -28
  35. package/lib/esm/services/pathCompletion.js +84 -158
  36. package/lib/esm/services/scssCompletion.js +283 -307
  37. package/lib/esm/services/scssNavigation.js +65 -137
  38. package/lib/esm/services/selectorPrinting.js +131 -175
  39. package/lib/esm/utils/arrays.js +6 -12
  40. package/lib/esm/utils/objects.js +1 -1
  41. package/lib/esm/utils/resources.js +3 -16
  42. package/lib/esm/utils/strings.js +10 -12
  43. package/lib/umd/beautify/beautify-css.js +11 -4
  44. package/lib/umd/cssLanguageService.d.ts +2 -1
  45. package/lib/umd/cssLanguageService.js +34 -32
  46. package/lib/umd/cssLanguageTypes.js +4 -3
  47. package/lib/umd/data/webCustomData.js +355 -231
  48. package/lib/umd/languageFacts/colors.js +65 -68
  49. package/lib/umd/languageFacts/dataManager.js +41 -44
  50. package/lib/umd/languageFacts/dataProvider.js +17 -22
  51. package/lib/umd/languageFacts/entry.js +22 -23
  52. package/lib/umd/languageFacts/facts.js +5 -1
  53. package/lib/umd/parser/cssErrors.js +5 -6
  54. package/lib/umd/parser/cssNodes.js +870 -1307
  55. package/lib/umd/parser/cssParser.js +424 -380
  56. package/lib/umd/parser/cssScanner.js +168 -173
  57. package/lib/umd/parser/cssSymbolScope.js +109 -134
  58. package/lib/umd/parser/lessParser.js +182 -206
  59. package/lib/umd/parser/lessScanner.js +22 -42
  60. package/lib/umd/parser/scssErrors.js +5 -6
  61. package/lib/umd/parser/scssParser.js +202 -213
  62. package/lib/umd/parser/scssScanner.js +25 -45
  63. package/lib/umd/services/cssCodeActions.js +41 -44
  64. package/lib/umd/services/cssCompletion.js +308 -402
  65. package/lib/umd/services/cssFolding.js +35 -38
  66. package/lib/umd/services/cssFormatter.js +25 -25
  67. package/lib/umd/services/cssHover.js +36 -38
  68. package/lib/umd/services/cssNavigation.js +267 -295
  69. package/lib/umd/services/cssSelectionRange.js +8 -8
  70. package/lib/umd/services/cssValidation.js +17 -19
  71. package/lib/umd/services/lessCompletion.js +354 -372
  72. package/lib/umd/services/lint.js +167 -180
  73. package/lib/umd/services/lintRules.js +20 -24
  74. package/lib/umd/services/lintUtil.js +20 -28
  75. package/lib/umd/services/pathCompletion.js +87 -160
  76. package/lib/umd/services/scssCompletion.js +287 -310
  77. package/lib/umd/services/scssNavigation.js +69 -140
  78. package/lib/umd/services/selectorPrinting.js +134 -174
  79. package/lib/umd/utils/arrays.js +6 -12
  80. package/lib/umd/utils/objects.js +1 -1
  81. package/lib/umd/utils/resources.js +4 -17
  82. package/lib/umd/utils/strings.js +10 -12
  83. package/package.json +16 -15
@@ -3,21 +3,6 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  'use strict';
6
- var __extends = (this && this.__extends) || (function () {
7
- var extendStatics = function (d, b) {
8
- extendStatics = Object.setPrototypeOf ||
9
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
10
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
11
- return extendStatics(d, b);
12
- };
13
- return function (d, b) {
14
- if (typeof b !== "function" && b !== null)
15
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
16
- extendStatics(d, b);
17
- function __() { this.constructor = d; }
18
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
19
- };
20
- })();
21
6
  import * as lessScanner from './lessScanner';
22
7
  import { TokenType } from './cssScanner';
23
8
  import * as cssParser from './cssParser';
@@ -27,28 +12,26 @@ import { ParseError } from './cssErrors';
27
12
  /// A parser for LESS
28
13
  /// http://lesscss.org/
29
14
  /// </summary>
30
- var LESSParser = /** @class */ (function (_super) {
31
- __extends(LESSParser, _super);
32
- function LESSParser() {
33
- return _super.call(this, new lessScanner.LESSScanner()) || this;
15
+ export class LESSParser extends cssParser.Parser {
16
+ constructor() {
17
+ super(new lessScanner.LESSScanner());
34
18
  }
35
- LESSParser.prototype._parseStylesheetStatement = function (isNested) {
36
- if (isNested === void 0) { isNested = false; }
19
+ _parseStylesheetStatement(isNested = false) {
37
20
  if (this.peek(TokenType.AtKeyword)) {
38
21
  return this._parseVariableDeclaration()
39
22
  || this._parsePlugin()
40
- || _super.prototype._parseStylesheetAtStatement.call(this, isNested);
23
+ || super._parseStylesheetAtStatement(isNested);
41
24
  }
42
25
  return this._tryParseMixinDeclaration()
43
26
  || this._tryParseMixinReference()
44
27
  || this._parseFunction()
45
28
  || this._parseRuleset(true);
46
- };
47
- LESSParser.prototype._parseImport = function () {
29
+ }
30
+ _parseImport() {
48
31
  if (!this.peekKeyword('@import') && !this.peekKeyword('@import-once') /* deprecated in less 1.4.1 */) {
49
32
  return null;
50
33
  }
51
- var node = this.create(nodes.Import);
34
+ const node = this.create(nodes.Import);
52
35
  this.consumeToken();
53
36
  // less 1.4.1: @import (css) "lib"
54
37
  if (this.accept(TokenType.ParenthesisL)) {
@@ -71,12 +54,12 @@ var LESSParser = /** @class */ (function (_super) {
71
54
  node.setMedialist(this._parseMediaQueryList());
72
55
  }
73
56
  return this.finish(node);
74
- };
75
- LESSParser.prototype._parsePlugin = function () {
57
+ }
58
+ _parsePlugin() {
76
59
  if (!this.peekKeyword('@plugin')) {
77
60
  return null;
78
61
  }
79
- var node = this.createNode(nodes.NodeType.Plugin);
62
+ const node = this.createNode(nodes.NodeType.Plugin);
80
63
  this.consumeToken(); // @import
81
64
  if (!node.addChild(this._parseStringLiteral())) {
82
65
  return this.finish(node, ParseError.StringLiteralExpected);
@@ -85,34 +68,32 @@ var LESSParser = /** @class */ (function (_super) {
85
68
  return this.finish(node, ParseError.SemiColonExpected);
86
69
  }
87
70
  return this.finish(node);
88
- };
89
- LESSParser.prototype._parseMediaQuery = function () {
90
- var node = _super.prototype._parseMediaQuery.call(this);
71
+ }
72
+ _parseMediaQuery() {
73
+ const node = super._parseMediaQuery();
91
74
  if (!node) {
92
- var node_1 = this.create(nodes.MediaQuery);
93
- if (node_1.addChild(this._parseVariable())) {
94
- return this.finish(node_1);
75
+ const node = this.create(nodes.MediaQuery);
76
+ if (node.addChild(this._parseVariable())) {
77
+ return this.finish(node);
95
78
  }
96
79
  return null;
97
80
  }
98
81
  return node;
99
- };
100
- LESSParser.prototype._parseMediaDeclaration = function (isNested) {
101
- if (isNested === void 0) { isNested = false; }
82
+ }
83
+ _parseMediaDeclaration(isNested = false) {
102
84
  return this._tryParseRuleset(isNested)
103
85
  || this._tryToParseDeclaration()
104
86
  || this._tryParseMixinDeclaration()
105
87
  || this._tryParseMixinReference()
106
88
  || this._parseDetachedRuleSetMixin()
107
89
  || this._parseStylesheetStatement(isNested);
108
- };
109
- LESSParser.prototype._parseMediaFeatureName = function () {
90
+ }
91
+ _parseMediaFeatureName() {
110
92
  return this._parseIdent() || this._parseVariable();
111
- };
112
- LESSParser.prototype._parseVariableDeclaration = function (panic) {
113
- if (panic === void 0) { panic = []; }
114
- var node = this.create(nodes.VariableDeclaration);
115
- var mark = this.mark();
93
+ }
94
+ _parseVariableDeclaration(panic = []) {
95
+ const node = this.create(nodes.VariableDeclaration);
96
+ const mark = this.mark();
116
97
  if (!node.setVariable(this._parseVariable(true))) {
117
98
  return null;
118
99
  }
@@ -136,14 +117,14 @@ var LESSParser = /** @class */ (function (_super) {
136
117
  node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
137
118
  }
138
119
  return this.finish(node);
139
- };
140
- LESSParser.prototype._parseDetachedRuleSet = function () {
141
- var mark = this.mark();
120
+ }
121
+ _parseDetachedRuleSet() {
122
+ let mark = this.mark();
142
123
  // "Anonymous mixin" used in each() and possibly a generic type in the future
143
124
  if (this.peekDelim('#') || this.peekDelim('.')) {
144
125
  this.consumeToken();
145
126
  if (!this.hasWhitespace() && this.accept(TokenType.ParenthesisL)) {
146
- var node = this.create(nodes.MixinDeclaration);
127
+ let node = this.create(nodes.MixinDeclaration);
147
128
  if (node.getParameters().addChild(this._parseMixinParameter())) {
148
129
  while (this.accept(TokenType.Comma) || this.accept(TokenType.SemiColon)) {
149
130
  if (this.peek(TokenType.ParenthesisR)) {
@@ -167,18 +148,18 @@ var LESSParser = /** @class */ (function (_super) {
167
148
  if (!this.peek(TokenType.CurlyL)) {
168
149
  return null;
169
150
  }
170
- var content = this.create(nodes.BodyDeclaration);
151
+ const content = this.create(nodes.BodyDeclaration);
171
152
  this._parseBody(content, this._parseDetachedRuleSetBody.bind(this));
172
153
  return this.finish(content);
173
- };
174
- LESSParser.prototype._parseDetachedRuleSetBody = function () {
154
+ }
155
+ _parseDetachedRuleSetBody() {
175
156
  return this._tryParseKeyframeSelector() || this._parseRuleSetDeclaration();
176
- };
177
- LESSParser.prototype._addLookupChildren = function (node) {
157
+ }
158
+ _addLookupChildren(node) {
178
159
  if (!node.addChild(this._parseLookupValue())) {
179
160
  return false;
180
161
  }
181
- var expectsValue = false;
162
+ let expectsValue = false;
182
163
  while (true) {
183
164
  if (this.peek(TokenType.BracketL)) {
184
165
  expectsValue = true;
@@ -189,10 +170,10 @@ var LESSParser = /** @class */ (function (_super) {
189
170
  expectsValue = false;
190
171
  }
191
172
  return !expectsValue;
192
- };
193
- LESSParser.prototype._parseLookupValue = function () {
194
- var node = this.create(nodes.Node);
195
- var mark = this.mark();
173
+ }
174
+ _parseLookupValue() {
175
+ const node = this.create(nodes.Node);
176
+ const mark = this.mark();
196
177
  if (!this.accept(TokenType.BracketL)) {
197
178
  this.restoreAtMark(mark);
198
179
  return null;
@@ -204,16 +185,14 @@ var LESSParser = /** @class */ (function (_super) {
204
185
  }
205
186
  this.restoreAtMark(mark);
206
187
  return null;
207
- };
208
- LESSParser.prototype._parseVariable = function (declaration, insideLookup) {
209
- if (declaration === void 0) { declaration = false; }
210
- if (insideLookup === void 0) { insideLookup = false; }
211
- var isPropertyReference = !declaration && this.peekDelim('$');
188
+ }
189
+ _parseVariable(declaration = false, insideLookup = false) {
190
+ const isPropertyReference = !declaration && this.peekDelim('$');
212
191
  if (!this.peekDelim('@') && !isPropertyReference && !this.peek(TokenType.AtKeyword)) {
213
192
  return null;
214
193
  }
215
- var node = this.create(nodes.Variable);
216
- var mark = this.mark();
194
+ const node = this.create(nodes.Variable);
195
+ const mark = this.mark();
217
196
  while (this.acceptDelim('@') || (!declaration && this.acceptDelim('$'))) {
218
197
  if (this.hasWhitespace()) {
219
198
  this.restoreAtMark(mark);
@@ -231,22 +210,22 @@ var LESSParser = /** @class */ (function (_super) {
231
210
  }
232
211
  }
233
212
  return node;
234
- };
235
- LESSParser.prototype._parseTermExpression = function () {
213
+ }
214
+ _parseTermExpression() {
236
215
  return this._parseVariable() ||
237
216
  this._parseEscaped() ||
238
- _super.prototype._parseTermExpression.call(this) || // preference for colors before mixin references
217
+ super._parseTermExpression() || // preference for colors before mixin references
239
218
  this._tryParseMixinReference(false);
240
- };
241
- LESSParser.prototype._parseEscaped = function () {
219
+ }
220
+ _parseEscaped() {
242
221
  if (this.peek(TokenType.EscapedJavaScript) ||
243
222
  this.peek(TokenType.BadEscapedJavaScript)) {
244
- var node = this.createNode(nodes.NodeType.EscapedValue);
223
+ const node = this.createNode(nodes.NodeType.EscapedValue);
245
224
  this.consumeToken();
246
225
  return this.finish(node);
247
226
  }
248
227
  if (this.peekDelim('~')) {
249
- var node = this.createNode(nodes.NodeType.EscapedValue);
228
+ const node = this.createNode(nodes.NodeType.EscapedValue);
250
229
  this.consumeToken();
251
230
  if (this.accept(TokenType.String) || this.accept(TokenType.EscapedJavaScript)) {
252
231
  return this.finish(node);
@@ -256,75 +235,76 @@ var LESSParser = /** @class */ (function (_super) {
256
235
  }
257
236
  }
258
237
  return null;
259
- };
260
- LESSParser.prototype._parseOperator = function () {
261
- var node = this._parseGuardOperator();
238
+ }
239
+ _parseOperator() {
240
+ const node = this._parseGuardOperator();
262
241
  if (node) {
263
242
  return node;
264
243
  }
265
244
  else {
266
- return _super.prototype._parseOperator.call(this);
245
+ return super._parseOperator();
267
246
  }
268
- };
269
- LESSParser.prototype._parseGuardOperator = function () {
247
+ }
248
+ _parseGuardOperator() {
270
249
  if (this.peekDelim('>')) {
271
- var node = this.createNode(nodes.NodeType.Operator);
250
+ const node = this.createNode(nodes.NodeType.Operator);
272
251
  this.consumeToken();
273
252
  this.acceptDelim('=');
274
253
  return node;
275
254
  }
276
255
  else if (this.peekDelim('=')) {
277
- var node = this.createNode(nodes.NodeType.Operator);
256
+ const node = this.createNode(nodes.NodeType.Operator);
278
257
  this.consumeToken();
279
258
  this.acceptDelim('<');
280
259
  return node;
281
260
  }
282
261
  else if (this.peekDelim('<')) {
283
- var node = this.createNode(nodes.NodeType.Operator);
262
+ const node = this.createNode(nodes.NodeType.Operator);
284
263
  this.consumeToken();
285
264
  this.acceptDelim('=');
286
265
  return node;
287
266
  }
288
267
  return null;
289
- };
290
- LESSParser.prototype._parseRuleSetDeclaration = function () {
268
+ }
269
+ _parseRuleSetDeclaration() {
291
270
  if (this.peek(TokenType.AtKeyword)) {
292
271
  return this._parseKeyframe()
293
272
  || this._parseMedia(true)
294
273
  || this._parseImport()
295
274
  || this._parseSupports(true) // @supports
275
+ || this._parseLayer() // @layer
296
276
  || this._parseDetachedRuleSetMixin() // less detached ruleset mixin
297
277
  || this._parseVariableDeclaration() // Variable declarations
298
- || _super.prototype._parseRuleSetDeclarationAtStatement.call(this);
278
+ || super._parseRuleSetDeclarationAtStatement();
299
279
  }
300
280
  return this._tryParseMixinDeclaration()
301
281
  || this._tryParseRuleset(true) // nested ruleset
302
282
  || this._tryParseMixinReference() // less mixin reference
303
283
  || this._parseFunction()
304
284
  || this._parseExtend() // less extend declaration
305
- || _super.prototype._parseRuleSetDeclaration.call(this); // try css ruleset declaration as the last option
306
- };
307
- LESSParser.prototype._parseKeyframeIdent = function () {
285
+ || super._parseRuleSetDeclaration(); // try css ruleset declaration as the last option
286
+ }
287
+ _parseKeyframeIdent() {
308
288
  return this._parseIdent([nodes.ReferenceType.Keyframe]) || this._parseVariable();
309
- };
310
- LESSParser.prototype._parseKeyframeSelector = function () {
289
+ }
290
+ _parseKeyframeSelector() {
311
291
  return this._parseDetachedRuleSetMixin() // less detached ruleset mixin
312
- || _super.prototype._parseKeyframeSelector.call(this);
313
- };
314
- LESSParser.prototype._parseSimpleSelectorBody = function () {
315
- return this._parseSelectorCombinator() || _super.prototype._parseSimpleSelectorBody.call(this);
316
- };
317
- LESSParser.prototype._parseSelector = function (isNested) {
292
+ || super._parseKeyframeSelector();
293
+ }
294
+ _parseSimpleSelectorBody() {
295
+ return this._parseSelectorCombinator() || super._parseSimpleSelectorBody();
296
+ }
297
+ _parseSelector(isNested) {
318
298
  // CSS Guards
319
- var node = this.create(nodes.Selector);
320
- var hasContent = false;
299
+ const node = this.create(nodes.Selector);
300
+ let hasContent = false;
321
301
  if (isNested) {
322
302
  // nested selectors can start with a combinator
323
303
  hasContent = node.addChild(this._parseCombinator());
324
304
  }
325
305
  while (node.addChild(this._parseSimpleSelector())) {
326
306
  hasContent = true;
327
- var mark = this.mark();
307
+ const mark = this.mark();
328
308
  if (node.addChild(this._parseGuard()) && this.peek(TokenType.CurlyL)) {
329
309
  break;
330
310
  }
@@ -332,10 +312,10 @@ var LESSParser = /** @class */ (function (_super) {
332
312
  node.addChild(this._parseCombinator()); // optional
333
313
  }
334
314
  return hasContent ? this.finish(node) : null;
335
- };
336
- LESSParser.prototype._parseSelectorCombinator = function () {
315
+ }
316
+ _parseSelectorCombinator() {
337
317
  if (this.peekDelim('&')) {
338
- var node = this.createNode(nodes.NodeType.SelectorCombinator);
318
+ const node = this.createNode(nodes.NodeType.SelectorCombinator);
339
319
  this.consumeToken();
340
320
  while (!this.hasWhitespace() && (this.acceptDelim('-') || this.accept(TokenType.Num) || this.accept(TokenType.Dimension) || node.addChild(this._parseIdent()) || this.acceptDelim('&'))) {
341
321
  // support &-foo
@@ -343,25 +323,24 @@ var LESSParser = /** @class */ (function (_super) {
343
323
  return this.finish(node);
344
324
  }
345
325
  return null;
346
- };
347
- LESSParser.prototype._parseSelectorIdent = function () {
326
+ }
327
+ _parseSelectorIdent() {
348
328
  if (!this.peekInterpolatedIdent()) {
349
329
  return null;
350
330
  }
351
- var node = this.createNode(nodes.NodeType.SelectorInterpolation);
352
- var hasContent = this._acceptInterpolatedIdent(node);
331
+ const node = this.createNode(nodes.NodeType.SelectorInterpolation);
332
+ const hasContent = this._acceptInterpolatedIdent(node);
353
333
  return hasContent ? this.finish(node) : null;
354
- };
355
- LESSParser.prototype._parsePropertyIdentifier = function (inLookup) {
356
- if (inLookup === void 0) { inLookup = false; }
357
- var propertyRegex = /^[\w-]+/;
334
+ }
335
+ _parsePropertyIdentifier(inLookup = false) {
336
+ const propertyRegex = /^[\w-]+/;
358
337
  if (!this.peekInterpolatedIdent() && !this.peekRegExp(this.token.type, propertyRegex)) {
359
338
  return null;
360
339
  }
361
- var mark = this.mark();
362
- var node = this.create(nodes.Identifier);
340
+ const mark = this.mark();
341
+ const node = this.create(nodes.Identifier);
363
342
  node.isCustomProperty = this.acceptDelim('-') && this.acceptDelim('-');
364
- var childAdded = false;
343
+ let childAdded = false;
365
344
  if (!inLookup) {
366
345
  if (node.isCustomProperty) {
367
346
  childAdded = this._acceptInterpolatedIdent(node);
@@ -389,32 +368,31 @@ var LESSParser = /** @class */ (function (_super) {
389
368
  }
390
369
  }
391
370
  return this.finish(node);
392
- };
393
- LESSParser.prototype.peekInterpolatedIdent = function () {
371
+ }
372
+ peekInterpolatedIdent() {
394
373
  return this.peek(TokenType.Ident) ||
395
374
  this.peekDelim('@') ||
396
375
  this.peekDelim('$') ||
397
376
  this.peekDelim('-');
398
- };
399
- LESSParser.prototype._acceptInterpolatedIdent = function (node, identRegex) {
400
- var _this = this;
401
- var hasContent = false;
402
- var indentInterpolation = function () {
403
- var pos = _this.mark();
404
- if (_this.acceptDelim('-')) {
405
- if (!_this.hasWhitespace()) {
406
- _this.acceptDelim('-');
377
+ }
378
+ _acceptInterpolatedIdent(node, identRegex) {
379
+ let hasContent = false;
380
+ const indentInterpolation = () => {
381
+ const pos = this.mark();
382
+ if (this.acceptDelim('-')) {
383
+ if (!this.hasWhitespace()) {
384
+ this.acceptDelim('-');
407
385
  }
408
- if (_this.hasWhitespace()) {
409
- _this.restoreAtMark(pos);
386
+ if (this.hasWhitespace()) {
387
+ this.restoreAtMark(pos);
410
388
  return null;
411
389
  }
412
390
  }
413
- return _this._parseInterpolation();
391
+ return this._parseInterpolation();
414
392
  };
415
- var accept = identRegex ?
416
- function () { return _this.acceptRegexp(identRegex); } :
417
- function () { return _this.accept(TokenType.Ident); };
393
+ const accept = identRegex ?
394
+ () => this.acceptRegexp(identRegex) :
395
+ () => this.accept(TokenType.Ident);
418
396
  while (accept() ||
419
397
  node.addChild(this._parseInterpolation() ||
420
398
  this.try(indentInterpolation))) {
@@ -424,13 +402,13 @@ var LESSParser = /** @class */ (function (_super) {
424
402
  }
425
403
  }
426
404
  return hasContent;
427
- };
428
- LESSParser.prototype._parseInterpolation = function () {
405
+ }
406
+ _parseInterpolation() {
429
407
  // @{name} Variable or
430
408
  // ${name} Property
431
- var mark = this.mark();
409
+ const mark = this.mark();
432
410
  if (this.peekDelim('@') || this.peekDelim('$')) {
433
- var node = this.createNode(nodes.NodeType.Interpolation);
411
+ const node = this.createNode(nodes.NodeType.Interpolation);
434
412
  this.consumeToken();
435
413
  if (this.hasWhitespace() || !this.accept(TokenType.CurlyL)) {
436
414
  this.restoreAtMark(mark);
@@ -445,10 +423,10 @@ var LESSParser = /** @class */ (function (_super) {
445
423
  return this.finish(node);
446
424
  }
447
425
  return null;
448
- };
449
- LESSParser.prototype._tryParseMixinDeclaration = function () {
450
- var mark = this.mark();
451
- var node = this.create(nodes.MixinDeclaration);
426
+ }
427
+ _tryParseMixinDeclaration() {
428
+ const mark = this.mark();
429
+ const node = this.create(nodes.MixinDeclaration);
452
430
  if (!node.setIdentifier(this._parseMixinDeclarationIdentifier()) || !this.accept(TokenType.ParenthesisL)) {
453
431
  this.restoreAtMark(mark);
454
432
  return null;
@@ -473,12 +451,12 @@ var LESSParser = /** @class */ (function (_super) {
473
451
  return null;
474
452
  }
475
453
  return this._parseBody(node, this._parseMixInBodyDeclaration.bind(this));
476
- };
477
- LESSParser.prototype._parseMixInBodyDeclaration = function () {
454
+ }
455
+ _parseMixInBodyDeclaration() {
478
456
  return this._parseFontFace() || this._parseRuleSetDeclaration();
479
- };
480
- LESSParser.prototype._parseMixinDeclarationIdentifier = function () {
481
- var identifier;
457
+ }
458
+ _parseMixinDeclarationIdentifier() {
459
+ let identifier;
482
460
  if (this.peekDelim('#') || this.peekDelim('.')) {
483
461
  identifier = this.create(nodes.Identifier);
484
462
  this.consumeToken(); // # or .
@@ -495,38 +473,38 @@ var LESSParser = /** @class */ (function (_super) {
495
473
  }
496
474
  identifier.referenceTypes = [nodes.ReferenceType.Mixin];
497
475
  return this.finish(identifier);
498
- };
499
- LESSParser.prototype._parsePseudo = function () {
476
+ }
477
+ _parsePseudo() {
500
478
  if (!this.peek(TokenType.Colon)) {
501
479
  return null;
502
480
  }
503
- var mark = this.mark();
504
- var node = this.create(nodes.ExtendsReference);
481
+ const mark = this.mark();
482
+ const node = this.create(nodes.ExtendsReference);
505
483
  this.consumeToken(); // :
506
484
  if (this.acceptIdent('extend')) {
507
485
  return this._completeExtends(node);
508
486
  }
509
487
  this.restoreAtMark(mark);
510
- return _super.prototype._parsePseudo.call(this);
511
- };
512
- LESSParser.prototype._parseExtend = function () {
488
+ return super._parsePseudo();
489
+ }
490
+ _parseExtend() {
513
491
  if (!this.peekDelim('&')) {
514
492
  return null;
515
493
  }
516
- var mark = this.mark();
517
- var node = this.create(nodes.ExtendsReference);
494
+ const mark = this.mark();
495
+ const node = this.create(nodes.ExtendsReference);
518
496
  this.consumeToken(); // &
519
497
  if (this.hasWhitespace() || !this.accept(TokenType.Colon) || !this.acceptIdent('extend')) {
520
498
  this.restoreAtMark(mark);
521
499
  return null;
522
500
  }
523
501
  return this._completeExtends(node);
524
- };
525
- LESSParser.prototype._completeExtends = function (node) {
502
+ }
503
+ _completeExtends(node) {
526
504
  if (!this.accept(TokenType.ParenthesisL)) {
527
505
  return this.finish(node, ParseError.LeftParenthesisExpected);
528
506
  }
529
- var selectors = node.getSelectors();
507
+ const selectors = node.getSelectors();
530
508
  if (!selectors.addChild(this._parseSelector(true))) {
531
509
  return this.finish(node, ParseError.SelectorExpected);
532
510
  }
@@ -539,13 +517,13 @@ var LESSParser = /** @class */ (function (_super) {
539
517
  return this.finish(node, ParseError.RightParenthesisExpected);
540
518
  }
541
519
  return this.finish(node);
542
- };
543
- LESSParser.prototype._parseDetachedRuleSetMixin = function () {
520
+ }
521
+ _parseDetachedRuleSetMixin() {
544
522
  if (!this.peek(TokenType.AtKeyword)) {
545
523
  return null;
546
524
  }
547
- var mark = this.mark();
548
- var node = this.create(nodes.MixinReference);
525
+ const mark = this.mark();
526
+ const node = this.create(nodes.MixinReference);
549
527
  if (node.addChild(this._parseVariable(true)) && (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL))) {
550
528
  this.restoreAtMark(mark);
551
529
  return null;
@@ -554,15 +532,14 @@ var LESSParser = /** @class */ (function (_super) {
554
532
  return this.finish(node, ParseError.RightParenthesisExpected);
555
533
  }
556
534
  return this.finish(node);
557
- };
558
- LESSParser.prototype._tryParseMixinReference = function (atRoot) {
559
- if (atRoot === void 0) { atRoot = true; }
560
- var mark = this.mark();
561
- var node = this.create(nodes.MixinReference);
562
- var identifier = this._parseMixinDeclarationIdentifier();
535
+ }
536
+ _tryParseMixinReference(atRoot = true) {
537
+ const mark = this.mark();
538
+ const node = this.create(nodes.MixinReference);
539
+ let identifier = this._parseMixinDeclarationIdentifier();
563
540
  while (identifier) {
564
541
  this.acceptDelim('>');
565
- var nextId = this._parseMixinDeclarationIdentifier();
542
+ const nextId = this._parseMixinDeclarationIdentifier();
566
543
  if (nextId) {
567
544
  node.getNamespaces().addChild(identifier);
568
545
  identifier = nextId;
@@ -575,7 +552,7 @@ var LESSParser = /** @class */ (function (_super) {
575
552
  this.restoreAtMark(mark);
576
553
  return null;
577
554
  }
578
- var hasArguments = false;
555
+ let hasArguments = false;
579
556
  if (this.accept(TokenType.ParenthesisL)) {
580
557
  hasArguments = true;
581
558
  if (node.getArguments().addChild(this._parseMixinArgument())) {
@@ -609,12 +586,12 @@ var LESSParser = /** @class */ (function (_super) {
609
586
  return null;
610
587
  }
611
588
  return this.finish(node);
612
- };
613
- LESSParser.prototype._parseMixinArgument = function () {
589
+ }
590
+ _parseMixinArgument() {
614
591
  // [variableName ':'] expression | variableName '...'
615
- var node = this.create(nodes.FunctionArgument);
616
- var pos = this.mark();
617
- var argument = this._parseVariable();
592
+ const node = this.create(nodes.FunctionArgument);
593
+ const pos = this.mark();
594
+ const argument = this._parseVariable();
618
595
  if (argument) {
619
596
  if (!this.accept(TokenType.Colon)) {
620
597
  this.restoreAtMark(pos);
@@ -628,12 +605,12 @@ var LESSParser = /** @class */ (function (_super) {
628
605
  }
629
606
  this.restoreAtMark(pos);
630
607
  return null;
631
- };
632
- LESSParser.prototype._parseMixinParameter = function () {
633
- var node = this.create(nodes.FunctionParameter);
608
+ }
609
+ _parseMixinParameter() {
610
+ const node = this.create(nodes.FunctionParameter);
634
611
  // special rest variable: @rest...
635
612
  if (this.peekKeyword('@rest')) {
636
- var restNode = this.create(nodes.Node);
613
+ const restNode = this.create(nodes.Node);
637
614
  this.consumeToken();
638
615
  if (!this.accept(lessScanner.Ellipsis)) {
639
616
  return this.finish(node, ParseError.DotExpected, [], [TokenType.Comma, TokenType.ParenthesisR]);
@@ -643,12 +620,12 @@ var LESSParser = /** @class */ (function (_super) {
643
620
  }
644
621
  // special const args: ...
645
622
  if (this.peek(lessScanner.Ellipsis)) {
646
- var varargsNode = this.create(nodes.Node);
623
+ const varargsNode = this.create(nodes.Node);
647
624
  this.consumeToken();
648
625
  node.setIdentifier(this.finish(varargsNode));
649
626
  return this.finish(node);
650
627
  }
651
- var hasContent = false;
628
+ let hasContent = false;
652
629
  // default variable declaration: @param: 12 or @name
653
630
  if (node.setIdentifier(this._parseVariable())) {
654
631
  this.accept(TokenType.Colon);
@@ -658,12 +635,12 @@ var LESSParser = /** @class */ (function (_super) {
658
635
  return null;
659
636
  }
660
637
  return this.finish(node);
661
- };
662
- LESSParser.prototype._parseGuard = function () {
638
+ }
639
+ _parseGuard() {
663
640
  if (!this.peekIdent('when')) {
664
641
  return null;
665
642
  }
666
- var node = this.create(nodes.LessGuard);
643
+ const node = this.create(nodes.LessGuard);
667
644
  this.consumeToken(); // when
668
645
  node.isNegated = this.acceptIdent('not');
669
646
  if (!node.getConditions().addChild(this._parseGuardCondition())) {
@@ -675,12 +652,12 @@ var LESSParser = /** @class */ (function (_super) {
675
652
  }
676
653
  }
677
654
  return this.finish(node);
678
- };
679
- LESSParser.prototype._parseGuardCondition = function () {
655
+ }
656
+ _parseGuardCondition() {
680
657
  if (!this.peek(TokenType.ParenthesisL)) {
681
658
  return null;
682
659
  }
683
- var node = this.create(nodes.GuardCondition);
660
+ const node = this.create(nodes.GuardCondition);
684
661
  this.consumeToken(); // ParenthesisL
685
662
  if (!node.addChild(this._parseExpr())) {
686
663
  // empty (?)
@@ -689,10 +666,10 @@ var LESSParser = /** @class */ (function (_super) {
689
666
  return this.finish(node, ParseError.RightParenthesisExpected);
690
667
  }
691
668
  return this.finish(node);
692
- };
693
- LESSParser.prototype._parseFunction = function () {
694
- var pos = this.mark();
695
- var node = this.create(nodes.Function);
669
+ }
670
+ _parseFunction() {
671
+ const pos = this.mark();
672
+ const node = this.create(nodes.Function);
696
673
  if (!node.setIdentifier(this._parseFunctionIdentifier())) {
697
674
  return null;
698
675
  }
@@ -714,27 +691,25 @@ var LESSParser = /** @class */ (function (_super) {
714
691
  return this.finish(node, ParseError.RightParenthesisExpected);
715
692
  }
716
693
  return this.finish(node);
717
- };
718
- LESSParser.prototype._parseFunctionIdentifier = function () {
694
+ }
695
+ _parseFunctionIdentifier() {
719
696
  if (this.peekDelim('%')) {
720
- var node = this.create(nodes.Identifier);
697
+ const node = this.create(nodes.Identifier);
721
698
  node.referenceTypes = [nodes.ReferenceType.Function];
722
699
  this.consumeToken();
723
700
  return this.finish(node);
724
701
  }
725
- return _super.prototype._parseFunctionIdentifier.call(this);
726
- };
727
- LESSParser.prototype._parseURLArgument = function () {
728
- var pos = this.mark();
729
- var node = _super.prototype._parseURLArgument.call(this);
702
+ return super._parseFunctionIdentifier();
703
+ }
704
+ _parseURLArgument() {
705
+ const pos = this.mark();
706
+ const node = super._parseURLArgument();
730
707
  if (!node || !this.peek(TokenType.ParenthesisR)) {
731
708
  this.restoreAtMark(pos);
732
- var node_2 = this.create(nodes.Node);
733
- node_2.addChild(this._parseBinaryExpr());
734
- return this.finish(node_2);
709
+ const node = this.create(nodes.Node);
710
+ node.addChild(this._parseBinaryExpr());
711
+ return this.finish(node);
735
712
  }
736
713
  return node;
737
- };
738
- return LESSParser;
739
- }(cssParser.Parser));
740
- export { LESSParser };
714
+ }
715
+ }