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.
Files changed (84) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/lib/esm/cssLanguageService.d.ts +37 -37
  3. package/lib/esm/cssLanguageService.js +72 -75
  4. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  5. package/lib/esm/cssLanguageTypes.js +42 -42
  6. package/lib/esm/data/webCustomData.js +21965 -21965
  7. package/lib/esm/languageFacts/builtinData.js +142 -142
  8. package/lib/esm/languageFacts/colors.js +469 -472
  9. package/lib/esm/languageFacts/dataManager.js +88 -92
  10. package/lib/esm/languageFacts/dataProvider.js +73 -79
  11. package/lib/esm/languageFacts/entry.js +137 -138
  12. package/lib/esm/languageFacts/facts.js +8 -8
  13. package/lib/esm/parser/cssErrors.js +48 -50
  14. package/lib/esm/parser/cssNodes.js +1502 -2019
  15. package/lib/esm/parser/cssParser.js +1534 -1563
  16. package/lib/esm/parser/cssScanner.js +592 -599
  17. package/lib/esm/parser/cssSymbolScope.js +311 -341
  18. package/lib/esm/parser/lessParser.js +714 -740
  19. package/lib/esm/parser/lessScanner.js +57 -78
  20. package/lib/esm/parser/scssErrors.js +18 -20
  21. package/lib/esm/parser/scssParser.js +796 -818
  22. package/lib/esm/parser/scssScanner.js +95 -116
  23. package/lib/esm/services/cssCodeActions.js +77 -81
  24. package/lib/esm/services/cssCompletion.js +1054 -1149
  25. package/lib/esm/services/cssFolding.js +190 -193
  26. package/lib/esm/services/cssFormatter.js +136 -136
  27. package/lib/esm/services/cssHover.js +148 -151
  28. package/lib/esm/services/cssNavigation.js +378 -470
  29. package/lib/esm/services/cssSelectionRange.js +47 -47
  30. package/lib/esm/services/cssValidation.js +41 -44
  31. package/lib/esm/services/lessCompletion.js +378 -397
  32. package/lib/esm/services/lint.js +518 -532
  33. package/lib/esm/services/lintRules.js +76 -83
  34. package/lib/esm/services/lintUtil.js +196 -205
  35. package/lib/esm/services/pathCompletion.js +157 -231
  36. package/lib/esm/services/scssCompletion.js +354 -378
  37. package/lib/esm/services/scssNavigation.js +82 -154
  38. package/lib/esm/services/selectorPrinting.js +492 -536
  39. package/lib/esm/utils/arrays.js +40 -46
  40. package/lib/esm/utils/objects.js +11 -11
  41. package/lib/esm/utils/resources.js +11 -24
  42. package/lib/esm/utils/strings.js +102 -104
  43. package/lib/umd/cssLanguageService.d.ts +37 -37
  44. package/lib/umd/cssLanguageService.js +99 -102
  45. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  46. package/lib/umd/cssLanguageTypes.js +89 -88
  47. package/lib/umd/data/webCustomData.js +21978 -21978
  48. package/lib/umd/languageFacts/builtinData.js +154 -154
  49. package/lib/umd/languageFacts/colors.js +492 -495
  50. package/lib/umd/languageFacts/dataManager.js +101 -104
  51. package/lib/umd/languageFacts/dataProvider.js +86 -91
  52. package/lib/umd/languageFacts/entry.js +152 -153
  53. package/lib/umd/languageFacts/facts.js +29 -29
  54. package/lib/umd/parser/cssErrors.js +61 -62
  55. package/lib/umd/parser/cssNodes.js +1587 -2034
  56. package/lib/umd/parser/cssParser.js +1547 -1575
  57. package/lib/umd/parser/cssScanner.js +606 -611
  58. package/lib/umd/parser/cssSymbolScope.js +328 -353
  59. package/lib/umd/parser/lessParser.js +727 -752
  60. package/lib/umd/parser/lessScanner.js +70 -90
  61. package/lib/umd/parser/scssErrors.js +31 -32
  62. package/lib/umd/parser/scssParser.js +809 -830
  63. package/lib/umd/parser/scssScanner.js +108 -128
  64. package/lib/umd/services/cssCodeActions.js +90 -93
  65. package/lib/umd/services/cssCompletion.js +1067 -1161
  66. package/lib/umd/services/cssFolding.js +203 -206
  67. package/lib/umd/services/cssFormatter.js +150 -150
  68. package/lib/umd/services/cssHover.js +161 -163
  69. package/lib/umd/services/cssNavigation.js +391 -482
  70. package/lib/umd/services/cssSelectionRange.js +60 -60
  71. package/lib/umd/services/cssValidation.js +54 -56
  72. package/lib/umd/services/lessCompletion.js +391 -409
  73. package/lib/umd/services/lint.js +531 -544
  74. package/lib/umd/services/lintRules.js +91 -95
  75. package/lib/umd/services/lintUtil.js +210 -218
  76. package/lib/umd/services/pathCompletion.js +171 -244
  77. package/lib/umd/services/scssCompletion.js +367 -390
  78. package/lib/umd/services/scssNavigation.js +95 -166
  79. package/lib/umd/services/selectorPrinting.js +510 -550
  80. package/lib/umd/utils/arrays.js +55 -61
  81. package/lib/umd/utils/objects.js +25 -25
  82. package/lib/umd/utils/resources.js +26 -39
  83. package/lib/umd/utils/strings.js +120 -122
  84. 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
- var arrays_1 = require("../utils/arrays");
18
- var Element = /** @class */ (function () {
19
- function Element(decl) {
20
- this.fullPropertyName = decl.getFullPropertyName().toLowerCase();
21
- this.node = decl;
22
- }
23
- return Element;
24
- }());
25
- exports.Element = Element;
26
- function setSide(model, side, value, property) {
27
- var state = model[side];
28
- state.value = value;
29
- if (value) {
30
- if (!(0, arrays_1.includes)(state.properties, property)) {
31
- state.properties.push(property);
32
- }
33
- }
34
- }
35
- function setAllSides(model, value, property) {
36
- setSide(model, 'top', value, property);
37
- setSide(model, 'right', value, property);
38
- setSide(model, 'bottom', value, property);
39
- setSide(model, 'left', value, property);
40
- }
41
- function updateModelWithValue(model, side, value, property) {
42
- if (side === 'top' || side === 'right' ||
43
- side === 'bottom' || side === 'left') {
44
- setSide(model, side, value, property);
45
- }
46
- else {
47
- setAllSides(model, value, property);
48
- }
49
- }
50
- function updateModelWithList(model, values, property) {
51
- switch (values.length) {
52
- case 1:
53
- updateModelWithValue(model, undefined, values[0], property);
54
- break;
55
- case 2:
56
- updateModelWithValue(model, 'top', values[0], property);
57
- updateModelWithValue(model, 'bottom', values[0], property);
58
- updateModelWithValue(model, 'right', values[1], property);
59
- updateModelWithValue(model, 'left', values[1], property);
60
- break;
61
- case 3:
62
- updateModelWithValue(model, 'top', values[0], property);
63
- updateModelWithValue(model, 'right', values[1], property);
64
- updateModelWithValue(model, 'left', values[1], property);
65
- updateModelWithValue(model, 'bottom', values[2], property);
66
- break;
67
- case 4:
68
- updateModelWithValue(model, 'top', values[0], property);
69
- updateModelWithValue(model, 'right', values[1], property);
70
- updateModelWithValue(model, 'bottom', values[2], property);
71
- updateModelWithValue(model, 'left', values[3], property);
72
- break;
73
- }
74
- }
75
- function matches(value, candidates) {
76
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
77
- var candidate = candidates_1[_i];
78
- if (value.matches(candidate)) {
79
- return true;
80
- }
81
- }
82
- return false;
83
- }
84
- /**
85
- * @param allowsKeywords whether the initial value of property is zero, so keywords `initial` and `unset` count as zero
86
- * @return `true` if this node represents a non-zero border; otherwise, `false`
87
- */
88
- function checkLineWidth(value, allowsKeywords) {
89
- if (allowsKeywords === void 0) { allowsKeywords = true; }
90
- if (allowsKeywords && matches(value, ['initial', 'unset'])) {
91
- return false;
92
- }
93
- // a <length> is a value and a unit
94
- // so use `parseFloat` to strip the unit
95
- return parseFloat(value.getText()) !== 0;
96
- }
97
- function checkLineWidthList(nodes, allowsKeywords) {
98
- if (allowsKeywords === void 0) { allowsKeywords = true; }
99
- return nodes.map(function (node) { return checkLineWidth(node, allowsKeywords); });
100
- }
101
- /**
102
- * @param allowsKeywords whether keywords `initial` and `unset` count as zero
103
- * @return `true` if this node represents a non-zero border; otherwise, `false`
104
- */
105
- function checkLineStyle(valueNode, allowsKeywords) {
106
- if (allowsKeywords === void 0) { allowsKeywords = true; }
107
- if (matches(valueNode, ['none', 'hidden'])) {
108
- return false;
109
- }
110
- if (allowsKeywords && matches(valueNode, ['initial', 'unset'])) {
111
- return false;
112
- }
113
- return true;
114
- }
115
- function checkLineStyleList(nodes, allowsKeywords) {
116
- if (allowsKeywords === void 0) { allowsKeywords = true; }
117
- return nodes.map(function (node) { return checkLineStyle(node, allowsKeywords); });
118
- }
119
- function checkBorderShorthand(node) {
120
- var children = node.getChildren();
121
- // the only child can be a keyword, a <line-width>, or a <line-style>
122
- // if either check returns false, the result is no border
123
- if (children.length === 1) {
124
- var value = children[0];
125
- return checkLineWidth(value) && checkLineStyle(value);
126
- }
127
- // multiple children can't contain keywords
128
- // if any child means no border, the result is no border
129
- for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
130
- var child = children_1[_i];
131
- var value = child;
132
- if (!checkLineWidth(value, /* allowsKeywords: */ false) ||
133
- !checkLineStyle(value, /* allowsKeywords: */ false)) {
134
- return false;
135
- }
136
- }
137
- return true;
138
- }
139
- function calculateBoxModel(propertyTable) {
140
- var model = {
141
- top: { value: false, properties: [] },
142
- right: { value: false, properties: [] },
143
- bottom: { value: false, properties: [] },
144
- left: { value: false, properties: [] },
145
- };
146
- for (var _i = 0, propertyTable_1 = propertyTable; _i < propertyTable_1.length; _i++) {
147
- var property = propertyTable_1[_i];
148
- var value = property.node.value;
149
- if (typeof value === 'undefined') {
150
- continue;
151
- }
152
- switch (property.fullPropertyName) {
153
- case 'box-sizing':
154
- // has `box-sizing`, bail out
155
- return {
156
- top: { value: false, properties: [] },
157
- right: { value: false, properties: [] },
158
- bottom: { value: false, properties: [] },
159
- left: { value: false, properties: [] },
160
- };
161
- case 'width':
162
- model.width = property;
163
- break;
164
- case 'height':
165
- model.height = property;
166
- break;
167
- default:
168
- var segments = property.fullPropertyName.split('-');
169
- switch (segments[0]) {
170
- case 'border':
171
- switch (segments[1]) {
172
- case undefined:
173
- case 'top':
174
- case 'right':
175
- case 'bottom':
176
- case 'left':
177
- switch (segments[2]) {
178
- case undefined:
179
- updateModelWithValue(model, segments[1], checkBorderShorthand(value), property);
180
- break;
181
- case 'width':
182
- // the initial value of `border-width` is `medium`, not zero
183
- updateModelWithValue(model, segments[1], checkLineWidth(value, false), property);
184
- break;
185
- case 'style':
186
- // the initial value of `border-style` is `none`
187
- updateModelWithValue(model, segments[1], checkLineStyle(value, true), property);
188
- break;
189
- }
190
- break;
191
- case 'width':
192
- // the initial value of `border-width` is `medium`, not zero
193
- updateModelWithList(model, checkLineWidthList(value.getChildren(), false), property);
194
- break;
195
- case 'style':
196
- // the initial value of `border-style` is `none`
197
- updateModelWithList(model, checkLineStyleList(value.getChildren(), true), property);
198
- break;
199
- }
200
- break;
201
- case 'padding':
202
- if (segments.length === 1) {
203
- // the initial value of `padding` is zero
204
- updateModelWithList(model, checkLineWidthList(value.getChildren(), true), property);
205
- }
206
- else {
207
- // the initial value of `padding` is zero
208
- updateModelWithValue(model, segments[1], checkLineWidth(value, true), property);
209
- }
210
- break;
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
+ });