vscode-css-languageservice 6.0.1 → 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 (87) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/beautify/beautify-css.js +11 -4
  4. package/lib/esm/cssLanguageService.d.ts +38 -37
  5. package/lib/esm/cssLanguageService.js +73 -72
  6. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  7. package/lib/esm/cssLanguageTypes.js +42 -42
  8. package/lib/esm/data/webCustomData.js +22089 -21959
  9. package/lib/esm/languageFacts/builtinData.js +142 -142
  10. package/lib/esm/languageFacts/colors.js +469 -469
  11. package/lib/esm/languageFacts/dataManager.js +88 -88
  12. package/lib/esm/languageFacts/dataProvider.js +73 -73
  13. package/lib/esm/languageFacts/entry.js +137 -137
  14. package/lib/esm/languageFacts/facts.js +8 -8
  15. package/lib/esm/parser/cssErrors.js +48 -48
  16. package/lib/esm/parser/cssNodes.js +1511 -1502
  17. package/lib/esm/parser/cssParser.js +1606 -1534
  18. package/lib/esm/parser/cssScanner.js +592 -592
  19. package/lib/esm/parser/cssSymbolScope.js +311 -311
  20. package/lib/esm/parser/lessParser.js +715 -714
  21. package/lib/esm/parser/lessScanner.js +57 -57
  22. package/lib/esm/parser/scssErrors.js +18 -18
  23. package/lib/esm/parser/scssParser.js +806 -796
  24. package/lib/esm/parser/scssScanner.js +95 -95
  25. package/lib/esm/services/cssCodeActions.js +77 -77
  26. package/lib/esm/services/cssCompletion.js +1054 -1054
  27. package/lib/esm/services/cssFolding.js +190 -190
  28. package/lib/esm/services/cssFormatter.js +136 -136
  29. package/lib/esm/services/cssHover.js +148 -148
  30. package/lib/esm/services/cssNavigation.js +441 -378
  31. package/lib/esm/services/cssSelectionRange.js +47 -47
  32. package/lib/esm/services/cssValidation.js +41 -41
  33. package/lib/esm/services/lessCompletion.js +378 -378
  34. package/lib/esm/services/lint.js +518 -518
  35. package/lib/esm/services/lintRules.js +76 -76
  36. package/lib/esm/services/lintUtil.js +196 -196
  37. package/lib/esm/services/pathCompletion.js +157 -157
  38. package/lib/esm/services/scssCompletion.js +354 -354
  39. package/lib/esm/services/scssNavigation.js +82 -82
  40. package/lib/esm/services/selectorPrinting.js +492 -492
  41. package/lib/esm/utils/arrays.js +40 -40
  42. package/lib/esm/utils/objects.js +11 -11
  43. package/lib/esm/utils/resources.js +11 -11
  44. package/lib/esm/utils/strings.js +102 -102
  45. package/lib/umd/beautify/beautify-css.js +11 -4
  46. package/lib/umd/cssLanguageService.d.ts +38 -37
  47. package/lib/umd/cssLanguageService.js +104 -99
  48. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  49. package/lib/umd/cssLanguageTypes.js +89 -89
  50. package/lib/umd/data/webCustomData.js +22102 -21972
  51. package/lib/umd/languageFacts/builtinData.js +154 -154
  52. package/lib/umd/languageFacts/colors.js +492 -492
  53. package/lib/umd/languageFacts/dataManager.js +101 -101
  54. package/lib/umd/languageFacts/dataProvider.js +86 -86
  55. package/lib/umd/languageFacts/entry.js +152 -152
  56. package/lib/umd/languageFacts/facts.js +33 -29
  57. package/lib/umd/parser/cssErrors.js +61 -61
  58. package/lib/umd/parser/cssNodes.js +1597 -1587
  59. package/lib/umd/parser/cssParser.js +1619 -1547
  60. package/lib/umd/parser/cssScanner.js +606 -606
  61. package/lib/umd/parser/cssSymbolScope.js +328 -328
  62. package/lib/umd/parser/lessParser.js +728 -727
  63. package/lib/umd/parser/lessScanner.js +70 -70
  64. package/lib/umd/parser/scssErrors.js +31 -31
  65. package/lib/umd/parser/scssParser.js +819 -809
  66. package/lib/umd/parser/scssScanner.js +108 -108
  67. package/lib/umd/services/cssCodeActions.js +90 -90
  68. package/lib/umd/services/cssCompletion.js +1067 -1067
  69. package/lib/umd/services/cssFolding.js +203 -203
  70. package/lib/umd/services/cssFormatter.js +150 -150
  71. package/lib/umd/services/cssHover.js +161 -161
  72. package/lib/umd/services/cssNavigation.js +454 -391
  73. package/lib/umd/services/cssSelectionRange.js +60 -60
  74. package/lib/umd/services/cssValidation.js +54 -54
  75. package/lib/umd/services/lessCompletion.js +391 -391
  76. package/lib/umd/services/lint.js +531 -531
  77. package/lib/umd/services/lintRules.js +91 -91
  78. package/lib/umd/services/lintUtil.js +210 -210
  79. package/lib/umd/services/pathCompletion.js +171 -171
  80. package/lib/umd/services/scssCompletion.js +367 -367
  81. package/lib/umd/services/scssNavigation.js +95 -95
  82. package/lib/umd/services/selectorPrinting.js +510 -510
  83. package/lib/umd/utils/arrays.js +55 -55
  84. package/lib/umd/utils/objects.js +25 -25
  85. package/lib/umd/utils/resources.js +26 -26
  86. package/lib/umd/utils/strings.js +120 -120
  87. package/package.json +13 -12
@@ -1,796 +1,806 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
5
- 'use strict';
6
- import * as scssScanner from './scssScanner';
7
- import { TokenType } from './cssScanner';
8
- import * as cssParser from './cssParser';
9
- import * as nodes from './cssNodes';
10
- import { SCSSParseError } from './scssErrors';
11
- import { ParseError } from './cssErrors';
12
- /// <summary>
13
- /// A parser for scss
14
- /// http://sass-lang.com/documentation/file.SASS_REFERENCE.html
15
- /// </summary>
16
- export class SCSSParser extends cssParser.Parser {
17
- constructor() {
18
- super(new scssScanner.SCSSScanner());
19
- }
20
- _parseStylesheetStatement(isNested = false) {
21
- if (this.peek(TokenType.AtKeyword)) {
22
- return this._parseWarnAndDebug() // @warn, @debug and @error statements
23
- || this._parseControlStatement() // @if, @while, @for, @each
24
- || this._parseMixinDeclaration() // @mixin
25
- || this._parseMixinContent() // @content
26
- || this._parseMixinReference() // @include
27
- || this._parseFunctionDeclaration() // @function
28
- || this._parseForward() // @forward
29
- || this._parseUse() // @use
30
- || this._parseRuleset(isNested) // @at-rule
31
- || super._parseStylesheetAtStatement(isNested);
32
- }
33
- return this._parseRuleset(true) || this._parseVariableDeclaration();
34
- }
35
- _parseImport() {
36
- if (!this.peekKeyword('@import')) {
37
- return null;
38
- }
39
- const node = this.create(nodes.Import);
40
- this.consumeToken();
41
- if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) {
42
- return this.finish(node, ParseError.URIOrStringExpected);
43
- }
44
- while (this.accept(TokenType.Comma)) {
45
- if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) {
46
- return this.finish(node, ParseError.URIOrStringExpected);
47
- }
48
- }
49
- if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {
50
- node.setMedialist(this._parseMediaQueryList());
51
- }
52
- return this.finish(node);
53
- }
54
- // scss variables: $font-size: 12px;
55
- _parseVariableDeclaration(panic = []) {
56
- if (!this.peek(scssScanner.VariableName)) {
57
- return null;
58
- }
59
- const node = this.create(nodes.VariableDeclaration);
60
- if (!node.setVariable(this._parseVariable())) {
61
- return null;
62
- }
63
- if (!this.accept(TokenType.Colon)) {
64
- return this.finish(node, ParseError.ColonExpected);
65
- }
66
- if (this.prevToken) {
67
- node.colonPosition = this.prevToken.offset;
68
- }
69
- if (!node.setValue(this._parseExpr())) {
70
- return this.finish(node, ParseError.VariableValueExpected, [], panic);
71
- }
72
- while (this.peek(TokenType.Exclamation)) {
73
- if (node.addChild(this._tryParsePrio())) {
74
- // !important
75
- }
76
- else {
77
- this.consumeToken();
78
- if (!this.peekRegExp(TokenType.Ident, /^(default|global)$/)) {
79
- return this.finish(node, ParseError.UnknownKeyword);
80
- }
81
- this.consumeToken();
82
- }
83
- }
84
- if (this.peek(TokenType.SemiColon)) {
85
- node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
86
- }
87
- return this.finish(node);
88
- }
89
- _parseMediaCondition() {
90
- return this._parseInterpolation() || super._parseMediaCondition();
91
- }
92
- _parseMediaFeatureName() {
93
- return this._parseModuleMember()
94
- || this._parseFunction() // function before ident
95
- || this._parseIdent()
96
- || this._parseVariable();
97
- }
98
- _parseKeyframeSelector() {
99
- return this._tryParseKeyframeSelector()
100
- || this._parseControlStatement(this._parseKeyframeSelector.bind(this))
101
- || this._parseVariableDeclaration()
102
- || this._parseMixinContent();
103
- }
104
- _parseVariable() {
105
- if (!this.peek(scssScanner.VariableName)) {
106
- return null;
107
- }
108
- const node = this.create(nodes.Variable);
109
- this.consumeToken();
110
- return node;
111
- }
112
- _parseModuleMember() {
113
- const pos = this.mark();
114
- const node = this.create(nodes.Module);
115
- if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Module]))) {
116
- return null;
117
- }
118
- if (this.hasWhitespace()
119
- || !this.acceptDelim('.')
120
- || this.hasWhitespace()) {
121
- this.restoreAtMark(pos);
122
- return null;
123
- }
124
- if (!node.addChild(this._parseVariable() || this._parseFunction())) {
125
- return this.finish(node, ParseError.IdentifierOrVariableExpected);
126
- }
127
- return node;
128
- }
129
- _parseIdent(referenceTypes) {
130
- if (!this.peek(TokenType.Ident) && !this.peek(scssScanner.InterpolationFunction) && !this.peekDelim('-')) {
131
- return null;
132
- }
133
- const node = this.create(nodes.Identifier);
134
- node.referenceTypes = referenceTypes;
135
- node.isCustomProperty = this.peekRegExp(TokenType.Ident, /^--/);
136
- let hasContent = false;
137
- const indentInterpolation = () => {
138
- const pos = this.mark();
139
- if (this.acceptDelim('-')) {
140
- if (!this.hasWhitespace()) {
141
- this.acceptDelim('-');
142
- }
143
- if (this.hasWhitespace()) {
144
- this.restoreAtMark(pos);
145
- return null;
146
- }
147
- }
148
- return this._parseInterpolation();
149
- };
150
- while (this.accept(TokenType.Ident) || node.addChild(indentInterpolation()) || (hasContent && this.acceptRegexp(/^[\w-]/))) {
151
- hasContent = true;
152
- if (this.hasWhitespace()) {
153
- break;
154
- }
155
- }
156
- return hasContent ? this.finish(node) : null;
157
- }
158
- _parseTermExpression() {
159
- return this._parseModuleMember() ||
160
- this._parseVariable() ||
161
- this._parseSelectorCombinator() ||
162
- //this._tryParsePrio() ||
163
- super._parseTermExpression();
164
- }
165
- _parseInterpolation() {
166
- if (this.peek(scssScanner.InterpolationFunction)) {
167
- const node = this.create(nodes.Interpolation);
168
- this.consumeToken();
169
- if (!node.addChild(this._parseExpr()) && !this._parseSelectorCombinator()) {
170
- if (this.accept(TokenType.CurlyR)) {
171
- return this.finish(node);
172
- }
173
- return this.finish(node, ParseError.ExpressionExpected);
174
- }
175
- if (!this.accept(TokenType.CurlyR)) {
176
- return this.finish(node, ParseError.RightCurlyExpected);
177
- }
178
- return this.finish(node);
179
- }
180
- return null;
181
- }
182
- _parseOperator() {
183
- if (this.peek(scssScanner.EqualsOperator) || this.peek(scssScanner.NotEqualsOperator)
184
- || this.peek(scssScanner.GreaterEqualsOperator) || this.peek(scssScanner.SmallerEqualsOperator)
185
- || this.peekDelim('>') || this.peekDelim('<')
186
- || this.peekIdent('and') || this.peekIdent('or')
187
- || this.peekDelim('%')) {
188
- const node = this.createNode(nodes.NodeType.Operator);
189
- this.consumeToken();
190
- return this.finish(node);
191
- }
192
- return super._parseOperator();
193
- }
194
- _parseUnaryOperator() {
195
- if (this.peekIdent('not')) {
196
- const node = this.create(nodes.Node);
197
- this.consumeToken();
198
- return this.finish(node);
199
- }
200
- return super._parseUnaryOperator();
201
- }
202
- _parseRuleSetDeclaration() {
203
- if (this.peek(TokenType.AtKeyword)) {
204
- return this._parseKeyframe() // nested @keyframe
205
- || this._parseImport() // nested @import
206
- || this._parseMedia(true) // nested @media
207
- || this._parseFontFace() // nested @font-face
208
- || this._parseWarnAndDebug() // @warn, @debug and @error statements
209
- || this._parseControlStatement() // @if, @while, @for, @each
210
- || this._parseFunctionDeclaration() // @function
211
- || this._parseExtends() // @extends
212
- || this._parseMixinReference() // @include
213
- || this._parseMixinContent() // @content
214
- || this._parseMixinDeclaration() // nested @mixin
215
- || this._parseRuleset(true) // @at-rule
216
- || this._parseSupports(true) // @supports
217
- || super._parseRuleSetDeclarationAtStatement();
218
- }
219
- return this._parseVariableDeclaration() // variable declaration
220
- || this._tryParseRuleset(true) // nested ruleset
221
- || super._parseRuleSetDeclaration(); // try css ruleset declaration as last so in the error case, the ast will contain a declaration
222
- }
223
- _parseDeclaration(stopTokens) {
224
- const custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
225
- if (custonProperty) {
226
- return custonProperty;
227
- }
228
- const node = this.create(nodes.Declaration);
229
- if (!node.setProperty(this._parseProperty())) {
230
- return null;
231
- }
232
- if (!this.accept(TokenType.Colon)) {
233
- return this.finish(node, ParseError.ColonExpected, [TokenType.Colon], stopTokens || [TokenType.SemiColon]);
234
- }
235
- if (this.prevToken) {
236
- node.colonPosition = this.prevToken.offset;
237
- }
238
- let hasContent = false;
239
- if (node.setValue(this._parseExpr())) {
240
- hasContent = true;
241
- node.addChild(this._parsePrio());
242
- }
243
- if (this.peek(TokenType.CurlyL)) {
244
- node.setNestedProperties(this._parseNestedProperties());
245
- }
246
- else {
247
- if (!hasContent) {
248
- return this.finish(node, ParseError.PropertyValueExpected);
249
- }
250
- }
251
- if (this.peek(TokenType.SemiColon)) {
252
- node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
253
- }
254
- return this.finish(node);
255
- }
256
- _parseNestedProperties() {
257
- const node = this.create(nodes.NestedProperties);
258
- return this._parseBody(node, this._parseDeclaration.bind(this));
259
- }
260
- _parseExtends() {
261
- if (this.peekKeyword('@extend')) {
262
- const node = this.create(nodes.ExtendsReference);
263
- this.consumeToken();
264
- if (!node.getSelectors().addChild(this._parseSimpleSelector())) {
265
- return this.finish(node, ParseError.SelectorExpected);
266
- }
267
- while (this.accept(TokenType.Comma)) {
268
- node.getSelectors().addChild(this._parseSimpleSelector());
269
- }
270
- if (this.accept(TokenType.Exclamation)) {
271
- if (!this.acceptIdent('optional')) {
272
- return this.finish(node, ParseError.UnknownKeyword);
273
- }
274
- }
275
- return this.finish(node);
276
- }
277
- return null;
278
- }
279
- _parseSimpleSelectorBody() {
280
- return this._parseSelectorCombinator() || this._parseSelectorPlaceholder() || super._parseSimpleSelectorBody();
281
- }
282
- _parseSelectorCombinator() {
283
- if (this.peekDelim('&')) {
284
- const node = this.createNode(nodes.NodeType.SelectorCombinator);
285
- this.consumeToken();
286
- while (!this.hasWhitespace() && (this.acceptDelim('-') || this.accept(TokenType.Num) || this.accept(TokenType.Dimension) || node.addChild(this._parseIdent()) || this.acceptDelim('&'))) {
287
- // support &-foo-1
288
- }
289
- return this.finish(node);
290
- }
291
- return null;
292
- }
293
- _parseSelectorPlaceholder() {
294
- if (this.peekDelim('%')) {
295
- const node = this.createNode(nodes.NodeType.SelectorPlaceholder);
296
- this.consumeToken();
297
- this._parseIdent();
298
- return this.finish(node);
299
- }
300
- else if (this.peekKeyword('@at-root')) {
301
- const node = this.createNode(nodes.NodeType.SelectorPlaceholder);
302
- this.consumeToken();
303
- return this.finish(node);
304
- }
305
- return null;
306
- }
307
- _parseElementName() {
308
- const pos = this.mark();
309
- const node = super._parseElementName();
310
- if (node && !this.hasWhitespace() && this.peek(TokenType.ParenthesisL)) { // for #49589
311
- this.restoreAtMark(pos);
312
- return null;
313
- }
314
- return node;
315
- }
316
- _tryParsePseudoIdentifier() {
317
- return this._parseInterpolation() || super._tryParsePseudoIdentifier(); // for #49589
318
- }
319
- _parseWarnAndDebug() {
320
- if (!this.peekKeyword('@debug')
321
- && !this.peekKeyword('@warn')
322
- && !this.peekKeyword('@error')) {
323
- return null;
324
- }
325
- const node = this.createNode(nodes.NodeType.Debug);
326
- this.consumeToken(); // @debug, @warn or @error
327
- node.addChild(this._parseExpr()); // optional
328
- return this.finish(node);
329
- }
330
- _parseControlStatement(parseStatement = this._parseRuleSetDeclaration.bind(this)) {
331
- if (!this.peek(TokenType.AtKeyword)) {
332
- return null;
333
- }
334
- return this._parseIfStatement(parseStatement) || this._parseForStatement(parseStatement)
335
- || this._parseEachStatement(parseStatement) || this._parseWhileStatement(parseStatement);
336
- }
337
- _parseIfStatement(parseStatement) {
338
- if (!this.peekKeyword('@if')) {
339
- return null;
340
- }
341
- return this._internalParseIfStatement(parseStatement);
342
- }
343
- _internalParseIfStatement(parseStatement) {
344
- const node = this.create(nodes.IfStatement);
345
- this.consumeToken(); // @if or if
346
- if (!node.setExpression(this._parseExpr(true))) {
347
- return this.finish(node, ParseError.ExpressionExpected);
348
- }
349
- this._parseBody(node, parseStatement);
350
- if (this.acceptKeyword('@else')) {
351
- if (this.peekIdent('if')) {
352
- node.setElseClause(this._internalParseIfStatement(parseStatement));
353
- }
354
- else if (this.peek(TokenType.CurlyL)) {
355
- const elseNode = this.create(nodes.ElseStatement);
356
- this._parseBody(elseNode, parseStatement);
357
- node.setElseClause(elseNode);
358
- }
359
- }
360
- return this.finish(node);
361
- }
362
- _parseForStatement(parseStatement) {
363
- if (!this.peekKeyword('@for')) {
364
- return null;
365
- }
366
- const node = this.create(nodes.ForStatement);
367
- this.consumeToken(); // @for
368
- if (!node.setVariable(this._parseVariable())) {
369
- return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
370
- }
371
- if (!this.acceptIdent('from')) {
372
- return this.finish(node, SCSSParseError.FromExpected, [TokenType.CurlyR]);
373
- }
374
- if (!node.addChild(this._parseBinaryExpr())) {
375
- return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
376
- }
377
- if (!this.acceptIdent('to') && !this.acceptIdent('through')) {
378
- return this.finish(node, SCSSParseError.ThroughOrToExpected, [TokenType.CurlyR]);
379
- }
380
- if (!node.addChild(this._parseBinaryExpr())) {
381
- return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
382
- }
383
- return this._parseBody(node, parseStatement);
384
- }
385
- _parseEachStatement(parseStatement) {
386
- if (!this.peekKeyword('@each')) {
387
- return null;
388
- }
389
- const node = this.create(nodes.EachStatement);
390
- this.consumeToken(); // @each
391
- const variables = node.getVariables();
392
- if (!variables.addChild(this._parseVariable())) {
393
- return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
394
- }
395
- while (this.accept(TokenType.Comma)) {
396
- if (!variables.addChild(this._parseVariable())) {
397
- return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
398
- }
399
- }
400
- this.finish(variables);
401
- if (!this.acceptIdent('in')) {
402
- return this.finish(node, SCSSParseError.InExpected, [TokenType.CurlyR]);
403
- }
404
- if (!node.addChild(this._parseExpr())) {
405
- return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
406
- }
407
- return this._parseBody(node, parseStatement);
408
- }
409
- _parseWhileStatement(parseStatement) {
410
- if (!this.peekKeyword('@while')) {
411
- return null;
412
- }
413
- const node = this.create(nodes.WhileStatement);
414
- this.consumeToken(); // @while
415
- if (!node.addChild(this._parseBinaryExpr())) {
416
- return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
417
- }
418
- return this._parseBody(node, parseStatement);
419
- }
420
- _parseFunctionBodyDeclaration() {
421
- return this._parseVariableDeclaration() || this._parseReturnStatement() || this._parseWarnAndDebug()
422
- || this._parseControlStatement(this._parseFunctionBodyDeclaration.bind(this));
423
- }
424
- _parseFunctionDeclaration() {
425
- if (!this.peekKeyword('@function')) {
426
- return null;
427
- }
428
- const node = this.create(nodes.FunctionDeclaration);
429
- this.consumeToken(); // @function
430
- if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Function]))) {
431
- return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
432
- }
433
- if (!this.accept(TokenType.ParenthesisL)) {
434
- return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.CurlyR]);
435
- }
436
- if (node.getParameters().addChild(this._parseParameterDeclaration())) {
437
- while (this.accept(TokenType.Comma)) {
438
- if (this.peek(TokenType.ParenthesisR)) {
439
- break;
440
- }
441
- if (!node.getParameters().addChild(this._parseParameterDeclaration())) {
442
- return this.finish(node, ParseError.VariableNameExpected);
443
- }
444
- }
445
- }
446
- if (!this.accept(TokenType.ParenthesisR)) {
447
- return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyR]);
448
- }
449
- return this._parseBody(node, this._parseFunctionBodyDeclaration.bind(this));
450
- }
451
- _parseReturnStatement() {
452
- if (!this.peekKeyword('@return')) {
453
- return null;
454
- }
455
- const node = this.createNode(nodes.NodeType.ReturnStatement);
456
- this.consumeToken(); // @function
457
- if (!node.addChild(this._parseExpr())) {
458
- return this.finish(node, ParseError.ExpressionExpected);
459
- }
460
- return this.finish(node);
461
- }
462
- _parseMixinDeclaration() {
463
- if (!this.peekKeyword('@mixin')) {
464
- return null;
465
- }
466
- const node = this.create(nodes.MixinDeclaration);
467
- this.consumeToken();
468
- if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Mixin]))) {
469
- return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
470
- }
471
- if (this.accept(TokenType.ParenthesisL)) {
472
- if (node.getParameters().addChild(this._parseParameterDeclaration())) {
473
- while (this.accept(TokenType.Comma)) {
474
- if (this.peek(TokenType.ParenthesisR)) {
475
- break;
476
- }
477
- if (!node.getParameters().addChild(this._parseParameterDeclaration())) {
478
- return this.finish(node, ParseError.VariableNameExpected);
479
- }
480
- }
481
- }
482
- if (!this.accept(TokenType.ParenthesisR)) {
483
- return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyR]);
484
- }
485
- }
486
- return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
487
- }
488
- _parseParameterDeclaration() {
489
- const node = this.create(nodes.FunctionParameter);
490
- if (!node.setIdentifier(this._parseVariable())) {
491
- return null;
492
- }
493
- if (this.accept(scssScanner.Ellipsis)) {
494
- // ok
495
- }
496
- if (this.accept(TokenType.Colon)) {
497
- if (!node.setDefaultValue(this._parseExpr(true))) {
498
- return this.finish(node, ParseError.VariableValueExpected, [], [TokenType.Comma, TokenType.ParenthesisR]);
499
- }
500
- }
501
- return this.finish(node);
502
- }
503
- _parseMixinContent() {
504
- if (!this.peekKeyword('@content')) {
505
- return null;
506
- }
507
- const node = this.create(nodes.MixinContentReference);
508
- this.consumeToken();
509
- if (this.accept(TokenType.ParenthesisL)) {
510
- if (node.getArguments().addChild(this._parseFunctionArgument())) {
511
- while (this.accept(TokenType.Comma)) {
512
- if (this.peek(TokenType.ParenthesisR)) {
513
- break;
514
- }
515
- if (!node.getArguments().addChild(this._parseFunctionArgument())) {
516
- return this.finish(node, ParseError.ExpressionExpected);
517
- }
518
- }
519
- }
520
- if (!this.accept(TokenType.ParenthesisR)) {
521
- return this.finish(node, ParseError.RightParenthesisExpected);
522
- }
523
- }
524
- return this.finish(node);
525
- }
526
- _parseMixinReference() {
527
- if (!this.peekKeyword('@include')) {
528
- return null;
529
- }
530
- const node = this.create(nodes.MixinReference);
531
- this.consumeToken();
532
- // Could be module or mixin identifier, set as mixin as default.
533
- const firstIdent = this._parseIdent([nodes.ReferenceType.Mixin]);
534
- if (!node.setIdentifier(firstIdent)) {
535
- return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
536
- }
537
- // Is a module accessor.
538
- if (!this.hasWhitespace() && this.acceptDelim('.') && !this.hasWhitespace()) {
539
- const secondIdent = this._parseIdent([nodes.ReferenceType.Mixin]);
540
- if (!secondIdent) {
541
- return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
542
- }
543
- const moduleToken = this.create(nodes.Module);
544
- // Re-purpose first matched ident as identifier for module token.
545
- firstIdent.referenceTypes = [nodes.ReferenceType.Module];
546
- moduleToken.setIdentifier(firstIdent);
547
- // Override identifier with second ident.
548
- node.setIdentifier(secondIdent);
549
- node.addChild(moduleToken);
550
- }
551
- if (this.accept(TokenType.ParenthesisL)) {
552
- if (node.getArguments().addChild(this._parseFunctionArgument())) {
553
- while (this.accept(TokenType.Comma)) {
554
- if (this.peek(TokenType.ParenthesisR)) {
555
- break;
556
- }
557
- if (!node.getArguments().addChild(this._parseFunctionArgument())) {
558
- return this.finish(node, ParseError.ExpressionExpected);
559
- }
560
- }
561
- }
562
- if (!this.accept(TokenType.ParenthesisR)) {
563
- return this.finish(node, ParseError.RightParenthesisExpected);
564
- }
565
- }
566
- if (this.peekIdent('using') || this.peek(TokenType.CurlyL)) {
567
- node.setContent(this._parseMixinContentDeclaration());
568
- }
569
- return this.finish(node);
570
- }
571
- _parseMixinContentDeclaration() {
572
- const node = this.create(nodes.MixinContentDeclaration);
573
- if (this.acceptIdent('using')) {
574
- if (!this.accept(TokenType.ParenthesisL)) {
575
- return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.CurlyL]);
576
- }
577
- if (node.getParameters().addChild(this._parseParameterDeclaration())) {
578
- while (this.accept(TokenType.Comma)) {
579
- if (this.peek(TokenType.ParenthesisR)) {
580
- break;
581
- }
582
- if (!node.getParameters().addChild(this._parseParameterDeclaration())) {
583
- return this.finish(node, ParseError.VariableNameExpected);
584
- }
585
- }
586
- }
587
- if (!this.accept(TokenType.ParenthesisR)) {
588
- return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyL]);
589
- }
590
- }
591
- if (this.peek(TokenType.CurlyL)) {
592
- this._parseBody(node, this._parseMixinReferenceBodyStatement.bind(this));
593
- }
594
- return this.finish(node);
595
- }
596
- _parseMixinReferenceBodyStatement() {
597
- return this._tryParseKeyframeSelector() || this._parseRuleSetDeclaration();
598
- }
599
- _parseFunctionArgument() {
600
- // [variableName ':'] expression | variableName '...'
601
- const node = this.create(nodes.FunctionArgument);
602
- const pos = this.mark();
603
- const argument = this._parseVariable();
604
- if (argument) {
605
- if (!this.accept(TokenType.Colon)) {
606
- if (this.accept(scssScanner.Ellipsis)) { // optional
607
- node.setValue(argument);
608
- return this.finish(node);
609
- }
610
- else {
611
- this.restoreAtMark(pos);
612
- }
613
- }
614
- else {
615
- node.setIdentifier(argument);
616
- }
617
- }
618
- if (node.setValue(this._parseExpr(true))) {
619
- this.accept(scssScanner.Ellipsis); // #43746
620
- node.addChild(this._parsePrio()); // #9859
621
- return this.finish(node);
622
- }
623
- else if (node.setValue(this._tryParsePrio())) {
624
- return this.finish(node);
625
- }
626
- return null;
627
- }
628
- _parseURLArgument() {
629
- const pos = this.mark();
630
- const node = super._parseURLArgument();
631
- if (!node || !this.peek(TokenType.ParenthesisR)) {
632
- this.restoreAtMark(pos);
633
- const node = this.create(nodes.Node);
634
- node.addChild(this._parseBinaryExpr());
635
- return this.finish(node);
636
- }
637
- return node;
638
- }
639
- _parseOperation() {
640
- if (!this.peek(TokenType.ParenthesisL)) {
641
- return null;
642
- }
643
- const node = this.create(nodes.Node);
644
- this.consumeToken();
645
- while (node.addChild(this._parseListElement())) {
646
- this.accept(TokenType.Comma); // optional
647
- }
648
- if (!this.accept(TokenType.ParenthesisR)) {
649
- return this.finish(node, ParseError.RightParenthesisExpected);
650
- }
651
- return this.finish(node);
652
- }
653
- _parseListElement() {
654
- const node = this.create(nodes.ListEntry);
655
- const child = this._parseBinaryExpr();
656
- if (!child) {
657
- return null;
658
- }
659
- if (this.accept(TokenType.Colon)) {
660
- node.setKey(child);
661
- if (!node.setValue(this._parseBinaryExpr())) {
662
- return this.finish(node, ParseError.ExpressionExpected);
663
- }
664
- }
665
- else {
666
- node.setValue(child);
667
- }
668
- return this.finish(node);
669
- }
670
- _parseUse() {
671
- if (!this.peekKeyword('@use')) {
672
- return null;
673
- }
674
- const node = this.create(nodes.Use);
675
- this.consumeToken(); // @use
676
- if (!node.addChild(this._parseStringLiteral())) {
677
- return this.finish(node, ParseError.StringLiteralExpected);
678
- }
679
- if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {
680
- if (!this.peekRegExp(TokenType.Ident, /as|with/)) {
681
- return this.finish(node, ParseError.UnknownKeyword);
682
- }
683
- if (this.acceptIdent('as') &&
684
- (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Module])) && !this.acceptDelim('*'))) {
685
- return this.finish(node, ParseError.IdentifierOrWildcardExpected);
686
- }
687
- if (this.acceptIdent('with')) {
688
- if (!this.accept(TokenType.ParenthesisL)) {
689
- return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.ParenthesisR]);
690
- }
691
- // First variable statement, no comma.
692
- if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
693
- return this.finish(node, ParseError.VariableNameExpected);
694
- }
695
- while (this.accept(TokenType.Comma)) {
696
- if (this.peek(TokenType.ParenthesisR)) {
697
- break;
698
- }
699
- if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
700
- return this.finish(node, ParseError.VariableNameExpected);
701
- }
702
- }
703
- if (!this.accept(TokenType.ParenthesisR)) {
704
- return this.finish(node, ParseError.RightParenthesisExpected);
705
- }
706
- }
707
- }
708
- if (!this.accept(TokenType.SemiColon) && !this.accept(TokenType.EOF)) {
709
- return this.finish(node, ParseError.SemiColonExpected);
710
- }
711
- return this.finish(node);
712
- }
713
- _parseModuleConfigDeclaration() {
714
- const node = this.create(nodes.ModuleConfiguration);
715
- if (!node.setIdentifier(this._parseVariable())) {
716
- return null;
717
- }
718
- if (!this.accept(TokenType.Colon) || !node.setValue(this._parseExpr(true))) {
719
- return this.finish(node, ParseError.VariableValueExpected, [], [TokenType.Comma, TokenType.ParenthesisR]);
720
- }
721
- if (this.accept(TokenType.Exclamation)) {
722
- if (this.hasWhitespace() || !this.acceptIdent('default')) {
723
- return this.finish(node, ParseError.UnknownKeyword);
724
- }
725
- }
726
- return this.finish(node);
727
- }
728
- _parseForward() {
729
- if (!this.peekKeyword('@forward')) {
730
- return null;
731
- }
732
- const node = this.create(nodes.Forward);
733
- this.consumeToken();
734
- if (!node.addChild(this._parseStringLiteral())) {
735
- return this.finish(node, ParseError.StringLiteralExpected);
736
- }
737
- if (this.acceptIdent('with')) {
738
- if (!this.accept(TokenType.ParenthesisL)) {
739
- return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.ParenthesisR]);
740
- }
741
- // First variable statement, no comma.
742
- if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
743
- return this.finish(node, ParseError.VariableNameExpected);
744
- }
745
- while (this.accept(TokenType.Comma)) {
746
- if (this.peek(TokenType.ParenthesisR)) {
747
- break;
748
- }
749
- if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
750
- return this.finish(node, ParseError.VariableNameExpected);
751
- }
752
- }
753
- if (!this.accept(TokenType.ParenthesisR)) {
754
- return this.finish(node, ParseError.RightParenthesisExpected);
755
- }
756
- }
757
- if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {
758
- if (!this.peekRegExp(TokenType.Ident, /as|hide|show/)) {
759
- return this.finish(node, ParseError.UnknownKeyword);
760
- }
761
- if (this.acceptIdent('as')) {
762
- const identifier = this._parseIdent([nodes.ReferenceType.Forward]);
763
- if (!node.setIdentifier(identifier)) {
764
- return this.finish(node, ParseError.IdentifierExpected);
765
- }
766
- // Wildcard must be the next character after the identifier string.
767
- if (this.hasWhitespace() || !this.acceptDelim('*')) {
768
- return this.finish(node, ParseError.WildcardExpected);
769
- }
770
- }
771
- if (this.peekIdent('hide') || this.peekIdent('show')) {
772
- if (!node.addChild(this._parseForwardVisibility())) {
773
- return this.finish(node, ParseError.IdentifierOrVariableExpected);
774
- }
775
- }
776
- }
777
- if (!this.accept(TokenType.SemiColon) && !this.accept(TokenType.EOF)) {
778
- return this.finish(node, ParseError.SemiColonExpected);
779
- }
780
- return this.finish(node);
781
- }
782
- _parseForwardVisibility() {
783
- const node = this.create(nodes.ForwardVisibility);
784
- // Assume to be "hide" or "show".
785
- node.setIdentifier(this._parseIdent());
786
- while (node.addChild(this._parseVariable() || this._parseIdent())) {
787
- // Consume all variables and idents ahead.
788
- this.accept(TokenType.Comma);
789
- }
790
- // More than just identifier
791
- return node.getChildren().length > 1 ? node : null;
792
- }
793
- _parseSupportsCondition() {
794
- return this._parseInterpolation() || super._parseSupportsCondition();
795
- }
796
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ 'use strict';
6
+ import * as scssScanner from './scssScanner';
7
+ import { TokenType } from './cssScanner';
8
+ import * as cssParser from './cssParser';
9
+ import * as nodes from './cssNodes';
10
+ import { SCSSParseError } from './scssErrors';
11
+ import { ParseError } from './cssErrors';
12
+ /// <summary>
13
+ /// A parser for scss
14
+ /// http://sass-lang.com/documentation/file.SASS_REFERENCE.html
15
+ /// </summary>
16
+ export class SCSSParser extends cssParser.Parser {
17
+ constructor() {
18
+ super(new scssScanner.SCSSScanner());
19
+ }
20
+ _parseStylesheetStatement(isNested = false) {
21
+ if (this.peek(TokenType.AtKeyword)) {
22
+ return this._parseWarnAndDebug() // @warn, @debug and @error statements
23
+ || this._parseControlStatement() // @if, @while, @for, @each
24
+ || this._parseMixinDeclaration() // @mixin
25
+ || this._parseMixinContent() // @content
26
+ || this._parseMixinReference() // @include
27
+ || this._parseFunctionDeclaration() // @function
28
+ || this._parseForward() // @forward
29
+ || this._parseUse() // @use
30
+ || this._parseRuleset(isNested) // @at-rule
31
+ || super._parseStylesheetAtStatement(isNested);
32
+ }
33
+ return this._parseRuleset(true) || this._parseVariableDeclaration();
34
+ }
35
+ _parseImport() {
36
+ if (!this.peekKeyword('@import')) {
37
+ return null;
38
+ }
39
+ const node = this.create(nodes.Import);
40
+ this.consumeToken();
41
+ if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) {
42
+ return this.finish(node, ParseError.URIOrStringExpected);
43
+ }
44
+ while (this.accept(TokenType.Comma)) {
45
+ if (!node.addChild(this._parseURILiteral()) && !node.addChild(this._parseStringLiteral())) {
46
+ return this.finish(node, ParseError.URIOrStringExpected);
47
+ }
48
+ }
49
+ if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {
50
+ node.setMedialist(this._parseMediaQueryList());
51
+ }
52
+ return this.finish(node);
53
+ }
54
+ // scss variables: $font-size: 12px;
55
+ _parseVariableDeclaration(panic = []) {
56
+ if (!this.peek(scssScanner.VariableName)) {
57
+ return null;
58
+ }
59
+ const node = this.create(nodes.VariableDeclaration);
60
+ if (!node.setVariable(this._parseVariable())) {
61
+ return null;
62
+ }
63
+ if (!this.accept(TokenType.Colon)) {
64
+ return this.finish(node, ParseError.ColonExpected);
65
+ }
66
+ if (this.prevToken) {
67
+ node.colonPosition = this.prevToken.offset;
68
+ }
69
+ if (!node.setValue(this._parseExpr())) {
70
+ return this.finish(node, ParseError.VariableValueExpected, [], panic);
71
+ }
72
+ while (this.peek(TokenType.Exclamation)) {
73
+ if (node.addChild(this._tryParsePrio())) {
74
+ // !important
75
+ }
76
+ else {
77
+ this.consumeToken();
78
+ if (!this.peekRegExp(TokenType.Ident, /^(default|global)$/)) {
79
+ return this.finish(node, ParseError.UnknownKeyword);
80
+ }
81
+ this.consumeToken();
82
+ }
83
+ }
84
+ if (this.peek(TokenType.SemiColon)) {
85
+ node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
86
+ }
87
+ return this.finish(node);
88
+ }
89
+ _parseMediaCondition() {
90
+ return this._parseInterpolation() || super._parseMediaCondition();
91
+ }
92
+ _parseMediaFeatureName() {
93
+ return this._parseModuleMember()
94
+ || this._parseFunction() // function before ident
95
+ || this._parseIdent()
96
+ || this._parseVariable();
97
+ }
98
+ _parseKeyframeSelector() {
99
+ return this._tryParseKeyframeSelector()
100
+ || this._parseControlStatement(this._parseKeyframeSelector.bind(this))
101
+ || this._parseVariableDeclaration()
102
+ || this._parseMixinContent();
103
+ }
104
+ _parseVariable() {
105
+ if (!this.peek(scssScanner.VariableName)) {
106
+ return null;
107
+ }
108
+ const node = this.create(nodes.Variable);
109
+ this.consumeToken();
110
+ return node;
111
+ }
112
+ _parseModuleMember() {
113
+ const pos = this.mark();
114
+ const node = this.create(nodes.Module);
115
+ if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Module]))) {
116
+ return null;
117
+ }
118
+ if (this.hasWhitespace()
119
+ || !this.acceptDelim('.')
120
+ || this.hasWhitespace()) {
121
+ this.restoreAtMark(pos);
122
+ return null;
123
+ }
124
+ if (!node.addChild(this._parseVariable() || this._parseFunction())) {
125
+ return this.finish(node, ParseError.IdentifierOrVariableExpected);
126
+ }
127
+ return node;
128
+ }
129
+ _parseIdent(referenceTypes) {
130
+ if (!this.peek(TokenType.Ident) && !this.peek(scssScanner.InterpolationFunction) && !this.peekDelim('-')) {
131
+ return null;
132
+ }
133
+ const node = this.create(nodes.Identifier);
134
+ node.referenceTypes = referenceTypes;
135
+ node.isCustomProperty = this.peekRegExp(TokenType.Ident, /^--/);
136
+ let hasContent = false;
137
+ const indentInterpolation = () => {
138
+ const pos = this.mark();
139
+ if (this.acceptDelim('-')) {
140
+ if (!this.hasWhitespace()) {
141
+ this.acceptDelim('-');
142
+ }
143
+ if (this.hasWhitespace()) {
144
+ this.restoreAtMark(pos);
145
+ return null;
146
+ }
147
+ }
148
+ return this._parseInterpolation();
149
+ };
150
+ while (this.accept(TokenType.Ident) || node.addChild(indentInterpolation()) || (hasContent && this.acceptRegexp(/^[\w-]/))) {
151
+ hasContent = true;
152
+ if (this.hasWhitespace()) {
153
+ break;
154
+ }
155
+ }
156
+ return hasContent ? this.finish(node) : null;
157
+ }
158
+ _parseTermExpression() {
159
+ return this._parseModuleMember() ||
160
+ this._parseVariable() ||
161
+ this._parseSelectorCombinator() ||
162
+ //this._tryParsePrio() ||
163
+ super._parseTermExpression();
164
+ }
165
+ _parseInterpolation() {
166
+ if (this.peek(scssScanner.InterpolationFunction)) {
167
+ const node = this.create(nodes.Interpolation);
168
+ this.consumeToken();
169
+ if (!node.addChild(this._parseExpr()) && !this._parseSelectorCombinator()) {
170
+ if (this.accept(TokenType.CurlyR)) {
171
+ return this.finish(node);
172
+ }
173
+ return this.finish(node, ParseError.ExpressionExpected);
174
+ }
175
+ if (!this.accept(TokenType.CurlyR)) {
176
+ return this.finish(node, ParseError.RightCurlyExpected);
177
+ }
178
+ return this.finish(node);
179
+ }
180
+ return null;
181
+ }
182
+ _parseOperator() {
183
+ if (this.peek(scssScanner.EqualsOperator) || this.peek(scssScanner.NotEqualsOperator)
184
+ || this.peek(scssScanner.GreaterEqualsOperator) || this.peek(scssScanner.SmallerEqualsOperator)
185
+ || this.peekDelim('>') || this.peekDelim('<')
186
+ || this.peekIdent('and') || this.peekIdent('or')
187
+ || this.peekDelim('%')) {
188
+ const node = this.createNode(nodes.NodeType.Operator);
189
+ this.consumeToken();
190
+ return this.finish(node);
191
+ }
192
+ return super._parseOperator();
193
+ }
194
+ _parseUnaryOperator() {
195
+ if (this.peekIdent('not')) {
196
+ const node = this.create(nodes.Node);
197
+ this.consumeToken();
198
+ return this.finish(node);
199
+ }
200
+ return super._parseUnaryOperator();
201
+ }
202
+ _parseRuleSetDeclaration() {
203
+ if (this.peek(TokenType.AtKeyword)) {
204
+ return this._parseKeyframe() // nested @keyframe
205
+ || this._parseImport() // nested @import
206
+ || this._parseMedia(true) // nested @media
207
+ || this._parseFontFace() // nested @font-face
208
+ || this._parseWarnAndDebug() // @warn, @debug and @error statements
209
+ || this._parseControlStatement() // @if, @while, @for, @each
210
+ || this._parseFunctionDeclaration() // @function
211
+ || this._parseExtends() // @extends
212
+ || this._parseMixinReference() // @include
213
+ || this._parseMixinContent() // @content
214
+ || this._parseMixinDeclaration() // nested @mixin
215
+ || this._parseRuleset(true) // @at-rule
216
+ || this._parseSupports(true) // @supports
217
+ || this._parseLayer() // @layer
218
+ || super._parseRuleSetDeclarationAtStatement();
219
+ }
220
+ return this._parseVariableDeclaration() // variable declaration
221
+ || this._tryParseRuleset(true) // nested ruleset
222
+ || super._parseRuleSetDeclaration(); // try css ruleset declaration as last so in the error case, the ast will contain a declaration
223
+ }
224
+ _parseDeclaration(stopTokens) {
225
+ const custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
226
+ if (custonProperty) {
227
+ return custonProperty;
228
+ }
229
+ const node = this.create(nodes.Declaration);
230
+ if (!node.setProperty(this._parseProperty())) {
231
+ return null;
232
+ }
233
+ if (!this.accept(TokenType.Colon)) {
234
+ return this.finish(node, ParseError.ColonExpected, [TokenType.Colon], stopTokens || [TokenType.SemiColon]);
235
+ }
236
+ if (this.prevToken) {
237
+ node.colonPosition = this.prevToken.offset;
238
+ }
239
+ let hasContent = false;
240
+ if (node.setValue(this._parseExpr())) {
241
+ hasContent = true;
242
+ node.addChild(this._parsePrio());
243
+ }
244
+ if (this.peek(TokenType.CurlyL)) {
245
+ node.setNestedProperties(this._parseNestedProperties());
246
+ }
247
+ else {
248
+ if (!hasContent) {
249
+ return this.finish(node, ParseError.PropertyValueExpected);
250
+ }
251
+ }
252
+ if (this.peek(TokenType.SemiColon)) {
253
+ node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
254
+ }
255
+ return this.finish(node);
256
+ }
257
+ _parseNestedProperties() {
258
+ const node = this.create(nodes.NestedProperties);
259
+ return this._parseBody(node, this._parseDeclaration.bind(this));
260
+ }
261
+ _parseExtends() {
262
+ if (this.peekKeyword('@extend')) {
263
+ const node = this.create(nodes.ExtendsReference);
264
+ this.consumeToken();
265
+ if (!node.getSelectors().addChild(this._parseSimpleSelector())) {
266
+ return this.finish(node, ParseError.SelectorExpected);
267
+ }
268
+ while (this.accept(TokenType.Comma)) {
269
+ node.getSelectors().addChild(this._parseSimpleSelector());
270
+ }
271
+ if (this.accept(TokenType.Exclamation)) {
272
+ if (!this.acceptIdent('optional')) {
273
+ return this.finish(node, ParseError.UnknownKeyword);
274
+ }
275
+ }
276
+ return this.finish(node);
277
+ }
278
+ return null;
279
+ }
280
+ _parseSimpleSelectorBody() {
281
+ return this._parseSelectorCombinator() || this._parseSelectorPlaceholder() || super._parseSimpleSelectorBody();
282
+ }
283
+ _parseSelectorCombinator() {
284
+ if (this.peekDelim('&')) {
285
+ const node = this.createNode(nodes.NodeType.SelectorCombinator);
286
+ this.consumeToken();
287
+ while (!this.hasWhitespace() && (this.acceptDelim('-') || this.accept(TokenType.Num) || this.accept(TokenType.Dimension) || node.addChild(this._parseIdent()) || this.acceptDelim('&'))) {
288
+ // support &-foo-1
289
+ }
290
+ return this.finish(node);
291
+ }
292
+ return null;
293
+ }
294
+ _parseSelectorPlaceholder() {
295
+ if (this.peekDelim('%')) {
296
+ const node = this.createNode(nodes.NodeType.SelectorPlaceholder);
297
+ this.consumeToken();
298
+ this._parseIdent();
299
+ return this.finish(node);
300
+ }
301
+ else if (this.peekKeyword('@at-root')) {
302
+ const node = this.createNode(nodes.NodeType.SelectorPlaceholder);
303
+ this.consumeToken();
304
+ if (this.accept(TokenType.ParenthesisL)) {
305
+ if (!this.acceptIdent('with') && !this.acceptIdent('without')) {
306
+ return this.finish(node, ParseError.IdentifierExpected);
307
+ }
308
+ if (!this.accept(TokenType.Colon)) {
309
+ return this.finish(node, ParseError.ColonExpected);
310
+ }
311
+ if (!node.addChild(this._parseIdent())) {
312
+ return this.finish(node, ParseError.IdentifierExpected);
313
+ }
314
+ if (!this.accept(TokenType.ParenthesisR)) {
315
+ return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyR]);
316
+ }
317
+ }
318
+ return this.finish(node);
319
+ }
320
+ return null;
321
+ }
322
+ _parseElementName() {
323
+ const pos = this.mark();
324
+ const node = super._parseElementName();
325
+ if (node && !this.hasWhitespace() && this.peek(TokenType.ParenthesisL)) { // for #49589
326
+ this.restoreAtMark(pos);
327
+ return null;
328
+ }
329
+ return node;
330
+ }
331
+ _tryParsePseudoIdentifier() {
332
+ return this._parseInterpolation() || super._tryParsePseudoIdentifier(); // for #49589
333
+ }
334
+ _parseWarnAndDebug() {
335
+ if (!this.peekKeyword('@debug')
336
+ && !this.peekKeyword('@warn')
337
+ && !this.peekKeyword('@error')) {
338
+ return null;
339
+ }
340
+ const node = this.createNode(nodes.NodeType.Debug);
341
+ this.consumeToken(); // @debug, @warn or @error
342
+ node.addChild(this._parseExpr()); // optional
343
+ return this.finish(node);
344
+ }
345
+ _parseControlStatement(parseStatement = this._parseRuleSetDeclaration.bind(this)) {
346
+ if (!this.peek(TokenType.AtKeyword)) {
347
+ return null;
348
+ }
349
+ return this._parseIfStatement(parseStatement) || this._parseForStatement(parseStatement)
350
+ || this._parseEachStatement(parseStatement) || this._parseWhileStatement(parseStatement);
351
+ }
352
+ _parseIfStatement(parseStatement) {
353
+ if (!this.peekKeyword('@if')) {
354
+ return null;
355
+ }
356
+ return this._internalParseIfStatement(parseStatement);
357
+ }
358
+ _internalParseIfStatement(parseStatement) {
359
+ const node = this.create(nodes.IfStatement);
360
+ this.consumeToken(); // @if or if
361
+ if (!node.setExpression(this._parseExpr(true))) {
362
+ return this.finish(node, ParseError.ExpressionExpected);
363
+ }
364
+ this._parseBody(node, parseStatement);
365
+ if (this.acceptKeyword('@else')) {
366
+ if (this.peekIdent('if')) {
367
+ node.setElseClause(this._internalParseIfStatement(parseStatement));
368
+ }
369
+ else if (this.peek(TokenType.CurlyL)) {
370
+ const elseNode = this.create(nodes.ElseStatement);
371
+ this._parseBody(elseNode, parseStatement);
372
+ node.setElseClause(elseNode);
373
+ }
374
+ }
375
+ return this.finish(node);
376
+ }
377
+ _parseForStatement(parseStatement) {
378
+ if (!this.peekKeyword('@for')) {
379
+ return null;
380
+ }
381
+ const node = this.create(nodes.ForStatement);
382
+ this.consumeToken(); // @for
383
+ if (!node.setVariable(this._parseVariable())) {
384
+ return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
385
+ }
386
+ if (!this.acceptIdent('from')) {
387
+ return this.finish(node, SCSSParseError.FromExpected, [TokenType.CurlyR]);
388
+ }
389
+ if (!node.addChild(this._parseBinaryExpr())) {
390
+ return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
391
+ }
392
+ if (!this.acceptIdent('to') && !this.acceptIdent('through')) {
393
+ return this.finish(node, SCSSParseError.ThroughOrToExpected, [TokenType.CurlyR]);
394
+ }
395
+ if (!node.addChild(this._parseBinaryExpr())) {
396
+ return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
397
+ }
398
+ return this._parseBody(node, parseStatement);
399
+ }
400
+ _parseEachStatement(parseStatement) {
401
+ if (!this.peekKeyword('@each')) {
402
+ return null;
403
+ }
404
+ const node = this.create(nodes.EachStatement);
405
+ this.consumeToken(); // @each
406
+ const variables = node.getVariables();
407
+ if (!variables.addChild(this._parseVariable())) {
408
+ return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
409
+ }
410
+ while (this.accept(TokenType.Comma)) {
411
+ if (!variables.addChild(this._parseVariable())) {
412
+ return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
413
+ }
414
+ }
415
+ this.finish(variables);
416
+ if (!this.acceptIdent('in')) {
417
+ return this.finish(node, SCSSParseError.InExpected, [TokenType.CurlyR]);
418
+ }
419
+ if (!node.addChild(this._parseExpr())) {
420
+ return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
421
+ }
422
+ return this._parseBody(node, parseStatement);
423
+ }
424
+ _parseWhileStatement(parseStatement) {
425
+ if (!this.peekKeyword('@while')) {
426
+ return null;
427
+ }
428
+ const node = this.create(nodes.WhileStatement);
429
+ this.consumeToken(); // @while
430
+ if (!node.addChild(this._parseBinaryExpr())) {
431
+ return this.finish(node, ParseError.ExpressionExpected, [TokenType.CurlyR]);
432
+ }
433
+ return this._parseBody(node, parseStatement);
434
+ }
435
+ _parseFunctionBodyDeclaration() {
436
+ return this._parseVariableDeclaration() || this._parseReturnStatement() || this._parseWarnAndDebug()
437
+ || this._parseControlStatement(this._parseFunctionBodyDeclaration.bind(this));
438
+ }
439
+ _parseFunctionDeclaration() {
440
+ if (!this.peekKeyword('@function')) {
441
+ return null;
442
+ }
443
+ const node = this.create(nodes.FunctionDeclaration);
444
+ this.consumeToken(); // @function
445
+ if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Function]))) {
446
+ return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
447
+ }
448
+ if (!this.accept(TokenType.ParenthesisL)) {
449
+ return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.CurlyR]);
450
+ }
451
+ if (node.getParameters().addChild(this._parseParameterDeclaration())) {
452
+ while (this.accept(TokenType.Comma)) {
453
+ if (this.peek(TokenType.ParenthesisR)) {
454
+ break;
455
+ }
456
+ if (!node.getParameters().addChild(this._parseParameterDeclaration())) {
457
+ return this.finish(node, ParseError.VariableNameExpected);
458
+ }
459
+ }
460
+ }
461
+ if (!this.accept(TokenType.ParenthesisR)) {
462
+ return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyR]);
463
+ }
464
+ return this._parseBody(node, this._parseFunctionBodyDeclaration.bind(this));
465
+ }
466
+ _parseReturnStatement() {
467
+ if (!this.peekKeyword('@return')) {
468
+ return null;
469
+ }
470
+ const node = this.createNode(nodes.NodeType.ReturnStatement);
471
+ this.consumeToken(); // @function
472
+ if (!node.addChild(this._parseExpr())) {
473
+ return this.finish(node, ParseError.ExpressionExpected);
474
+ }
475
+ return this.finish(node);
476
+ }
477
+ _parseMixinDeclaration() {
478
+ if (!this.peekKeyword('@mixin')) {
479
+ return null;
480
+ }
481
+ const node = this.create(nodes.MixinDeclaration);
482
+ this.consumeToken();
483
+ if (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Mixin]))) {
484
+ return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
485
+ }
486
+ if (this.accept(TokenType.ParenthesisL)) {
487
+ if (node.getParameters().addChild(this._parseParameterDeclaration())) {
488
+ while (this.accept(TokenType.Comma)) {
489
+ if (this.peek(TokenType.ParenthesisR)) {
490
+ break;
491
+ }
492
+ if (!node.getParameters().addChild(this._parseParameterDeclaration())) {
493
+ return this.finish(node, ParseError.VariableNameExpected);
494
+ }
495
+ }
496
+ }
497
+ if (!this.accept(TokenType.ParenthesisR)) {
498
+ return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyR]);
499
+ }
500
+ }
501
+ return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
502
+ }
503
+ _parseParameterDeclaration() {
504
+ const node = this.create(nodes.FunctionParameter);
505
+ if (!node.setIdentifier(this._parseVariable())) {
506
+ return null;
507
+ }
508
+ if (this.accept(scssScanner.Ellipsis)) {
509
+ // ok
510
+ }
511
+ if (this.accept(TokenType.Colon)) {
512
+ if (!node.setDefaultValue(this._parseExpr(true))) {
513
+ return this.finish(node, ParseError.VariableValueExpected, [], [TokenType.Comma, TokenType.ParenthesisR]);
514
+ }
515
+ }
516
+ return this.finish(node);
517
+ }
518
+ _parseMixinContent() {
519
+ if (!this.peekKeyword('@content')) {
520
+ return null;
521
+ }
522
+ const node = this.create(nodes.MixinContentReference);
523
+ this.consumeToken();
524
+ if (this.accept(TokenType.ParenthesisL)) {
525
+ if (node.getArguments().addChild(this._parseFunctionArgument())) {
526
+ while (this.accept(TokenType.Comma)) {
527
+ if (this.peek(TokenType.ParenthesisR)) {
528
+ break;
529
+ }
530
+ if (!node.getArguments().addChild(this._parseFunctionArgument())) {
531
+ return this.finish(node, ParseError.ExpressionExpected);
532
+ }
533
+ }
534
+ }
535
+ if (!this.accept(TokenType.ParenthesisR)) {
536
+ return this.finish(node, ParseError.RightParenthesisExpected);
537
+ }
538
+ }
539
+ return this.finish(node);
540
+ }
541
+ _parseMixinReference() {
542
+ if (!this.peekKeyword('@include')) {
543
+ return null;
544
+ }
545
+ const node = this.create(nodes.MixinReference);
546
+ this.consumeToken();
547
+ // Could be module or mixin identifier, set as mixin as default.
548
+ const firstIdent = this._parseIdent([nodes.ReferenceType.Mixin]);
549
+ if (!node.setIdentifier(firstIdent)) {
550
+ return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
551
+ }
552
+ // Is a module accessor.
553
+ if (!this.hasWhitespace() && this.acceptDelim('.') && !this.hasWhitespace()) {
554
+ const secondIdent = this._parseIdent([nodes.ReferenceType.Mixin]);
555
+ if (!secondIdent) {
556
+ return this.finish(node, ParseError.IdentifierExpected, [TokenType.CurlyR]);
557
+ }
558
+ const moduleToken = this.create(nodes.Module);
559
+ // Re-purpose first matched ident as identifier for module token.
560
+ firstIdent.referenceTypes = [nodes.ReferenceType.Module];
561
+ moduleToken.setIdentifier(firstIdent);
562
+ // Override identifier with second ident.
563
+ node.setIdentifier(secondIdent);
564
+ node.addChild(moduleToken);
565
+ }
566
+ if (this.accept(TokenType.ParenthesisL)) {
567
+ if (node.getArguments().addChild(this._parseFunctionArgument())) {
568
+ while (this.accept(TokenType.Comma)) {
569
+ if (this.peek(TokenType.ParenthesisR)) {
570
+ break;
571
+ }
572
+ if (!node.getArguments().addChild(this._parseFunctionArgument())) {
573
+ return this.finish(node, ParseError.ExpressionExpected);
574
+ }
575
+ }
576
+ }
577
+ if (!this.accept(TokenType.ParenthesisR)) {
578
+ return this.finish(node, ParseError.RightParenthesisExpected);
579
+ }
580
+ }
581
+ if (this.peekIdent('using') || this.peek(TokenType.CurlyL)) {
582
+ node.setContent(this._parseMixinContentDeclaration());
583
+ }
584
+ return this.finish(node);
585
+ }
586
+ _parseMixinContentDeclaration() {
587
+ const node = this.create(nodes.MixinContentDeclaration);
588
+ if (this.acceptIdent('using')) {
589
+ if (!this.accept(TokenType.ParenthesisL)) {
590
+ return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.CurlyL]);
591
+ }
592
+ if (node.getParameters().addChild(this._parseParameterDeclaration())) {
593
+ while (this.accept(TokenType.Comma)) {
594
+ if (this.peek(TokenType.ParenthesisR)) {
595
+ break;
596
+ }
597
+ if (!node.getParameters().addChild(this._parseParameterDeclaration())) {
598
+ return this.finish(node, ParseError.VariableNameExpected);
599
+ }
600
+ }
601
+ }
602
+ if (!this.accept(TokenType.ParenthesisR)) {
603
+ return this.finish(node, ParseError.RightParenthesisExpected, [TokenType.CurlyL]);
604
+ }
605
+ }
606
+ if (this.peek(TokenType.CurlyL)) {
607
+ this._parseBody(node, this._parseMixinReferenceBodyStatement.bind(this));
608
+ }
609
+ return this.finish(node);
610
+ }
611
+ _parseMixinReferenceBodyStatement() {
612
+ return this._tryParseKeyframeSelector() || this._parseRuleSetDeclaration();
613
+ }
614
+ _parseFunctionArgument() {
615
+ // [variableName ':'] expression | variableName '...'
616
+ const node = this.create(nodes.FunctionArgument);
617
+ const pos = this.mark();
618
+ const argument = this._parseVariable();
619
+ if (argument) {
620
+ if (!this.accept(TokenType.Colon)) {
621
+ if (this.accept(scssScanner.Ellipsis)) { // optional
622
+ node.setValue(argument);
623
+ return this.finish(node);
624
+ }
625
+ else {
626
+ this.restoreAtMark(pos);
627
+ }
628
+ }
629
+ else {
630
+ node.setIdentifier(argument);
631
+ }
632
+ }
633
+ if (node.setValue(this._parseExpr(true))) {
634
+ this.accept(scssScanner.Ellipsis); // #43746
635
+ node.addChild(this._parsePrio()); // #9859
636
+ return this.finish(node);
637
+ }
638
+ else if (node.setValue(this._tryParsePrio())) {
639
+ return this.finish(node);
640
+ }
641
+ return null;
642
+ }
643
+ _parseURLArgument() {
644
+ const pos = this.mark();
645
+ const node = super._parseURLArgument();
646
+ if (!node || !this.peek(TokenType.ParenthesisR)) {
647
+ this.restoreAtMark(pos);
648
+ const node = this.create(nodes.Node);
649
+ node.addChild(this._parseBinaryExpr());
650
+ return this.finish(node);
651
+ }
652
+ return node;
653
+ }
654
+ _parseOperation() {
655
+ if (!this.peek(TokenType.ParenthesisL)) {
656
+ return null;
657
+ }
658
+ const node = this.create(nodes.Node);
659
+ this.consumeToken();
660
+ while (node.addChild(this._parseListElement())) {
661
+ this.accept(TokenType.Comma); // optional
662
+ }
663
+ if (!this.accept(TokenType.ParenthesisR)) {
664
+ return this.finish(node, ParseError.RightParenthesisExpected);
665
+ }
666
+ return this.finish(node);
667
+ }
668
+ _parseListElement() {
669
+ const node = this.create(nodes.ListEntry);
670
+ const child = this._parseBinaryExpr();
671
+ if (!child) {
672
+ return null;
673
+ }
674
+ if (this.accept(TokenType.Colon)) {
675
+ node.setKey(child);
676
+ if (!node.setValue(this._parseBinaryExpr())) {
677
+ return this.finish(node, ParseError.ExpressionExpected);
678
+ }
679
+ }
680
+ else {
681
+ node.setValue(child);
682
+ }
683
+ return this.finish(node);
684
+ }
685
+ _parseUse() {
686
+ if (!this.peekKeyword('@use')) {
687
+ return null;
688
+ }
689
+ const node = this.create(nodes.Use);
690
+ this.consumeToken(); // @use
691
+ if (!node.addChild(this._parseStringLiteral())) {
692
+ return this.finish(node, ParseError.StringLiteralExpected);
693
+ }
694
+ if (!this.peek(TokenType.SemiColon) && !this.peek(TokenType.EOF)) {
695
+ if (!this.peekRegExp(TokenType.Ident, /as|with/)) {
696
+ return this.finish(node, ParseError.UnknownKeyword);
697
+ }
698
+ if (this.acceptIdent('as') &&
699
+ (!node.setIdentifier(this._parseIdent([nodes.ReferenceType.Module])) && !this.acceptDelim('*'))) {
700
+ return this.finish(node, ParseError.IdentifierOrWildcardExpected);
701
+ }
702
+ if (this.acceptIdent('with')) {
703
+ if (!this.accept(TokenType.ParenthesisL)) {
704
+ return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.ParenthesisR]);
705
+ }
706
+ // First variable statement, no comma.
707
+ if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
708
+ return this.finish(node, ParseError.VariableNameExpected);
709
+ }
710
+ while (this.accept(TokenType.Comma)) {
711
+ if (this.peek(TokenType.ParenthesisR)) {
712
+ break;
713
+ }
714
+ if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
715
+ return this.finish(node, ParseError.VariableNameExpected);
716
+ }
717
+ }
718
+ if (!this.accept(TokenType.ParenthesisR)) {
719
+ return this.finish(node, ParseError.RightParenthesisExpected);
720
+ }
721
+ }
722
+ }
723
+ if (!this.accept(TokenType.SemiColon) && !this.accept(TokenType.EOF)) {
724
+ return this.finish(node, ParseError.SemiColonExpected);
725
+ }
726
+ return this.finish(node);
727
+ }
728
+ _parseModuleConfigDeclaration() {
729
+ const node = this.create(nodes.ModuleConfiguration);
730
+ if (!node.setIdentifier(this._parseVariable())) {
731
+ return null;
732
+ }
733
+ if (!this.accept(TokenType.Colon) || !node.setValue(this._parseExpr(true))) {
734
+ return this.finish(node, ParseError.VariableValueExpected, [], [TokenType.Comma, TokenType.ParenthesisR]);
735
+ }
736
+ if (this.accept(TokenType.Exclamation)) {
737
+ if (this.hasWhitespace() || !this.acceptIdent('default')) {
738
+ return this.finish(node, ParseError.UnknownKeyword);
739
+ }
740
+ }
741
+ return this.finish(node);
742
+ }
743
+ _parseForward() {
744
+ if (!this.peekKeyword('@forward')) {
745
+ return null;
746
+ }
747
+ const node = this.create(nodes.Forward);
748
+ this.consumeToken();
749
+ if (!node.addChild(this._parseStringLiteral())) {
750
+ return this.finish(node, ParseError.StringLiteralExpected);
751
+ }
752
+ if (this.acceptIdent('as')) {
753
+ const identifier = this._parseIdent([nodes.ReferenceType.Forward]);
754
+ if (!node.setIdentifier(identifier)) {
755
+ return this.finish(node, ParseError.IdentifierExpected);
756
+ }
757
+ // Wildcard must be the next character after the identifier string.
758
+ if (this.hasWhitespace() || !this.acceptDelim('*')) {
759
+ return this.finish(node, ParseError.WildcardExpected);
760
+ }
761
+ }
762
+ if (this.acceptIdent('with')) {
763
+ if (!this.accept(TokenType.ParenthesisL)) {
764
+ return this.finish(node, ParseError.LeftParenthesisExpected, [TokenType.ParenthesisR]);
765
+ }
766
+ // First variable statement, no comma.
767
+ if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
768
+ return this.finish(node, ParseError.VariableNameExpected);
769
+ }
770
+ while (this.accept(TokenType.Comma)) {
771
+ if (this.peek(TokenType.ParenthesisR)) {
772
+ break;
773
+ }
774
+ if (!node.getParameters().addChild(this._parseModuleConfigDeclaration())) {
775
+ return this.finish(node, ParseError.VariableNameExpected);
776
+ }
777
+ }
778
+ if (!this.accept(TokenType.ParenthesisR)) {
779
+ return this.finish(node, ParseError.RightParenthesisExpected);
780
+ }
781
+ }
782
+ else if (this.peekIdent('hide') || this.peekIdent('show')) {
783
+ if (!node.addChild(this._parseForwardVisibility())) {
784
+ return this.finish(node, ParseError.IdentifierOrVariableExpected);
785
+ }
786
+ }
787
+ if (!this.accept(TokenType.SemiColon) && !this.accept(TokenType.EOF)) {
788
+ return this.finish(node, ParseError.SemiColonExpected);
789
+ }
790
+ return this.finish(node);
791
+ }
792
+ _parseForwardVisibility() {
793
+ const node = this.create(nodes.ForwardVisibility);
794
+ // Assume to be "hide" or "show".
795
+ node.setIdentifier(this._parseIdent());
796
+ while (node.addChild(this._parseVariable() || this._parseIdent())) {
797
+ // Consume all variables and idents ahead.
798
+ this.accept(TokenType.Comma);
799
+ }
800
+ // More than just identifier
801
+ return node.getChildren().length > 1 ? node : null;
802
+ }
803
+ _parseSupportsCondition() {
804
+ return this._parseInterpolation() || super._parseSupportsCondition();
805
+ }
806
+ }