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