vscode-css-languageservice 6.3.9 → 7.0.0-next.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/esm/beautify/beautify-css.js +1437 -1606
  3. package/lib/esm/cssLanguageService.d.ts +2 -2
  4. package/lib/esm/cssLanguageService.js +18 -18
  5. package/lib/esm/data/webCustomData.js +13251 -2444
  6. package/lib/esm/languageFacts/builtinData.js +2 -1
  7. package/lib/esm/languageFacts/colors.js +1 -1
  8. package/lib/esm/languageFacts/dataManager.js +3 -3
  9. package/lib/esm/languageFacts/entry.js +1 -1
  10. package/lib/esm/languageFacts/facts.js +3 -3
  11. package/lib/esm/parser/cssErrors.js +1 -0
  12. package/lib/esm/parser/cssNodes.js +1 -1
  13. package/lib/esm/parser/cssParser.js +164 -17
  14. package/lib/esm/parser/cssSymbolScope.js +2 -2
  15. package/lib/esm/parser/lessParser.js +5 -5
  16. package/lib/esm/parser/lessScanner.js +1 -1
  17. package/lib/esm/parser/scssParser.js +64 -6
  18. package/lib/esm/parser/scssScanner.js +1 -1
  19. package/lib/esm/services/cssCodeActions.js +4 -4
  20. package/lib/esm/services/cssCompletion.js +7 -7
  21. package/lib/esm/services/cssFolding.js +3 -3
  22. package/lib/esm/services/cssFormatter.js +3 -3
  23. package/lib/esm/services/cssHover.js +6 -6
  24. package/lib/esm/services/cssNavigation.js +6 -6
  25. package/lib/esm/services/cssSelectionRange.js +2 -2
  26. package/lib/esm/services/cssValidation.js +4 -4
  27. package/lib/esm/services/lessCompletion.js +2 -2
  28. package/lib/esm/services/lint.js +5 -5
  29. package/lib/esm/services/lintRules.js +1 -1
  30. package/lib/esm/services/lintUtil.js +1 -1
  31. package/lib/esm/services/pathCompletion.js +3 -3
  32. package/lib/esm/services/scssCompletion.js +3 -3
  33. package/lib/esm/services/scssNavigation.js +4 -4
  34. package/lib/esm/services/selectorPrinting.js +3 -3
  35. package/package.json +20 -20
  36. package/lib/umd/beautify/beautify-css.js +0 -1695
  37. package/lib/umd/cssLanguageService.d.ts +0 -39
  38. package/lib/umd/cssLanguageService.js +0 -105
  39. package/lib/umd/cssLanguageTypes.d.ts +0 -267
  40. package/lib/umd/cssLanguageTypes.js +0 -89
  41. package/lib/umd/data/webCustomData.js +0 -33806
  42. package/lib/umd/languageFacts/builtinData.js +0 -154
  43. package/lib/umd/languageFacts/colors.js +0 -949
  44. package/lib/umd/languageFacts/dataManager.js +0 -101
  45. package/lib/umd/languageFacts/dataProvider.js +0 -86
  46. package/lib/umd/languageFacts/entry.js +0 -217
  47. package/lib/umd/languageFacts/facts.js +0 -33
  48. package/lib/umd/parser/cssErrors.js +0 -60
  49. package/lib/umd/parser/cssNodes.js +0 -1676
  50. package/lib/umd/parser/cssParser.js +0 -1888
  51. package/lib/umd/parser/cssScanner.js +0 -619
  52. package/lib/umd/parser/cssSymbolScope.js +0 -328
  53. package/lib/umd/parser/lessParser.js +0 -732
  54. package/lib/umd/parser/lessScanner.js +0 -70
  55. package/lib/umd/parser/scssErrors.js +0 -30
  56. package/lib/umd/parser/scssParser.js +0 -816
  57. package/lib/umd/parser/scssScanner.js +0 -108
  58. package/lib/umd/services/cssCodeActions.js +0 -89
  59. package/lib/umd/services/cssCompletion.js +0 -1109
  60. package/lib/umd/services/cssFolding.js +0 -202
  61. package/lib/umd/services/cssFormatter.js +0 -149
  62. package/lib/umd/services/cssHover.js +0 -174
  63. package/lib/umd/services/cssNavigation.js +0 -539
  64. package/lib/umd/services/cssSelectionRange.js +0 -59
  65. package/lib/umd/services/cssValidation.js +0 -54
  66. package/lib/umd/services/lessCompletion.js +0 -390
  67. package/lib/umd/services/lint.js +0 -577
  68. package/lib/umd/services/lintRules.js +0 -90
  69. package/lib/umd/services/lintUtil.js +0 -210
  70. package/lib/umd/services/pathCompletion.js +0 -171
  71. package/lib/umd/services/scssCompletion.js +0 -367
  72. package/lib/umd/services/scssNavigation.js +0 -169
  73. package/lib/umd/services/selectorPrinting.js +0 -575
  74. package/lib/umd/utils/arrays.js +0 -54
  75. package/lib/umd/utils/objects.js +0 -24
  76. package/lib/umd/utils/resources.js +0 -25
  77. package/lib/umd/utils/strings.js +0 -123
@@ -1,328 +0,0 @@
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", "./cssNodes", "../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.Symbols = exports.ScopeBuilder = exports.Symbol = exports.GlobalScope = exports.Scope = void 0;
17
- const nodes = require("./cssNodes");
18
- const arrays_1 = require("../utils/arrays");
19
- class Scope {
20
- constructor(offset, length) {
21
- this.offset = offset;
22
- this.length = length;
23
- this.symbols = [];
24
- this.parent = null;
25
- this.children = [];
26
- }
27
- addChild(scope) {
28
- this.children.push(scope);
29
- scope.setParent(this);
30
- }
31
- setParent(scope) {
32
- this.parent = scope;
33
- }
34
- findScope(offset, length = 0) {
35
- if (this.offset <= offset && this.offset + this.length > offset + length || this.offset === offset && this.length === length) {
36
- return this.findInScope(offset, length);
37
- }
38
- return null;
39
- }
40
- findInScope(offset, length = 0) {
41
- // find the first scope child that has an offset larger than offset + length
42
- const end = offset + length;
43
- const idx = (0, arrays_1.findFirst)(this.children, s => s.offset > end);
44
- if (idx === 0) {
45
- // all scopes have offsets larger than our end
46
- return this;
47
- }
48
- const res = this.children[idx - 1];
49
- if (res.offset <= offset && res.offset + res.length >= offset + length) {
50
- return res.findInScope(offset, length);
51
- }
52
- return this;
53
- }
54
- addSymbol(symbol) {
55
- this.symbols.push(symbol);
56
- }
57
- getSymbol(name, type) {
58
- for (let index = 0; index < this.symbols.length; index++) {
59
- const symbol = this.symbols[index];
60
- if (symbol.name === name && symbol.type === type) {
61
- return symbol;
62
- }
63
- }
64
- return null;
65
- }
66
- getSymbols() {
67
- return this.symbols;
68
- }
69
- }
70
- exports.Scope = Scope;
71
- class GlobalScope extends Scope {
72
- constructor() {
73
- super(0, Number.MAX_VALUE);
74
- }
75
- }
76
- exports.GlobalScope = GlobalScope;
77
- class Symbol {
78
- constructor(name, value, node, type) {
79
- this.name = name;
80
- this.value = value;
81
- this.node = node;
82
- this.type = type;
83
- }
84
- }
85
- exports.Symbol = Symbol;
86
- class ScopeBuilder {
87
- constructor(scope) {
88
- this.scope = scope;
89
- }
90
- addSymbol(node, name, value, type) {
91
- if (node.offset !== -1) {
92
- const current = this.scope.findScope(node.offset, node.length);
93
- if (current) {
94
- current.addSymbol(new Symbol(name, value, node, type));
95
- }
96
- }
97
- }
98
- addScope(node) {
99
- if (node.offset !== -1) {
100
- const current = this.scope.findScope(node.offset, node.length);
101
- if (current && (current.offset !== node.offset || current.length !== node.length)) { // scope already known?
102
- const newScope = new Scope(node.offset, node.length);
103
- current.addChild(newScope);
104
- return newScope;
105
- }
106
- return current;
107
- }
108
- return null;
109
- }
110
- addSymbolToChildScope(scopeNode, node, name, value, type) {
111
- if (scopeNode && scopeNode.offset !== -1) {
112
- const current = this.addScope(scopeNode); // create the scope or gets the existing one
113
- if (current) {
114
- current.addSymbol(new Symbol(name, value, node, type));
115
- }
116
- }
117
- }
118
- visitNode(node) {
119
- switch (node.type) {
120
- case nodes.NodeType.Keyframe:
121
- this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Keyframe);
122
- return true;
123
- case nodes.NodeType.CustomPropertyDeclaration:
124
- return this.visitCustomPropertyDeclarationNode(node);
125
- case nodes.NodeType.VariableDeclaration:
126
- return this.visitVariableDeclarationNode(node);
127
- case nodes.NodeType.Ruleset:
128
- return this.visitRuleSet(node);
129
- case nodes.NodeType.MixinDeclaration:
130
- this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Mixin);
131
- return true;
132
- case nodes.NodeType.FunctionDeclaration:
133
- this.addSymbol(node, node.getName(), void 0, nodes.ReferenceType.Function);
134
- return true;
135
- case nodes.NodeType.FunctionParameter: {
136
- return this.visitFunctionParameterNode(node);
137
- }
138
- case nodes.NodeType.Declarations:
139
- this.addScope(node);
140
- return true;
141
- case nodes.NodeType.For:
142
- const forNode = node;
143
- const scopeNode = forNode.getDeclarations();
144
- if (scopeNode && forNode.variable) {
145
- this.addSymbolToChildScope(scopeNode, forNode.variable, forNode.variable.getName(), void 0, nodes.ReferenceType.Variable);
146
- }
147
- return true;
148
- case nodes.NodeType.Each: {
149
- const eachNode = node;
150
- const scopeNode = eachNode.getDeclarations();
151
- if (scopeNode) {
152
- const variables = eachNode.getVariables().getChildren();
153
- for (const variable of variables) {
154
- this.addSymbolToChildScope(scopeNode, variable, variable.getName(), void 0, nodes.ReferenceType.Variable);
155
- }
156
- }
157
- return true;
158
- }
159
- }
160
- return true;
161
- }
162
- visitRuleSet(node) {
163
- const current = this.scope.findScope(node.offset, node.length);
164
- if (current) {
165
- for (const child of node.getSelectors().getChildren()) {
166
- if (child instanceof nodes.Selector) {
167
- if (child.getChildren().length === 1) { // only selectors with a single element can be extended
168
- current.addSymbol(new Symbol(child.getChild(0).getText(), void 0, child, nodes.ReferenceType.Rule));
169
- }
170
- }
171
- }
172
- }
173
- return true;
174
- }
175
- visitVariableDeclarationNode(node) {
176
- const value = node.getValue() ? node.getValue().getText() : void 0;
177
- this.addSymbol(node, node.getName(), value, nodes.ReferenceType.Variable);
178
- return true;
179
- }
180
- visitFunctionParameterNode(node) {
181
- // parameters are part of the body scope
182
- const scopeNode = node.getParent().getDeclarations();
183
- if (scopeNode) {
184
- const valueNode = node.getDefaultValue();
185
- const value = valueNode ? valueNode.getText() : void 0;
186
- this.addSymbolToChildScope(scopeNode, node, node.getName(), value, nodes.ReferenceType.Variable);
187
- }
188
- return true;
189
- }
190
- visitCustomPropertyDeclarationNode(node) {
191
- const value = node.getValue() ? node.getValue().getText() : '';
192
- this.addCSSVariable(node.getProperty(), node.getProperty().getName(), value, nodes.ReferenceType.Variable);
193
- return true;
194
- }
195
- addCSSVariable(node, name, value, type) {
196
- if (node.offset !== -1) {
197
- this.scope.addSymbol(new Symbol(name, value, node, type));
198
- }
199
- }
200
- }
201
- exports.ScopeBuilder = ScopeBuilder;
202
- class Symbols {
203
- constructor(node) {
204
- this.global = new GlobalScope();
205
- node.acceptVisitor(new ScopeBuilder(this.global));
206
- }
207
- findSymbolsAtOffset(offset, referenceType) {
208
- let scope = this.global.findScope(offset, 0);
209
- const result = [];
210
- const names = {};
211
- while (scope) {
212
- const symbols = scope.getSymbols();
213
- for (let i = 0; i < symbols.length; i++) {
214
- const symbol = symbols[i];
215
- if (symbol.type === referenceType && !names[symbol.name]) {
216
- result.push(symbol);
217
- names[symbol.name] = true;
218
- }
219
- }
220
- scope = scope.parent;
221
- }
222
- return result;
223
- }
224
- internalFindSymbol(node, referenceTypes) {
225
- let scopeNode = node;
226
- if (node.parent instanceof nodes.FunctionParameter && node.parent.getParent() instanceof nodes.BodyDeclaration) {
227
- scopeNode = node.parent.getParent().getDeclarations();
228
- }
229
- if (node.parent instanceof nodes.FunctionArgument && node.parent.getParent() instanceof nodes.Function) {
230
- const funcId = node.parent.getParent().getIdentifier();
231
- if (funcId) {
232
- const functionSymbol = this.internalFindSymbol(funcId, [nodes.ReferenceType.Function]);
233
- if (functionSymbol) {
234
- scopeNode = functionSymbol.node.getDeclarations();
235
- }
236
- }
237
- }
238
- if (!scopeNode) {
239
- return null;
240
- }
241
- const name = node.getText();
242
- let scope = this.global.findScope(scopeNode.offset, scopeNode.length);
243
- while (scope) {
244
- for (let index = 0; index < referenceTypes.length; index++) {
245
- const type = referenceTypes[index];
246
- const symbol = scope.getSymbol(name, type);
247
- if (symbol) {
248
- return symbol;
249
- }
250
- }
251
- scope = scope.parent;
252
- }
253
- return null;
254
- }
255
- evaluateReferenceTypes(node) {
256
- if (node instanceof nodes.Identifier) {
257
- const referenceTypes = node.referenceTypes;
258
- if (referenceTypes) {
259
- return referenceTypes;
260
- }
261
- else {
262
- if (node.isCustomProperty) {
263
- return [nodes.ReferenceType.Variable];
264
- }
265
- // are a reference to a keyframe?
266
- const decl = nodes.getParentDeclaration(node);
267
- if (decl) {
268
- const propertyName = decl.getNonPrefixedPropertyName();
269
- if ((propertyName === 'animation' || propertyName === 'animation-name')
270
- && decl.getValue() && decl.getValue().offset === node.offset) {
271
- return [nodes.ReferenceType.Keyframe];
272
- }
273
- }
274
- }
275
- }
276
- else if (node instanceof nodes.Variable) {
277
- return [nodes.ReferenceType.Variable];
278
- }
279
- const selector = node.findAParent(nodes.NodeType.Selector, nodes.NodeType.ExtendsReference);
280
- if (selector) {
281
- return [nodes.ReferenceType.Rule];
282
- }
283
- return null;
284
- }
285
- findSymbolFromNode(node) {
286
- if (!node) {
287
- return null;
288
- }
289
- while (node.type === nodes.NodeType.Interpolation) {
290
- node = node.getParent();
291
- }
292
- const referenceTypes = this.evaluateReferenceTypes(node);
293
- if (referenceTypes) {
294
- return this.internalFindSymbol(node, referenceTypes);
295
- }
296
- return null;
297
- }
298
- matchesSymbol(node, symbol) {
299
- if (!node) {
300
- return false;
301
- }
302
- while (node.type === nodes.NodeType.Interpolation) {
303
- node = node.getParent();
304
- }
305
- if (!node.matches(symbol.name)) {
306
- return false;
307
- }
308
- const referenceTypes = this.evaluateReferenceTypes(node);
309
- if (!referenceTypes || referenceTypes.indexOf(symbol.type) === -1) {
310
- return false;
311
- }
312
- const nodeSymbol = this.internalFindSymbol(node, referenceTypes);
313
- return nodeSymbol === symbol;
314
- }
315
- findSymbol(name, type, offset) {
316
- let scope = this.global.findScope(offset);
317
- while (scope) {
318
- const symbol = scope.getSymbol(name, type);
319
- if (symbol) {
320
- return symbol;
321
- }
322
- scope = scope.parent;
323
- }
324
- return null;
325
- }
326
- }
327
- exports.Symbols = Symbols;
328
- });