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,18 +1,3 @@
1
- var __extends = (this && this.__extends) || (function () {
2
- var extendStatics = function (d, b) {
3
- extendStatics = Object.setPrototypeOf ||
4
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
- return extendStatics(d, b);
7
- };
8
- return function (d, b) {
9
- if (typeof b !== "function" && b !== null)
10
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
- extendStatics(d, b);
12
- function __() { this.constructor = d; }
13
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
- };
15
- })();
16
1
  (function (factory) {
17
2
  if (typeof module === "object" && typeof module.exports === "object") {
18
3
  var v = factory(require, exports);
@@ -29,21 +14,21 @@ var __extends = (this && this.__extends) || (function () {
29
14
  'use strict';
30
15
  Object.defineProperty(exports, "__esModule", { value: true });
31
16
  exports.SCSSScanner = exports.Module = exports.Ellipsis = exports.SmallerEqualsOperator = exports.GreaterEqualsOperator = exports.NotEqualsOperator = exports.EqualsOperator = exports.Default = exports.InterpolationFunction = exports.VariableName = void 0;
32
- var cssScanner_1 = require("./cssScanner");
33
- var _FSL = '/'.charCodeAt(0);
34
- var _NWL = '\n'.charCodeAt(0);
35
- var _CAR = '\r'.charCodeAt(0);
36
- var _LFD = '\f'.charCodeAt(0);
37
- var _DLR = '$'.charCodeAt(0);
38
- var _HSH = '#'.charCodeAt(0);
39
- var _CUL = '{'.charCodeAt(0);
40
- var _EQS = '='.charCodeAt(0);
41
- var _BNG = '!'.charCodeAt(0);
42
- var _LAN = '<'.charCodeAt(0);
43
- var _RAN = '>'.charCodeAt(0);
44
- var _DOT = '.'.charCodeAt(0);
45
- var _ATS = '@'.charCodeAt(0);
46
- var customTokenValue = cssScanner_1.TokenType.CustomToken;
17
+ const cssScanner_1 = require("./cssScanner");
18
+ const _FSL = '/'.charCodeAt(0);
19
+ const _NWL = '\n'.charCodeAt(0);
20
+ const _CAR = '\r'.charCodeAt(0);
21
+ const _LFD = '\f'.charCodeAt(0);
22
+ const _DLR = '$'.charCodeAt(0);
23
+ const _HSH = '#'.charCodeAt(0);
24
+ const _CUL = '{'.charCodeAt(0);
25
+ const _EQS = '='.charCodeAt(0);
26
+ const _BNG = '!'.charCodeAt(0);
27
+ const _LAN = '<'.charCodeAt(0);
28
+ const _RAN = '>'.charCodeAt(0);
29
+ const _DOT = '.'.charCodeAt(0);
30
+ const _ATS = '@'.charCodeAt(0);
31
+ let customTokenValue = cssScanner_1.TokenType.CustomToken;
47
32
  exports.VariableName = customTokenValue++;
48
33
  exports.InterpolationFunction = customTokenValue++;
49
34
  exports.Default = customTokenValue++;
@@ -53,15 +38,11 @@ var __extends = (this && this.__extends) || (function () {
53
38
  exports.SmallerEqualsOperator = customTokenValue++;
54
39
  exports.Ellipsis = customTokenValue++;
55
40
  exports.Module = customTokenValue++;
56
- var SCSSScanner = /** @class */ (function (_super) {
57
- __extends(SCSSScanner, _super);
58
- function SCSSScanner() {
59
- return _super !== null && _super.apply(this, arguments) || this;
60
- }
61
- SCSSScanner.prototype.scanNext = function (offset) {
41
+ class SCSSScanner extends cssScanner_1.Scanner {
42
+ scanNext(offset) {
62
43
  // scss variable
63
44
  if (this.stream.advanceIfChar(_DLR)) {
64
- var content = ['$'];
45
+ const content = ['$'];
65
46
  if (this.ident(content)) {
66
47
  return this.finishToken(offset, exports.VariableName, content.join(''));
67
48
  }
@@ -99,14 +80,14 @@ var __extends = (this && this.__extends) || (function () {
99
80
  if (this.stream.advanceIfChars([_DOT, _DOT, _DOT])) {
100
81
  return this.finishToken(offset, exports.Ellipsis);
101
82
  }
102
- return _super.prototype.scanNext.call(this, offset);
103
- };
104
- SCSSScanner.prototype.comment = function () {
105
- if (_super.prototype.comment.call(this)) {
83
+ return super.scanNext(offset);
84
+ }
85
+ comment() {
86
+ if (super.comment()) {
106
87
  return true;
107
88
  }
108
89
  if (!this.inURL && this.stream.advanceIfChars([_FSL, _FSL])) {
109
- this.stream.advanceWhileChar(function (ch) {
90
+ this.stream.advanceWhileChar((ch) => {
110
91
  switch (ch) {
111
92
  case _NWL:
112
93
  case _CAR:
@@ -121,8 +102,7 @@ var __extends = (this && this.__extends) || (function () {
121
102
  else {
122
103
  return false;
123
104
  }
124
- };
125
- return SCSSScanner;
126
- }(cssScanner_1.Scanner));
105
+ }
106
+ }
127
107
  exports.SCSSScanner = SCSSScanner;
128
108
  });
@@ -14,80 +14,77 @@
14
14
  'use strict';
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
16
  exports.CSSCodeActions = void 0;
17
- var nodes = require("../parser/cssNodes");
18
- var strings_1 = require("../utils/strings");
19
- var lintRules_1 = require("../services/lintRules");
20
- var cssLanguageTypes_1 = require("../cssLanguageTypes");
21
- var nls = require("vscode-nls");
22
- var localize = nls.loadMessageBundle();
23
- var CSSCodeActions = /** @class */ (function () {
24
- function CSSCodeActions(cssDataManager) {
17
+ const nodes = require("../parser/cssNodes");
18
+ const strings_1 = require("../utils/strings");
19
+ const lintRules_1 = require("../services/lintRules");
20
+ const cssLanguageTypes_1 = require("../cssLanguageTypes");
21
+ const nls = require("vscode-nls");
22
+ const localize = nls.loadMessageBundle();
23
+ class CSSCodeActions {
24
+ constructor(cssDataManager) {
25
25
  this.cssDataManager = cssDataManager;
26
26
  }
27
- CSSCodeActions.prototype.doCodeActions = function (document, range, context, stylesheet) {
28
- return this.doCodeActions2(document, range, context, stylesheet).map(function (ca) {
29
- var textDocumentEdit = ca.edit && ca.edit.documentChanges && ca.edit.documentChanges[0];
27
+ doCodeActions(document, range, context, stylesheet) {
28
+ return this.doCodeActions2(document, range, context, stylesheet).map(ca => {
29
+ const textDocumentEdit = ca.edit && ca.edit.documentChanges && ca.edit.documentChanges[0];
30
30
  return cssLanguageTypes_1.Command.create(ca.title, '_css.applyCodeAction', document.uri, document.version, textDocumentEdit && textDocumentEdit.edits);
31
31
  });
32
- };
33
- CSSCodeActions.prototype.doCodeActions2 = function (document, range, context, stylesheet) {
34
- var result = [];
32
+ }
33
+ doCodeActions2(document, range, context, stylesheet) {
34
+ const result = [];
35
35
  if (context.diagnostics) {
36
- for (var _i = 0, _a = context.diagnostics; _i < _a.length; _i++) {
37
- var diagnostic = _a[_i];
36
+ for (const diagnostic of context.diagnostics) {
38
37
  this.appendFixesForMarker(document, stylesheet, diagnostic, result);
39
38
  }
40
39
  }
41
40
  return result;
42
- };
43
- CSSCodeActions.prototype.getFixesForUnknownProperty = function (document, property, marker, result) {
44
- var propertyName = property.getName();
45
- var candidates = [];
46
- this.cssDataManager.getProperties().forEach(function (p) {
47
- var score = (0, strings_1.difference)(propertyName, p.name);
41
+ }
42
+ getFixesForUnknownProperty(document, property, marker, result) {
43
+ const propertyName = property.getName();
44
+ const candidates = [];
45
+ this.cssDataManager.getProperties().forEach(p => {
46
+ const score = (0, strings_1.difference)(propertyName, p.name);
48
47
  if (score >= propertyName.length / 2 /*score_lim*/) {
49
- candidates.push({ property: p.name, score: score });
48
+ candidates.push({ property: p.name, score });
50
49
  }
51
50
  });
52
51
  // Sort in descending order.
53
- candidates.sort(function (a, b) {
52
+ candidates.sort((a, b) => {
54
53
  return b.score - a.score || a.property.localeCompare(b.property);
55
54
  });
56
- var maxActions = 3;
57
- for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
58
- var candidate = candidates_1[_i];
59
- var propertyName_1 = candidate.property;
60
- var title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName_1);
61
- var edit = cssLanguageTypes_1.TextEdit.replace(marker.range, propertyName_1);
62
- var documentIdentifier = cssLanguageTypes_1.VersionedTextDocumentIdentifier.create(document.uri, document.version);
63
- var workspaceEdit = { documentChanges: [cssLanguageTypes_1.TextDocumentEdit.create(documentIdentifier, [edit])] };
64
- var codeAction = cssLanguageTypes_1.CodeAction.create(title, workspaceEdit, cssLanguageTypes_1.CodeActionKind.QuickFix);
55
+ let maxActions = 3;
56
+ for (const candidate of candidates) {
57
+ const propertyName = candidate.property;
58
+ const title = localize('css.codeaction.rename', "Rename to '{0}'", propertyName);
59
+ const edit = cssLanguageTypes_1.TextEdit.replace(marker.range, propertyName);
60
+ const documentIdentifier = cssLanguageTypes_1.VersionedTextDocumentIdentifier.create(document.uri, document.version);
61
+ const workspaceEdit = { documentChanges: [cssLanguageTypes_1.TextDocumentEdit.create(documentIdentifier, [edit])] };
62
+ const codeAction = cssLanguageTypes_1.CodeAction.create(title, workspaceEdit, cssLanguageTypes_1.CodeActionKind.QuickFix);
65
63
  codeAction.diagnostics = [marker];
66
64
  result.push(codeAction);
67
65
  if (--maxActions <= 0) {
68
66
  return;
69
67
  }
70
68
  }
71
- };
72
- CSSCodeActions.prototype.appendFixesForMarker = function (document, stylesheet, marker, result) {
69
+ }
70
+ appendFixesForMarker(document, stylesheet, marker, result) {
73
71
  if (marker.code !== lintRules_1.Rules.UnknownProperty.id) {
74
72
  return;
75
73
  }
76
- var offset = document.offsetAt(marker.range.start);
77
- var end = document.offsetAt(marker.range.end);
78
- var nodepath = nodes.getNodePath(stylesheet, offset);
79
- for (var i = nodepath.length - 1; i >= 0; i--) {
80
- var node = nodepath[i];
74
+ const offset = document.offsetAt(marker.range.start);
75
+ const end = document.offsetAt(marker.range.end);
76
+ const nodepath = nodes.getNodePath(stylesheet, offset);
77
+ for (let i = nodepath.length - 1; i >= 0; i--) {
78
+ const node = nodepath[i];
81
79
  if (node instanceof nodes.Declaration) {
82
- var property = node.getProperty();
80
+ const property = node.getProperty();
83
81
  if (property && property.offset === offset && property.end === end) {
84
82
  this.getFixesForUnknownProperty(document, property, marker, result);
85
83
  return;
86
84
  }
87
85
  }
88
86
  }
89
- };
90
- return CSSCodeActions;
91
- }());
87
+ }
88
+ }
92
89
  exports.CSSCodeActions = CSSCodeActions;
93
90
  });