vscode-css-languageservice 5.4.2 → 6.1.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 (83) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/beautify/beautify-css.js +11 -4
  4. package/lib/esm/cssLanguageService.d.ts +2 -1
  5. package/lib/esm/cssLanguageService.js +15 -17
  6. package/lib/esm/cssLanguageTypes.js +2 -2
  7. package/lib/esm/data/webCustomData.js +356 -232
  8. package/lib/esm/languageFacts/builtinData.js +15 -15
  9. package/lib/esm/languageFacts/colors.js +66 -69
  10. package/lib/esm/languageFacts/dataManager.js +38 -42
  11. package/lib/esm/languageFacts/dataProvider.js +17 -23
  12. package/lib/esm/languageFacts/entry.js +22 -23
  13. package/lib/esm/parser/cssErrors.js +5 -7
  14. package/lib/esm/parser/cssNodes.js +869 -1377
  15. package/lib/esm/parser/cssParser.js +419 -376
  16. package/lib/esm/parser/cssScanner.js +168 -175
  17. package/lib/esm/parser/cssSymbolScope.js +107 -137
  18. package/lib/esm/parser/lessParser.js +177 -202
  19. package/lib/esm/parser/lessScanner.js +22 -43
  20. package/lib/esm/parser/scssErrors.js +5 -7
  21. package/lib/esm/parser/scssParser.js +196 -208
  22. package/lib/esm/parser/scssScanner.js +33 -54
  23. package/lib/esm/services/cssCodeActions.js +36 -40
  24. package/lib/esm/services/cssCompletion.js +300 -395
  25. package/lib/esm/services/cssFolding.js +32 -35
  26. package/lib/esm/services/cssFormatter.js +22 -22
  27. package/lib/esm/services/cssHover.js +30 -33
  28. package/lib/esm/services/cssNavigation.js +260 -289
  29. package/lib/esm/services/cssSelectionRange.js +6 -6
  30. package/lib/esm/services/cssValidation.js +13 -16
  31. package/lib/esm/services/lessCompletion.js +351 -370
  32. package/lib/esm/services/lint.js +161 -175
  33. package/lib/esm/services/lintRules.js +20 -27
  34. package/lib/esm/services/lintUtil.js +19 -28
  35. package/lib/esm/services/pathCompletion.js +84 -158
  36. package/lib/esm/services/scssCompletion.js +283 -307
  37. package/lib/esm/services/scssNavigation.js +65 -137
  38. package/lib/esm/services/selectorPrinting.js +131 -175
  39. package/lib/esm/utils/arrays.js +6 -12
  40. package/lib/esm/utils/objects.js +1 -1
  41. package/lib/esm/utils/resources.js +3 -16
  42. package/lib/esm/utils/strings.js +10 -12
  43. package/lib/umd/beautify/beautify-css.js +11 -4
  44. package/lib/umd/cssLanguageService.d.ts +2 -1
  45. package/lib/umd/cssLanguageService.js +34 -32
  46. package/lib/umd/cssLanguageTypes.js +4 -3
  47. package/lib/umd/data/webCustomData.js +355 -231
  48. package/lib/umd/languageFacts/colors.js +65 -68
  49. package/lib/umd/languageFacts/dataManager.js +41 -44
  50. package/lib/umd/languageFacts/dataProvider.js +17 -22
  51. package/lib/umd/languageFacts/entry.js +22 -23
  52. package/lib/umd/languageFacts/facts.js +5 -1
  53. package/lib/umd/parser/cssErrors.js +5 -6
  54. package/lib/umd/parser/cssNodes.js +870 -1307
  55. package/lib/umd/parser/cssParser.js +424 -380
  56. package/lib/umd/parser/cssScanner.js +168 -173
  57. package/lib/umd/parser/cssSymbolScope.js +109 -134
  58. package/lib/umd/parser/lessParser.js +182 -206
  59. package/lib/umd/parser/lessScanner.js +22 -42
  60. package/lib/umd/parser/scssErrors.js +5 -6
  61. package/lib/umd/parser/scssParser.js +202 -213
  62. package/lib/umd/parser/scssScanner.js +25 -45
  63. package/lib/umd/services/cssCodeActions.js +41 -44
  64. package/lib/umd/services/cssCompletion.js +308 -402
  65. package/lib/umd/services/cssFolding.js +35 -38
  66. package/lib/umd/services/cssFormatter.js +25 -25
  67. package/lib/umd/services/cssHover.js +36 -38
  68. package/lib/umd/services/cssNavigation.js +267 -295
  69. package/lib/umd/services/cssSelectionRange.js +8 -8
  70. package/lib/umd/services/cssValidation.js +17 -19
  71. package/lib/umd/services/lessCompletion.js +354 -372
  72. package/lib/umd/services/lint.js +167 -180
  73. package/lib/umd/services/lintRules.js +20 -24
  74. package/lib/umd/services/lintUtil.js +20 -28
  75. package/lib/umd/services/pathCompletion.js +87 -160
  76. package/lib/umd/services/scssCompletion.js +287 -310
  77. package/lib/umd/services/scssNavigation.js +69 -140
  78. package/lib/umd/services/selectorPrinting.js +134 -174
  79. package/lib/umd/utils/arrays.js +6 -12
  80. package/lib/umd/utils/objects.js +1 -1
  81. package/lib/umd/utils/resources.js +4 -17
  82. package/lib/umd/utils/strings.js +10 -12
  83. package/package.json +16 -15
@@ -1,39 +1,3 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __generator = (this && this.__generator) || function (thisArg, body) {
11
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
- function verb(n) { return function (v) { return step([n, v]); }; }
14
- function step(op) {
15
- if (f) throw new TypeError("Generator is already executing.");
16
- while (_) try {
17
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
- if (y = 0, t) op = [op[0] & 2, t.value];
19
- switch (op[0]) {
20
- case 0: case 1: t = op; break;
21
- case 4: _.label++; return { value: op[1], done: false };
22
- case 5: _.label++; y = op[1]; op = [0]; continue;
23
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
- default:
25
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
- if (t[2]) _.ops.pop();
30
- _.trys.pop(); continue;
31
- }
32
- op = body.call(thisArg, _);
33
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
- }
36
- };
37
1
  (function (factory) {
38
2
  if (typeof module === "object" && typeof module.exports === "object") {
39
3
  var v = factory(require, exports);
@@ -50,17 +14,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
14
  'use strict';
51
15
  Object.defineProperty(exports, "__esModule", { value: true });
52
16
  exports.CSSCompletion = void 0;
53
- var nodes = require("../parser/cssNodes");
54
- var cssSymbolScope_1 = require("../parser/cssSymbolScope");
55
- var languageFacts = require("../languageFacts/facts");
56
- var strings = require("../utils/strings");
57
- var cssLanguageTypes_1 = require("../cssLanguageTypes");
58
- var nls = require("vscode-nls");
59
- var objects_1 = require("../utils/objects");
60
- var pathCompletion_1 = require("./pathCompletion");
61
- var localize = nls.loadMessageBundle();
62
- var SnippetFormat = cssLanguageTypes_1.InsertTextFormat.Snippet;
63
- var retriggerCommand = {
17
+ const nodes = require("../parser/cssNodes");
18
+ const cssSymbolScope_1 = require("../parser/cssSymbolScope");
19
+ const languageFacts = require("../languageFacts/facts");
20
+ const strings = require("../utils/strings");
21
+ const cssLanguageTypes_1 = require("../cssLanguageTypes");
22
+ const nls = require("vscode-nls");
23
+ const objects_1 = require("../utils/objects");
24
+ const pathCompletion_1 = require("./pathCompletion");
25
+ const localize = nls.loadMessageBundle();
26
+ const SnippetFormat = cssLanguageTypes_1.InsertTextFormat.Snippet;
27
+ const retriggerCommand = {
64
28
  title: 'Suggest',
65
29
  command: 'editor.action.triggerSuggest'
66
30
  };
@@ -73,59 +37,45 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
73
37
  SortTexts["Term"] = "y";
74
38
  SortTexts["Variable"] = "z";
75
39
  })(SortTexts || (SortTexts = {}));
76
- var CSSCompletion = /** @class */ (function () {
77
- function CSSCompletion(variablePrefix, lsOptions, cssDataManager) {
78
- if (variablePrefix === void 0) { variablePrefix = null; }
40
+ class CSSCompletion {
41
+ constructor(variablePrefix = null, lsOptions, cssDataManager) {
79
42
  this.variablePrefix = variablePrefix;
80
43
  this.lsOptions = lsOptions;
81
44
  this.cssDataManager = cssDataManager;
82
45
  this.completionParticipants = [];
83
46
  }
84
- CSSCompletion.prototype.configure = function (settings) {
47
+ configure(settings) {
85
48
  this.defaultSettings = settings;
86
- };
87
- CSSCompletion.prototype.getSymbolContext = function () {
49
+ }
50
+ getSymbolContext() {
88
51
  if (!this.symbolContext) {
89
52
  this.symbolContext = new cssSymbolScope_1.Symbols(this.styleSheet);
90
53
  }
91
54
  return this.symbolContext;
92
- };
93
- CSSCompletion.prototype.setCompletionParticipants = function (registeredCompletionParticipants) {
55
+ }
56
+ setCompletionParticipants(registeredCompletionParticipants) {
94
57
  this.completionParticipants = registeredCompletionParticipants || [];
95
- };
96
- CSSCompletion.prototype.doComplete2 = function (document, position, styleSheet, documentContext, completionSettings) {
97
- if (completionSettings === void 0) { completionSettings = this.defaultSettings; }
98
- return __awaiter(this, void 0, void 0, function () {
99
- var participant, contributedParticipants, result, pathCompletionResult;
100
- return __generator(this, function (_a) {
101
- switch (_a.label) {
102
- case 0:
103
- if (!this.lsOptions.fileSystemProvider || !this.lsOptions.fileSystemProvider.readDirectory) {
104
- return [2 /*return*/, this.doComplete(document, position, styleSheet, completionSettings)];
105
- }
106
- participant = new pathCompletion_1.PathCompletionParticipant(this.lsOptions.fileSystemProvider.readDirectory);
107
- contributedParticipants = this.completionParticipants;
108
- this.completionParticipants = [participant].concat(contributedParticipants);
109
- result = this.doComplete(document, position, styleSheet, completionSettings);
110
- _a.label = 1;
111
- case 1:
112
- _a.trys.push([1, , 3, 4]);
113
- return [4 /*yield*/, participant.computeCompletions(document, documentContext)];
114
- case 2:
115
- pathCompletionResult = _a.sent();
116
- return [2 /*return*/, {
117
- isIncomplete: result.isIncomplete || pathCompletionResult.isIncomplete,
118
- items: pathCompletionResult.items.concat(result.items)
119
- }];
120
- case 3:
121
- this.completionParticipants = contributedParticipants;
122
- return [7 /*endfinally*/];
123
- case 4: return [2 /*return*/];
124
- }
125
- });
126
- });
127
- };
128
- CSSCompletion.prototype.doComplete = function (document, position, styleSheet, documentSettings) {
58
+ }
59
+ async doComplete2(document, position, styleSheet, documentContext, completionSettings = this.defaultSettings) {
60
+ if (!this.lsOptions.fileSystemProvider || !this.lsOptions.fileSystemProvider.readDirectory) {
61
+ return this.doComplete(document, position, styleSheet, completionSettings);
62
+ }
63
+ const participant = new pathCompletion_1.PathCompletionParticipant(this.lsOptions.fileSystemProvider.readDirectory);
64
+ const contributedParticipants = this.completionParticipants;
65
+ this.completionParticipants = [participant].concat(contributedParticipants);
66
+ const result = this.doComplete(document, position, styleSheet, completionSettings);
67
+ try {
68
+ const pathCompletionResult = await participant.computeCompletions(document, documentContext);
69
+ return {
70
+ isIncomplete: result.isIncomplete || pathCompletionResult.isIncomplete,
71
+ items: pathCompletionResult.items.concat(result.items)
72
+ };
73
+ }
74
+ finally {
75
+ this.completionParticipants = contributedParticipants;
76
+ }
77
+ }
78
+ doComplete(document, position, styleSheet, documentSettings) {
129
79
  this.offset = document.offsetAt(position);
130
80
  this.position = position;
131
81
  this.currentWord = getCurrentWord(document, this.offset);
@@ -134,10 +84,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
134
84
  this.styleSheet = styleSheet;
135
85
  this.documentSettings = documentSettings;
136
86
  try {
137
- var result = { isIncomplete: false, items: [] };
87
+ const result = { isIncomplete: false, items: [] };
138
88
  this.nodePath = nodes.getNodePath(this.styleSheet, this.offset);
139
- for (var i = this.nodePath.length - 1; i >= 0; i--) {
140
- var node = this.nodePath[i];
89
+ for (let i = this.nodePath.length - 1; i >= 0; i--) {
90
+ const node = this.nodePath[i];
141
91
  if (node instanceof nodes.Property) {
142
92
  this.getCompletionsForDeclarationProperty(node.getParent(), result);
143
93
  }
@@ -150,13 +100,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
150
100
  }
151
101
  }
152
102
  else if (node instanceof nodes.SimpleSelector) {
153
- var parentRef = node.findAParent(nodes.NodeType.ExtendsReference, nodes.NodeType.Ruleset);
103
+ const parentRef = node.findAParent(nodes.NodeType.ExtendsReference, nodes.NodeType.Ruleset);
154
104
  if (parentRef) {
155
105
  if (parentRef.type === nodes.NodeType.ExtendsReference) {
156
106
  this.getCompletionsForExtendsReference(parentRef, node, result);
157
107
  }
158
108
  else {
159
- var parentRuleSet = parentRef;
109
+ const parentRuleSet = parentRef;
160
110
  this.getCompletionsForSelector(parentRuleSet, parentRuleSet && parentRuleSet.isNested(), result);
161
111
  }
162
112
  }
@@ -230,40 +180,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
230
180
  this.defaultReplaceRange = null;
231
181
  this.nodePath = null;
232
182
  }
233
- };
234
- CSSCompletion.prototype.isImportPathParent = function (type) {
183
+ }
184
+ isImportPathParent(type) {
235
185
  return type === nodes.NodeType.Import;
236
- };
237
- CSSCompletion.prototype.finalize = function (result) {
186
+ }
187
+ finalize(result) {
238
188
  return result;
239
- };
240
- CSSCompletion.prototype.findInNodePath = function () {
241
- var types = [];
242
- for (var _i = 0; _i < arguments.length; _i++) {
243
- types[_i] = arguments[_i];
244
- }
245
- for (var i = this.nodePath.length - 1; i >= 0; i--) {
246
- var node = this.nodePath[i];
189
+ }
190
+ findInNodePath(...types) {
191
+ for (let i = this.nodePath.length - 1; i >= 0; i--) {
192
+ const node = this.nodePath[i];
247
193
  if (types.indexOf(node.type) !== -1) {
248
194
  return node;
249
195
  }
250
196
  }
251
197
  return null;
252
- };
253
- CSSCompletion.prototype.getCompletionsForDeclarationProperty = function (declaration, result) {
198
+ }
199
+ getCompletionsForDeclarationProperty(declaration, result) {
254
200
  return this.getPropertyProposals(declaration, result);
255
- };
256
- CSSCompletion.prototype.getPropertyProposals = function (declaration, result) {
257
- var _this = this;
258
- var triggerPropertyValueCompletion = this.isTriggerPropertyValueCompletionEnabled;
259
- var completePropertyWithSemicolon = this.isCompletePropertyWithSemicolonEnabled;
260
- var properties = this.cssDataManager.getProperties();
261
- properties.forEach(function (entry) {
262
- var range;
263
- var insertText;
264
- var retrigger = false;
201
+ }
202
+ getPropertyProposals(declaration, result) {
203
+ const triggerPropertyValueCompletion = this.isTriggerPropertyValueCompletionEnabled;
204
+ const completePropertyWithSemicolon = this.isCompletePropertyWithSemicolonEnabled;
205
+ const properties = this.cssDataManager.getProperties();
206
+ properties.forEach(entry => {
207
+ let range;
208
+ let insertText;
209
+ let retrigger = false;
265
210
  if (declaration) {
266
- range = _this.getCompletionRange(declaration.getProperty());
211
+ range = this.getCompletionRange(declaration.getProperty());
267
212
  insertText = entry.name;
268
213
  if (!(0, objects_1.isDefined)(declaration.colonPosition)) {
269
214
  insertText += ': ';
@@ -271,7 +216,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
271
216
  }
272
217
  }
273
218
  else {
274
- range = _this.getCompletionRange(null);
219
+ range = this.getCompletionRange(null);
275
220
  insertText = entry.name + ': ';
276
221
  retrigger = true;
277
222
  }
@@ -281,13 +226,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
281
226
  }
282
227
  // Cases such as .selector { p; } or .selector { p:; }
283
228
  if (declaration && !declaration.semicolonPosition) {
284
- if (completePropertyWithSemicolon && _this.offset >= _this.textDocument.offsetAt(range.end)) {
229
+ if (completePropertyWithSemicolon && this.offset >= this.textDocument.offsetAt(range.end)) {
285
230
  insertText += '$0;';
286
231
  }
287
232
  }
288
- var item = {
233
+ const item = {
289
234
  label: entry.name,
290
- documentation: languageFacts.getEntryDescription(entry, _this.doesSupportMarkdown()),
235
+ documentation: languageFacts.getEntryDescription(entry, this.doesSupportMarkdown()),
291
236
  tags: isDeprecated(entry) ? [cssLanguageTypes_1.CompletionItemTag.Deprecated] : [],
292
237
  textEdit: cssLanguageTypes_1.TextEdit.replace(range, insertText),
293
238
  insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
@@ -299,59 +244,47 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
299
244
  if (triggerPropertyValueCompletion && retrigger) {
300
245
  item.command = retriggerCommand;
301
246
  }
302
- var relevance = typeof entry.relevance === 'number' ? Math.min(Math.max(entry.relevance, 0), 99) : 50;
303
- var sortTextSuffix = (255 - relevance).toString(16);
304
- var sortTextPrefix = strings.startsWith(entry.name, '-') ? SortTexts.VendorPrefixed : SortTexts.Normal;
247
+ const relevance = typeof entry.relevance === 'number' ? Math.min(Math.max(entry.relevance, 0), 99) : 50;
248
+ const sortTextSuffix = (255 - relevance).toString(16);
249
+ const sortTextPrefix = strings.startsWith(entry.name, '-') ? SortTexts.VendorPrefixed : SortTexts.Normal;
305
250
  item.sortText = sortTextPrefix + '_' + sortTextSuffix;
306
251
  result.items.push(item);
307
252
  });
308
- this.completionParticipants.forEach(function (participant) {
253
+ this.completionParticipants.forEach(participant => {
309
254
  if (participant.onCssProperty) {
310
255
  participant.onCssProperty({
311
- propertyName: _this.currentWord,
312
- range: _this.defaultReplaceRange
256
+ propertyName: this.currentWord,
257
+ range: this.defaultReplaceRange
313
258
  });
314
259
  }
315
260
  });
316
261
  return result;
317
- };
318
- Object.defineProperty(CSSCompletion.prototype, "isTriggerPropertyValueCompletionEnabled", {
319
- get: function () {
320
- var _a, _b;
321
- return (_b = (_a = this.documentSettings) === null || _a === void 0 ? void 0 : _a.triggerPropertyValueCompletion) !== null && _b !== void 0 ? _b : true;
322
- },
323
- enumerable: false,
324
- configurable: true
325
- });
326
- Object.defineProperty(CSSCompletion.prototype, "isCompletePropertyWithSemicolonEnabled", {
327
- get: function () {
328
- var _a, _b;
329
- return (_b = (_a = this.documentSettings) === null || _a === void 0 ? void 0 : _a.completePropertyWithSemicolon) !== null && _b !== void 0 ? _b : true;
330
- },
331
- enumerable: false,
332
- configurable: true
333
- });
334
- CSSCompletion.prototype.getCompletionsForDeclarationValue = function (node, result) {
335
- var _this = this;
336
- var propertyName = node.getFullPropertyName();
337
- var entry = this.cssDataManager.getProperty(propertyName);
338
- var existingNode = node.getValue() || null;
262
+ }
263
+ get isTriggerPropertyValueCompletionEnabled() {
264
+ return this.documentSettings?.triggerPropertyValueCompletion ?? true;
265
+ }
266
+ get isCompletePropertyWithSemicolonEnabled() {
267
+ return this.documentSettings?.completePropertyWithSemicolon ?? true;
268
+ }
269
+ getCompletionsForDeclarationValue(node, result) {
270
+ const propertyName = node.getFullPropertyName();
271
+ const entry = this.cssDataManager.getProperty(propertyName);
272
+ let existingNode = node.getValue() || null;
339
273
  while (existingNode && existingNode.hasChildren()) {
340
274
  existingNode = existingNode.findChildAtOffset(this.offset, false);
341
275
  }
342
- this.completionParticipants.forEach(function (participant) {
276
+ this.completionParticipants.forEach(participant => {
343
277
  if (participant.onCssPropertyValue) {
344
278
  participant.onCssPropertyValue({
345
- propertyName: propertyName,
346
- propertyValue: _this.currentWord,
347
- range: _this.getCompletionRange(existingNode)
279
+ propertyName,
280
+ propertyValue: this.currentWord,
281
+ range: this.getCompletionRange(existingNode)
348
282
  });
349
283
  }
350
284
  });
351
285
  if (entry) {
352
286
  if (entry.restrictions) {
353
- for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) {
354
- var restriction = _a[_i];
287
+ for (const restriction of entry.restrictions) {
355
288
  switch (restriction) {
356
289
  case 'color':
357
290
  this.getColorProposals(entry, existingNode, result);
@@ -391,9 +324,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
391
324
  this.getUnitProposals(entry, existingNode, result);
392
325
  }
393
326
  else {
394
- var existingValues = collectValues(this.styleSheet, node);
395
- for (var _b = 0, _c = existingValues.getEntries(); _b < _c.length; _b++) {
396
- var existingValue = _c[_b];
327
+ const existingValues = collectValues(this.styleSheet, node);
328
+ for (const existingValue of existingValues.getEntries()) {
397
329
  result.items.push({
398
330
  label: existingValue,
399
331
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), existingValue),
@@ -404,40 +336,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
404
336
  this.getVariableProposals(existingNode, result);
405
337
  this.getTermProposals(entry, existingNode, result);
406
338
  return result;
407
- };
408
- CSSCompletion.prototype.getValueEnumProposals = function (entry, existingNode, result) {
339
+ }
340
+ getValueEnumProposals(entry, existingNode, result) {
409
341
  if (entry.values) {
410
- for (var _i = 0, _a = entry.values; _i < _a.length; _i++) {
411
- var value = _a[_i];
412
- var insertString = value.name;
413
- var insertTextFormat = void 0;
342
+ for (const value of entry.values) {
343
+ let insertString = value.name;
344
+ let insertTextFormat;
414
345
  if (strings.endsWith(insertString, ')')) {
415
- var from = insertString.lastIndexOf('(');
346
+ const from = insertString.lastIndexOf('(');
416
347
  if (from !== -1) {
417
- insertString = insertString.substr(0, from) + '($1)';
348
+ insertString = insertString.substring(0, from + 1) + '$1' + insertString.substring(from + 1);
418
349
  insertTextFormat = SnippetFormat;
419
350
  }
420
351
  }
421
- var sortText = SortTexts.Enums;
352
+ let sortText = SortTexts.Enums;
422
353
  if (strings.startsWith(value.name, '-')) {
423
354
  sortText += SortTexts.VendorPrefixed;
424
355
  }
425
- var item = {
356
+ const item = {
426
357
  label: value.name,
427
358
  documentation: languageFacts.getEntryDescription(value, this.doesSupportMarkdown()),
428
359
  tags: isDeprecated(entry) ? [cssLanguageTypes_1.CompletionItemTag.Deprecated] : [],
429
360
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertString),
430
- sortText: sortText,
361
+ sortText,
431
362
  kind: cssLanguageTypes_1.CompletionItemKind.Value,
432
- insertTextFormat: insertTextFormat
363
+ insertTextFormat
433
364
  };
434
365
  result.items.push(item);
435
366
  }
436
367
  }
437
368
  return result;
438
- };
439
- CSSCompletion.prototype.getCSSWideKeywordProposals = function (entry, existingNode, result) {
440
- for (var keywords in languageFacts.cssWideKeywords) {
369
+ }
370
+ getCSSWideKeywordProposals(entry, existingNode, result) {
371
+ for (const keywords in languageFacts.cssWideKeywords) {
441
372
  result.items.push({
442
373
  label: keywords,
443
374
  documentation: languageFacts.cssWideKeywords[keywords],
@@ -445,8 +376,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
445
376
  kind: cssLanguageTypes_1.CompletionItemKind.Value
446
377
  });
447
378
  }
448
- for (var func in languageFacts.cssWideFunctions) {
449
- var insertText = moveCursorInsideParenthesis(func);
379
+ for (const func in languageFacts.cssWideFunctions) {
380
+ const insertText = moveCursorInsideParenthesis(func);
450
381
  result.items.push({
451
382
  label: func,
452
383
  documentation: languageFacts.cssWideFunctions[func],
@@ -457,19 +388,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
457
388
  });
458
389
  }
459
390
  return result;
460
- };
461
- CSSCompletion.prototype.getCompletionsForInterpolation = function (node, result) {
391
+ }
392
+ getCompletionsForInterpolation(node, result) {
462
393
  if (this.offset >= node.offset + 2) {
463
394
  this.getVariableProposals(null, result);
464
395
  }
465
396
  return result;
466
- };
467
- CSSCompletion.prototype.getVariableProposals = function (existingNode, result) {
468
- var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
469
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
470
- var symbol = symbols_1[_i];
471
- var insertText = strings.startsWith(symbol.name, '--') ? "var(".concat(symbol.name, ")") : symbol.name;
472
- var completionItem = {
397
+ }
398
+ getVariableProposals(existingNode, result) {
399
+ const symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
400
+ for (const symbol of symbols) {
401
+ const insertText = strings.startsWith(symbol.name, '--') ? `var(${symbol.name})` : symbol.name;
402
+ const completionItem = {
473
403
  label: symbol.name,
474
404
  documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
475
405
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
@@ -480,7 +410,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
480
410
  completionItem.kind = cssLanguageTypes_1.CompletionItemKind.Color;
481
411
  }
482
412
  if (symbol.node.type === nodes.NodeType.FunctionParameter) {
483
- var mixinNode = (symbol.node.getParent());
413
+ const mixinNode = (symbol.node.getParent());
484
414
  if (mixinNode.type === nodes.NodeType.MixinDeclaration) {
485
415
  completionItem.detail = localize('completion.argument', 'argument from \'{0}\'', mixinNode.getName());
486
416
  }
@@ -488,15 +418,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
488
418
  result.items.push(completionItem);
489
419
  }
490
420
  return result;
491
- };
492
- CSSCompletion.prototype.getVariableProposalsForCSSVarFunction = function (result) {
493
- var allReferencedVariables = new Set();
421
+ }
422
+ getVariableProposalsForCSSVarFunction(result) {
423
+ const allReferencedVariables = new Set();
494
424
  this.styleSheet.acceptVisitor(new VariableCollector(allReferencedVariables, this.offset));
495
- var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
496
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
497
- var symbol = symbols_2[_i];
425
+ let symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
426
+ for (const symbol of symbols) {
498
427
  if (strings.startsWith(symbol.name, '--')) {
499
- var completionItem = {
428
+ const completionItem = {
500
429
  label: symbol.name,
501
430
  documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
502
431
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), symbol.name),
@@ -509,10 +438,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
509
438
  }
510
439
  allReferencedVariables.remove(symbol.name);
511
440
  }
512
- for (var _a = 0, _b = allReferencedVariables.getEntries(); _a < _b.length; _a++) {
513
- var name = _b[_a];
441
+ for (const name of allReferencedVariables.getEntries()) {
514
442
  if (strings.startsWith(name, '--')) {
515
- var completionItem = {
443
+ const completionItem = {
516
444
  label: name,
517
445
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), name),
518
446
  kind: cssLanguageTypes_1.CompletionItemKind.Variable
@@ -521,11 +449,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
521
449
  }
522
450
  }
523
451
  return result;
524
- };
525
- CSSCompletion.prototype.getUnitProposals = function (entry, existingNode, result) {
526
- var currentWord = '0';
452
+ }
453
+ getUnitProposals(entry, existingNode, result) {
454
+ let currentWord = '0';
527
455
  if (this.currentWord.length > 0) {
528
- var numMatch = this.currentWord.match(/^-?\d[\.\d+]*/);
456
+ const numMatch = this.currentWord.match(/^-?\d[\.\d+]*/);
529
457
  if (numMatch) {
530
458
  currentWord = numMatch[0];
531
459
  result.isIncomplete = currentWord.length === this.currentWord.length;
@@ -538,13 +466,11 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
538
466
  existingNode = existingNode.getParent(); // include the unary operator
539
467
  }
540
468
  if (entry.restrictions) {
541
- for (var _i = 0, _a = entry.restrictions; _i < _a.length; _i++) {
542
- var restriction = _a[_i];
543
- var units = languageFacts.units[restriction];
469
+ for (const restriction of entry.restrictions) {
470
+ const units = languageFacts.units[restriction];
544
471
  if (units) {
545
- for (var _b = 0, units_1 = units; _b < units_1.length; _b++) {
546
- var unit = units_1[_b];
547
- var insertText = currentWord + unit;
472
+ for (const unit of units) {
473
+ const insertText = currentWord + unit;
548
474
  result.items.push({
549
475
  label: insertText,
550
476
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
@@ -555,19 +481,19 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
555
481
  }
556
482
  }
557
483
  return result;
558
- };
559
- CSSCompletion.prototype.getCompletionRange = function (existingNode) {
484
+ }
485
+ getCompletionRange(existingNode) {
560
486
  if (existingNode && existingNode.offset <= this.offset && this.offset <= existingNode.end) {
561
- var end = existingNode.end !== -1 ? this.textDocument.positionAt(existingNode.end) : this.position;
562
- var start = this.textDocument.positionAt(existingNode.offset);
487
+ const end = existingNode.end !== -1 ? this.textDocument.positionAt(existingNode.end) : this.position;
488
+ const start = this.textDocument.positionAt(existingNode.offset);
563
489
  if (start.line === end.line) {
564
490
  return cssLanguageTypes_1.Range.create(start, end); // multi line edits are not allowed
565
491
  }
566
492
  }
567
493
  return this.defaultReplaceRange;
568
- };
569
- CSSCompletion.prototype.getColorProposals = function (entry, existingNode, result) {
570
- for (var color in languageFacts.colors) {
494
+ }
495
+ getColorProposals(entry, existingNode, result) {
496
+ for (const color in languageFacts.colors) {
571
497
  result.items.push({
572
498
  label: color,
573
499
  documentation: languageFacts.colors[color],
@@ -575,7 +501,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
575
501
  kind: cssLanguageTypes_1.CompletionItemKind.Color
576
502
  });
577
503
  }
578
- for (var color in languageFacts.colorKeywords) {
504
+ for (const color in languageFacts.colorKeywords) {
579
505
  result.items.push({
580
506
  label: color,
581
507
  documentation: languageFacts.colorKeywords[color],
@@ -583,38 +509,32 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
583
509
  kind: cssLanguageTypes_1.CompletionItemKind.Value
584
510
  });
585
511
  }
586
- var colorValues = new Set();
512
+ const colorValues = new Set();
587
513
  this.styleSheet.acceptVisitor(new ColorValueCollector(colorValues, this.offset));
588
- for (var _i = 0, _a = colorValues.getEntries(); _i < _a.length; _i++) {
589
- var color = _a[_i];
514
+ for (const color of colorValues.getEntries()) {
590
515
  result.items.push({
591
516
  label: color,
592
517
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), color),
593
518
  kind: cssLanguageTypes_1.CompletionItemKind.Color
594
519
  });
595
520
  }
596
- var _loop_1 = function (p) {
597
- var tabStop = 1;
598
- var replaceFunction = function (_match, p1) { return '${' + tabStop++ + ':' + p1 + '}'; };
599
- var insertText = p.func.replace(/\[?\$(\w+)\]?/g, replaceFunction);
521
+ for (const p of languageFacts.colorFunctions) {
522
+ let tabStop = 1;
523
+ const replaceFunction = (_match, p1) => '${' + tabStop++ + ':' + p1 + '}';
524
+ const insertText = p.func.replace(/\[?\$(\w+)\]?/g, replaceFunction);
600
525
  result.items.push({
601
526
  label: p.func.substr(0, p.func.indexOf('(')),
602
527
  detail: p.func,
603
528
  documentation: p.desc,
604
- textEdit: cssLanguageTypes_1.TextEdit.replace(this_1.getCompletionRange(existingNode), insertText),
529
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
605
530
  insertTextFormat: SnippetFormat,
606
531
  kind: cssLanguageTypes_1.CompletionItemKind.Function
607
532
  });
608
- };
609
- var this_1 = this;
610
- for (var _b = 0, _c = languageFacts.colorFunctions; _b < _c.length; _b++) {
611
- var p = _c[_b];
612
- _loop_1(p);
613
533
  }
614
534
  return result;
615
- };
616
- CSSCompletion.prototype.getPositionProposals = function (entry, existingNode, result) {
617
- for (var position in languageFacts.positionKeywords) {
535
+ }
536
+ getPositionProposals(entry, existingNode, result) {
537
+ for (const position in languageFacts.positionKeywords) {
618
538
  result.items.push({
619
539
  label: position,
620
540
  documentation: languageFacts.positionKeywords[position],
@@ -623,9 +543,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
623
543
  });
624
544
  }
625
545
  return result;
626
- };
627
- CSSCompletion.prototype.getRepeatStyleProposals = function (entry, existingNode, result) {
628
- for (var repeat in languageFacts.repeatStyleKeywords) {
546
+ }
547
+ getRepeatStyleProposals(entry, existingNode, result) {
548
+ for (const repeat in languageFacts.repeatStyleKeywords) {
629
549
  result.items.push({
630
550
  label: repeat,
631
551
  documentation: languageFacts.repeatStyleKeywords[repeat],
@@ -634,9 +554,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
634
554
  });
635
555
  }
636
556
  return result;
637
- };
638
- CSSCompletion.prototype.getLineStyleProposals = function (entry, existingNode, result) {
639
- for (var lineStyle in languageFacts.lineStyleKeywords) {
557
+ }
558
+ getLineStyleProposals(entry, existingNode, result) {
559
+ for (const lineStyle in languageFacts.lineStyleKeywords) {
640
560
  result.items.push({
641
561
  label: lineStyle,
642
562
  documentation: languageFacts.lineStyleKeywords[lineStyle],
@@ -645,10 +565,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
645
565
  });
646
566
  }
647
567
  return result;
648
- };
649
- CSSCompletion.prototype.getLineWidthProposals = function (entry, existingNode, result) {
650
- for (var _i = 0, _a = languageFacts.lineWidthKeywords; _i < _a.length; _i++) {
651
- var lineWidth = _a[_i];
568
+ }
569
+ getLineWidthProposals(entry, existingNode, result) {
570
+ for (const lineWidth of languageFacts.lineWidthKeywords) {
652
571
  result.items.push({
653
572
  label: lineWidth,
654
573
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), lineWidth),
@@ -656,9 +575,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
656
575
  });
657
576
  }
658
577
  return result;
659
- };
660
- CSSCompletion.prototype.getGeometryBoxProposals = function (entry, existingNode, result) {
661
- for (var box in languageFacts.geometryBoxKeywords) {
578
+ }
579
+ getGeometryBoxProposals(entry, existingNode, result) {
580
+ for (const box in languageFacts.geometryBoxKeywords) {
662
581
  result.items.push({
663
582
  label: box,
664
583
  documentation: languageFacts.geometryBoxKeywords[box],
@@ -667,9 +586,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
667
586
  });
668
587
  }
669
588
  return result;
670
- };
671
- CSSCompletion.prototype.getBoxProposals = function (entry, existingNode, result) {
672
- for (var box in languageFacts.boxKeywords) {
589
+ }
590
+ getBoxProposals(entry, existingNode, result) {
591
+ for (const box in languageFacts.boxKeywords) {
673
592
  result.items.push({
674
593
  label: box,
675
594
  documentation: languageFacts.boxKeywords[box],
@@ -678,10 +597,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
678
597
  });
679
598
  }
680
599
  return result;
681
- };
682
- CSSCompletion.prototype.getImageProposals = function (entry, existingNode, result) {
683
- for (var image in languageFacts.imageFunctions) {
684
- var insertText = moveCursorInsideParenthesis(image);
600
+ }
601
+ getImageProposals(entry, existingNode, result) {
602
+ for (const image in languageFacts.imageFunctions) {
603
+ const insertText = moveCursorInsideParenthesis(image);
685
604
  result.items.push({
686
605
  label: image,
687
606
  documentation: languageFacts.imageFunctions[image],
@@ -691,10 +610,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
691
610
  });
692
611
  }
693
612
  return result;
694
- };
695
- CSSCompletion.prototype.getTimingFunctionProposals = function (entry, existingNode, result) {
696
- for (var timing in languageFacts.transitionTimingFunctions) {
697
- var insertText = moveCursorInsideParenthesis(timing);
613
+ }
614
+ getTimingFunctionProposals(entry, existingNode, result) {
615
+ for (const timing in languageFacts.transitionTimingFunctions) {
616
+ const insertText = moveCursorInsideParenthesis(timing);
698
617
  result.items.push({
699
618
  label: timing,
700
619
  documentation: languageFacts.transitionTimingFunctions[timing],
@@ -704,10 +623,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
704
623
  });
705
624
  }
706
625
  return result;
707
- };
708
- CSSCompletion.prototype.getBasicShapeProposals = function (entry, existingNode, result) {
709
- for (var shape in languageFacts.basicShapeFunctions) {
710
- var insertText = moveCursorInsideParenthesis(shape);
626
+ }
627
+ getBasicShapeProposals(entry, existingNode, result) {
628
+ for (const shape in languageFacts.basicShapeFunctions) {
629
+ const insertText = moveCursorInsideParenthesis(shape);
711
630
  result.items.push({
712
631
  label: shape,
713
632
  documentation: languageFacts.basicShapeFunctions[shape],
@@ -717,9 +636,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
717
636
  });
718
637
  }
719
638
  return result;
720
- };
721
- CSSCompletion.prototype.getCompletionsForStylesheet = function (result) {
722
- var node = this.styleSheet.findFirstChildBeforeOffset(this.offset);
639
+ }
640
+ getCompletionsForStylesheet(result) {
641
+ const node = this.styleSheet.findFirstChildBeforeOffset(this.offset);
723
642
  if (!node) {
724
643
  return this.getCompletionForTopLevel(result);
725
644
  }
@@ -730,36 +649,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
730
649
  return this.getCompletionsForSupports(node, result);
731
650
  }
732
651
  return result;
733
- };
734
- CSSCompletion.prototype.getCompletionForTopLevel = function (result) {
735
- var _this = this;
736
- this.cssDataManager.getAtDirectives().forEach(function (entry) {
652
+ }
653
+ getCompletionForTopLevel(result) {
654
+ this.cssDataManager.getAtDirectives().forEach(entry => {
737
655
  result.items.push({
738
656
  label: entry.name,
739
- textEdit: cssLanguageTypes_1.TextEdit.replace(_this.getCompletionRange(null), entry.name),
740
- documentation: languageFacts.getEntryDescription(entry, _this.doesSupportMarkdown()),
657
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), entry.name),
658
+ documentation: languageFacts.getEntryDescription(entry, this.doesSupportMarkdown()),
741
659
  tags: isDeprecated(entry) ? [cssLanguageTypes_1.CompletionItemTag.Deprecated] : [],
742
660
  kind: cssLanguageTypes_1.CompletionItemKind.Keyword
743
661
  });
744
662
  });
745
663
  this.getCompletionsForSelector(null, false, result);
746
664
  return result;
747
- };
748
- CSSCompletion.prototype.getCompletionsForRuleSet = function (ruleSet, result) {
749
- var declarations = ruleSet.getDeclarations();
750
- var isAfter = declarations && declarations.endsWith('}') && this.offset >= declarations.end;
665
+ }
666
+ getCompletionsForRuleSet(ruleSet, result) {
667
+ const declarations = ruleSet.getDeclarations();
668
+ const isAfter = declarations && declarations.endsWith('}') && this.offset >= declarations.end;
751
669
  if (isAfter) {
752
670
  return this.getCompletionForTopLevel(result);
753
671
  }
754
- var isInSelectors = !declarations || this.offset <= declarations.offset;
672
+ const isInSelectors = !declarations || this.offset <= declarations.offset;
755
673
  if (isInSelectors) {
756
674
  return this.getCompletionsForSelector(ruleSet, ruleSet.isNested(), result);
757
675
  }
758
676
  return this.getCompletionsForDeclarations(ruleSet.getDeclarations(), result);
759
- };
760
- CSSCompletion.prototype.getCompletionsForSelector = function (ruleSet, isNested, result) {
761
- var _this = this;
762
- var existingNode = this.findInNodePath(nodes.NodeType.PseudoSelector, nodes.NodeType.IdentifierSelector, nodes.NodeType.ClassSelector, nodes.NodeType.ElementNameSelector);
677
+ }
678
+ getCompletionsForSelector(ruleSet, isNested, result) {
679
+ const existingNode = this.findInNodePath(nodes.NodeType.PseudoSelector, nodes.NodeType.IdentifierSelector, nodes.NodeType.ClassSelector, nodes.NodeType.ElementNameSelector);
763
680
  if (!existingNode && this.hasCharacterAtPosition(this.offset - this.currentWord.length - 1, ':')) {
764
681
  // after the ':' of a pseudo selector, no node generated for just ':'
765
682
  this.currentWord = ':' + this.currentWord;
@@ -768,13 +685,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
768
685
  }
769
686
  this.defaultReplaceRange = cssLanguageTypes_1.Range.create(cssLanguageTypes_1.Position.create(this.position.line, this.position.character - this.currentWord.length), this.position);
770
687
  }
771
- var pseudoClasses = this.cssDataManager.getPseudoClasses();
772
- pseudoClasses.forEach(function (entry) {
773
- var insertText = moveCursorInsideParenthesis(entry.name);
774
- var item = {
688
+ const pseudoClasses = this.cssDataManager.getPseudoClasses();
689
+ pseudoClasses.forEach(entry => {
690
+ const insertText = moveCursorInsideParenthesis(entry.name);
691
+ const item = {
775
692
  label: entry.name,
776
- textEdit: cssLanguageTypes_1.TextEdit.replace(_this.getCompletionRange(existingNode), insertText),
777
- documentation: languageFacts.getEntryDescription(entry, _this.doesSupportMarkdown()),
693
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
694
+ documentation: languageFacts.getEntryDescription(entry, this.doesSupportMarkdown()),
778
695
  tags: isDeprecated(entry) ? [cssLanguageTypes_1.CompletionItemTag.Deprecated] : [],
779
696
  kind: cssLanguageTypes_1.CompletionItemKind.Function,
780
697
  insertTextFormat: entry.name !== insertText ? SnippetFormat : void 0
@@ -784,13 +701,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
784
701
  }
785
702
  result.items.push(item);
786
703
  });
787
- var pseudoElements = this.cssDataManager.getPseudoElements();
788
- pseudoElements.forEach(function (entry) {
789
- var insertText = moveCursorInsideParenthesis(entry.name);
790
- var item = {
704
+ const pseudoElements = this.cssDataManager.getPseudoElements();
705
+ pseudoElements.forEach(entry => {
706
+ const insertText = moveCursorInsideParenthesis(entry.name);
707
+ const item = {
791
708
  label: entry.name,
792
- textEdit: cssLanguageTypes_1.TextEdit.replace(_this.getCompletionRange(existingNode), insertText),
793
- documentation: languageFacts.getEntryDescription(entry, _this.doesSupportMarkdown()),
709
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
710
+ documentation: languageFacts.getEntryDescription(entry, this.doesSupportMarkdown()),
794
711
  tags: isDeprecated(entry) ? [cssLanguageTypes_1.CompletionItemTag.Deprecated] : [],
795
712
  kind: cssLanguageTypes_1.CompletionItemKind.Function,
796
713
  insertTextFormat: entry.name !== insertText ? SnippetFormat : void 0
@@ -801,16 +718,14 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
801
718
  result.items.push(item);
802
719
  });
803
720
  if (!isNested) { // show html tags only for top level
804
- for (var _i = 0, _a = languageFacts.html5Tags; _i < _a.length; _i++) {
805
- var entry = _a[_i];
721
+ for (const entry of languageFacts.html5Tags) {
806
722
  result.items.push({
807
723
  label: entry,
808
724
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), entry),
809
725
  kind: cssLanguageTypes_1.CompletionItemKind.Keyword
810
726
  });
811
727
  }
812
- for (var _b = 0, _c = languageFacts.svgElements; _b < _c.length; _b++) {
813
- var entry = _c[_b];
728
+ for (const entry of languageFacts.svgElements) {
814
729
  result.items.push({
815
730
  label: entry,
816
731
  textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), entry),
@@ -818,17 +733,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
818
733
  });
819
734
  }
820
735
  }
821
- var visited = {};
736
+ const visited = {};
822
737
  visited[this.currentWord] = true;
823
- var docText = this.textDocument.getText();
824
- this.styleSheet.accept(function (n) {
738
+ const docText = this.textDocument.getText();
739
+ this.styleSheet.accept(n => {
825
740
  if (n.type === nodes.NodeType.SimpleSelector && n.length > 0) {
826
- var selector = docText.substr(n.offset, n.length);
741
+ const selector = docText.substr(n.offset, n.length);
827
742
  if (selector.charAt(0) === '.' && !visited[selector]) {
828
743
  visited[selector] = true;
829
744
  result.items.push({
830
745
  label: selector,
831
- textEdit: cssLanguageTypes_1.TextEdit.replace(_this.getCompletionRange(existingNode), selector),
746
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), selector),
832
747
  kind: cssLanguageTypes_1.CompletionItemKind.Keyword
833
748
  });
834
749
  }
@@ -837,23 +752,23 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
837
752
  return true;
838
753
  });
839
754
  if (ruleSet && ruleSet.isNested()) {
840
- var selector = ruleSet.getSelectors().findFirstChildBeforeOffset(this.offset);
755
+ const selector = ruleSet.getSelectors().findFirstChildBeforeOffset(this.offset);
841
756
  if (selector && ruleSet.getSelectors().getChildren().indexOf(selector) === 0) {
842
757
  this.getPropertyProposals(null, result);
843
758
  }
844
759
  }
845
760
  return result;
846
- };
847
- CSSCompletion.prototype.getCompletionsForDeclarations = function (declarations, result) {
761
+ }
762
+ getCompletionsForDeclarations(declarations, result) {
848
763
  if (!declarations || this.offset === declarations.offset) { // incomplete nodes
849
764
  return result;
850
765
  }
851
- var node = declarations.findFirstChildBeforeOffset(this.offset);
766
+ const node = declarations.findFirstChildBeforeOffset(this.offset);
852
767
  if (!node) {
853
768
  return this.getCompletionsForDeclarationProperty(null, result);
854
769
  }
855
770
  if (node instanceof nodes.AbstractDeclaration) {
856
- var declaration = node;
771
+ const declaration = node;
857
772
  if (!(0, objects_1.isDefined)(declaration.colonPosition) || this.offset <= declaration.colonPosition) {
858
773
  // complete property
859
774
  return this.getCompletionsForDeclarationProperty(declaration, result);
@@ -880,25 +795,25 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
880
795
  this.getCompletionsForDeclarationProperty(null, result);
881
796
  }
882
797
  return result;
883
- };
884
- CSSCompletion.prototype.getCompletionsForVariableDeclaration = function (declaration, result) {
798
+ }
799
+ getCompletionsForVariableDeclaration(declaration, result) {
885
800
  if (this.offset && (0, objects_1.isDefined)(declaration.colonPosition) && this.offset > declaration.colonPosition) {
886
- this.getVariableProposals(declaration.getValue(), result);
801
+ this.getVariableProposals(declaration.getValue() || null, result);
887
802
  }
888
803
  return result;
889
- };
890
- CSSCompletion.prototype.getCompletionsForExpression = function (expression, result) {
891
- var parent = expression.getParent();
804
+ }
805
+ getCompletionsForExpression(expression, result) {
806
+ const parent = expression.getParent();
892
807
  if (parent instanceof nodes.FunctionArgument) {
893
808
  this.getCompletionsForFunctionArgument(parent, parent.getParent(), result);
894
809
  return result;
895
810
  }
896
- var declaration = expression.findParent(nodes.NodeType.Declaration);
811
+ const declaration = expression.findParent(nodes.NodeType.Declaration);
897
812
  if (!declaration) {
898
813
  this.getTermProposals(undefined, null, result);
899
814
  return result;
900
815
  }
901
- var node = expression.findChildAtOffset(this.offset, true);
816
+ const node = expression.findChildAtOffset(this.offset, true);
902
817
  if (!node) {
903
818
  return this.getCompletionsForDeclarationValue(declaration, result);
904
819
  }
@@ -906,59 +821,56 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
906
821
  return this.getCompletionsForDeclarationValue(declaration, result);
907
822
  }
908
823
  return result;
909
- };
910
- CSSCompletion.prototype.getCompletionsForFunctionArgument = function (arg, func, result) {
911
- var identifier = func.getIdentifier();
824
+ }
825
+ getCompletionsForFunctionArgument(arg, func, result) {
826
+ const identifier = func.getIdentifier();
912
827
  if (identifier && identifier.matches('var')) {
913
828
  if (!func.getArguments().hasChildren() || func.getArguments().getChild(0) === arg) {
914
829
  this.getVariableProposalsForCSSVarFunction(result);
915
830
  }
916
831
  }
917
832
  return result;
918
- };
919
- CSSCompletion.prototype.getCompletionsForFunctionDeclaration = function (decl, result) {
920
- var declarations = decl.getDeclarations();
833
+ }
834
+ getCompletionsForFunctionDeclaration(decl, result) {
835
+ const declarations = decl.getDeclarations();
921
836
  if (declarations && this.offset > declarations.offset && this.offset < declarations.end) {
922
837
  this.getTermProposals(undefined, null, result);
923
838
  }
924
839
  return result;
925
- };
926
- CSSCompletion.prototype.getCompletionsForMixinReference = function (ref, result) {
927
- var _this = this;
928
- var allMixins = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Mixin);
929
- for (var _i = 0, allMixins_1 = allMixins; _i < allMixins_1.length; _i++) {
930
- var mixinSymbol = allMixins_1[_i];
840
+ }
841
+ getCompletionsForMixinReference(ref, result) {
842
+ const allMixins = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Mixin);
843
+ for (const mixinSymbol of allMixins) {
931
844
  if (mixinSymbol.node instanceof nodes.MixinDeclaration) {
932
845
  result.items.push(this.makeTermProposal(mixinSymbol, mixinSymbol.node.getParameters(), null));
933
846
  }
934
847
  }
935
- var identifierNode = ref.getIdentifier() || null;
936
- this.completionParticipants.forEach(function (participant) {
848
+ const identifierNode = ref.getIdentifier() || null;
849
+ this.completionParticipants.forEach(participant => {
937
850
  if (participant.onCssMixinReference) {
938
851
  participant.onCssMixinReference({
939
- mixinName: _this.currentWord,
940
- range: _this.getCompletionRange(identifierNode)
852
+ mixinName: this.currentWord,
853
+ range: this.getCompletionRange(identifierNode)
941
854
  });
942
855
  }
943
856
  });
944
857
  return result;
945
- };
946
- CSSCompletion.prototype.getTermProposals = function (entry, existingNode, result) {
947
- var allFunctions = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Function);
948
- for (var _i = 0, allFunctions_1 = allFunctions; _i < allFunctions_1.length; _i++) {
949
- var functionSymbol = allFunctions_1[_i];
858
+ }
859
+ getTermProposals(entry, existingNode, result) {
860
+ const allFunctions = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Function);
861
+ for (const functionSymbol of allFunctions) {
950
862
  if (functionSymbol.node instanceof nodes.FunctionDeclaration) {
951
863
  result.items.push(this.makeTermProposal(functionSymbol, functionSymbol.node.getParameters(), existingNode));
952
864
  }
953
865
  }
954
866
  return result;
955
- };
956
- CSSCompletion.prototype.makeTermProposal = function (symbol, parameters, existingNode) {
957
- var decl = symbol.node;
958
- var params = parameters.getChildren().map(function (c) {
867
+ }
868
+ makeTermProposal(symbol, parameters, existingNode) {
869
+ const decl = symbol.node;
870
+ const params = parameters.getChildren().map((c) => {
959
871
  return (c instanceof nodes.FunctionParameter) ? c.getName() : c.getText();
960
872
  });
961
- var insertText = symbol.name + '(' + params.map(function (p, index) { return '${' + (index + 1) + ':' + p + '}'; }).join(', ') + ')';
873
+ const insertText = symbol.name + '(' + params.map((p, index) => '${' + (index + 1) + ':' + p + '}').join(', ') + ')';
962
874
  return {
963
875
  label: symbol.name,
964
876
  detail: symbol.name + '(' + params.join(', ') + ')',
@@ -967,9 +879,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
967
879
  kind: cssLanguageTypes_1.CompletionItemKind.Function,
968
880
  sortText: SortTexts.Term
969
881
  };
970
- };
971
- CSSCompletion.prototype.getCompletionsForSupportsCondition = function (supportsCondition, result) {
972
- var child = supportsCondition.findFirstChildBeforeOffset(this.offset);
882
+ }
883
+ getCompletionsForSupportsCondition(supportsCondition, result) {
884
+ const child = supportsCondition.findFirstChildBeforeOffset(this.offset);
973
885
  if (child) {
974
886
  if (child instanceof nodes.Declaration) {
975
887
  if (!(0, objects_1.isDefined)(child.colonPosition) || this.offset <= child.colonPosition) {
@@ -987,81 +899,78 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
987
899
  return this.getCompletionsForDeclarationProperty(null, result);
988
900
  }
989
901
  return result;
990
- };
991
- CSSCompletion.prototype.getCompletionsForSupports = function (supports, result) {
992
- var declarations = supports.getDeclarations();
993
- var inInCondition = !declarations || this.offset <= declarations.offset;
902
+ }
903
+ getCompletionsForSupports(supports, result) {
904
+ const declarations = supports.getDeclarations();
905
+ const inInCondition = !declarations || this.offset <= declarations.offset;
994
906
  if (inInCondition) {
995
- var child = supports.findFirstChildBeforeOffset(this.offset);
907
+ const child = supports.findFirstChildBeforeOffset(this.offset);
996
908
  if (child instanceof nodes.SupportsCondition) {
997
909
  return this.getCompletionsForSupportsCondition(child, result);
998
910
  }
999
911
  return result;
1000
912
  }
1001
913
  return this.getCompletionForTopLevel(result);
1002
- };
1003
- CSSCompletion.prototype.getCompletionsForExtendsReference = function (extendsRef, existingNode, result) {
914
+ }
915
+ getCompletionsForExtendsReference(extendsRef, existingNode, result) {
1004
916
  return result;
1005
- };
1006
- CSSCompletion.prototype.getCompletionForUriLiteralValue = function (uriLiteralNode, result) {
1007
- var uriValue;
1008
- var position;
1009
- var range;
917
+ }
918
+ getCompletionForUriLiteralValue(uriLiteralNode, result) {
919
+ let uriValue;
920
+ let position;
921
+ let range;
1010
922
  // No children, empty value
1011
923
  if (!uriLiteralNode.hasChildren()) {
1012
924
  uriValue = '';
1013
925
  position = this.position;
1014
- var emptyURIValuePosition = this.textDocument.positionAt(uriLiteralNode.offset + 'url('.length);
926
+ const emptyURIValuePosition = this.textDocument.positionAt(uriLiteralNode.offset + 'url('.length);
1015
927
  range = cssLanguageTypes_1.Range.create(emptyURIValuePosition, emptyURIValuePosition);
1016
928
  }
1017
929
  else {
1018
- var uriValueNode = uriLiteralNode.getChild(0);
930
+ const uriValueNode = uriLiteralNode.getChild(0);
1019
931
  uriValue = uriValueNode.getText();
1020
932
  position = this.position;
1021
933
  range = this.getCompletionRange(uriValueNode);
1022
934
  }
1023
- this.completionParticipants.forEach(function (participant) {
935
+ this.completionParticipants.forEach(participant => {
1024
936
  if (participant.onCssURILiteralValue) {
1025
937
  participant.onCssURILiteralValue({
1026
- uriValue: uriValue,
1027
- position: position,
1028
- range: range
938
+ uriValue,
939
+ position,
940
+ range
1029
941
  });
1030
942
  }
1031
943
  });
1032
944
  return result;
1033
- };
1034
- CSSCompletion.prototype.getCompletionForImportPath = function (importPathNode, result) {
1035
- var _this = this;
1036
- this.completionParticipants.forEach(function (participant) {
945
+ }
946
+ getCompletionForImportPath(importPathNode, result) {
947
+ this.completionParticipants.forEach(participant => {
1037
948
  if (participant.onCssImportPath) {
1038
949
  participant.onCssImportPath({
1039
950
  pathValue: importPathNode.getText(),
1040
- position: _this.position,
1041
- range: _this.getCompletionRange(importPathNode)
951
+ position: this.position,
952
+ range: this.getCompletionRange(importPathNode)
1042
953
  });
1043
954
  }
1044
955
  });
1045
956
  return result;
1046
- };
1047
- CSSCompletion.prototype.hasCharacterAtPosition = function (offset, char) {
1048
- var text = this.textDocument.getText();
957
+ }
958
+ hasCharacterAtPosition(offset, char) {
959
+ const text = this.textDocument.getText();
1049
960
  return (offset >= 0 && offset < text.length) && text.charAt(offset) === char;
1050
- };
1051
- CSSCompletion.prototype.doesSupportMarkdown = function () {
1052
- var _a, _b, _c;
961
+ }
962
+ doesSupportMarkdown() {
1053
963
  if (!(0, objects_1.isDefined)(this.supportsMarkdown)) {
1054
964
  if (!(0, objects_1.isDefined)(this.lsOptions.clientCapabilities)) {
1055
965
  this.supportsMarkdown = true;
1056
966
  return this.supportsMarkdown;
1057
967
  }
1058
- var documentationFormat = (_c = (_b = (_a = this.lsOptions.clientCapabilities.textDocument) === null || _a === void 0 ? void 0 : _a.completion) === null || _b === void 0 ? void 0 : _b.completionItem) === null || _c === void 0 ? void 0 : _c.documentationFormat;
968
+ const documentationFormat = this.lsOptions.clientCapabilities.textDocument?.completion?.completionItem?.documentationFormat;
1059
969
  this.supportsMarkdown = Array.isArray(documentationFormat) && documentationFormat.indexOf(cssLanguageTypes_1.MarkupKind.Markdown) !== -1;
1060
970
  }
1061
971
  return this.supportsMarkdown;
1062
- };
1063
- return CSSCompletion;
1064
- }());
972
+ }
973
+ }
1065
974
  exports.CSSCompletion = CSSCompletion;
1066
975
  function isDeprecated(entry) {
1067
976
  if (entry.status && (entry.status === 'nonstandard' || entry.status === 'obsolete')) {
@@ -1069,27 +978,26 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1069
978
  }
1070
979
  return false;
1071
980
  }
1072
- var Set = /** @class */ (function () {
1073
- function Set() {
981
+ class Set {
982
+ constructor() {
1074
983
  this.entries = {};
1075
984
  }
1076
- Set.prototype.add = function (entry) {
985
+ add(entry) {
1077
986
  this.entries[entry] = true;
1078
- };
1079
- Set.prototype.remove = function (entry) {
987
+ }
988
+ remove(entry) {
1080
989
  delete this.entries[entry];
1081
- };
1082
- Set.prototype.getEntries = function () {
990
+ }
991
+ getEntries() {
1083
992
  return Object.keys(this.entries);
1084
- };
1085
- return Set;
1086
- }());
993
+ }
994
+ }
1087
995
  function moveCursorInsideParenthesis(text) {
1088
996
  return text.replace(/\(\)$/, "($1)");
1089
997
  }
1090
998
  function collectValues(styleSheet, declaration) {
1091
- var fullPropertyName = declaration.getFullPropertyName();
1092
- var entries = new Set();
999
+ const fullPropertyName = declaration.getFullPropertyName();
1000
+ const entries = new Set();
1093
1001
  function visitValue(node) {
1094
1002
  if (node instanceof nodes.Identifier || node instanceof nodes.NumericValue || node instanceof nodes.HexColorValue) {
1095
1003
  entries.add(node.getText());
@@ -1097,13 +1005,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1097
1005
  return true;
1098
1006
  }
1099
1007
  function matchesProperty(decl) {
1100
- var propertyName = decl.getFullPropertyName();
1008
+ const propertyName = decl.getFullPropertyName();
1101
1009
  return fullPropertyName === propertyName;
1102
1010
  }
1103
1011
  function vistNode(node) {
1104
1012
  if (node instanceof nodes.Declaration && node !== declaration) {
1105
1013
  if (matchesProperty(node)) {
1106
- var value = node.getValue();
1014
+ const value = node.getValue();
1107
1015
  if (value) {
1108
1016
  value.accept(visitValue);
1109
1017
  }
@@ -1114,41 +1022,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1114
1022
  styleSheet.accept(vistNode);
1115
1023
  return entries;
1116
1024
  }
1117
- var ColorValueCollector = /** @class */ (function () {
1118
- function ColorValueCollector(entries, currentOffset) {
1025
+ class ColorValueCollector {
1026
+ constructor(entries, currentOffset) {
1119
1027
  this.entries = entries;
1120
1028
  this.currentOffset = currentOffset;
1121
1029
  // nothing to do
1122
1030
  }
1123
- ColorValueCollector.prototype.visitNode = function (node) {
1031
+ visitNode(node) {
1124
1032
  if (node instanceof nodes.HexColorValue || (node instanceof nodes.Function && languageFacts.isColorConstructor(node))) {
1125
1033
  if (this.currentOffset < node.offset || node.end < this.currentOffset) {
1126
1034
  this.entries.add(node.getText());
1127
1035
  }
1128
1036
  }
1129
1037
  return true;
1130
- };
1131
- return ColorValueCollector;
1132
- }());
1133
- var VariableCollector = /** @class */ (function () {
1134
- function VariableCollector(entries, currentOffset) {
1038
+ }
1039
+ }
1040
+ class VariableCollector {
1041
+ constructor(entries, currentOffset) {
1135
1042
  this.entries = entries;
1136
1043
  this.currentOffset = currentOffset;
1137
1044
  // nothing to do
1138
1045
  }
1139
- VariableCollector.prototype.visitNode = function (node) {
1046
+ visitNode(node) {
1140
1047
  if (node instanceof nodes.Identifier && node.isCustomProperty) {
1141
1048
  if (this.currentOffset < node.offset || node.end < this.currentOffset) {
1142
1049
  this.entries.add(node.getText());
1143
1050
  }
1144
1051
  }
1145
1052
  return true;
1146
- };
1147
- return VariableCollector;
1148
- }());
1053
+ }
1054
+ }
1149
1055
  function getCurrentWord(document, offset) {
1150
- var i = offset - 1;
1151
- var text = document.getText();
1056
+ let i = offset - 1;
1057
+ const text = document.getText();
1152
1058
  while (i >= 0 && ' \t\n\r":{[()]},*>+'.indexOf(text.charAt(i)) === -1) {
1153
1059
  i--;
1154
1060
  }