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,21 +14,21 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
29
14
|
'use strict';
|
|
30
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
16
|
exports.SCSSScanner = exports.Module = exports.Ellipsis = exports.SmallerEqualsOperator = exports.GreaterEqualsOperator = exports.NotEqualsOperator = exports.EqualsOperator = exports.Default = exports.InterpolationFunction = exports.VariableName = void 0;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
17
|
+
const cssScanner_1 = require("./cssScanner");
|
|
18
|
+
const _FSL = '/'.charCodeAt(0);
|
|
19
|
+
const _NWL = '\n'.charCodeAt(0);
|
|
20
|
+
const _CAR = '\r'.charCodeAt(0);
|
|
21
|
+
const _LFD = '\f'.charCodeAt(0);
|
|
22
|
+
const _DLR = '$'.charCodeAt(0);
|
|
23
|
+
const _HSH = '#'.charCodeAt(0);
|
|
24
|
+
const _CUL = '{'.charCodeAt(0);
|
|
25
|
+
const _EQS = '='.charCodeAt(0);
|
|
26
|
+
const _BNG = '!'.charCodeAt(0);
|
|
27
|
+
const _LAN = '<'.charCodeAt(0);
|
|
28
|
+
const _RAN = '>'.charCodeAt(0);
|
|
29
|
+
const _DOT = '.'.charCodeAt(0);
|
|
30
|
+
const _ATS = '@'.charCodeAt(0);
|
|
31
|
+
let customTokenValue = cssScanner_1.TokenType.CustomToken;
|
|
47
32
|
exports.VariableName = customTokenValue++;
|
|
48
33
|
exports.InterpolationFunction = customTokenValue++;
|
|
49
34
|
exports.Default = customTokenValue++;
|
|
@@ -53,15 +38,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
53
38
|
exports.SmallerEqualsOperator = customTokenValue++;
|
|
54
39
|
exports.Ellipsis = customTokenValue++;
|
|
55
40
|
exports.Module = customTokenValue++;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
function SCSSScanner() {
|
|
59
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
60
|
-
}
|
|
61
|
-
SCSSScanner.prototype.scanNext = function (offset) {
|
|
41
|
+
class SCSSScanner extends cssScanner_1.Scanner {
|
|
42
|
+
scanNext(offset) {
|
|
62
43
|
// scss variable
|
|
63
44
|
if (this.stream.advanceIfChar(_DLR)) {
|
|
64
|
-
|
|
45
|
+
const content = ['$'];
|
|
65
46
|
if (this.ident(content)) {
|
|
66
47
|
return this.finishToken(offset, exports.VariableName, content.join(''));
|
|
67
48
|
}
|
|
@@ -99,14 +80,14 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
99
80
|
if (this.stream.advanceIfChars([_DOT, _DOT, _DOT])) {
|
|
100
81
|
return this.finishToken(offset, exports.Ellipsis);
|
|
101
82
|
}
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (
|
|
83
|
+
return super.scanNext(offset);
|
|
84
|
+
}
|
|
85
|
+
comment() {
|
|
86
|
+
if (super.comment()) {
|
|
106
87
|
return true;
|
|
107
88
|
}
|
|
108
89
|
if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) {
|
|
109
|
-
this.stream.advanceWhileChar(
|
|
90
|
+
this.stream.advanceWhileChar((ch) => {
|
|
110
91
|
switch (ch) {
|
|
111
92
|
case _NWL:
|
|
112
93
|
case _CAR:
|
|
@@ -121,8 +102,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
121
102
|
else {
|
|
122
103
|
return false;
|
|
123
104
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
}(cssScanner_1.Scanner));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
127
107
|
exports.SCSSScanner = SCSSScanner;
|
|
128
108
|
});
|
|
@@ -14,80 +14,77 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.CSSCodeActions = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const nodes = require("../parser/cssNodes");
|
|
18
|
+
const strings_1 = require("../utils/strings");
|
|
19
|
+
const lintRules_1 = require("../services/lintRules");
|
|
20
|
+
const cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
21
|
+
const nls = require("vscode-nls");
|
|
22
|
+
const localize = nls.loadMessageBundle();
|
|
23
|
+
class CSSCodeActions {
|
|
24
|
+
constructor(cssDataManager) {
|
|
25
25
|
this.cssDataManager = cssDataManager;
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
return this.doCodeActions2(document, range, context, stylesheet).map(
|
|
29
|
-
|
|
27
|
+
doCodeActions(document, range, context, stylesheet) {
|
|
28
|
+
return this.doCodeActions2(document, range, context, stylesheet).map(ca => {
|
|
29
|
+
const textDocumentEdit = ca.edit && ca.edit.documentChanges && ca.edit.documentChanges[0];
|
|
30
30
|
return cssLanguageTypes_1.Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, textDocumentEdit && textDocumentEdit.edits);
|
|
31
31
|
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
}
|
|
33
|
+
doCodeActions2(document, range, context, stylesheet) {
|
|
34
|
+
const result = [];
|
|
35
35
|
if (context.diagnostics) {
|
|
36
|
-
for (
|
|
37
|
-
var diagnostic = _a[_i];
|
|
36
|
+
for (const diagnostic of context.diagnostics) {
|
|
38
37
|
this.appendFixesForMarker(document, stylesheet, diagnostic, result);
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
return result;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
this.cssDataManager.getProperties().forEach(
|
|
47
|
-
|
|
41
|
+
}
|
|
42
|
+
getFixesForUnknownProperty(document, property, marker, result) {
|
|
43
|
+
const propertyName = property.getName();
|
|
44
|
+
const candidates = [];
|
|
45
|
+
this.cssDataManager.getProperties().forEach(p => {
|
|
46
|
+
const score = (0, strings_1.difference)(propertyName, p.name);
|
|
48
47
|
if (score >= propertyName.length / 2 /*score_lim*/) {
|
|
49
|
-
candidates.push({ property: p.name, score
|
|
48
|
+
candidates.push({ property: p.name, score });
|
|
50
49
|
}
|
|
51
50
|
});
|
|
52
51
|
// Sort in descending order.
|
|
53
|
-
candidates.sort(
|
|
52
|
+
candidates.sort((a, b) => {
|
|
54
53
|
return b.score - a.score || a.property.localeCompare(b.property);
|
|
55
54
|
});
|
|
56
|
-
|
|
57
|
-
for (
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
var codeAction = cssLanguageTypes_1.CodeAction.create(title, workspaceEdit, cssLanguageTypes_1.CodeActionKind.QuickFix);
|
|
55
|
+
let maxActions = 3;
|
|
56
|
+
for (const candidate of candidates) {
|
|
57
|
+
const propertyName = candidate.property;
|
|
58
|
+
const title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName);
|
|
59
|
+
const edit = cssLanguageTypes_1.TextEdit.replace(marker.range, propertyName);
|
|
60
|
+
const documentIdentifier = cssLanguageTypes_1.VersionedTextDocumentIdentifier.create(document.uri, document.version);
|
|
61
|
+
const workspaceEdit = { documentChanges: [cssLanguageTypes_1.TextDocumentEdit.create(documentIdentifier, [edit])] };
|
|
62
|
+
const codeAction = cssLanguageTypes_1.CodeAction.create(title, workspaceEdit, cssLanguageTypes_1.CodeActionKind.QuickFix);
|
|
65
63
|
codeAction.diagnostics = [marker];
|
|
66
64
|
result.push(codeAction);
|
|
67
65
|
if (--maxActions <= 0) {
|
|
68
66
|
return;
|
|
69
67
|
}
|
|
70
68
|
}
|
|
71
|
-
}
|
|
72
|
-
|
|
69
|
+
}
|
|
70
|
+
appendFixesForMarker(document, stylesheet, marker, result) {
|
|
73
71
|
if (marker.code !== lintRules_1.Rules.UnknownProperty.id) {
|
|
74
72
|
return;
|
|
75
73
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
for (
|
|
80
|
-
|
|
74
|
+
const offset = document.offsetAt(marker.range.start);
|
|
75
|
+
const end = document.offsetAt(marker.range.end);
|
|
76
|
+
const nodepath = nodes.getNodePath(stylesheet, offset);
|
|
77
|
+
for (let i = nodepath.length - 1; i >= 0; i--) {
|
|
78
|
+
const node = nodepath[i];
|
|
81
79
|
if (node instanceof nodes.Declaration) {
|
|
82
|
-
|
|
80
|
+
const property = node.getProperty();
|
|
83
81
|
if (property && property.offset === offset && property.end === end) {
|
|
84
82
|
this.getFixesForUnknownProperty(document, property, marker, result);
|
|
85
83
|
return;
|
|
86
84
|
}
|
|
87
85
|
}
|
|
88
86
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
92
89
|
exports.CSSCodeActions = CSSCodeActions;
|
|
93
90
|
});
|