vscode-css-languageservice 5.1.5 → 5.1.9

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.
@@ -60,6 +60,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
60
60
  var pathCompletion_1 = require("./pathCompletion");
61
61
  var localize = nls.loadMessageBundle();
62
62
  var SnippetFormat = cssLanguageTypes_1.InsertTextFormat.Snippet;
63
+ var retriggerCommand = {
64
+ title: 'Suggest',
65
+ command: 'editor.action.triggerSuggest'
66
+ };
63
67
  var SortTexts;
64
68
  (function (SortTexts) {
65
69
  // char code 32, comes before everything
@@ -293,10 +297,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
293
297
  retrigger = false;
294
298
  }
295
299
  if (triggerPropertyValueCompletion && retrigger) {
296
- item.command = {
297
- title: 'Suggest',
298
- command: 'editor.action.triggerSuggest'
299
- };
300
+ item.command = retriggerCommand;
300
301
  }
301
302
  var relevance = typeof entry.relevance === 'number' ? Math.min(Math.max(entry.relevance, 0), 99) : 50;
302
303
  var sortTextSuffix = (255 - relevance).toString(16);
@@ -444,6 +445,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
444
445
  kind: cssLanguageTypes_1.CompletionItemKind.Value
445
446
  });
446
447
  }
448
+ for (var func in languageFacts.cssWideFunctions) {
449
+ var insertText = moveCursorInsideParenthesis(func);
450
+ result.items.push({
451
+ label: func,
452
+ documentation: languageFacts.cssWideFunctions[func],
453
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
454
+ kind: cssLanguageTypes_1.CompletionItemKind.Function,
455
+ insertTextFormat: SnippetFormat,
456
+ command: strings.startsWith(func, 'var') ? retriggerCommand : undefined
457
+ });
458
+ }
447
459
  return result;
448
460
  };
449
461
  CSSCompletion.prototype.getCompletionsForInterpolation = function (node, result) {
@@ -478,22 +490,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
478
490
  return result;
479
491
  };
480
492
  CSSCompletion.prototype.getVariableProposalsForCSSVarFunction = function (result) {
493
+ var allReferencedVariables = new Set();
494
+ this.styleSheet.acceptVisitor(new VariableCollector(allReferencedVariables, this.offset));
481
495
  var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
482
- symbols = symbols.filter(function (symbol) {
483
- return strings.startsWith(symbol.name, '--');
484
- });
485
496
  for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
486
497
  var symbol = symbols_2[_i];
487
- var completionItem = {
488
- label: symbol.name,
489
- documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
490
- textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), symbol.name),
491
- kind: cssLanguageTypes_1.CompletionItemKind.Variable
492
- };
493
- if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
494
- completionItem.kind = cssLanguageTypes_1.CompletionItemKind.Color;
498
+ if (strings.startsWith(symbol.name, '--')) {
499
+ var completionItem = {
500
+ label: symbol.name,
501
+ documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
502
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), symbol.name),
503
+ kind: cssLanguageTypes_1.CompletionItemKind.Variable
504
+ };
505
+ if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
506
+ completionItem.kind = cssLanguageTypes_1.CompletionItemKind.Color;
507
+ }
508
+ result.items.push(completionItem);
509
+ }
510
+ allReferencedVariables.remove(symbol.name);
511
+ }
512
+ for (var _a = 0, _b = allReferencedVariables.getEntries(); _a < _b.length; _a++) {
513
+ var name = _b[_a];
514
+ if (strings.startsWith(name, '--')) {
515
+ var completionItem = {
516
+ label: name,
517
+ textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), name),
518
+ kind: cssLanguageTypes_1.CompletionItemKind.Variable
519
+ };
520
+ result.items.push(completionItem);
495
521
  }
496
- result.items.push(completionItem);
497
522
  }
498
523
  return result;
499
524
  };
@@ -1044,24 +1069,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1044
1069
  }
1045
1070
  return false;
1046
1071
  }
1047
- /**
1048
- * Rank number should all be same length strings
1049
- */
1050
- function computeRankNumber(n) {
1051
- var nstr = n.toString();
1052
- switch (nstr.length) {
1053
- case 4:
1054
- return nstr;
1055
- case 3:
1056
- return '0' + nstr;
1057
- case 2:
1058
- return '00' + nstr;
1059
- case 1:
1060
- return '000' + nstr;
1061
- default:
1062
- return '0000';
1063
- }
1064
- }
1065
1072
  var Set = /** @class */ (function () {
1066
1073
  function Set() {
1067
1074
  this.entries = {};
@@ -1069,6 +1076,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1069
1076
  Set.prototype.add = function (entry) {
1070
1077
  this.entries[entry] = true;
1071
1078
  };
1079
+ Set.prototype.remove = function (entry) {
1080
+ delete this.entries[entry];
1081
+ };
1072
1082
  Set.prototype.getEntries = function () {
1073
1083
  return Object.keys(this.entries);
1074
1084
  };
@@ -1120,6 +1130,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
1120
1130
  };
1121
1131
  return ColorValueCollector;
1122
1132
  }());
1133
+ var VariableCollector = /** @class */ (function () {
1134
+ function VariableCollector(entries, currentOffset) {
1135
+ this.entries = entries;
1136
+ this.currentOffset = currentOffset;
1137
+ // nothing to do
1138
+ }
1139
+ VariableCollector.prototype.visitNode = function (node) {
1140
+ if (node instanceof nodes.Identifier && node.isCustomProperty) {
1141
+ if (this.currentOffset < node.offset || node.end < this.currentOffset) {
1142
+ this.entries.add(node.getText());
1143
+ }
1144
+ }
1145
+ return true;
1146
+ };
1147
+ return VariableCollector;
1148
+ }());
1123
1149
  function getCurrentWord(document, offset) {
1124
1150
  var i = offset - 1;
1125
1151
  var text = document.getText();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-css-languageservice",
3
- "version": "5.1.5",
3
+ "version": "5.1.9",
4
4
  "description": "Language service for CSS, LESS and SCSS",
5
5
  "main": "./lib/umd/cssLanguageService.js",
6
6
  "typings": "./lib/umd/cssLanguageService",
@@ -15,12 +15,12 @@
15
15
  "url": "https://github.com/Microsoft/vscode-css-languageservice"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/mocha": "^8.2.2",
18
+ "@types/mocha": "^9.0.0",
19
19
  "@types/node": "^10.12.21",
20
- "@typescript-eslint/eslint-plugin": "^4.31.0",
21
- "@typescript-eslint/parser": "^4.31.0",
20
+ "@typescript-eslint/eslint-plugin": "^4.32.0",
21
+ "@typescript-eslint/parser": "^4.32.0",
22
22
  "eslint": "^7.32.0",
23
- "mocha": "^8.4.0",
23
+ "mocha": "^9.1.2",
24
24
  "rimraf": "^3.0.2",
25
25
  "typescript": "^4.4.2",
26
26
  "vscode-web-custom-data": "^0.3.5"