vscode-css-languageservice 5.1.8 → 5.1.12
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 +30 -2
- package/lib/esm/languageFacts/entry.js +11 -6
- package/lib/esm/parser/cssParser.js +1 -0
- package/lib/esm/services/cssCompletion.js +1 -1
- package/lib/esm/services/cssNavigation.js +39 -12
- 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 +5 -5
- package/lib/umd/cssLanguageService.js +2 -2
- package/lib/umd/data/webCustomData.js +172 -151
- package/lib/umd/languageFacts/colors.js +30 -2
- package/lib/umd/languageFacts/entry.js +12 -7
- package/lib/umd/parser/cssParser.js +1 -0
- package/lib/umd/services/cssCompletion.js +1 -1
- package/lib/umd/services/cssNavigation.js +39 -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 +5 -5
- package/package.json +9 -9
|
@@ -181,9 +181,22 @@ function getNumericValue(node, factor) {
|
|
|
181
181
|
}
|
|
182
182
|
function getAngle(node) {
|
|
183
183
|
var val = node.getText();
|
|
184
|
-
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg)?$/);
|
|
184
|
+
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg|rad|grad|turn)?$/);
|
|
185
185
|
if (m) {
|
|
186
|
-
|
|
186
|
+
switch (m[2]) {
|
|
187
|
+
case 'deg':
|
|
188
|
+
return parseFloat(val) % 360;
|
|
189
|
+
case 'rad':
|
|
190
|
+
return (parseFloat(val) * 180 / Math.PI) % 360;
|
|
191
|
+
case 'grad':
|
|
192
|
+
return (parseFloat(val) * 0.9) % 360;
|
|
193
|
+
case 'turn':
|
|
194
|
+
return (parseFloat(val) * 360) % 360;
|
|
195
|
+
default:
|
|
196
|
+
if ('undefined' === typeof m[2]) {
|
|
197
|
+
return parseFloat(val) % 360;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
187
200
|
}
|
|
188
201
|
throw new Error();
|
|
189
202
|
}
|
|
@@ -354,6 +367,21 @@ export function getColorValue(node) {
|
|
|
354
367
|
var functionNode = node;
|
|
355
368
|
var name = functionNode.getName();
|
|
356
369
|
var colorValues = functionNode.getArguments().getChildren();
|
|
370
|
+
if (colorValues.length === 1) {
|
|
371
|
+
var functionArg = colorValues[0].getChildren();
|
|
372
|
+
if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
|
|
373
|
+
colorValues = functionArg[0].getChildren();
|
|
374
|
+
if (colorValues.length === 3) {
|
|
375
|
+
var lastValue = colorValues[2];
|
|
376
|
+
if (lastValue instanceof nodes.BinaryExpression) {
|
|
377
|
+
var left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
|
|
378
|
+
if (left && right && operator && operator.matches('/')) {
|
|
379
|
+
colorValues = [colorValues[0], colorValues[1], left, right];
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
357
385
|
if (!name || colorValues.length < 3 || colorValues.length > 4) {
|
|
358
386
|
return null;
|
|
359
387
|
}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
'use strict';
|
|
6
|
+
import { MarkupKind } from '../cssLanguageTypes';
|
|
6
7
|
export var browserNames = {
|
|
7
8
|
E: 'Edge',
|
|
8
9
|
FF: 'Firefox',
|
|
@@ -64,7 +65,7 @@ function getEntryStringDescription(entry, settings) {
|
|
|
64
65
|
result += '\n(' + browserLabel + ')';
|
|
65
66
|
}
|
|
66
67
|
if ('syntax' in entry) {
|
|
67
|
-
result += "\n\nSyntax: "
|
|
68
|
+
result += "\n\nSyntax: ".concat(entry.syntax);
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -72,7 +73,7 @@ function getEntryStringDescription(entry, settings) {
|
|
|
72
73
|
result += '\n\n';
|
|
73
74
|
}
|
|
74
75
|
result += entry.references.map(function (r) {
|
|
75
|
-
return r.name
|
|
76
|
+
return "".concat(r.name, ": ").concat(r.url);
|
|
76
77
|
}).join(' | ');
|
|
77
78
|
}
|
|
78
79
|
return result;
|
|
@@ -86,14 +87,18 @@ function getEntryMarkdownDescription(entry, settings) {
|
|
|
86
87
|
if (entry.status) {
|
|
87
88
|
result += getEntryStatus(entry.status);
|
|
88
89
|
}
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
if (typeof entry.description === 'string') {
|
|
91
|
+
result += textToMarkedString(entry.description);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
result += entry.description.kind === MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
|
|
95
|
+
}
|
|
91
96
|
var browserLabel = getBrowserLabel(entry.browsers);
|
|
92
97
|
if (browserLabel) {
|
|
93
98
|
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
94
99
|
}
|
|
95
100
|
if ('syntax' in entry && entry.syntax) {
|
|
96
|
-
result += "\n\nSyntax: "
|
|
101
|
+
result += "\n\nSyntax: ".concat(textToMarkedString(entry.syntax));
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -101,7 +106,7 @@ function getEntryMarkdownDescription(entry, settings) {
|
|
|
101
106
|
result += '\n\n';
|
|
102
107
|
}
|
|
103
108
|
result += entry.references.map(function (r) {
|
|
104
|
-
return "["
|
|
109
|
+
return "[".concat(r.name, "](").concat(r.url, ")");
|
|
105
110
|
}).join(' | ');
|
|
106
111
|
}
|
|
107
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,
|
|
@@ -50,8 +50,9 @@ 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,25 @@ 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, ")");
|
|
303
304
|
}
|
|
304
305
|
result.push({ label: label, textEdit: TextEdit.replace(range, label) });
|
|
305
306
|
return result;
|
|
@@ -312,14 +313,12 @@ var CSSNavigation = /** @class */ (function () {
|
|
|
312
313
|
changes: (_a = {}, _a[document.uri] = edits, _a)
|
|
313
314
|
};
|
|
314
315
|
};
|
|
315
|
-
CSSNavigation.prototype.
|
|
316
|
+
CSSNavigation.prototype.resolveModuleReference = function (ref, documentUri, documentContext) {
|
|
316
317
|
return __awaiter(this, void 0, void 0, function () {
|
|
317
318
|
var moduleName, rootFolderUri, documentFolderUri, modulePath, pathWithinModule;
|
|
318
319
|
return __generator(this, function (_a) {
|
|
319
320
|
switch (_a.label) {
|
|
320
321
|
case 0:
|
|
321
|
-
if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 3];
|
|
322
|
-
ref = ref.substring(1);
|
|
323
322
|
if (!startsWith(documentUri, 'file://')) return [3 /*break*/, 2];
|
|
324
323
|
moduleName = getModuleNameFromPath(ref);
|
|
325
324
|
rootFolderUri = documentContext.resolveReference('/', documentUri);
|
|
@@ -332,8 +331,36 @@ var CSSNavigation = /** @class */ (function () {
|
|
|
332
331
|
return [2 /*return*/, joinPath(modulePath, pathWithinModule)];
|
|
333
332
|
}
|
|
334
333
|
_a.label = 2;
|
|
335
|
-
case 2: return [2 /*return*/,
|
|
336
|
-
|
|
334
|
+
case 2: return [2 /*return*/, undefined];
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
CSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext, isRawLink) {
|
|
340
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
341
|
+
var relativeReference, _a;
|
|
342
|
+
return __generator(this, function (_b) {
|
|
343
|
+
switch (_b.label) {
|
|
344
|
+
case 0:
|
|
345
|
+
relativeReference = documentContext.resolveReference(ref, documentUri);
|
|
346
|
+
if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 2];
|
|
347
|
+
ref = ref.substring(1);
|
|
348
|
+
return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
|
|
349
|
+
case 1: return [2 /*return*/, (_b.sent()) || relativeReference];
|
|
350
|
+
case 2:
|
|
351
|
+
if (!this.resolveModuleReferences) return [3 /*break*/, 7];
|
|
352
|
+
_a = relativeReference;
|
|
353
|
+
if (!_a) return [3 /*break*/, 4];
|
|
354
|
+
return [4 /*yield*/, this.fileExists(relativeReference)];
|
|
355
|
+
case 3:
|
|
356
|
+
_a = (_b.sent());
|
|
357
|
+
_b.label = 4;
|
|
358
|
+
case 4:
|
|
359
|
+
if (!_a) return [3 /*break*/, 5];
|
|
360
|
+
return [2 /*return*/, relativeReference];
|
|
361
|
+
case 5: return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
|
|
362
|
+
case 6: return [2 /*return*/, (_b.sent()) || relativeReference];
|
|
363
|
+
case 7: return [2 /*return*/, relativeReference];
|
|
337
364
|
}
|
|
338
365
|
});
|
|
339
366
|
});
|
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()));
|
|
@@ -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
|
});
|