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