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