vscode-css-languageservice 5.4.1 → 6.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +1 -0
  3. package/lib/esm/beautify/beautify-css.js +50 -8
  4. package/lib/esm/cssLanguageService.d.ts +37 -37
  5. package/lib/esm/cssLanguageService.js +72 -75
  6. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  7. package/lib/esm/cssLanguageTypes.js +42 -42
  8. package/lib/esm/data/webCustomData.js +21959 -21965
  9. package/lib/esm/languageFacts/builtinData.js +142 -142
  10. package/lib/esm/languageFacts/colors.js +469 -472
  11. package/lib/esm/languageFacts/dataManager.js +88 -92
  12. package/lib/esm/languageFacts/dataProvider.js +73 -79
  13. package/lib/esm/languageFacts/entry.js +137 -138
  14. package/lib/esm/languageFacts/facts.js +8 -8
  15. package/lib/esm/parser/cssErrors.js +48 -50
  16. package/lib/esm/parser/cssNodes.js +1502 -2019
  17. package/lib/esm/parser/cssParser.js +1534 -1566
  18. package/lib/esm/parser/cssScanner.js +592 -599
  19. package/lib/esm/parser/cssSymbolScope.js +311 -341
  20. package/lib/esm/parser/lessParser.js +714 -740
  21. package/lib/esm/parser/lessScanner.js +57 -78
  22. package/lib/esm/parser/scssErrors.js +18 -20
  23. package/lib/esm/parser/scssParser.js +796 -818
  24. package/lib/esm/parser/scssScanner.js +95 -116
  25. package/lib/esm/services/cssCodeActions.js +77 -81
  26. package/lib/esm/services/cssCompletion.js +1054 -1149
  27. package/lib/esm/services/cssFolding.js +190 -193
  28. package/lib/esm/services/cssFormatter.js +136 -136
  29. package/lib/esm/services/cssHover.js +148 -151
  30. package/lib/esm/services/cssNavigation.js +378 -470
  31. package/lib/esm/services/cssSelectionRange.js +47 -47
  32. package/lib/esm/services/cssValidation.js +41 -44
  33. package/lib/esm/services/lessCompletion.js +378 -397
  34. package/lib/esm/services/lint.js +518 -532
  35. package/lib/esm/services/lintRules.js +76 -83
  36. package/lib/esm/services/lintUtil.js +196 -205
  37. package/lib/esm/services/pathCompletion.js +157 -231
  38. package/lib/esm/services/scssCompletion.js +354 -378
  39. package/lib/esm/services/scssNavigation.js +82 -154
  40. package/lib/esm/services/selectorPrinting.js +492 -536
  41. package/lib/esm/utils/arrays.js +40 -46
  42. package/lib/esm/utils/objects.js +11 -11
  43. package/lib/esm/utils/resources.js +11 -24
  44. package/lib/esm/utils/strings.js +102 -104
  45. package/lib/umd/beautify/beautify-css.js +50 -8
  46. package/lib/umd/cssLanguageService.d.ts +37 -37
  47. package/lib/umd/cssLanguageService.js +99 -102
  48. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  49. package/lib/umd/cssLanguageTypes.js +89 -88
  50. package/lib/umd/data/webCustomData.js +21972 -21978
  51. package/lib/umd/languageFacts/builtinData.js +154 -154
  52. package/lib/umd/languageFacts/colors.js +492 -495
  53. package/lib/umd/languageFacts/dataManager.js +101 -104
  54. package/lib/umd/languageFacts/dataProvider.js +86 -91
  55. package/lib/umd/languageFacts/entry.js +152 -153
  56. package/lib/umd/languageFacts/facts.js +29 -29
  57. package/lib/umd/parser/cssErrors.js +61 -62
  58. package/lib/umd/parser/cssNodes.js +1587 -2034
  59. package/lib/umd/parser/cssParser.js +1547 -1578
  60. package/lib/umd/parser/cssScanner.js +606 -611
  61. package/lib/umd/parser/cssSymbolScope.js +328 -353
  62. package/lib/umd/parser/lessParser.js +727 -752
  63. package/lib/umd/parser/lessScanner.js +70 -90
  64. package/lib/umd/parser/scssErrors.js +31 -32
  65. package/lib/umd/parser/scssParser.js +809 -830
  66. package/lib/umd/parser/scssScanner.js +108 -128
  67. package/lib/umd/services/cssCodeActions.js +90 -93
  68. package/lib/umd/services/cssCompletion.js +1067 -1161
  69. package/lib/umd/services/cssFolding.js +203 -206
  70. package/lib/umd/services/cssFormatter.js +150 -150
  71. package/lib/umd/services/cssHover.js +161 -163
  72. package/lib/umd/services/cssNavigation.js +391 -482
  73. package/lib/umd/services/cssSelectionRange.js +60 -60
  74. package/lib/umd/services/cssValidation.js +54 -56
  75. package/lib/umd/services/lessCompletion.js +391 -409
  76. package/lib/umd/services/lint.js +531 -544
  77. package/lib/umd/services/lintRules.js +91 -95
  78. package/lib/umd/services/lintUtil.js +210 -218
  79. package/lib/umd/services/pathCompletion.js +171 -244
  80. package/lib/umd/services/scssCompletion.js +367 -390
  81. package/lib/umd/services/scssNavigation.js +95 -166
  82. package/lib/umd/services/selectorPrinting.js +510 -550
  83. package/lib/umd/utils/arrays.js +55 -61
  84. package/lib/umd/utils/objects.js +25 -25
  85. package/lib/umd/utils/resources.js +26 -39
  86. package/lib/umd/utils/strings.js +120 -122
  87. package/package.json +11 -11
@@ -1,166 +1,95 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
- return new (P || (P = Promise))(function (resolve, reject) {
19
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
- step((generator = generator.apply(thisArg, _arguments || [])).next());
23
- });
24
- };
25
- var __generator = (this && this.__generator) || function (thisArg, body) {
26
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
27
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
- function verb(n) { return function (v) { return step([n, v]); }; }
29
- function step(op) {
30
- if (f) throw new TypeError("Generator is already executing.");
31
- while (_) try {
32
- 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;
33
- if (y = 0, t) op = [op[0] & 2, t.value];
34
- switch (op[0]) {
35
- case 0: case 1: t = op; break;
36
- case 4: _.label++; return { value: op[1], done: false };
37
- case 5: _.label++; y = op[1]; op = [0]; continue;
38
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
- default:
40
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
- if (t[2]) _.ops.pop();
45
- _.trys.pop(); continue;
46
- }
47
- op = body.call(thisArg, _);
48
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
- }
51
- };
52
- (function (factory) {
53
- if (typeof module === "object" && typeof module.exports === "object") {
54
- var v = factory(require, exports);
55
- if (v !== undefined) module.exports = v;
56
- }
57
- else if (typeof define === "function" && define.amd) {
58
- define(["require", "exports", "./cssNavigation", "../parser/cssNodes", "vscode-uri", "../utils/strings"], factory);
59
- }
60
- })(function (require, exports) {
61
- /*---------------------------------------------------------------------------------------------
62
- * Copyright (c) Microsoft Corporation. All rights reserved.
63
- * Licensed under the MIT License. See License.txt in the project root for license information.
64
- *--------------------------------------------------------------------------------------------*/
65
- 'use strict';
66
- Object.defineProperty(exports, "__esModule", { value: true });
67
- exports.SCSSNavigation = void 0;
68
- var cssNavigation_1 = require("./cssNavigation");
69
- var nodes = require("../parser/cssNodes");
70
- var vscode_uri_1 = require("vscode-uri");
71
- var strings_1 = require("../utils/strings");
72
- var SCSSNavigation = /** @class */ (function (_super) {
73
- __extends(SCSSNavigation, _super);
74
- function SCSSNavigation(fileSystemProvider) {
75
- return _super.call(this, fileSystemProvider, true) || this;
76
- }
77
- SCSSNavigation.prototype.isRawStringDocumentLinkNode = function (node) {
78
- return (_super.prototype.isRawStringDocumentLinkNode.call(this, node) ||
79
- node.type === nodes.NodeType.Use ||
80
- node.type === nodes.NodeType.Forward);
81
- };
82
- SCSSNavigation.prototype.resolveRelativeReference = function (ref, documentUri, documentContext, isRawLink) {
83
- return __awaiter(this, void 0, void 0, function () {
84
- function toPathVariations(uri) {
85
- // No valid path
86
- if (uri.path === '') {
87
- return undefined;
88
- }
89
- // No variation for links that ends with suffix
90
- if (uri.path.endsWith('.scss') || uri.path.endsWith('.css')) {
91
- return undefined;
92
- }
93
- // If a link is like a/, try resolving a/index.scss and a/_index.scss
94
- if (uri.path.endsWith('/')) {
95
- return [
96
- uri.with({ path: uri.path + 'index.scss' }).toString(),
97
- uri.with({ path: uri.path + '_index.scss' }).toString()
98
- ];
99
- }
100
- // Use `uri.path` since it's normalized to use `/` in all platforms
101
- var pathFragments = uri.path.split('/');
102
- var basename = pathFragments[pathFragments.length - 1];
103
- var pathWithoutBasename = uri.path.slice(0, -basename.length);
104
- // No variation for links such as _a
105
- if (basename.startsWith('_')) {
106
- if (uri.path.endsWith('.scss')) {
107
- return undefined;
108
- }
109
- else {
110
- return [uri.with({ path: uri.path + '.scss' }).toString()];
111
- }
112
- }
113
- var normalizedBasename = basename + '.scss';
114
- var documentUriWithBasename = function (newBasename) {
115
- return uri.with({ path: pathWithoutBasename + newBasename }).toString();
116
- };
117
- var normalizedPath = documentUriWithBasename(normalizedBasename);
118
- var underScorePath = documentUriWithBasename('_' + normalizedBasename);
119
- var indexPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/index.scss');
120
- var indexUnderscoreUri = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/_index.scss');
121
- var cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
122
- return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
123
- }
124
- var target, parsedUri, pathVariations, j, e_1;
125
- return __generator(this, function (_a) {
126
- switch (_a.label) {
127
- case 0:
128
- if ((0, strings_1.startsWith)(ref, 'sass:')) {
129
- return [2 /*return*/, undefined]; // sass library
130
- }
131
- return [4 /*yield*/, _super.prototype.resolveRelativeReference.call(this, ref, documentUri, documentContext, isRawLink)];
132
- case 1:
133
- target = _a.sent();
134
- if (!(this.fileSystemProvider && target && isRawLink)) return [3 /*break*/, 8];
135
- parsedUri = vscode_uri_1.URI.parse(target);
136
- _a.label = 2;
137
- case 2:
138
- _a.trys.push([2, 7, , 8]);
139
- pathVariations = toPathVariations(parsedUri);
140
- if (!pathVariations) return [3 /*break*/, 6];
141
- j = 0;
142
- _a.label = 3;
143
- case 3:
144
- if (!(j < pathVariations.length)) return [3 /*break*/, 6];
145
- return [4 /*yield*/, this.fileExists(pathVariations[j])];
146
- case 4:
147
- if (_a.sent()) {
148
- return [2 /*return*/, pathVariations[j]];
149
- }
150
- _a.label = 5;
151
- case 5:
152
- j++;
153
- return [3 /*break*/, 3];
154
- case 6: return [3 /*break*/, 8];
155
- case 7:
156
- e_1 = _a.sent();
157
- return [3 /*break*/, 8];
158
- case 8: return [2 /*return*/, target];
159
- }
160
- });
161
- });
162
- };
163
- return SCSSNavigation;
164
- }(cssNavigation_1.CSSNavigation));
165
- exports.SCSSNavigation = SCSSNavigation;
166
- });
1
+ (function (factory) {
2
+ if (typeof module === "object" && typeof module.exports === "object") {
3
+ var v = factory(require, exports);
4
+ if (v !== undefined) module.exports = v;
5
+ }
6
+ else if (typeof define === "function" && define.amd) {
7
+ define(["require", "exports", "./cssNavigation", "../parser/cssNodes", "vscode-uri", "../utils/strings"], factory);
8
+ }
9
+ })(function (require, exports) {
10
+ /*---------------------------------------------------------------------------------------------
11
+ * Copyright (c) Microsoft Corporation. All rights reserved.
12
+ * Licensed under the MIT License. See License.txt in the project root for license information.
13
+ *--------------------------------------------------------------------------------------------*/
14
+ 'use strict';
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.SCSSNavigation = void 0;
17
+ const cssNavigation_1 = require("./cssNavigation");
18
+ const nodes = require("../parser/cssNodes");
19
+ const vscode_uri_1 = require("vscode-uri");
20
+ const strings_1 = require("../utils/strings");
21
+ class SCSSNavigation extends cssNavigation_1.CSSNavigation {
22
+ constructor(fileSystemProvider) {
23
+ super(fileSystemProvider, true);
24
+ }
25
+ isRawStringDocumentLinkNode(node) {
26
+ return (super.isRawStringDocumentLinkNode(node) ||
27
+ node.type === nodes.NodeType.Use ||
28
+ node.type === nodes.NodeType.Forward);
29
+ }
30
+ async resolveRelativeReference(ref, documentUri, documentContext, isRawLink) {
31
+ if ((0, strings_1.startsWith)(ref, 'sass:')) {
32
+ return undefined; // sass library
33
+ }
34
+ const target = await super.resolveRelativeReference(ref, documentUri, documentContext, isRawLink);
35
+ if (this.fileSystemProvider && target && isRawLink) {
36
+ const parsedUri = vscode_uri_1.URI.parse(target);
37
+ try {
38
+ const pathVariations = toPathVariations(parsedUri);
39
+ if (pathVariations) {
40
+ for (let j = 0; j < pathVariations.length; j++) {
41
+ if (await this.fileExists(pathVariations[j])) {
42
+ return pathVariations[j];
43
+ }
44
+ }
45
+ }
46
+ }
47
+ catch (e) {
48
+ // ignore
49
+ }
50
+ }
51
+ return target;
52
+ function toPathVariations(uri) {
53
+ // No valid path
54
+ if (uri.path === '') {
55
+ return undefined;
56
+ }
57
+ // No variation for links that ends with suffix
58
+ if (uri.path.endsWith('.scss') || uri.path.endsWith('.css')) {
59
+ return undefined;
60
+ }
61
+ // If a link is like a/, try resolving a/index.scss and a/_index.scss
62
+ if (uri.path.endsWith('/')) {
63
+ return [
64
+ uri.with({ path: uri.path + 'index.scss' }).toString(),
65
+ uri.with({ path: uri.path + '_index.scss' }).toString()
66
+ ];
67
+ }
68
+ // Use `uri.path` since it's normalized to use `/` in all platforms
69
+ const pathFragments = uri.path.split('/');
70
+ const basename = pathFragments[pathFragments.length - 1];
71
+ const pathWithoutBasename = uri.path.slice(0, -basename.length);
72
+ // No variation for links such as _a
73
+ if (basename.startsWith('_')) {
74
+ if (uri.path.endsWith('.scss')) {
75
+ return undefined;
76
+ }
77
+ else {
78
+ return [uri.with({ path: uri.path + '.scss' }).toString()];
79
+ }
80
+ }
81
+ const normalizedBasename = basename + '.scss';
82
+ const documentUriWithBasename = (newBasename) => {
83
+ return uri.with({ path: pathWithoutBasename + newBasename }).toString();
84
+ };
85
+ const normalizedPath = documentUriWithBasename(normalizedBasename);
86
+ const underScorePath = documentUriWithBasename('_' + normalizedBasename);
87
+ const indexPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/index.scss');
88
+ const indexUnderscoreUri = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/_index.scss');
89
+ const cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
90
+ return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
91
+ }
92
+ }
93
+ }
94
+ exports.SCSSNavigation = SCSSNavigation;
95
+ });