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,218 +1,210 @@
|
|
|
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", "../utils/arrays"], 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.Element = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
this.fullPropertyName = decl.getFullPropertyName().toLowerCase();
|
|
21
|
-
this.node = decl;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
setSide(model, '
|
|
37
|
-
setSide(model, '
|
|
38
|
-
setSide(model, '
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
updateModelWithValue(model, '
|
|
57
|
-
updateModelWithValue(model, '
|
|
58
|
-
updateModelWithValue(model, '
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
updateModelWithValue(model, '
|
|
63
|
-
updateModelWithValue(model, '
|
|
64
|
-
updateModelWithValue(model, '
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
updateModelWithValue(model, '
|
|
69
|
-
updateModelWithValue(model, '
|
|
70
|
-
updateModelWithValue(model, '
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
if
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
//
|
|
122
|
-
// if
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
case '
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
updateModelWithValue(model, segments[1],
|
|
180
|
-
break;
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
break;
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
break;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
return model;
|
|
216
|
-
}
|
|
217
|
-
exports.default = calculateBoxModel;
|
|
218
|
-
});
|
|
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", "../utils/arrays"], 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.Element = void 0;
|
|
17
|
+
const arrays_1 = require("../utils/arrays");
|
|
18
|
+
class Element {
|
|
19
|
+
constructor(decl) {
|
|
20
|
+
this.fullPropertyName = decl.getFullPropertyName().toLowerCase();
|
|
21
|
+
this.node = decl;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.Element = Element;
|
|
25
|
+
function setSide(model, side, value, property) {
|
|
26
|
+
const state = model[side];
|
|
27
|
+
state.value = value;
|
|
28
|
+
if (value) {
|
|
29
|
+
if (!(0, arrays_1.includes)(state.properties, property)) {
|
|
30
|
+
state.properties.push(property);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function setAllSides(model, value, property) {
|
|
35
|
+
setSide(model, 'top', value, property);
|
|
36
|
+
setSide(model, 'right', value, property);
|
|
37
|
+
setSide(model, 'bottom', value, property);
|
|
38
|
+
setSide(model, 'left', value, property);
|
|
39
|
+
}
|
|
40
|
+
function updateModelWithValue(model, side, value, property) {
|
|
41
|
+
if (side === 'top' || side === 'right' ||
|
|
42
|
+
side === 'bottom' || side === 'left') {
|
|
43
|
+
setSide(model, side, value, property);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
setAllSides(model, value, property);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function updateModelWithList(model, values, property) {
|
|
50
|
+
switch (values.length) {
|
|
51
|
+
case 1:
|
|
52
|
+
updateModelWithValue(model, undefined, values[0], property);
|
|
53
|
+
break;
|
|
54
|
+
case 2:
|
|
55
|
+
updateModelWithValue(model, 'top', values[0], property);
|
|
56
|
+
updateModelWithValue(model, 'bottom', values[0], property);
|
|
57
|
+
updateModelWithValue(model, 'right', values[1], property);
|
|
58
|
+
updateModelWithValue(model, 'left', values[1], property);
|
|
59
|
+
break;
|
|
60
|
+
case 3:
|
|
61
|
+
updateModelWithValue(model, 'top', values[0], property);
|
|
62
|
+
updateModelWithValue(model, 'right', values[1], property);
|
|
63
|
+
updateModelWithValue(model, 'left', values[1], property);
|
|
64
|
+
updateModelWithValue(model, 'bottom', values[2], property);
|
|
65
|
+
break;
|
|
66
|
+
case 4:
|
|
67
|
+
updateModelWithValue(model, 'top', values[0], property);
|
|
68
|
+
updateModelWithValue(model, 'right', values[1], property);
|
|
69
|
+
updateModelWithValue(model, 'bottom', values[2], property);
|
|
70
|
+
updateModelWithValue(model, 'left', values[3], property);
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function matches(value, candidates) {
|
|
75
|
+
for (let candidate of candidates) {
|
|
76
|
+
if (value.matches(candidate)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* @param allowsKeywords whether the initial value of property is zero, so keywords `initial` and `unset` count as zero
|
|
84
|
+
* @return `true` if this node represents a non-zero border; otherwise, `false`
|
|
85
|
+
*/
|
|
86
|
+
function checkLineWidth(value, allowsKeywords = true) {
|
|
87
|
+
if (allowsKeywords && matches(value, ['initial', 'unset'])) {
|
|
88
|
+
return false;
|
|
89
|
+
}
|
|
90
|
+
// a <length> is a value and a unit
|
|
91
|
+
// so use `parseFloat` to strip the unit
|
|
92
|
+
return parseFloat(value.getText()) !== 0;
|
|
93
|
+
}
|
|
94
|
+
function checkLineWidthList(nodes, allowsKeywords = true) {
|
|
95
|
+
return nodes.map(node => checkLineWidth(node, allowsKeywords));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* @param allowsKeywords whether keywords `initial` and `unset` count as zero
|
|
99
|
+
* @return `true` if this node represents a non-zero border; otherwise, `false`
|
|
100
|
+
*/
|
|
101
|
+
function checkLineStyle(valueNode, allowsKeywords = true) {
|
|
102
|
+
if (matches(valueNode, ['none', 'hidden'])) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
if (allowsKeywords && matches(valueNode, ['initial', 'unset'])) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
function checkLineStyleList(nodes, allowsKeywords = true) {
|
|
111
|
+
return nodes.map(node => checkLineStyle(node, allowsKeywords));
|
|
112
|
+
}
|
|
113
|
+
function checkBorderShorthand(node) {
|
|
114
|
+
const children = node.getChildren();
|
|
115
|
+
// the only child can be a keyword, a <line-width>, or a <line-style>
|
|
116
|
+
// if either check returns false, the result is no border
|
|
117
|
+
if (children.length === 1) {
|
|
118
|
+
const value = children[0];
|
|
119
|
+
return checkLineWidth(value) && checkLineStyle(value);
|
|
120
|
+
}
|
|
121
|
+
// multiple children can't contain keywords
|
|
122
|
+
// if any child means no border, the result is no border
|
|
123
|
+
for (const child of children) {
|
|
124
|
+
const value = child;
|
|
125
|
+
if (!checkLineWidth(value, /* allowsKeywords: */ false) ||
|
|
126
|
+
!checkLineStyle(value, /* allowsKeywords: */ false)) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
function calculateBoxModel(propertyTable) {
|
|
133
|
+
const model = {
|
|
134
|
+
top: { value: false, properties: [] },
|
|
135
|
+
right: { value: false, properties: [] },
|
|
136
|
+
bottom: { value: false, properties: [] },
|
|
137
|
+
left: { value: false, properties: [] },
|
|
138
|
+
};
|
|
139
|
+
for (const property of propertyTable) {
|
|
140
|
+
const value = property.node.value;
|
|
141
|
+
if (typeof value === 'undefined') {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
switch (property.fullPropertyName) {
|
|
145
|
+
case 'box-sizing':
|
|
146
|
+
// has `box-sizing`, bail out
|
|
147
|
+
return {
|
|
148
|
+
top: { value: false, properties: [] },
|
|
149
|
+
right: { value: false, properties: [] },
|
|
150
|
+
bottom: { value: false, properties: [] },
|
|
151
|
+
left: { value: false, properties: [] },
|
|
152
|
+
};
|
|
153
|
+
case 'width':
|
|
154
|
+
model.width = property;
|
|
155
|
+
break;
|
|
156
|
+
case 'height':
|
|
157
|
+
model.height = property;
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
const segments = property.fullPropertyName.split('-');
|
|
161
|
+
switch (segments[0]) {
|
|
162
|
+
case 'border':
|
|
163
|
+
switch (segments[1]) {
|
|
164
|
+
case undefined:
|
|
165
|
+
case 'top':
|
|
166
|
+
case 'right':
|
|
167
|
+
case 'bottom':
|
|
168
|
+
case 'left':
|
|
169
|
+
switch (segments[2]) {
|
|
170
|
+
case undefined:
|
|
171
|
+
updateModelWithValue(model, segments[1], checkBorderShorthand(value), property);
|
|
172
|
+
break;
|
|
173
|
+
case 'width':
|
|
174
|
+
// the initial value of `border-width` is `medium`, not zero
|
|
175
|
+
updateModelWithValue(model, segments[1], checkLineWidth(value, false), property);
|
|
176
|
+
break;
|
|
177
|
+
case 'style':
|
|
178
|
+
// the initial value of `border-style` is `none`
|
|
179
|
+
updateModelWithValue(model, segments[1], checkLineStyle(value, true), property);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
break;
|
|
183
|
+
case 'width':
|
|
184
|
+
// the initial value of `border-width` is `medium`, not zero
|
|
185
|
+
updateModelWithList(model, checkLineWidthList(value.getChildren(), false), property);
|
|
186
|
+
break;
|
|
187
|
+
case 'style':
|
|
188
|
+
// the initial value of `border-style` is `none`
|
|
189
|
+
updateModelWithList(model, checkLineStyleList(value.getChildren(), true), property);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
break;
|
|
193
|
+
case 'padding':
|
|
194
|
+
if (segments.length === 1) {
|
|
195
|
+
// the initial value of `padding` is zero
|
|
196
|
+
updateModelWithList(model, checkLineWidthList(value.getChildren(), true), property);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
// the initial value of `padding` is zero
|
|
200
|
+
updateModelWithValue(model, segments[1], checkLineWidth(value, true), property);
|
|
201
|
+
}
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return model;
|
|
208
|
+
}
|
|
209
|
+
exports.default = calculateBoxModel;
|
|
210
|
+
});
|