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