vscode-css-languageservice 5.1.9 → 5.1.13
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/lib/esm/cssLanguageService.js +2 -2
- package/lib/esm/data/webCustomData.js +172 -151
- package/lib/esm/languageFacts/colors.js +58 -4
- package/lib/esm/languageFacts/entry.js +4 -4
- package/lib/esm/parser/cssParser.js +1 -0
- package/lib/esm/services/cssCompletion.js +1 -1
- package/lib/esm/services/cssNavigation.js +48 -13
- package/lib/esm/services/lint.js +1 -1
- package/lib/esm/services/scssCompletion.js +2 -2
- package/lib/esm/services/scssNavigation.js +1 -1
- package/lib/esm/services/selectorPrinting.js +58 -14
- package/lib/umd/cssLanguageService.js +2 -2
- package/lib/umd/data/webCustomData.js +172 -151
- package/lib/umd/languageFacts/colors.js +61 -5
- package/lib/umd/languageFacts/entry.js +4 -4
- package/lib/umd/parser/cssParser.js +1 -0
- package/lib/umd/services/cssCompletion.js +1 -1
- package/lib/umd/services/cssNavigation.js +47 -12
- package/lib/umd/services/lint.js +1 -1
- package/lib/umd/services/scssCompletion.js +2 -2
- package/lib/umd/services/scssNavigation.js +1 -1
- package/lib/umd/services/selectorPrinting.js +58 -14
- package/package.json +9 -9
|
@@ -9,7 +9,8 @@ export var colorFunctions = [
|
|
|
9
9
|
{ func: 'rgb($red, $green, $blue)', desc: localize('css.builtin.rgb', 'Creates a Color from red, green, and blue values.') },
|
|
10
10
|
{ func: 'rgba($red, $green, $blue, $alpha)', desc: localize('css.builtin.rgba', 'Creates a Color from red, green, blue, and alpha values.') },
|
|
11
11
|
{ func: 'hsl($hue, $saturation, $lightness)', desc: localize('css.builtin.hsl', 'Creates a Color from hue, saturation, and lightness values.') },
|
|
12
|
-
{ func: 'hsla($hue, $saturation, $lightness, $alpha)', desc: localize('css.builtin.hsla', 'Creates a Color from hue, saturation, lightness, and alpha values.') }
|
|
12
|
+
{ func: 'hsla($hue, $saturation, $lightness, $alpha)', desc: localize('css.builtin.hsla', 'Creates a Color from hue, saturation, lightness, and alpha values.') },
|
|
13
|
+
{ func: 'hwb($hue $white $black)', desc: localize('css.builtin.hwb', 'Creates a Color from hue, white and black.') }
|
|
13
14
|
];
|
|
14
15
|
export var colors = {
|
|
15
16
|
aliceblue: '#f0f8ff',
|
|
@@ -181,9 +182,22 @@ function getNumericValue(node, factor) {
|
|
|
181
182
|
}
|
|
182
183
|
function getAngle(node) {
|
|
183
184
|
var val = node.getText();
|
|
184
|
-
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg)?$/);
|
|
185
|
+
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg|rad|grad|turn)?$/);
|
|
185
186
|
if (m) {
|
|
186
|
-
|
|
187
|
+
switch (m[2]) {
|
|
188
|
+
case 'deg':
|
|
189
|
+
return parseFloat(val) % 360;
|
|
190
|
+
case 'rad':
|
|
191
|
+
return (parseFloat(val) * 180 / Math.PI) % 360;
|
|
192
|
+
case 'grad':
|
|
193
|
+
return (parseFloat(val) * 0.9) % 360;
|
|
194
|
+
case 'turn':
|
|
195
|
+
return (parseFloat(val) * 360) % 360;
|
|
196
|
+
default:
|
|
197
|
+
if ('undefined' === typeof m[2]) {
|
|
198
|
+
return parseFloat(val) % 360;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
187
201
|
}
|
|
188
202
|
throw new Error();
|
|
189
203
|
}
|
|
@@ -192,7 +206,7 @@ export function isColorConstructor(node) {
|
|
|
192
206
|
if (!name) {
|
|
193
207
|
return false;
|
|
194
208
|
}
|
|
195
|
-
return /^(rgb|rgba|hsl|hsla)$/gi.test(name);
|
|
209
|
+
return /^(rgb|rgba|hsl|hsla|hwb)$/gi.test(name);
|
|
196
210
|
}
|
|
197
211
|
/**
|
|
198
212
|
* Returns true if the node is a color value - either
|
|
@@ -345,6 +359,40 @@ export function hslFromColor(rgba) {
|
|
|
345
359
|
}
|
|
346
360
|
return { h: h, s: s, l: l, a: a };
|
|
347
361
|
}
|
|
362
|
+
export function colorFromHWB(hue, white, black, alpha) {
|
|
363
|
+
if (alpha === void 0) { alpha = 1.0; }
|
|
364
|
+
if (white + black >= 1) {
|
|
365
|
+
var gray = white / (white + black);
|
|
366
|
+
return { red: gray, green: gray, blue: gray, alpha: alpha };
|
|
367
|
+
}
|
|
368
|
+
var rgb = colorFromHSL(hue, 1, 0.5, alpha);
|
|
369
|
+
var red = rgb.red;
|
|
370
|
+
red *= (1 - white - black);
|
|
371
|
+
red += white;
|
|
372
|
+
var green = rgb.green;
|
|
373
|
+
green *= (1 - white - black);
|
|
374
|
+
green += white;
|
|
375
|
+
var blue = rgb.blue;
|
|
376
|
+
blue *= (1 - white - black);
|
|
377
|
+
blue += white;
|
|
378
|
+
return {
|
|
379
|
+
red: red,
|
|
380
|
+
green: green,
|
|
381
|
+
blue: blue,
|
|
382
|
+
alpha: alpha
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
export function hwbFromColor(rgba) {
|
|
386
|
+
var hsl = hslFromColor(rgba);
|
|
387
|
+
var white = Math.min(rgba.red, rgba.green, rgba.blue);
|
|
388
|
+
var black = 1 - Math.max(rgba.red, rgba.green, rgba.blue);
|
|
389
|
+
return {
|
|
390
|
+
h: hsl.h,
|
|
391
|
+
w: white,
|
|
392
|
+
b: black,
|
|
393
|
+
a: hsl.a
|
|
394
|
+
};
|
|
395
|
+
}
|
|
348
396
|
export function getColorValue(node) {
|
|
349
397
|
if (node.type === nodes.NodeType.HexColorValue) {
|
|
350
398
|
var text = node.getText();
|
|
@@ -388,6 +436,12 @@ export function getColorValue(node) {
|
|
|
388
436
|
var l = getNumericValue(colorValues[2], 100.0);
|
|
389
437
|
return colorFromHSL(h, s, l, alpha);
|
|
390
438
|
}
|
|
439
|
+
else if (name === 'hwb') {
|
|
440
|
+
var h = getAngle(colorValues[0]);
|
|
441
|
+
var w = getNumericValue(colorValues[1], 100.0);
|
|
442
|
+
var b = getNumericValue(colorValues[2], 100.0);
|
|
443
|
+
return colorFromHWB(h, w, b, alpha);
|
|
444
|
+
}
|
|
391
445
|
}
|
|
392
446
|
catch (e) {
|
|
393
447
|
// parse error on numeric value
|
|
@@ -65,7 +65,7 @@ function getEntryStringDescription(entry, settings) {
|
|
|
65
65
|
result += '\n(' + browserLabel + ')';
|
|
66
66
|
}
|
|
67
67
|
if ('syntax' in entry) {
|
|
68
|
-
result += "\n\nSyntax: "
|
|
68
|
+
result += "\n\nSyntax: ".concat(entry.syntax);
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -73,7 +73,7 @@ function getEntryStringDescription(entry, settings) {
|
|
|
73
73
|
result += '\n\n';
|
|
74
74
|
}
|
|
75
75
|
result += entry.references.map(function (r) {
|
|
76
|
-
return r.name
|
|
76
|
+
return "".concat(r.name, ": ").concat(r.url);
|
|
77
77
|
}).join(' | ');
|
|
78
78
|
}
|
|
79
79
|
return result;
|
|
@@ -98,7 +98,7 @@ function getEntryMarkdownDescription(entry, settings) {
|
|
|
98
98
|
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
99
99
|
}
|
|
100
100
|
if ('syntax' in entry && entry.syntax) {
|
|
101
|
-
result += "\n\nSyntax: "
|
|
101
|
+
result += "\n\nSyntax: ".concat(textToMarkedString(entry.syntax));
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -106,7 +106,7 @@ function getEntryMarkdownDescription(entry, settings) {
|
|
|
106
106
|
result += '\n\n';
|
|
107
107
|
}
|
|
108
108
|
result += entry.references.map(function (r) {
|
|
109
|
-
return "["
|
|
109
|
+
return "[".concat(r.name, "](").concat(r.url, ")");
|
|
110
110
|
}).join(' | ');
|
|
111
111
|
}
|
|
112
112
|
return result;
|
|
@@ -1259,6 +1259,7 @@ var Parser = /** @class */ (function () {
|
|
|
1259
1259
|
if (node.setOperator(this._parseOperator())) {
|
|
1260
1260
|
node.setValue(this._parseBinaryExpr());
|
|
1261
1261
|
this.acceptIdent('i'); // case insensitive matching
|
|
1262
|
+
this.acceptIdent('s'); // case sensitive matching
|
|
1262
1263
|
}
|
|
1263
1264
|
if (!this.accept(TokenType.BracketR)) {
|
|
1264
1265
|
return this.finish(node, ParseError.RightSquareBracketExpected);
|
|
@@ -457,7 +457,7 @@ var CSSCompletion = /** @class */ (function () {
|
|
|
457
457
|
var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
|
|
458
458
|
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
459
459
|
var symbol = symbols_1[_i];
|
|
460
|
-
var insertText = strings.startsWith(symbol.name, '--') ? "var("
|
|
460
|
+
var insertText = strings.startsWith(symbol.name, '--') ? "var(".concat(symbol.name, ")") : symbol.name;
|
|
461
461
|
var completionItem = {
|
|
462
462
|
label: symbol.name,
|
|
463
463
|
documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
|
|
@@ -43,15 +43,16 @@ import { DocumentHighlightKind, Location, Range, SymbolKind, TextEdit, FileType
|
|
|
43
43
|
import * as nls from 'vscode-nls';
|
|
44
44
|
import * as nodes from '../parser/cssNodes';
|
|
45
45
|
import { Symbols } from '../parser/cssSymbolScope';
|
|
46
|
-
import { getColorValue, hslFromColor } from '../languageFacts/facts';
|
|
46
|
+
import { getColorValue, hslFromColor, hwbFromColor } from '../languageFacts/facts';
|
|
47
47
|
import { startsWith } from '../utils/strings';
|
|
48
48
|
import { dirname, joinPath } from '../utils/resources';
|
|
49
49
|
var localize = nls.loadMessageBundle();
|
|
50
50
|
var startsWithSchemeRegex = /^\w+:\/\//;
|
|
51
51
|
var startsWithData = /^data:/;
|
|
52
52
|
var CSSNavigation = /** @class */ (function () {
|
|
53
|
-
function CSSNavigation(fileSystemProvider) {
|
|
53
|
+
function CSSNavigation(fileSystemProvider, resolveModuleReferences) {
|
|
54
54
|
this.fileSystemProvider = fileSystemProvider;
|
|
55
|
+
this.resolveModuleReferences = resolveModuleReferences;
|
|
55
56
|
}
|
|
56
57
|
CSSNavigation.prototype.findDefinition = function (document, position, stylesheet) {
|
|
57
58
|
var symbols = new Symbols(stylesheet);
|
|
@@ -281,25 +282,33 @@ var CSSNavigation = /** @class */ (function () {
|
|
|
281
282
|
var red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
|
|
282
283
|
var label;
|
|
283
284
|
if (color.alpha === 1) {
|
|
284
|
-
label = "rgb("
|
|
285
|
+
label = "rgb(".concat(red256, ", ").concat(green256, ", ").concat(blue256, ")");
|
|
285
286
|
}
|
|
286
287
|
else {
|
|
287
|
-
label = "rgba("
|
|
288
|
+
label = "rgba(".concat(red256, ", ").concat(green256, ", ").concat(blue256, ", ").concat(color.alpha, ")");
|
|
288
289
|
}
|
|
289
290
|
result.push({ label: label, textEdit: TextEdit.replace(range, label) });
|
|
290
291
|
if (color.alpha === 1) {
|
|
291
|
-
label = "#"
|
|
292
|
+
label = "#".concat(toTwoDigitHex(red256)).concat(toTwoDigitHex(green256)).concat(toTwoDigitHex(blue256));
|
|
292
293
|
}
|
|
293
294
|
else {
|
|
294
|
-
label = "#"
|
|
295
|
+
label = "#".concat(toTwoDigitHex(red256)).concat(toTwoDigitHex(green256)).concat(toTwoDigitHex(blue256)).concat(toTwoDigitHex(Math.round(color.alpha * 255)));
|
|
295
296
|
}
|
|
296
297
|
result.push({ label: label, textEdit: TextEdit.replace(range, label) });
|
|
297
298
|
var hsl = hslFromColor(color);
|
|
298
299
|
if (hsl.a === 1) {
|
|
299
|
-
label = "hsl("
|
|
300
|
+
label = "hsl(".concat(hsl.h, ", ").concat(Math.round(hsl.s * 100), "%, ").concat(Math.round(hsl.l * 100), "%)");
|
|
300
301
|
}
|
|
301
302
|
else {
|
|
302
|
-
label = "hsla("
|
|
303
|
+
label = "hsla(".concat(hsl.h, ", ").concat(Math.round(hsl.s * 100), "%, ").concat(Math.round(hsl.l * 100), "%, ").concat(hsl.a, ")");
|
|
304
|
+
}
|
|
305
|
+
result.push({ label: label, textEdit: TextEdit.replace(range, label) });
|
|
306
|
+
var hwb = hwbFromColor(color);
|
|
307
|
+
if (hwb.a === 1) {
|
|
308
|
+
label = "hwb(".concat(hwb.h, " ").concat(Math.round(hwb.w * 100), "% ").concat(Math.round(hwb.b * 100), "%)");
|
|
309
|
+
}
|
|
310
|
+
else {
|
|
311
|
+
label = "hwb(".concat(hwb.h, " ").concat(Math.round(hwb.w * 100), "% ").concat(Math.round(hwb.b * 100), "% / ").concat(hwb.a, ")");
|
|
303
312
|
}
|
|
304
313
|
result.push({ label: label, textEdit: TextEdit.replace(range, label) });
|
|
305
314
|
return result;
|
|
@@ -312,14 +321,12 @@ var CSSNavigation = /** @class */ (function () {
|
|
|
312
321
|
changes: (_a = {}, _a[document.uri] = edits, _a)
|
|
313
322
|
};
|
|
314
323
|
};
|
|
315
|
-
CSSNavigation.prototype.
|
|
324
|
+
CSSNavigation.prototype.resolveModuleReference = function (ref, documentUri, documentContext) {
|
|
316
325
|
return __awaiter(this, void 0, void 0, function () {
|
|
317
326
|
var moduleName, rootFolderUri, documentFolderUri, modulePath, pathWithinModule;
|
|
318
327
|
return __generator(this, function (_a) {
|
|
319
328
|
switch (_a.label) {
|
|
320
329
|
case 0:
|
|
321
|
-
if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 3];
|
|
322
|
-
ref = ref.substring(1);
|
|
323
330
|
if (!startsWith(documentUri, 'file://')) return [3 /*break*/, 2];
|
|
324
331
|
moduleName = getModuleNameFromPath(ref);
|
|
325
332
|
rootFolderUri = documentContext.resolveReference('/', documentUri);
|
|
@@ -332,8 +339,36 @@ var CSSNavigation = /** @class */ (function () {
|
|
|
332
339
|
return [2 /*return*/, joinPath(modulePath, pathWithinModule)];
|
|
333
340
|
}
|
|
334
341
|
_a.label = 2;
|
|
335
|
-
case 2: return [2 /*return*/,
|
|
336
|
-
|
|
342
|
+
case 2: return [2 /*return*/, undefined];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
CSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext, isRawLink) {
|
|
348
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
349
|
+
var relativeReference, _a;
|
|
350
|
+
return __generator(this, function (_b) {
|
|
351
|
+
switch (_b.label) {
|
|
352
|
+
case 0:
|
|
353
|
+
relativeReference = documentContext.resolveReference(ref, documentUri);
|
|
354
|
+
if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 2];
|
|
355
|
+
ref = ref.substring(1);
|
|
356
|
+
return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
|
|
357
|
+
case 1: return [2 /*return*/, (_b.sent()) || relativeReference];
|
|
358
|
+
case 2:
|
|
359
|
+
if (!this.resolveModuleReferences) return [3 /*break*/, 7];
|
|
360
|
+
_a = relativeReference;
|
|
361
|
+
if (!_a) return [3 /*break*/, 4];
|
|
362
|
+
return [4 /*yield*/, this.fileExists(relativeReference)];
|
|
363
|
+
case 3:
|
|
364
|
+
_a = (_b.sent());
|
|
365
|
+
_b.label = 4;
|
|
366
|
+
case 4:
|
|
367
|
+
if (!_a) return [3 /*break*/, 5];
|
|
368
|
+
return [2 /*return*/, relativeReference];
|
|
369
|
+
case 5: return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
|
|
370
|
+
case 6: return [2 /*return*/, (_b.sent()) || relativeReference];
|
|
371
|
+
case 7: return [2 /*return*/, relativeReference];
|
|
337
372
|
}
|
|
338
373
|
});
|
|
339
374
|
});
|
package/lib/esm/services/lint.js
CHANGED
|
@@ -162,7 +162,7 @@ var LintVisitor = /** @class */ (function () {
|
|
|
162
162
|
if (atDirective) {
|
|
163
163
|
return false;
|
|
164
164
|
}
|
|
165
|
-
this.addEntry(atRuleName, Rules.UnknownAtRules, "Unknown at rule "
|
|
165
|
+
this.addEntry(atRuleName, Rules.UnknownAtRules, "Unknown at rule ".concat(atRuleName.getText()));
|
|
166
166
|
return true;
|
|
167
167
|
};
|
|
168
168
|
LintVisitor.prototype.visitKeyframe = function (node) {
|
|
@@ -44,7 +44,7 @@ var SCSSCompletion = /** @class */ (function (_super) {
|
|
|
44
44
|
var item = {
|
|
45
45
|
label: p.label,
|
|
46
46
|
documentation: p.documentation,
|
|
47
|
-
textEdit: TextEdit.replace(this.getCompletionRange(importPathNode), "'"
|
|
47
|
+
textEdit: TextEdit.replace(this.getCompletionRange(importPathNode), "'".concat(p.label, "'")),
|
|
48
48
|
kind: CompletionItemKind.Module
|
|
49
49
|
};
|
|
50
50
|
result.items.push(item);
|
|
@@ -369,7 +369,7 @@ function addReferencesToDocumentation(items) {
|
|
|
369
369
|
markdownDoc.value += '\n\n';
|
|
370
370
|
markdownDoc.value += i.references
|
|
371
371
|
.map(function (r) {
|
|
372
|
-
return "["
|
|
372
|
+
return "[".concat(r.name, "](").concat(r.url, ")");
|
|
373
373
|
})
|
|
374
374
|
.join(' | ');
|
|
375
375
|
i.documentation = markdownDoc;
|
|
@@ -61,7 +61,7 @@ import { startsWith } from '../utils/strings';
|
|
|
61
61
|
var SCSSNavigation = /** @class */ (function (_super) {
|
|
62
62
|
__extends(SCSSNavigation, _super);
|
|
63
63
|
function SCSSNavigation(fileSystemProvider) {
|
|
64
|
-
return _super.call(this, fileSystemProvider) || this;
|
|
64
|
+
return _super.call(this, fileSystemProvider, true) || this;
|
|
65
65
|
}
|
|
66
66
|
SCSSNavigation.prototype.isRawStringDocumentLinkNode = function (node) {
|
|
67
67
|
return (_super.prototype.isRawStringDocumentLinkNode.call(this, node) ||
|
|
@@ -291,23 +291,23 @@ export function toElement(node, parentElement) {
|
|
|
291
291
|
switch (unescape(operator.getText())) {
|
|
292
292
|
case '|=':
|
|
293
293
|
// excatly or followed by -words
|
|
294
|
-
value = quotes.remove(unescape(expression.getText()))
|
|
294
|
+
value = "".concat(quotes.remove(unescape(expression.getText())), "-\u2026");
|
|
295
295
|
break;
|
|
296
296
|
case '^=':
|
|
297
297
|
// prefix
|
|
298
|
-
value = quotes.remove(unescape(expression.getText()))
|
|
298
|
+
value = "".concat(quotes.remove(unescape(expression.getText())), "\u2026");
|
|
299
299
|
break;
|
|
300
300
|
case '$=':
|
|
301
301
|
// suffix
|
|
302
|
-
value = "\u2026"
|
|
302
|
+
value = "\u2026".concat(quotes.remove(unescape(expression.getText())));
|
|
303
303
|
break;
|
|
304
304
|
case '~=':
|
|
305
305
|
// one of a list of words
|
|
306
|
-
value = " \u2026 "
|
|
306
|
+
value = " \u2026 ".concat(quotes.remove(unescape(expression.getText())), " \u2026 ");
|
|
307
307
|
break;
|
|
308
308
|
case '*=':
|
|
309
309
|
// substring
|
|
310
|
-
value = "\u2026"
|
|
310
|
+
value = "\u2026".concat(quotes.remove(unescape(expression.getText())), "\u2026");
|
|
311
311
|
break;
|
|
312
312
|
default:
|
|
313
313
|
value = quotes.remove(unescape(expression.getText()));
|
|
@@ -362,7 +362,8 @@ var SelectorPrinting = /** @class */ (function () {
|
|
|
362
362
|
var _this = this;
|
|
363
363
|
//https://www.w3.org/TR/selectors-3/#specificity
|
|
364
364
|
var calculateScore = function (node) {
|
|
365
|
-
|
|
365
|
+
var specificity = new Specificity();
|
|
366
|
+
elementLoop: for (var _i = 0, _a = node.getChildren(); _i < _a.length; _i++) {
|
|
366
367
|
var element = _a[_i];
|
|
367
368
|
switch (element.type) {
|
|
368
369
|
case nodes.NodeType.IdentifierSelector:
|
|
@@ -383,23 +384,66 @@ var SelectorPrinting = /** @class */ (function () {
|
|
|
383
384
|
var text = element.getText();
|
|
384
385
|
if (_this.isPseudoElementIdentifier(text)) {
|
|
385
386
|
specificity.tag++; // pseudo element
|
|
387
|
+
break;
|
|
386
388
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
389
|
+
// where and child selectors have zero specificity
|
|
390
|
+
if (text.match(/^:where/i)) {
|
|
391
|
+
continue elementLoop;
|
|
392
|
+
}
|
|
393
|
+
// the most specific child selector
|
|
394
|
+
if (text.match(/^:(not|has|is)/i) && element.getChildren().length > 0) {
|
|
395
|
+
var mostSpecificListItem = new Specificity();
|
|
396
|
+
for (var _b = 0, _c = element.getChildren(); _b < _c.length; _b++) {
|
|
397
|
+
var containerElement = _c[_b];
|
|
398
|
+
var list = void 0;
|
|
399
|
+
if (containerElement.type === nodes.NodeType.Undefined) { // containerElement is a list of selectors
|
|
400
|
+
list = containerElement.getChildren();
|
|
401
|
+
}
|
|
402
|
+
else { // containerElement is a selector
|
|
403
|
+
list = [containerElement];
|
|
404
|
+
}
|
|
405
|
+
for (var _d = 0, _e = containerElement.getChildren(); _d < _e.length; _d++) {
|
|
406
|
+
var childElement = _e[_d];
|
|
407
|
+
var itemSpecificity = calculateScore(childElement);
|
|
408
|
+
if (itemSpecificity.id > mostSpecificListItem.id) {
|
|
409
|
+
mostSpecificListItem = itemSpecificity;
|
|
410
|
+
continue;
|
|
411
|
+
}
|
|
412
|
+
else if (itemSpecificity.id < mostSpecificListItem.id) {
|
|
413
|
+
continue;
|
|
414
|
+
}
|
|
415
|
+
if (itemSpecificity.attr > mostSpecificListItem.attr) {
|
|
416
|
+
mostSpecificListItem = itemSpecificity;
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
else if (itemSpecificity.attr < mostSpecificListItem.attr) {
|
|
420
|
+
continue;
|
|
421
|
+
}
|
|
422
|
+
if (itemSpecificity.tag > mostSpecificListItem.tag) {
|
|
423
|
+
mostSpecificListItem = itemSpecificity;
|
|
424
|
+
continue;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
391
427
|
}
|
|
392
|
-
specificity.
|
|
428
|
+
specificity.id += mostSpecificListItem.id;
|
|
429
|
+
specificity.attr += mostSpecificListItem.attr;
|
|
430
|
+
specificity.tag += mostSpecificListItem.tag;
|
|
431
|
+
continue elementLoop;
|
|
393
432
|
}
|
|
433
|
+
specificity.attr++; //pseudo class
|
|
394
434
|
break;
|
|
395
435
|
}
|
|
396
436
|
if (element.getChildren().length > 0) {
|
|
397
|
-
calculateScore(element);
|
|
437
|
+
var itemSpecificity = calculateScore(element);
|
|
438
|
+
specificity.id += itemSpecificity.id;
|
|
439
|
+
specificity.attr += itemSpecificity.attr;
|
|
440
|
+
specificity.tag += itemSpecificity.tag;
|
|
398
441
|
}
|
|
399
442
|
}
|
|
443
|
+
return specificity;
|
|
400
444
|
};
|
|
401
|
-
var specificity =
|
|
402
|
-
|
|
445
|
+
var specificity = calculateScore(node);
|
|
446
|
+
;
|
|
403
447
|
return localize('specificity', "[Selector Specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity): ({0}, {1}, {2})", specificity.id, specificity.attr, specificity.tag);
|
|
404
448
|
};
|
|
405
449
|
return SelectorPrinting;
|
|
@@ -82,7 +82,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
82
82
|
function getCSSLanguageService(options) {
|
|
83
83
|
if (options === void 0) { options = defaultLanguageServiceOptions; }
|
|
84
84
|
var cssDataManager = new dataManager_1.CSSDataManager(options);
|
|
85
|
-
return createFacade(new cssParser_1.Parser(), new cssCompletion_1.CSSCompletion(null, options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
|
|
85
|
+
return createFacade(new cssParser_1.Parser(), new cssCompletion_1.CSSCompletion(null, options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider, false), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
|
|
86
86
|
}
|
|
87
87
|
exports.getCSSLanguageService = getCSSLanguageService;
|
|
88
88
|
function getSCSSLanguageService(options) {
|
|
@@ -94,7 +94,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
94
94
|
function getLESSLanguageService(options) {
|
|
95
95
|
if (options === void 0) { options = defaultLanguageServiceOptions; }
|
|
96
96
|
var cssDataManager = new dataManager_1.CSSDataManager(options);
|
|
97
|
-
return createFacade(new lessParser_1.LESSParser(), new lessCompletion_1.LESSCompletion(options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
|
|
97
|
+
return createFacade(new lessParser_1.LESSParser(), new lessCompletion_1.LESSCompletion(options, cssDataManager), new cssHover_1.CSSHover(options && options.clientCapabilities, cssDataManager), new cssNavigation_1.CSSNavigation(options && options.fileSystemProvider, true), new cssCodeActions_1.CSSCodeActions(cssDataManager), new cssValidation_1.CSSValidation(cssDataManager), cssDataManager);
|
|
98
98
|
}
|
|
99
99
|
exports.getLESSLanguageService = getLESSLanguageService;
|
|
100
100
|
});
|