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.
- package/CHANGELOG.md +7 -1
- package/SECURITY.md +41 -0
- package/lib/esm/beautify/beautify-css.js +11 -4
- package/lib/esm/cssLanguageService.d.ts +2 -1
- package/lib/esm/cssLanguageService.js +15 -17
- package/lib/esm/cssLanguageTypes.js +2 -2
- package/lib/esm/data/webCustomData.js +356 -232
- package/lib/esm/languageFacts/builtinData.js +15 -15
- package/lib/esm/languageFacts/colors.js +66 -69
- package/lib/esm/languageFacts/dataManager.js +38 -42
- package/lib/esm/languageFacts/dataProvider.js +17 -23
- package/lib/esm/languageFacts/entry.js +22 -23
- package/lib/esm/parser/cssErrors.js +5 -7
- package/lib/esm/parser/cssNodes.js +869 -1377
- package/lib/esm/parser/cssParser.js +419 -376
- package/lib/esm/parser/cssScanner.js +168 -175
- package/lib/esm/parser/cssSymbolScope.js +107 -137
- package/lib/esm/parser/lessParser.js +177 -202
- package/lib/esm/parser/lessScanner.js +22 -43
- package/lib/esm/parser/scssErrors.js +5 -7
- package/lib/esm/parser/scssParser.js +196 -208
- package/lib/esm/parser/scssScanner.js +33 -54
- package/lib/esm/services/cssCodeActions.js +36 -40
- package/lib/esm/services/cssCompletion.js +300 -395
- package/lib/esm/services/cssFolding.js +32 -35
- package/lib/esm/services/cssFormatter.js +22 -22
- package/lib/esm/services/cssHover.js +30 -33
- package/lib/esm/services/cssNavigation.js +260 -289
- package/lib/esm/services/cssSelectionRange.js +6 -6
- package/lib/esm/services/cssValidation.js +13 -16
- package/lib/esm/services/lessCompletion.js +351 -370
- package/lib/esm/services/lint.js +161 -175
- package/lib/esm/services/lintRules.js +20 -27
- package/lib/esm/services/lintUtil.js +19 -28
- package/lib/esm/services/pathCompletion.js +84 -158
- package/lib/esm/services/scssCompletion.js +283 -307
- package/lib/esm/services/scssNavigation.js +65 -137
- package/lib/esm/services/selectorPrinting.js +131 -175
- package/lib/esm/utils/arrays.js +6 -12
- package/lib/esm/utils/objects.js +1 -1
- package/lib/esm/utils/resources.js +3 -16
- package/lib/esm/utils/strings.js +10 -12
- package/lib/umd/beautify/beautify-css.js +11 -4
- package/lib/umd/cssLanguageService.d.ts +2 -1
- package/lib/umd/cssLanguageService.js +34 -32
- package/lib/umd/cssLanguageTypes.js +4 -3
- package/lib/umd/data/webCustomData.js +355 -231
- package/lib/umd/languageFacts/colors.js +65 -68
- package/lib/umd/languageFacts/dataManager.js +41 -44
- package/lib/umd/languageFacts/dataProvider.js +17 -22
- package/lib/umd/languageFacts/entry.js +22 -23
- package/lib/umd/languageFacts/facts.js +5 -1
- package/lib/umd/parser/cssErrors.js +5 -6
- package/lib/umd/parser/cssNodes.js +870 -1307
- package/lib/umd/parser/cssParser.js +424 -380
- package/lib/umd/parser/cssScanner.js +168 -173
- package/lib/umd/parser/cssSymbolScope.js +109 -134
- package/lib/umd/parser/lessParser.js +182 -206
- package/lib/umd/parser/lessScanner.js +22 -42
- package/lib/umd/parser/scssErrors.js +5 -6
- package/lib/umd/parser/scssParser.js +202 -213
- package/lib/umd/parser/scssScanner.js +25 -45
- package/lib/umd/services/cssCodeActions.js +41 -44
- package/lib/umd/services/cssCompletion.js +308 -402
- package/lib/umd/services/cssFolding.js +35 -38
- package/lib/umd/services/cssFormatter.js +25 -25
- package/lib/umd/services/cssHover.js +36 -38
- package/lib/umd/services/cssNavigation.js +267 -295
- package/lib/umd/services/cssSelectionRange.js +8 -8
- package/lib/umd/services/cssValidation.js +17 -19
- package/lib/umd/services/lessCompletion.js +354 -372
- package/lib/umd/services/lint.js +167 -180
- package/lib/umd/services/lintRules.js +20 -24
- package/lib/umd/services/lintUtil.js +20 -28
- package/lib/umd/services/pathCompletion.js +87 -160
- package/lib/umd/services/scssCompletion.js +287 -310
- package/lib/umd/services/scssNavigation.js +69 -140
- package/lib/umd/services/selectorPrinting.js +134 -174
- package/lib/umd/utils/arrays.js +6 -12
- package/lib/umd/utils/objects.js +1 -1
- package/lib/umd/utils/resources.js +4 -17
- package/lib/umd/utils/strings.js +10 -12
- package/package.json +16 -15
|
@@ -3,152 +3,80 @@
|
|
|
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 __extends = (this && this.__extends) || (function () {
|
|
7
|
-
var extendStatics = function (d, b) {
|
|
8
|
-
extendStatics = Object.setPrototypeOf ||
|
|
9
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
10
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
11
|
-
return extendStatics(d, b);
|
|
12
|
-
};
|
|
13
|
-
return function (d, b) {
|
|
14
|
-
if (typeof b !== "function" && b !== null)
|
|
15
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
16
|
-
extendStatics(d, b);
|
|
17
|
-
function __() { this.constructor = d; }
|
|
18
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
19
|
-
};
|
|
20
|
-
})();
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
31
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
32
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
33
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
34
|
-
function step(op) {
|
|
35
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
36
|
-
while (_) try {
|
|
37
|
-
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;
|
|
38
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
39
|
-
switch (op[0]) {
|
|
40
|
-
case 0: case 1: t = op; break;
|
|
41
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
42
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
43
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
44
|
-
default:
|
|
45
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
46
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
47
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
48
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
49
|
-
if (t[2]) _.ops.pop();
|
|
50
|
-
_.trys.pop(); continue;
|
|
51
|
-
}
|
|
52
|
-
op = body.call(thisArg, _);
|
|
53
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
54
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
6
|
import { CSSNavigation } from './cssNavigation';
|
|
58
7
|
import * as nodes from '../parser/cssNodes';
|
|
59
8
|
import { URI } from 'vscode-uri';
|
|
60
9
|
import { startsWith } from '../utils/strings';
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
return _super.call(this, fileSystemProvider, true) || this;
|
|
10
|
+
export class SCSSNavigation extends CSSNavigation {
|
|
11
|
+
constructor(fileSystemProvider) {
|
|
12
|
+
super(fileSystemProvider, true);
|
|
65
13
|
}
|
|
66
|
-
|
|
67
|
-
return (
|
|
14
|
+
isRawStringDocumentLinkNode(node) {
|
|
15
|
+
return (super.isRawStringDocumentLinkNode(node) ||
|
|
68
16
|
node.type === nodes.NodeType.Use ||
|
|
69
17
|
node.type === nodes.NodeType.Forward);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
18
|
+
}
|
|
19
|
+
async resolveRelativeReference(ref, documentUri, documentContext, isRawLink) {
|
|
20
|
+
if (startsWith(ref, 'sass:')) {
|
|
21
|
+
return undefined; // sass library
|
|
22
|
+
}
|
|
23
|
+
const target = await super.resolveRelativeReference(ref, documentUri, documentContext, isRawLink);
|
|
24
|
+
if (this.fileSystemProvider && target && isRawLink) {
|
|
25
|
+
const parsedUri = URI.parse(target);
|
|
26
|
+
try {
|
|
27
|
+
const pathVariations = toPathVariations(parsedUri);
|
|
28
|
+
if (pathVariations) {
|
|
29
|
+
for (let j = 0; j < pathVariations.length; j++) {
|
|
30
|
+
if (await this.fileExists(pathVariations[j])) {
|
|
31
|
+
return pathVariations[j];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
77
34
|
}
|
|
78
|
-
|
|
79
|
-
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
// ignore
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return target;
|
|
41
|
+
function toPathVariations(uri) {
|
|
42
|
+
// No valid path
|
|
43
|
+
if (uri.path === '') {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
// No variation for links that ends with suffix
|
|
47
|
+
if (uri.path.endsWith('.scss') || uri.path.endsWith('.css')) {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
// If a link is like a/, try resolving a/index.scss and a/_index.scss
|
|
51
|
+
if (uri.path.endsWith('/')) {
|
|
52
|
+
return [
|
|
53
|
+
uri.with({ path: uri.path + 'index.scss' }).toString(true),
|
|
54
|
+
uri.with({ path: uri.path + '_index.scss' }).toString(true)
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
// Use `uri.path` since it's normalized to use `/` in all platforms
|
|
58
|
+
const pathFragments = uri.path.split('/');
|
|
59
|
+
const basename = pathFragments[pathFragments.length - 1];
|
|
60
|
+
const pathWithoutBasename = uri.path.slice(0, -basename.length);
|
|
61
|
+
// No variation for links such as _a
|
|
62
|
+
if (basename.startsWith('_')) {
|
|
63
|
+
if (uri.path.endsWith('.scss')) {
|
|
80
64
|
return undefined;
|
|
81
65
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return [
|
|
85
|
-
uri.with({ path: uri.path + 'index.scss' }).toString(),
|
|
86
|
-
uri.with({ path: uri.path + '_index.scss' }).toString()
|
|
87
|
-
];
|
|
88
|
-
}
|
|
89
|
-
// Use `uri.path` since it's normalized to use `/` in all platforms
|
|
90
|
-
var pathFragments = uri.path.split('/');
|
|
91
|
-
var basename = pathFragments[pathFragments.length - 1];
|
|
92
|
-
var pathWithoutBasename = uri.path.slice(0, -basename.length);
|
|
93
|
-
// No variation for links such as _a
|
|
94
|
-
if (basename.startsWith('_')) {
|
|
95
|
-
if (uri.path.endsWith('.scss')) {
|
|
96
|
-
return undefined;
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
return [uri.with({ path: uri.path + '.scss' }).toString()];
|
|
100
|
-
}
|
|
66
|
+
else {
|
|
67
|
+
return [uri.with({ path: uri.path + '.scss' }).toString(true)];
|
|
101
68
|
}
|
|
102
|
-
var normalizedBasename = basename + '.scss';
|
|
103
|
-
var documentUriWithBasename = function (newBasename) {
|
|
104
|
-
return uri.with({ path: pathWithoutBasename + newBasename }).toString();
|
|
105
|
-
};
|
|
106
|
-
var normalizedPath = documentUriWithBasename(normalizedBasename);
|
|
107
|
-
var underScorePath = documentUriWithBasename('_' + normalizedBasename);
|
|
108
|
-
var indexPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/index.scss');
|
|
109
|
-
var indexUnderscoreUri = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/_index.scss');
|
|
110
|
-
var cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
|
|
111
|
-
return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
|
|
112
69
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
case 2:
|
|
127
|
-
_a.trys.push([2, 7, , 8]);
|
|
128
|
-
pathVariations = toPathVariations(parsedUri);
|
|
129
|
-
if (!pathVariations) return [3 /*break*/, 6];
|
|
130
|
-
j = 0;
|
|
131
|
-
_a.label = 3;
|
|
132
|
-
case 3:
|
|
133
|
-
if (!(j < pathVariations.length)) return [3 /*break*/, 6];
|
|
134
|
-
return [4 /*yield*/, this.fileExists(pathVariations[j])];
|
|
135
|
-
case 4:
|
|
136
|
-
if (_a.sent()) {
|
|
137
|
-
return [2 /*return*/, pathVariations[j]];
|
|
138
|
-
}
|
|
139
|
-
_a.label = 5;
|
|
140
|
-
case 5:
|
|
141
|
-
j++;
|
|
142
|
-
return [3 /*break*/, 3];
|
|
143
|
-
case 6: return [3 /*break*/, 8];
|
|
144
|
-
case 7:
|
|
145
|
-
e_1 = _a.sent();
|
|
146
|
-
return [3 /*break*/, 8];
|
|
147
|
-
case 8: return [2 /*return*/, target];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
};
|
|
152
|
-
return SCSSNavigation;
|
|
153
|
-
}(CSSNavigation));
|
|
154
|
-
export { SCSSNavigation };
|
|
70
|
+
const normalizedBasename = basename + '.scss';
|
|
71
|
+
const documentUriWithBasename = (newBasename) => {
|
|
72
|
+
return uri.with({ path: pathWithoutBasename + newBasename }).toString(true);
|
|
73
|
+
};
|
|
74
|
+
const normalizedPath = documentUriWithBasename(normalizedBasename);
|
|
75
|
+
const underScorePath = documentUriWithBasename('_' + normalizedBasename);
|
|
76
|
+
const indexPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/index.scss');
|
|
77
|
+
const indexUnderscoreUri = documentUriWithBasename(normalizedBasename.slice(0, -5) + '/_index.scss');
|
|
78
|
+
const cssPath = documentUriWithBasename(normalizedBasename.slice(0, -5) + '.css');
|
|
79
|
+
return [normalizedPath, underScorePath, indexPath, indexUnderscoreUri, cssPath];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|