vscode-css-languageservice 5.4.1 → 6.0.1
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/README.md +1 -0
- package/lib/esm/beautify/beautify-css.js +50 -8
- 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 +21959 -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 -1566
- 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/beautify/beautify-css.js +50 -8
- 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 +21972 -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 -1578
- 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 +11 -11
|
@@ -1,116 +1,95 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
'use strict';
|
|
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
|
-
if (this.stream.
|
|
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
|
-
return
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) {
|
|
98
|
-
this.stream.advanceWhileChar(function (ch) {
|
|
99
|
-
switch (ch) {
|
|
100
|
-
case _NWL:
|
|
101
|
-
case _CAR:
|
|
102
|
-
case _LFD:
|
|
103
|
-
return false;
|
|
104
|
-
default:
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
return true;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
return SCSSScanner;
|
|
115
|
-
}(Scanner));
|
|
116
|
-
export { SCSSScanner };
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
'use strict';
|
|
6
|
+
import { TokenType, Scanner } from './cssScanner';
|
|
7
|
+
const _FSL = '/'.charCodeAt(0);
|
|
8
|
+
const _NWL = '\n'.charCodeAt(0);
|
|
9
|
+
const _CAR = '\r'.charCodeAt(0);
|
|
10
|
+
const _LFD = '\f'.charCodeAt(0);
|
|
11
|
+
const _DLR = '$'.charCodeAt(0);
|
|
12
|
+
const _HSH = '#'.charCodeAt(0);
|
|
13
|
+
const _CUL = '{'.charCodeAt(0);
|
|
14
|
+
const _EQS = '='.charCodeAt(0);
|
|
15
|
+
const _BNG = '!'.charCodeAt(0);
|
|
16
|
+
const _LAN = '<'.charCodeAt(0);
|
|
17
|
+
const _RAN = '>'.charCodeAt(0);
|
|
18
|
+
const _DOT = '.'.charCodeAt(0);
|
|
19
|
+
const _ATS = '@'.charCodeAt(0);
|
|
20
|
+
let customTokenValue = TokenType.CustomToken;
|
|
21
|
+
export const VariableName = customTokenValue++;
|
|
22
|
+
export const InterpolationFunction = customTokenValue++;
|
|
23
|
+
export const Default = customTokenValue++;
|
|
24
|
+
export const EqualsOperator = customTokenValue++;
|
|
25
|
+
export const NotEqualsOperator = customTokenValue++;
|
|
26
|
+
export const GreaterEqualsOperator = customTokenValue++;
|
|
27
|
+
export const SmallerEqualsOperator = customTokenValue++;
|
|
28
|
+
export const Ellipsis = customTokenValue++;
|
|
29
|
+
export const Module = customTokenValue++;
|
|
30
|
+
export class SCSSScanner extends Scanner {
|
|
31
|
+
scanNext(offset) {
|
|
32
|
+
// scss variable
|
|
33
|
+
if (this.stream.advanceIfChar(_DLR)) {
|
|
34
|
+
const content = ['$'];
|
|
35
|
+
if (this.ident(content)) {
|
|
36
|
+
return this.finishToken(offset, VariableName, content.join(''));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.stream.goBackTo(offset);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
// scss: interpolation function #{..})
|
|
43
|
+
if (this.stream.advanceIfChars([_HSH, _CUL])) {
|
|
44
|
+
return this.finishToken(offset, InterpolationFunction);
|
|
45
|
+
}
|
|
46
|
+
// operator ==
|
|
47
|
+
if (this.stream.advanceIfChars([_EQS, _EQS])) {
|
|
48
|
+
return this.finishToken(offset, EqualsOperator);
|
|
49
|
+
}
|
|
50
|
+
// operator !=
|
|
51
|
+
if (this.stream.advanceIfChars([_BNG, _EQS])) {
|
|
52
|
+
return this.finishToken(offset, NotEqualsOperator);
|
|
53
|
+
}
|
|
54
|
+
// operators <, <=
|
|
55
|
+
if (this.stream.advanceIfChar(_LAN)) {
|
|
56
|
+
if (this.stream.advanceIfChar(_EQS)) {
|
|
57
|
+
return this.finishToken(offset, SmallerEqualsOperator);
|
|
58
|
+
}
|
|
59
|
+
return this.finishToken(offset, TokenType.Delim);
|
|
60
|
+
}
|
|
61
|
+
// ooperators >, >=
|
|
62
|
+
if (this.stream.advanceIfChar(_RAN)) {
|
|
63
|
+
if (this.stream.advanceIfChar(_EQS)) {
|
|
64
|
+
return this.finishToken(offset, GreaterEqualsOperator);
|
|
65
|
+
}
|
|
66
|
+
return this.finishToken(offset, TokenType.Delim);
|
|
67
|
+
}
|
|
68
|
+
// ellipis
|
|
69
|
+
if (this.stream.advanceIfChars([_DOT, _DOT, _DOT])) {
|
|
70
|
+
return this.finishToken(offset, Ellipsis);
|
|
71
|
+
}
|
|
72
|
+
return super.scanNext(offset);
|
|
73
|
+
}
|
|
74
|
+
comment() {
|
|
75
|
+
if (super.comment()) {
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) {
|
|
79
|
+
this.stream.advanceWhileChar((ch) => {
|
|
80
|
+
switch (ch) {
|
|
81
|
+
case _NWL:
|
|
82
|
+
case _CAR:
|
|
83
|
+
case _LFD:
|
|
84
|
+
return false;
|
|
85
|
+
default:
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -1,81 +1,77 @@
|
|
|
1
|
-
/*---------------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
-
*--------------------------------------------------------------------------------------------*/
|
|
5
|
-
'use strict';
|
|
6
|
-
import * as nodes from '../parser/cssNodes';
|
|
7
|
-
import { difference } from '../utils/strings';
|
|
8
|
-
import { Rules } from '../services/lintRules';
|
|
9
|
-
import { Command, TextEdit, CodeAction, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier } from '../cssLanguageTypes';
|
|
10
|
-
import * as nls from 'vscode-nls';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
this.cssDataManager = cssDataManager;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return this.doCodeActions2(document, range, context, stylesheet).map(
|
|
18
|
-
|
|
19
|
-
return Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, textDocumentEdit && textDocumentEdit.edits);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (context.diagnostics) {
|
|
25
|
-
for (
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
79
|
-
return CSSCodeActions;
|
|
80
|
-
}());
|
|
81
|
-
export { CSSCodeActions };
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
'use strict';
|
|
6
|
+
import * as nodes from '../parser/cssNodes';
|
|
7
|
+
import { difference } from '../utils/strings';
|
|
8
|
+
import { Rules } from '../services/lintRules';
|
|
9
|
+
import { Command, TextEdit, CodeAction, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier } from '../cssLanguageTypes';
|
|
10
|
+
import * as nls from 'vscode-nls';
|
|
11
|
+
const localize = nls.loadMessageBundle();
|
|
12
|
+
export class CSSCodeActions {
|
|
13
|
+
constructor(cssDataManager) {
|
|
14
|
+
this.cssDataManager = cssDataManager;
|
|
15
|
+
}
|
|
16
|
+
doCodeActions(document, range, context, stylesheet) {
|
|
17
|
+
return this.doCodeActions2(document, range, context, stylesheet).map(ca => {
|
|
18
|
+
const textDocumentEdit = ca.edit && ca.edit.documentChanges && ca.edit.documentChanges[0];
|
|
19
|
+
return Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, textDocumentEdit && textDocumentEdit.edits);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
doCodeActions2(document, range, context, stylesheet) {
|
|
23
|
+
const result = [];
|
|
24
|
+
if (context.diagnostics) {
|
|
25
|
+
for (const diagnostic of context.diagnostics) {
|
|
26
|
+
this.appendFixesForMarker(document, stylesheet, diagnostic, result);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
getFixesForUnknownProperty(document, property, marker, result) {
|
|
32
|
+
const propertyName = property.getName();
|
|
33
|
+
const candidates = [];
|
|
34
|
+
this.cssDataManager.getProperties().forEach(p => {
|
|
35
|
+
const score = difference(propertyName, p.name);
|
|
36
|
+
if (score >= propertyName.length / 2 /*score_lim*/) {
|
|
37
|
+
candidates.push({ property: p.name, score });
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
// Sort in descending order.
|
|
41
|
+
candidates.sort((a, b) => {
|
|
42
|
+
return b.score - a.score || a.property.localeCompare(b.property);
|
|
43
|
+
});
|
|
44
|
+
let maxActions = 3;
|
|
45
|
+
for (const candidate of candidates) {
|
|
46
|
+
const propertyName = candidate.property;
|
|
47
|
+
const title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName);
|
|
48
|
+
const edit = TextEdit.replace(marker.range, propertyName);
|
|
49
|
+
const documentIdentifier = VersionedTextDocumentIdentifier.create(document.uri, document.version);
|
|
50
|
+
const workspaceEdit = { documentChanges: [TextDocumentEdit.create(documentIdentifier, [edit])] };
|
|
51
|
+
const codeAction = CodeAction.create(title, workspaceEdit, CodeActionKind.QuickFix);
|
|
52
|
+
codeAction.diagnostics = [marker];
|
|
53
|
+
result.push(codeAction);
|
|
54
|
+
if (--maxActions <= 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
appendFixesForMarker(document, stylesheet, marker, result) {
|
|
60
|
+
if (marker.code !== Rules.UnknownProperty.id) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const offset = document.offsetAt(marker.range.start);
|
|
64
|
+
const end = document.offsetAt(marker.range.end);
|
|
65
|
+
const nodepath = nodes.getNodePath(stylesheet, offset);
|
|
66
|
+
for (let i = nodepath.length - 1; i >= 0; i--) {
|
|
67
|
+
const node = nodepath[i];
|
|
68
|
+
if (node instanceof nodes.Declaration) {
|
|
69
|
+
const property = node.getProperty();
|
|
70
|
+
if (property && property.offset === offset && property.end === end) {
|
|
71
|
+
this.getFixesForUnknownProperty(document, property, marker, result);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|