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
|
@@ -193,9 +193,22 @@
|
|
|
193
193
|
}
|
|
194
194
|
function getAngle(node) {
|
|
195
195
|
var val = node.getText();
|
|
196
|
-
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg)?$/);
|
|
196
|
+
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg|rad|grad|turn)?$/);
|
|
197
197
|
if (m) {
|
|
198
|
-
|
|
198
|
+
switch (m[2]) {
|
|
199
|
+
case 'deg':
|
|
200
|
+
return parseFloat(val) % 360;
|
|
201
|
+
case 'rad':
|
|
202
|
+
return (parseFloat(val) * 180 / Math.PI) % 360;
|
|
203
|
+
case 'grad':
|
|
204
|
+
return (parseFloat(val) * 0.9) % 360;
|
|
205
|
+
case 'turn':
|
|
206
|
+
return (parseFloat(val) * 360) % 360;
|
|
207
|
+
default:
|
|
208
|
+
if ('undefined' === typeof m[2]) {
|
|
209
|
+
return parseFloat(val) % 360;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
199
212
|
}
|
|
200
213
|
throw new Error();
|
|
201
214
|
}
|
|
@@ -373,6 +386,21 @@
|
|
|
373
386
|
var functionNode = node;
|
|
374
387
|
var name = functionNode.getName();
|
|
375
388
|
var colorValues = functionNode.getArguments().getChildren();
|
|
389
|
+
if (colorValues.length === 1) {
|
|
390
|
+
var functionArg = colorValues[0].getChildren();
|
|
391
|
+
if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
|
|
392
|
+
colorValues = functionArg[0].getChildren();
|
|
393
|
+
if (colorValues.length === 3) {
|
|
394
|
+
var lastValue = colorValues[2];
|
|
395
|
+
if (lastValue instanceof nodes.BinaryExpression) {
|
|
396
|
+
var left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
|
|
397
|
+
if (left && right && operator && operator.matches('/')) {
|
|
398
|
+
colorValues = [colorValues[0], colorValues[1], left, right];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
376
404
|
if (!name || colorValues.length < 3 || colorValues.length > 4) {
|
|
377
405
|
return null;
|
|
378
406
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
7
|
+
define(["require", "exports", "../cssLanguageTypes"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
/*---------------------------------------------------------------------------------------------
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.getBrowserLabel = exports.textToMarkedString = exports.getEntryDescription = exports.browserNames = void 0;
|
|
17
|
+
var cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
17
18
|
exports.browserNames = {
|
|
18
19
|
E: 'Edge',
|
|
19
20
|
FF: 'Firefox',
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
result += '\n(' + browserLabel + ')';
|
|
78
79
|
}
|
|
79
80
|
if ('syntax' in entry) {
|
|
80
|
-
result += "\n\nSyntax: "
|
|
81
|
+
result += "\n\nSyntax: ".concat(entry.syntax);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
result += '\n\n';
|
|
86
87
|
}
|
|
87
88
|
result += entry.references.map(function (r) {
|
|
88
|
-
return r.name
|
|
89
|
+
return "".concat(r.name, ": ").concat(r.url);
|
|
89
90
|
}).join(' | ');
|
|
90
91
|
}
|
|
91
92
|
return result;
|
|
@@ -99,14 +100,18 @@
|
|
|
99
100
|
if (entry.status) {
|
|
100
101
|
result += getEntryStatus(entry.status);
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
if (typeof entry.description === 'string') {
|
|
104
|
+
result += textToMarkedString(entry.description);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
result += entry.description.kind === cssLanguageTypes_1.MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
|
|
108
|
+
}
|
|
104
109
|
var browserLabel = getBrowserLabel(entry.browsers);
|
|
105
110
|
if (browserLabel) {
|
|
106
111
|
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
107
112
|
}
|
|
108
113
|
if ('syntax' in entry && entry.syntax) {
|
|
109
|
-
result += "\n\nSyntax: "
|
|
114
|
+
result += "\n\nSyntax: ".concat(textToMarkedString(entry.syntax));
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -114,7 +119,7 @@
|
|
|
114
119
|
result += '\n\n';
|
|
115
120
|
}
|
|
116
121
|
result += entry.references.map(function (r) {
|
|
117
|
-
return "["
|
|
122
|
+
return "[".concat(r.name, "](").concat(r.url, ")");
|
|
118
123
|
}).join(' | ');
|
|
119
124
|
}
|
|
120
125
|
return result;
|
|
@@ -1270,6 +1270,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1270
1270
|
if (node.setOperator(this._parseOperator())) {
|
|
1271
1271
|
node.setValue(this._parseBinaryExpr());
|
|
1272
1272
|
this.acceptIdent('i'); // case insensitive matching
|
|
1273
|
+
this.acceptIdent('s'); // case sensitive matching
|
|
1273
1274
|
}
|
|
1274
1275
|
if (!this.accept(cssScanner_1.TokenType.BracketR)) {
|
|
1275
1276
|
return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected);
|
|
@@ -468,7 +468,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
468
468
|
var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
|
|
469
469
|
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
470
470
|
var symbol = symbols_1[_i];
|
|
471
|
-
var insertText = strings.startsWith(symbol.name, '--') ? "var("
|
|
471
|
+
var insertText = strings.startsWith(symbol.name, '--') ? "var(".concat(symbol.name, ")") : symbol.name;
|
|
472
472
|
var completionItem = {
|
|
473
473
|
label: symbol.name,
|
|
474
474
|
documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
|
|
@@ -61,8 +61,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
61
61
|
var startsWithSchemeRegex = /^\w+:\/\//;
|
|
62
62
|
var startsWithData = /^data:/;
|
|
63
63
|
var CSSNavigation = /** @class */ (function () {
|
|
64
|
-
function CSSNavigation(fileSystemProvider) {
|
|
64
|
+
function CSSNavigation(fileSystemProvider, resolveModuleReferences) {
|
|
65
65
|
this.fileSystemProvider = fileSystemProvider;
|
|
66
|
+
this.resolveModuleReferences = resolveModuleReferences;
|
|
66
67
|
}
|
|
67
68
|
CSSNavigation.prototype.findDefinition = function (document, position, stylesheet) {
|
|
68
69
|
var symbols = new cssSymbolScope_1.Symbols(stylesheet);
|
|
@@ -292,25 +293,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
292
293
|
var red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
|
|
293
294
|
var label;
|
|
294
295
|
if (color.alpha === 1) {
|
|
295
|
-
label = "rgb("
|
|
296
|
+
label = "rgb(".concat(red256, ", ").concat(green256, ", ").concat(blue256, ")");
|
|
296
297
|
}
|
|
297
298
|
else {
|
|
298
|
-
label = "rgba("
|
|
299
|
+
label = "rgba(".concat(red256, ", ").concat(green256, ", ").concat(blue256, ", ").concat(color.alpha, ")");
|
|
299
300
|
}
|
|
300
301
|
result.push({ label: label, textEdit: cssLanguageTypes_1.TextEdit.replace(range, label) });
|
|
301
302
|
if (color.alpha === 1) {
|
|
302
|
-
label = "#"
|
|
303
|
+
label = "#".concat(toTwoDigitHex(red256)).concat(toTwoDigitHex(green256)).concat(toTwoDigitHex(blue256));
|
|
303
304
|
}
|
|
304
305
|
else {
|
|
305
|
-
label = "#"
|
|
306
|
+
label = "#".concat(toTwoDigitHex(red256)).concat(toTwoDigitHex(green256)).concat(toTwoDigitHex(blue256)).concat(toTwoDigitHex(Math.round(color.alpha * 255)));
|
|
306
307
|
}
|
|
307
308
|
result.push({ label: label, textEdit: cssLanguageTypes_1.TextEdit.replace(range, label) });
|
|
308
309
|
var hsl = (0, facts_1.hslFromColor)(color);
|
|
309
310
|
if (hsl.a === 1) {
|
|
310
|
-
label = "hsl("
|
|
311
|
+
label = "hsl(".concat(hsl.h, ", ").concat(Math.round(hsl.s * 100), "%, ").concat(Math.round(hsl.l * 100), "%)");
|
|
311
312
|
}
|
|
312
313
|
else {
|
|
313
|
-
label = "hsla("
|
|
314
|
+
label = "hsla(".concat(hsl.h, ", ").concat(Math.round(hsl.s * 100), "%, ").concat(Math.round(hsl.l * 100), "%, ").concat(hsl.a, ")");
|
|
314
315
|
}
|
|
315
316
|
result.push({ label: label, textEdit: cssLanguageTypes_1.TextEdit.replace(range, label) });
|
|
316
317
|
return result;
|
|
@@ -323,14 +324,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
323
324
|
changes: (_a = {}, _a[document.uri] = edits, _a)
|
|
324
325
|
};
|
|
325
326
|
};
|
|
326
|
-
CSSNavigation.prototype.
|
|
327
|
+
CSSNavigation.prototype.resolveModuleReference = function (ref, documentUri, documentContext) {
|
|
327
328
|
return __awaiter(this, void 0, void 0, function () {
|
|
328
329
|
var moduleName, rootFolderUri, documentFolderUri, modulePath, pathWithinModule;
|
|
329
330
|
return __generator(this, function (_a) {
|
|
330
331
|
switch (_a.label) {
|
|
331
332
|
case 0:
|
|
332
|
-
if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 3];
|
|
333
|
-
ref = ref.substring(1);
|
|
334
333
|
if (!(0, strings_1.startsWith)(documentUri, 'file://')) return [3 /*break*/, 2];
|
|
335
334
|
moduleName = getModuleNameFromPath(ref);
|
|
336
335
|
rootFolderUri = documentContext.resolveReference('/', documentUri);
|
|
@@ -343,8 +342,36 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
343
342
|
return [2 /*return*/, (0, resources_1.joinPath)(modulePath, pathWithinModule)];
|
|
344
343
|
}
|
|
345
344
|
_a.label = 2;
|
|
346
|
-
case 2: return [2 /*return*/,
|
|
347
|
-
|
|
345
|
+
case 2: return [2 /*return*/, undefined];
|
|
346
|
+
}
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
};
|
|
350
|
+
CSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext, isRawLink) {
|
|
351
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
352
|
+
var relativeReference, _a;
|
|
353
|
+
return __generator(this, function (_b) {
|
|
354
|
+
switch (_b.label) {
|
|
355
|
+
case 0:
|
|
356
|
+
relativeReference = documentContext.resolveReference(ref, documentUri);
|
|
357
|
+
if (!(ref[0] === '~' && ref[1] !== '/' && this.fileSystemProvider)) return [3 /*break*/, 2];
|
|
358
|
+
ref = ref.substring(1);
|
|
359
|
+
return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
|
|
360
|
+
case 1: return [2 /*return*/, (_b.sent()) || relativeReference];
|
|
361
|
+
case 2:
|
|
362
|
+
if (!this.resolveModuleReferences) return [3 /*break*/, 7];
|
|
363
|
+
_a = relativeReference;
|
|
364
|
+
if (!_a) return [3 /*break*/, 4];
|
|
365
|
+
return [4 /*yield*/, this.fileExists(relativeReference)];
|
|
366
|
+
case 3:
|
|
367
|
+
_a = (_b.sent());
|
|
368
|
+
_b.label = 4;
|
|
369
|
+
case 4:
|
|
370
|
+
if (!_a) return [3 /*break*/, 5];
|
|
371
|
+
return [2 /*return*/, relativeReference];
|
|
372
|
+
case 5: return [4 /*yield*/, this.resolveModuleReference(ref, documentUri, documentContext)];
|
|
373
|
+
case 6: return [2 /*return*/, (_b.sent()) || relativeReference];
|
|
374
|
+
case 7: return [2 /*return*/, relativeReference];
|
|
348
375
|
}
|
|
349
376
|
});
|
|
350
377
|
});
|
package/lib/umd/services/lint.js
CHANGED
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
if (atDirective) {
|
|
174
174
|
return false;
|
|
175
175
|
}
|
|
176
|
-
this.addEntry(atRuleName, lintRules_1.Rules.UnknownAtRules, "Unknown at rule "
|
|
176
|
+
this.addEntry(atRuleName, lintRules_1.Rules.UnknownAtRules, "Unknown at rule ".concat(atRuleName.getText()));
|
|
177
177
|
return true;
|
|
178
178
|
};
|
|
179
179
|
LintVisitor.prototype.visitKeyframe = function (node) {
|
|
@@ -55,7 +55,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
55
55
|
var item = {
|
|
56
56
|
label: p.label,
|
|
57
57
|
documentation: p.documentation,
|
|
58
|
-
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(importPathNode), "'"
|
|
58
|
+
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(importPathNode), "'".concat(p.label, "'")),
|
|
59
59
|
kind: cssLanguageTypes_1.CompletionItemKind.Module
|
|
60
60
|
};
|
|
61
61
|
result.items.push(item);
|
|
@@ -380,7 +380,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
380
380
|
markdownDoc.value += '\n\n';
|
|
381
381
|
markdownDoc.value += i.references
|
|
382
382
|
.map(function (r) {
|
|
383
|
-
return "["
|
|
383
|
+
return "[".concat(r.name, "](").concat(r.url, ")");
|
|
384
384
|
})
|
|
385
385
|
.join(' | ');
|
|
386
386
|
i.documentation = markdownDoc;
|
|
@@ -72,7 +72,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
72
72
|
var SCSSNavigation = /** @class */ (function (_super) {
|
|
73
73
|
__extends(SCSSNavigation, _super);
|
|
74
74
|
function SCSSNavigation(fileSystemProvider) {
|
|
75
|
-
return _super.call(this, fileSystemProvider) || this;
|
|
75
|
+
return _super.call(this, fileSystemProvider, true) || this;
|
|
76
76
|
}
|
|
77
77
|
SCSSNavigation.prototype.isRawStringDocumentLinkNode = function (node) {
|
|
78
78
|
return (_super.prototype.isRawStringDocumentLinkNode.call(this, node) ||
|
|
@@ -302,23 +302,23 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
302
302
|
switch (unescape(operator.getText())) {
|
|
303
303
|
case '|=':
|
|
304
304
|
// excatly or followed by -words
|
|
305
|
-
value = quotes.remove(unescape(expression.getText()))
|
|
305
|
+
value = "".concat(quotes.remove(unescape(expression.getText())), "-\u2026");
|
|
306
306
|
break;
|
|
307
307
|
case '^=':
|
|
308
308
|
// prefix
|
|
309
|
-
value = quotes.remove(unescape(expression.getText()))
|
|
309
|
+
value = "".concat(quotes.remove(unescape(expression.getText())), "\u2026");
|
|
310
310
|
break;
|
|
311
311
|
case '$=':
|
|
312
312
|
// suffix
|
|
313
|
-
value = "\u2026"
|
|
313
|
+
value = "\u2026".concat(quotes.remove(unescape(expression.getText())));
|
|
314
314
|
break;
|
|
315
315
|
case '~=':
|
|
316
316
|
// one of a list of words
|
|
317
|
-
value = " \u2026 "
|
|
317
|
+
value = " \u2026 ".concat(quotes.remove(unescape(expression.getText())), " \u2026 ");
|
|
318
318
|
break;
|
|
319
319
|
case '*=':
|
|
320
320
|
// substring
|
|
321
|
-
value = "\u2026"
|
|
321
|
+
value = "\u2026".concat(quotes.remove(unescape(expression.getText())), "\u2026");
|
|
322
322
|
break;
|
|
323
323
|
default:
|
|
324
324
|
value = quotes.remove(unescape(expression.getText()));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-css-languageservice",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.12",
|
|
4
4
|
"description": "Language service for CSS, LESS and SCSS",
|
|
5
5
|
"main": "./lib/umd/cssLanguageService.js",
|
|
6
6
|
"typings": "./lib/umd/cssLanguageService",
|
|
@@ -15,15 +15,15 @@
|
|
|
15
15
|
"url": "https://github.com/Microsoft/vscode-css-languageservice"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@types/mocha": "^9.
|
|
18
|
+
"@types/mocha": "^9.1.0",
|
|
19
19
|
"@types/node": "^10.12.21",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
21
|
-
"@typescript-eslint/parser": "^
|
|
22
|
-
"
|
|
23
|
-
"
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.10.1",
|
|
21
|
+
"@typescript-eslint/parser": "^5.10.1",
|
|
22
|
+
"@vscode/web-custom-data": "^0.3.7",
|
|
23
|
+
"eslint": "^8.7.0",
|
|
24
|
+
"mocha": "^9.2.0",
|
|
24
25
|
"rimraf": "^3.0.2",
|
|
25
|
-
"typescript": "^4.
|
|
26
|
-
"vscode-web-custom-data": "^0.3.5"
|
|
26
|
+
"typescript": "^4.5.5"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"vscode-languageserver-textdocument": "^1.0.1",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"mocha": "mocha",
|
|
44
44
|
"coverage": "npm run compile && npx nyc --reporter=html --reporter=text mocha",
|
|
45
45
|
"lint": "eslint src/**/*.ts",
|
|
46
|
-
"update-data": "yarn add vscode
|
|
46
|
+
"update-data": "yarn add @vscode/web-custom-data -D && node ./build/generateData.js",
|
|
47
47
|
"install-types-next": "yarn add vscode-languageserver-types@next -f -S && yarn add vscode-languageserver-textdocument@next -f -S",
|
|
48
48
|
"preversion": "npm test",
|
|
49
49
|
"postversion": "git push && git push --tags"
|