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