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,154 +1,82 @@
|
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
if (uri.path.endsWith('/')) {
|
|
84
|
-
return [
|
|
85
|
-
uri.with({ path: uri.path + 'index.scss' }).toString(),
|
|
86
|
-
uri.with({ path: uri.path + '_index.scss' }).toString()
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
// Use `uri.path` since it's normalized to use `/` in all platforms
|
|
90
|
-
var pathFragments = uri.path.split('/');
|
|
91
|
-
var basename = pathFragments[pathFragments.length - 1];
|
|
92
|
-
var pathWithoutBasename = uri.path.slice(0, -basename.length);
|
|
93
|
-
// No variation for links such as _a
|
|
94
|
-
if (basename.startsWith('_')) {
|
|
95
|
-
if (uri.path.endsWith('.scss')) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
return [uri.with({ path: uri.path + '.scss' }).toString()];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
var normalizedBasename = basename + '.scss';
|
|
103
|
-
var documentUriWithBasename = function (newBasename) {
|
|
104
|
-
return uri.with({ path: pathWithoutBasename + newBasename }).toString();
|
|
105
|
-
};
|
|
106
|
-
var normalizedPath = documentUriWithBasename(normalizedBasename);
|
|
107
|
-
var underScorePath = documentUriWithBasename('_' + normalizedBasename);
|
|
108
|
-
var indexPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/index.scss');
|
|
109
|
-
var indexUnderscoreUri = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/_index.scss');
|
|
110
|
-
var cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
|
|
111
|
-
return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
|
|
112
|
-
}
|
|
113
|
-
var target, parsedUri, pathVariations, j, e_1;
|
|
114
|
-
return __generator(this, function (_a) {
|
|
115
|
-
switch (_a.label) {
|
|
116
|
-
case 0:
|
|
117
|
-
if (startsWith(ref, 'sass:')) {
|
|
118
|
-
return [2 /*return*/, undefined]; // sass library
|
|
119
|
-
}
|
|
120
|
-
return [4 /*yield*/, _super.prototype.resolveRelativeReference.call(this, ref, documentUri, documentContext, isRawLink)];
|
|
121
|
-
case 1:
|
|
122
|
-
target = _a.sent();
|
|
123
|
-
if (!(this.fileSystemProvider && target && isRawLink)) return [3 /*break*/, 8];
|
|
124
|
-
parsedUri = URI.parse(target);
|
|
125
|
-
_a.label = 2;
|
|
126
|
-
case 2:
|
|
127
|
-
_a.trys.push([2, 7, , 8]);
|
|
128
|
-
pathVariations = toPathVariations(parsedUri);
|
|
129
|
-
if (!pathVariations) return [3 /*break*/, 6];
|
|
130
|
-
j = 0;
|
|
131
|
-
_a.label = 3;
|
|
132
|
-
case 3:
|
|
133
|
-
if (!(j < pathVariations.length)) return [3 /*break*/, 6];
|
|
134
|
-
return [4 /*yield*/, this.fileExists(pathVariations[j])];
|
|
135
|
-
case 4:
|
|
136
|
-
if (_a.sent()) {
|
|
137
|
-
return [2 /*return*/, pathVariations[j]];
|
|
138
|
-
}
|
|
139
|
-
_a.label = 5;
|
|
140
|
-
case 5:
|
|
141
|
-
j++;
|
|
142
|
-
return [3 /*break*/, 3];
|
|
143
|
-
case 6: return [3 /*break*/, 8];
|
|
144
|
-
case 7:
|
|
145
|
-
e_1 = _a.sent();
|
|
146
|
-
return [3 /*break*/, 8];
|
|
147
|
-
case 8: return [2 /*return*/, target];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
return SCSSNavigation;
|
|
153
|
-
}(CSSNavigation));
|
|
154
|
-
export { SCSSNavigation };
|
|
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 { CSSNavigation } from './cssNavigation';
|
|
7
|
+
import * as nodes from '../parser/cssNodes';
|
|
8
|
+
import { URI } from 'vscode-uri';
|
|
9
|
+
import { startsWith } from '../utils/strings';
|
|
10
|
+
export class SCSSNavigation extends CSSNavigation {
|
|
11
|
+
constructor(fileSystemProvider) {
|
|
12
|
+
super(fileSystemProvider, true);
|
|
13
|
+
}
|
|
14
|
+
isRawStringDocumentLinkNode(node) {
|
|
15
|
+
return (super.isRawStringDocumentLinkNode(node) ||
|
|
16
|
+
node.type === nodes.NodeType.Use ||
|
|
17
|
+
node.type === nodes.NodeType.Forward);
|
|
18
|
+
}
|
|
19
|
+
async resolveRelativeReference(ref, documentUri, documentContext, isRawLink) {
|
|
20
|
+
if (startsWith(ref, 'sass:')) {
|
|
21
|
+
return undefined; // sass library
|
|
22
|
+
}
|
|
23
|
+
const target = await super.resolveRelativeReference(ref, documentUri, documentContext, isRawLink);
|
|
24
|
+
if (this.fileSystemProvider && target && isRawLink) {
|
|
25
|
+
const parsedUri = URI.parse(target);
|
|
26
|
+
try {
|
|
27
|
+
const pathVariations = toPathVariations(parsedUri);
|
|
28
|
+
if (pathVariations) {
|
|
29
|
+
for (let j = 0; j < pathVariations.length; j++) {
|
|
30
|
+
if (await this.fileExists(pathVariations[j])) {
|
|
31
|
+
return pathVariations[j];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
// ignore
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return target;
|
|
41
|
+
function toPathVariations(uri) {
|
|
42
|
+
// No valid path
|
|
43
|
+
if (uri.path === '') {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
// No variation for links that ends with suffix
|
|
47
|
+
if (uri.path.endsWith('.scss') || uri.path.endsWith('.css')) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// If a link is like a/, try resolving a/index.scss and a/_index.scss
|
|
51
|
+
if (uri.path.endsWith('/')) {
|
|
52
|
+
return [
|
|
53
|
+
uri.with({ path: uri.path + 'index.scss' }).toString(),
|
|
54
|
+
uri.with({ path: uri.path + '_index.scss' }).toString()
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
// Use `uri.path` since it's normalized to use `/` in all platforms
|
|
58
|
+
const pathFragments = uri.path.split('/');
|
|
59
|
+
const basename = pathFragments[pathFragments.length - 1];
|
|
60
|
+
const pathWithoutBasename = uri.path.slice(0, -basename.length);
|
|
61
|
+
// No variation for links such as _a
|
|
62
|
+
if (basename.startsWith('_')) {
|
|
63
|
+
if (uri.path.endsWith('.scss')) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
return [uri.with({ path: uri.path + '.scss' }).toString()];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const normalizedBasename = basename + '.scss';
|
|
71
|
+
const documentUriWithBasename = (newBasename) => {
|
|
72
|
+
return uri.with({ path: pathWithoutBasename + newBasename }).toString();
|
|
73
|
+
};
|
|
74
|
+
const normalizedPath = documentUriWithBasename(normalizedBasename);
|
|
75
|
+
const underScorePath = documentUriWithBasename('_' + normalizedBasename);
|
|
76
|
+
const indexPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/index.scss');
|
|
77
|
+
const indexUnderscoreUri = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/_index.scss');
|
|
78
|
+
const cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
|
|
79
|
+
return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|