vscode-css-languageservice 5.4.2 → 6.0.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 +5 -1
- package/lib/esm/cssLanguageService.d.ts +37 -37
- package/lib/esm/cssLanguageService.js +72 -75
- package/lib/esm/cssLanguageTypes.d.ts +238 -238
- package/lib/esm/cssLanguageTypes.js +42 -42
- package/lib/esm/data/webCustomData.js +21965 -21965
- package/lib/esm/languageFacts/builtinData.js +142 -142
- package/lib/esm/languageFacts/colors.js +469 -472
- package/lib/esm/languageFacts/dataManager.js +88 -92
- package/lib/esm/languageFacts/dataProvider.js +73 -79
- package/lib/esm/languageFacts/entry.js +137 -138
- package/lib/esm/languageFacts/facts.js +8 -8
- package/lib/esm/parser/cssErrors.js +48 -50
- package/lib/esm/parser/cssNodes.js +1502 -2019
- package/lib/esm/parser/cssParser.js +1534 -1563
- package/lib/esm/parser/cssScanner.js +592 -599
- package/lib/esm/parser/cssSymbolScope.js +311 -341
- package/lib/esm/parser/lessParser.js +714 -740
- package/lib/esm/parser/lessScanner.js +57 -78
- package/lib/esm/parser/scssErrors.js +18 -20
- package/lib/esm/parser/scssParser.js +796 -818
- package/lib/esm/parser/scssScanner.js +95 -116
- package/lib/esm/services/cssCodeActions.js +77 -81
- package/lib/esm/services/cssCompletion.js +1054 -1149
- package/lib/esm/services/cssFolding.js +190 -193
- package/lib/esm/services/cssFormatter.js +136 -136
- package/lib/esm/services/cssHover.js +148 -151
- package/lib/esm/services/cssNavigation.js +378 -470
- package/lib/esm/services/cssSelectionRange.js +47 -47
- package/lib/esm/services/cssValidation.js +41 -44
- package/lib/esm/services/lessCompletion.js +378 -397
- package/lib/esm/services/lint.js +518 -532
- package/lib/esm/services/lintRules.js +76 -83
- package/lib/esm/services/lintUtil.js +196 -205
- package/lib/esm/services/pathCompletion.js +157 -231
- package/lib/esm/services/scssCompletion.js +354 -378
- package/lib/esm/services/scssNavigation.js +82 -154
- package/lib/esm/services/selectorPrinting.js +492 -536
- package/lib/esm/utils/arrays.js +40 -46
- package/lib/esm/utils/objects.js +11 -11
- package/lib/esm/utils/resources.js +11 -24
- package/lib/esm/utils/strings.js +102 -104
- package/lib/umd/cssLanguageService.d.ts +37 -37
- package/lib/umd/cssLanguageService.js +99 -102
- package/lib/umd/cssLanguageTypes.d.ts +238 -238
- package/lib/umd/cssLanguageTypes.js +89 -88
- package/lib/umd/data/webCustomData.js +21978 -21978
- package/lib/umd/languageFacts/builtinData.js +154 -154
- package/lib/umd/languageFacts/colors.js +492 -495
- package/lib/umd/languageFacts/dataManager.js +101 -104
- package/lib/umd/languageFacts/dataProvider.js +86 -91
- package/lib/umd/languageFacts/entry.js +152 -153
- package/lib/umd/languageFacts/facts.js +29 -29
- package/lib/umd/parser/cssErrors.js +61 -62
- package/lib/umd/parser/cssNodes.js +1587 -2034
- package/lib/umd/parser/cssParser.js +1547 -1575
- package/lib/umd/parser/cssScanner.js +606 -611
- package/lib/umd/parser/cssSymbolScope.js +328 -353
- package/lib/umd/parser/lessParser.js +727 -752
- package/lib/umd/parser/lessScanner.js +70 -90
- package/lib/umd/parser/scssErrors.js +31 -32
- package/lib/umd/parser/scssParser.js +809 -830
- package/lib/umd/parser/scssScanner.js +108 -128
- package/lib/umd/services/cssCodeActions.js +90 -93
- package/lib/umd/services/cssCompletion.js +1067 -1161
- package/lib/umd/services/cssFolding.js +203 -206
- package/lib/umd/services/cssFormatter.js +150 -150
- package/lib/umd/services/cssHover.js +161 -163
- package/lib/umd/services/cssNavigation.js +391 -482
- package/lib/umd/services/cssSelectionRange.js +60 -60
- package/lib/umd/services/cssValidation.js +54 -56
- package/lib/umd/services/lessCompletion.js +391 -409
- package/lib/umd/services/lint.js +531 -544
- package/lib/umd/services/lintRules.js +91 -95
- package/lib/umd/services/lintUtil.js +210 -218
- package/lib/umd/services/pathCompletion.js +171 -244
- package/lib/umd/services/scssCompletion.js +367 -390
- package/lib/umd/services/scssNavigation.js +95 -166
- package/lib/umd/services/selectorPrinting.js +510 -550
- package/lib/umd/utils/arrays.js +55 -61
- package/lib/umd/utils/objects.js +25 -25
- package/lib/umd/utils/resources.js +26 -39
- package/lib/umd/utils/strings.js +120 -122
- package/package.json +10 -10
|
@@ -1,128 +1,108 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
//
|
|
73
|
-
if (this.stream.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
this.stream.advanceWhileChar(function (ch) {
|
|
110
|
-
switch (ch) {
|
|
111
|
-
case _NWL:
|
|
112
|
-
case _CAR:
|
|
113
|
-
case _LFD:
|
|
114
|
-
return false;
|
|
115
|
-
default:
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
return SCSSScanner;
|
|
126
|
-
}(cssScanner_1.Scanner));
|
|
127
|
-
exports.SCSSScanner = SCSSScanner;
|
|
128
|
-
});
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "./cssScanner"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
/*---------------------------------------------------------------------------------------------
|
|
11
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
13
|
+
*--------------------------------------------------------------------------------------------*/
|
|
14
|
+
'use strict';
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.SCSSScanner = exports.Module = exports.Ellipsis = exports.SmallerEqualsOperator = exports.GreaterEqualsOperator = exports.NotEqualsOperator = exports.EqualsOperator = exports.Default = exports.InterpolationFunction = exports.VariableName = void 0;
|
|
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;
|
|
32
|
+
exports.VariableName = customTokenValue++;
|
|
33
|
+
exports.InterpolationFunction = customTokenValue++;
|
|
34
|
+
exports.Default = customTokenValue++;
|
|
35
|
+
exports.EqualsOperator = customTokenValue++;
|
|
36
|
+
exports.NotEqualsOperator = customTokenValue++;
|
|
37
|
+
exports.GreaterEqualsOperator = customTokenValue++;
|
|
38
|
+
exports.SmallerEqualsOperator = customTokenValue++;
|
|
39
|
+
exports.Ellipsis = customTokenValue++;
|
|
40
|
+
exports.Module = customTokenValue++;
|
|
41
|
+
class SCSSScanner extends cssScanner_1.Scanner {
|
|
42
|
+
scanNext(offset) {
|
|
43
|
+
// scss variable
|
|
44
|
+
if (this.stream.advanceIfChar(_DLR)) {
|
|
45
|
+
const content = ['$'];
|
|
46
|
+
if (this.ident(content)) {
|
|
47
|
+
return this.finishToken(offset, exports.VariableName, content.join(''));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
this.stream.goBackTo(offset);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// scss: interpolation function #{..})
|
|
54
|
+
if (this.stream.advanceIfChars([_HSH, _CUL])) {
|
|
55
|
+
return this.finishToken(offset, exports.InterpolationFunction);
|
|
56
|
+
}
|
|
57
|
+
// operator ==
|
|
58
|
+
if (this.stream.advanceIfChars([_EQS, _EQS])) {
|
|
59
|
+
return this.finishToken(offset, exports.EqualsOperator);
|
|
60
|
+
}
|
|
61
|
+
// operator !=
|
|
62
|
+
if (this.stream.advanceIfChars([_BNG, _EQS])) {
|
|
63
|
+
return this.finishToken(offset, exports.NotEqualsOperator);
|
|
64
|
+
}
|
|
65
|
+
// operators <, <=
|
|
66
|
+
if (this.stream.advanceIfChar(_LAN)) {
|
|
67
|
+
if (this.stream.advanceIfChar(_EQS)) {
|
|
68
|
+
return this.finishToken(offset, exports.SmallerEqualsOperator);
|
|
69
|
+
}
|
|
70
|
+
return this.finishToken(offset, cssScanner_1.TokenType.Delim);
|
|
71
|
+
}
|
|
72
|
+
// ooperators >, >=
|
|
73
|
+
if (this.stream.advanceIfChar(_RAN)) {
|
|
74
|
+
if (this.stream.advanceIfChar(_EQS)) {
|
|
75
|
+
return this.finishToken(offset, exports.GreaterEqualsOperator);
|
|
76
|
+
}
|
|
77
|
+
return this.finishToken(offset, cssScanner_1.TokenType.Delim);
|
|
78
|
+
}
|
|
79
|
+
// ellipis
|
|
80
|
+
if (this.stream.advanceIfChars([_DOT, _DOT, _DOT])) {
|
|
81
|
+
return this.finishToken(offset, exports.Ellipsis);
|
|
82
|
+
}
|
|
83
|
+
return super.scanNext(offset);
|
|
84
|
+
}
|
|
85
|
+
comment() {
|
|
86
|
+
if (super.comment()) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) {
|
|
90
|
+
this.stream.advanceWhileChar((ch) => {
|
|
91
|
+
switch (ch) {
|
|
92
|
+
case _NWL:
|
|
93
|
+
case _CAR:
|
|
94
|
+
case _LFD:
|
|
95
|
+
return false;
|
|
96
|
+
default:
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
exports.SCSSScanner = SCSSScanner;
|
|
108
|
+
});
|
|
@@ -1,93 +1,90 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "../parser/cssNodes", "../utils/strings", "../services/lintRules", "../cssLanguageTypes", "vscode-nls"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
/*---------------------------------------------------------------------------------------------
|
|
11
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
13
|
-
*--------------------------------------------------------------------------------------------*/
|
|
14
|
-
'use strict';
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.CSSCodeActions = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
this.cssDataManager = cssDataManager;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return this.doCodeActions2(document, range, context, stylesheet).map(
|
|
29
|
-
|
|
30
|
-
return cssLanguageTypes_1.Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, textDocumentEdit && textDocumentEdit.edits);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (context.diagnostics) {
|
|
36
|
-
for (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}());
|
|
92
|
-
exports.CSSCodeActions = CSSCodeActions;
|
|
93
|
-
});
|
|
1
|
+
(function (factory) {
|
|
2
|
+
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
+
var v = factory(require, exports);
|
|
4
|
+
if (v !== undefined) module.exports = v;
|
|
5
|
+
}
|
|
6
|
+
else if (typeof define === "function" && define.amd) {
|
|
7
|
+
define(["require", "exports", "../parser/cssNodes", "../utils/strings", "../services/lintRules", "../cssLanguageTypes", "vscode-nls"], factory);
|
|
8
|
+
}
|
|
9
|
+
})(function (require, exports) {
|
|
10
|
+
/*---------------------------------------------------------------------------------------------
|
|
11
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
12
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
13
|
+
*--------------------------------------------------------------------------------------------*/
|
|
14
|
+
'use strict';
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CSSCodeActions = void 0;
|
|
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
|
+
this.cssDataManager = cssDataManager;
|
|
26
|
+
}
|
|
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
|
+
return cssLanguageTypes_1.Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, textDocumentEdit && textDocumentEdit.edits);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
doCodeActions2(document, range, context, stylesheet) {
|
|
34
|
+
const result = [];
|
|
35
|
+
if (context.diagnostics) {
|
|
36
|
+
for (const diagnostic of context.diagnostics) {
|
|
37
|
+
this.appendFixesForMarker(document, stylesheet, diagnostic, result);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
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);
|
|
47
|
+
if (score >= propertyName.length / 2 /*score_lim*/) {
|
|
48
|
+
candidates.push({ property: p.name, score });
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
// Sort in descending order.
|
|
52
|
+
candidates.sort((a, b) => {
|
|
53
|
+
return b.score - a.score || a.property.localeCompare(b.property);
|
|
54
|
+
});
|
|
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);
|
|
63
|
+
codeAction.diagnostics = [marker];
|
|
64
|
+
result.push(codeAction);
|
|
65
|
+
if (--maxActions <= 0) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
appendFixesForMarker(document, stylesheet, marker, result) {
|
|
71
|
+
if (marker.code !== lintRules_1.Rules.UnknownProperty.id) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
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];
|
|
79
|
+
if (node instanceof nodes.Declaration) {
|
|
80
|
+
const property = node.getProperty();
|
|
81
|
+
if (property && property.offset === offset && property.end === end) {
|
|
82
|
+
this.getFixesForUnknownProperty(document, property, marker, result);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
exports.CSSCodeActions = CSSCodeActions;
|
|
90
|
+
});
|