vscode-css-languageservice 6.3.10 → 7.0.0-next.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.
- package/CHANGELOG.md +8 -0
- package/lib/esm/beautify/beautify-css.js +1437 -1606
- package/lib/esm/cssLanguageService.d.ts +2 -2
- package/lib/esm/cssLanguageService.js +18 -18
- package/lib/esm/languageFacts/colors.js +1 -1
- package/lib/esm/languageFacts/dataManager.js +3 -3
- package/lib/esm/languageFacts/entry.js +1 -1
- package/lib/esm/languageFacts/facts.js +3 -3
- package/lib/esm/parser/cssNodes.js +1 -1
- package/lib/esm/parser/cssParser.js +5 -5
- package/lib/esm/parser/cssSymbolScope.js +2 -2
- package/lib/esm/parser/lessParser.js +5 -5
- package/lib/esm/parser/lessScanner.js +1 -1
- package/lib/esm/parser/scssParser.js +6 -6
- package/lib/esm/parser/scssScanner.js +1 -1
- package/lib/esm/services/cssCodeActions.js +4 -4
- package/lib/esm/services/cssCompletion.js +7 -7
- package/lib/esm/services/cssFolding.js +3 -3
- package/lib/esm/services/cssFormatter.js +3 -3
- package/lib/esm/services/cssHover.js +6 -6
- package/lib/esm/services/cssNavigation.js +6 -6
- package/lib/esm/services/cssSelectionRange.js +2 -2
- package/lib/esm/services/cssValidation.js +4 -4
- package/lib/esm/services/lessCompletion.js +2 -2
- package/lib/esm/services/lint.js +5 -5
- package/lib/esm/services/lintRules.js +1 -1
- package/lib/esm/services/lintUtil.js +1 -1
- package/lib/esm/services/pathCompletion.js +3 -3
- package/lib/esm/services/scssCompletion.js +3 -3
- package/lib/esm/services/scssNavigation.js +4 -4
- package/lib/esm/services/selectorPrinting.js +3 -3
- package/package.json +15 -15
- package/lib/umd/beautify/beautify-css.js +0 -1695
- package/lib/umd/cssLanguageService.d.ts +0 -39
- package/lib/umd/cssLanguageService.js +0 -105
- package/lib/umd/cssLanguageTypes.d.ts +0 -267
- package/lib/umd/cssLanguageTypes.js +0 -89
- package/lib/umd/data/webCustomData.js +0 -44613
- package/lib/umd/languageFacts/builtinData.js +0 -155
- package/lib/umd/languageFacts/colors.js +0 -949
- package/lib/umd/languageFacts/dataManager.js +0 -101
- package/lib/umd/languageFacts/dataProvider.js +0 -86
- package/lib/umd/languageFacts/entry.js +0 -217
- package/lib/umd/languageFacts/facts.js +0 -33
- package/lib/umd/parser/cssErrors.js +0 -61
- package/lib/umd/parser/cssNodes.js +0 -1676
- package/lib/umd/parser/cssParser.js +0 -2035
- package/lib/umd/parser/cssScanner.js +0 -619
- package/lib/umd/parser/cssSymbolScope.js +0 -328
- package/lib/umd/parser/lessParser.js +0 -732
- package/lib/umd/parser/lessScanner.js +0 -70
- package/lib/umd/parser/scssErrors.js +0 -30
- package/lib/umd/parser/scssParser.js +0 -874
- package/lib/umd/parser/scssScanner.js +0 -108
- package/lib/umd/services/cssCodeActions.js +0 -89
- package/lib/umd/services/cssCompletion.js +0 -1109
- package/lib/umd/services/cssFolding.js +0 -202
- package/lib/umd/services/cssFormatter.js +0 -149
- package/lib/umd/services/cssHover.js +0 -174
- package/lib/umd/services/cssNavigation.js +0 -539
- package/lib/umd/services/cssSelectionRange.js +0 -59
- package/lib/umd/services/cssValidation.js +0 -54
- package/lib/umd/services/lessCompletion.js +0 -390
- package/lib/umd/services/lint.js +0 -577
- package/lib/umd/services/lintRules.js +0 -90
- package/lib/umd/services/lintUtil.js +0 -210
- package/lib/umd/services/pathCompletion.js +0 -171
- package/lib/umd/services/scssCompletion.js +0 -367
- package/lib/umd/services/scssNavigation.js +0 -169
- package/lib/umd/services/selectorPrinting.js +0 -575
- package/lib/umd/utils/arrays.js +0 -54
- package/lib/umd/utils/objects.js +0 -24
- package/lib/umd/utils/resources.js +0 -25
- package/lib/umd/utils/strings.js +0 -123
|
@@ -1,367 +0,0 @@
|
|
|
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", "./cssCompletion", "../parser/cssNodes", "../cssLanguageTypes", "@vscode/l10n"], 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.SCSSCompletion = void 0;
|
|
17
|
-
const cssCompletion_1 = require("./cssCompletion");
|
|
18
|
-
const nodes = require("../parser/cssNodes");
|
|
19
|
-
const cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
20
|
-
const l10n = require("@vscode/l10n");
|
|
21
|
-
const sassDocumentationName = l10n.t('Sass documentation');
|
|
22
|
-
class SCSSCompletion extends cssCompletion_1.CSSCompletion {
|
|
23
|
-
constructor(lsServiceOptions, cssDataManager) {
|
|
24
|
-
super('$', lsServiceOptions, cssDataManager);
|
|
25
|
-
addReferencesToDocumentation(SCSSCompletion.scssModuleLoaders);
|
|
26
|
-
addReferencesToDocumentation(SCSSCompletion.scssModuleBuiltIns);
|
|
27
|
-
}
|
|
28
|
-
isImportPathParent(type) {
|
|
29
|
-
return type === nodes.NodeType.Forward
|
|
30
|
-
|| type === nodes.NodeType.Use
|
|
31
|
-
|| super.isImportPathParent(type);
|
|
32
|
-
}
|
|
33
|
-
getCompletionForImportPath(importPathNode, result) {
|
|
34
|
-
const parentType = importPathNode.getParent().type;
|
|
35
|
-
if (parentType === nodes.NodeType.Forward || parentType === nodes.NodeType.Use) {
|
|
36
|
-
for (let p of SCSSCompletion.scssModuleBuiltIns) {
|
|
37
|
-
const item = {
|
|
38
|
-
label: p.label,
|
|
39
|
-
documentation: p.documentation,
|
|
40
|
-
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(importPathNode), `'${p.label}'`),
|
|
41
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Module
|
|
42
|
-
};
|
|
43
|
-
result.items.push(item);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return super.getCompletionForImportPath(importPathNode, result);
|
|
47
|
-
}
|
|
48
|
-
createReplaceFunction() {
|
|
49
|
-
let tabStopCounter = 1;
|
|
50
|
-
return (_match, p1) => {
|
|
51
|
-
return '\\' + p1 + ': ${' + tabStopCounter++ + ':' + (SCSSCompletion.variableDefaults[p1] || '') + '}';
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
createFunctionProposals(proposals, existingNode, sortToEnd, result) {
|
|
55
|
-
for (const p of proposals) {
|
|
56
|
-
const insertText = p.func.replace(/\[?(\$\w+)\]?/g, this.createReplaceFunction());
|
|
57
|
-
const label = p.func.substr(0, p.func.indexOf('('));
|
|
58
|
-
const item = {
|
|
59
|
-
label: label,
|
|
60
|
-
detail: p.func,
|
|
61
|
-
documentation: p.desc,
|
|
62
|
-
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
|
|
63
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
64
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Function
|
|
65
|
-
};
|
|
66
|
-
if (sortToEnd) {
|
|
67
|
-
item.sortText = 'z';
|
|
68
|
-
}
|
|
69
|
-
result.items.push(item);
|
|
70
|
-
}
|
|
71
|
-
return result;
|
|
72
|
-
}
|
|
73
|
-
getCompletionsForSelector(ruleSet, isNested, result) {
|
|
74
|
-
this.createFunctionProposals(SCSSCompletion.selectorFuncs, null, true, result);
|
|
75
|
-
return super.getCompletionsForSelector(ruleSet, isNested, result);
|
|
76
|
-
}
|
|
77
|
-
getTermProposals(entry, existingNode, result) {
|
|
78
|
-
let functions = SCSSCompletion.builtInFuncs;
|
|
79
|
-
if (entry) {
|
|
80
|
-
functions = functions.filter(f => !f.type || !entry.restrictions || entry.restrictions.indexOf(f.type) !== -1);
|
|
81
|
-
}
|
|
82
|
-
this.createFunctionProposals(functions, existingNode, true, result);
|
|
83
|
-
return super.getTermProposals(entry, existingNode, result);
|
|
84
|
-
}
|
|
85
|
-
getColorProposals(entry, existingNode, result) {
|
|
86
|
-
this.createFunctionProposals(SCSSCompletion.colorProposals, existingNode, false, result);
|
|
87
|
-
return super.getColorProposals(entry, existingNode, result);
|
|
88
|
-
}
|
|
89
|
-
getCompletionsForDeclarationProperty(declaration, result) {
|
|
90
|
-
this.getCompletionForAtDirectives(result);
|
|
91
|
-
this.getCompletionsForSelector(null, true, result);
|
|
92
|
-
return super.getCompletionsForDeclarationProperty(declaration, result);
|
|
93
|
-
}
|
|
94
|
-
getCompletionsForExtendsReference(_extendsRef, existingNode, result) {
|
|
95
|
-
const symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Rule);
|
|
96
|
-
for (const symbol of symbols) {
|
|
97
|
-
const suggest = {
|
|
98
|
-
label: symbol.name,
|
|
99
|
-
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), symbol.name),
|
|
100
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Function,
|
|
101
|
-
};
|
|
102
|
-
result.items.push(suggest);
|
|
103
|
-
}
|
|
104
|
-
return result;
|
|
105
|
-
}
|
|
106
|
-
getCompletionForAtDirectives(result) {
|
|
107
|
-
result.items.push(...SCSSCompletion.scssAtDirectives);
|
|
108
|
-
return result;
|
|
109
|
-
}
|
|
110
|
-
getCompletionForTopLevel(result) {
|
|
111
|
-
this.getCompletionForAtDirectives(result);
|
|
112
|
-
this.getCompletionForModuleLoaders(result);
|
|
113
|
-
super.getCompletionForTopLevel(result);
|
|
114
|
-
return result;
|
|
115
|
-
}
|
|
116
|
-
getCompletionForModuleLoaders(result) {
|
|
117
|
-
result.items.push(...SCSSCompletion.scssModuleLoaders);
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
exports.SCSSCompletion = SCSSCompletion;
|
|
122
|
-
SCSSCompletion.variableDefaults = {
|
|
123
|
-
'$red': '1',
|
|
124
|
-
'$green': '2',
|
|
125
|
-
'$blue': '3',
|
|
126
|
-
'$alpha': '1.0',
|
|
127
|
-
'$color': '#000000',
|
|
128
|
-
'$weight': '0.5',
|
|
129
|
-
'$hue': '0',
|
|
130
|
-
'$saturation': '0%',
|
|
131
|
-
'$lightness': '0%',
|
|
132
|
-
'$degrees': '0',
|
|
133
|
-
'$amount': '0',
|
|
134
|
-
'$string': '""',
|
|
135
|
-
'$substring': '"s"',
|
|
136
|
-
'$number': '0',
|
|
137
|
-
'$limit': '1'
|
|
138
|
-
};
|
|
139
|
-
SCSSCompletion.colorProposals = [
|
|
140
|
-
{ func: 'red($color)', desc: l10n.t('Gets the red component of a color.') },
|
|
141
|
-
{ func: 'green($color)', desc: l10n.t('Gets the green component of a color.') },
|
|
142
|
-
{ func: 'blue($color)', desc: l10n.t('Gets the blue component of a color.') },
|
|
143
|
-
{ func: 'mix($color, $color, [$weight])', desc: l10n.t('Mixes two colors together.') },
|
|
144
|
-
{ func: 'hue($color)', desc: l10n.t('Gets the hue component of a color.') },
|
|
145
|
-
{ func: 'saturation($color)', desc: l10n.t('Gets the saturation component of a color.') },
|
|
146
|
-
{ func: 'lightness($color)', desc: l10n.t('Gets the lightness component of a color.') },
|
|
147
|
-
{ func: 'adjust-hue($color, $degrees)', desc: l10n.t('Changes the hue of a color.') },
|
|
148
|
-
{ func: 'lighten($color, $amount)', desc: l10n.t('Makes a color lighter.') },
|
|
149
|
-
{ func: 'darken($color, $amount)', desc: l10n.t('Makes a color darker.') },
|
|
150
|
-
{ func: 'saturate($color, $amount)', desc: l10n.t('Makes a color more saturated.') },
|
|
151
|
-
{ func: 'desaturate($color, $amount)', desc: l10n.t('Makes a color less saturated.') },
|
|
152
|
-
{ func: 'grayscale($color)', desc: l10n.t('Converts a color to grayscale.') },
|
|
153
|
-
{ func: 'complement($color)', desc: l10n.t('Returns the complement of a color.') },
|
|
154
|
-
{ func: 'invert($color)', desc: l10n.t('Returns the inverse of a color.') },
|
|
155
|
-
{ func: 'alpha($color)', desc: l10n.t('Gets the opacity component of a color.') },
|
|
156
|
-
{ func: 'opacity($color)', desc: 'Gets the alpha component (opacity) of a color.' },
|
|
157
|
-
{ func: 'rgba($color, $alpha)', desc: l10n.t('Changes the alpha component for a color.') },
|
|
158
|
-
{ func: 'opacify($color, $amount)', desc: l10n.t('Makes a color more opaque.') },
|
|
159
|
-
{ func: 'fade-in($color, $amount)', desc: l10n.t('Makes a color more opaque.') },
|
|
160
|
-
{ func: 'transparentize($color, $amount)', desc: l10n.t('Makes a color more transparent.') },
|
|
161
|
-
{ func: 'fade-out($color, $amount)', desc: l10n.t('Makes a color more transparent.') },
|
|
162
|
-
{ func: 'adjust-color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])', desc: l10n.t('Increases or decreases one or more components of a color.') },
|
|
163
|
-
{ func: 'scale-color($color, [$red], [$green], [$blue], [$saturation], [$lightness], [$alpha])', desc: l10n.t('Fluidly scales one or more properties of a color.') },
|
|
164
|
-
{ func: 'change-color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])', desc: l10n.t('Changes one or more properties of a color.') },
|
|
165
|
-
{ func: 'ie-hex-str($color)', desc: l10n.t('Converts a color into the format understood by IE filters.') }
|
|
166
|
-
];
|
|
167
|
-
SCSSCompletion.selectorFuncs = [
|
|
168
|
-
{ func: 'selector-nest($selectors…)', desc: l10n.t('Nests selector beneath one another like they would be nested in the stylesheet.') },
|
|
169
|
-
{ func: 'selector-append($selectors…)', desc: l10n.t('Appends selectors to one another without spaces in between.') },
|
|
170
|
-
{ func: 'selector-extend($selector, $extendee, $extender)', desc: l10n.t('Extends $extendee with $extender within $selector.') },
|
|
171
|
-
{ func: 'selector-replace($selector, $original, $replacement)', desc: l10n.t('Replaces $original with $replacement within $selector.') },
|
|
172
|
-
{ func: 'selector-unify($selector1, $selector2)', desc: l10n.t('Unifies two selectors to produce a selector that matches elements matched by both.') },
|
|
173
|
-
{ func: 'is-superselector($super, $sub)', desc: l10n.t('Returns whether $super matches all the elements $sub does, and possibly more.') },
|
|
174
|
-
{ func: 'simple-selectors($selector)', desc: l10n.t('Returns the simple selectors that comprise a compound selector.') },
|
|
175
|
-
{ func: 'selector-parse($selector)', desc: l10n.t('Parses a selector into the format returned by &.') }
|
|
176
|
-
];
|
|
177
|
-
SCSSCompletion.builtInFuncs = [
|
|
178
|
-
{ func: 'unquote($string)', desc: l10n.t('Removes quotes from a string.') },
|
|
179
|
-
{ func: 'quote($string)', desc: l10n.t('Adds quotes to a string.') },
|
|
180
|
-
{ func: 'str-length($string)', desc: l10n.t('Returns the number of characters in a string.') },
|
|
181
|
-
{ func: 'str-insert($string, $insert, $index)', desc: l10n.t('Inserts $insert into $string at $index.') },
|
|
182
|
-
{ func: 'str-index($string, $substring)', desc: l10n.t('Returns the index of the first occurance of $substring in $string.') },
|
|
183
|
-
{ func: 'str-slice($string, $start-at, [$end-at])', desc: l10n.t('Extracts a substring from $string.') },
|
|
184
|
-
{ func: 'to-upper-case($string)', desc: l10n.t('Converts a string to upper case.') },
|
|
185
|
-
{ func: 'to-lower-case($string)', desc: l10n.t('Converts a string to lower case.') },
|
|
186
|
-
{ func: 'percentage($number)', desc: l10n.t('Converts a unitless number to a percentage.'), type: 'percentage' },
|
|
187
|
-
{ func: 'round($number)', desc: l10n.t('Rounds a number to the nearest whole number.') },
|
|
188
|
-
{ func: 'ceil($number)', desc: l10n.t('Rounds a number up to the next whole number.') },
|
|
189
|
-
{ func: 'floor($number)', desc: l10n.t('Rounds a number down to the previous whole number.') },
|
|
190
|
-
{ func: 'abs($number)', desc: l10n.t('Returns the absolute value of a number.') },
|
|
191
|
-
{ func: 'min($numbers)', desc: l10n.t('Finds the minimum of several numbers.') },
|
|
192
|
-
{ func: 'max($numbers)', desc: l10n.t('Finds the maximum of several numbers.') },
|
|
193
|
-
{ func: 'random([$limit])', desc: l10n.t('Returns a random number.') },
|
|
194
|
-
{ func: 'length($list)', desc: l10n.t('Returns the length of a list.') },
|
|
195
|
-
{ func: 'nth($list, $n)', desc: l10n.t('Returns a specific item in a list.') },
|
|
196
|
-
{ func: 'set-nth($list, $n, $value)', desc: l10n.t('Replaces the nth item in a list.') },
|
|
197
|
-
{ func: 'join($list1, $list2, [$separator])', desc: l10n.t('Joins together two lists into one.') },
|
|
198
|
-
{ func: 'append($list1, $val, [$separator])', desc: l10n.t('Appends a single value onto the end of a list.') },
|
|
199
|
-
{ func: 'zip($lists)', desc: l10n.t('Combines several lists into a single multidimensional list.') },
|
|
200
|
-
{ func: 'index($list, $value)', desc: l10n.t('Returns the position of a value within a list.') },
|
|
201
|
-
{ func: 'list-separator(#list)', desc: l10n.t('Returns the separator of a list.') },
|
|
202
|
-
{ func: 'map-get($map, $key)', desc: l10n.t('Returns the value in a map associated with a given key.') },
|
|
203
|
-
{ func: 'map-merge($map1, $map2)', desc: l10n.t('Merges two maps together into a new map.') },
|
|
204
|
-
{ func: 'map-remove($map, $keys)', desc: l10n.t('Returns a new map with keys removed.') },
|
|
205
|
-
{ func: 'map-keys($map)', desc: l10n.t('Returns a list of all keys in a map.') },
|
|
206
|
-
{ func: 'map-values($map)', desc: l10n.t('Returns a list of all values in a map.') },
|
|
207
|
-
{ func: 'map-has-key($map, $key)', desc: l10n.t('Returns whether a map has a value associated with a given key.') },
|
|
208
|
-
{ func: 'keywords($args)', desc: l10n.t('Returns the keywords passed to a function that takes variable arguments.') },
|
|
209
|
-
{ func: 'feature-exists($feature)', desc: l10n.t('Returns whether a feature exists in the current Sass runtime.') },
|
|
210
|
-
{ func: 'variable-exists($name)', desc: l10n.t('Returns whether a variable with the given name exists in the current scope.') },
|
|
211
|
-
{ func: 'global-variable-exists($name)', desc: l10n.t('Returns whether a variable with the given name exists in the global scope.') },
|
|
212
|
-
{ func: 'function-exists($name)', desc: l10n.t('Returns whether a function with the given name exists.') },
|
|
213
|
-
{ func: 'mixin-exists($name)', desc: l10n.t('Returns whether a mixin with the given name exists.') },
|
|
214
|
-
{ func: 'inspect($value)', desc: l10n.t('Returns the string representation of a value as it would be represented in Sass.') },
|
|
215
|
-
{ func: 'type-of($value)', desc: l10n.t('Returns the type of a value.') },
|
|
216
|
-
{ func: 'unit($number)', desc: l10n.t('Returns the unit(s) associated with a number.') },
|
|
217
|
-
{ func: 'unitless($number)', desc: l10n.t('Returns whether a number has units.') },
|
|
218
|
-
{ func: 'comparable($number1, $number2)', desc: l10n.t('Returns whether two numbers can be added, subtracted, or compared.') },
|
|
219
|
-
{ func: 'call($name, $args…)', desc: l10n.t('Dynamically calls a Sass function.') }
|
|
220
|
-
];
|
|
221
|
-
SCSSCompletion.scssAtDirectives = [
|
|
222
|
-
{
|
|
223
|
-
label: "@extend",
|
|
224
|
-
documentation: l10n.t("Inherits the styles of another selector."),
|
|
225
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
label: "@at-root",
|
|
229
|
-
documentation: l10n.t("Causes one or more rules to be emitted at the root of the document."),
|
|
230
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
label: "@debug",
|
|
234
|
-
documentation: l10n.t("Prints the value of an expression to the standard error output stream. Useful for debugging complicated Sass files."),
|
|
235
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
236
|
-
},
|
|
237
|
-
{
|
|
238
|
-
label: "@warn",
|
|
239
|
-
documentation: l10n.t("Prints the value of an expression to the standard error output stream. Useful for libraries that need to warn users of deprecations or recovering from minor mixin usage mistakes. Warnings can be turned off with the `--quiet` command-line option or the `:quiet` Sass option."),
|
|
240
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
241
|
-
},
|
|
242
|
-
{
|
|
243
|
-
label: "@error",
|
|
244
|
-
documentation: l10n.t("Throws the value of an expression as a fatal error with stack trace. Useful for validating arguments to mixins and functions."),
|
|
245
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
label: "@if",
|
|
249
|
-
documentation: l10n.t("Includes the body if the expression does not evaluate to `false` or `null`."),
|
|
250
|
-
insertText: "@if ${1:expr} {\n\t$0\n}",
|
|
251
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
252
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
label: "@for",
|
|
256
|
-
documentation: l10n.t("For loop that repeatedly outputs a set of styles for each `$var` in the `from/through` or `from/to` clause."),
|
|
257
|
-
insertText: "@for \\$${1:var} from ${2:start} ${3|to,through|} ${4:end} {\n\t$0\n}",
|
|
258
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
259
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
260
|
-
},
|
|
261
|
-
{
|
|
262
|
-
label: "@each",
|
|
263
|
-
documentation: l10n.t("Each loop that sets `$var` to each item in the list or map, then outputs the styles it contains using that value of `$var`."),
|
|
264
|
-
insertText: "@each \\$${1:var} in ${2:list} {\n\t$0\n}",
|
|
265
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
266
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
267
|
-
},
|
|
268
|
-
{
|
|
269
|
-
label: "@while",
|
|
270
|
-
documentation: l10n.t("While loop that takes an expression and repeatedly outputs the nested styles until the statement evaluates to `false`."),
|
|
271
|
-
insertText: "@while ${1:condition} {\n\t$0\n}",
|
|
272
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
273
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
label: "@mixin",
|
|
277
|
-
documentation: l10n.t("Defines styles that can be re-used throughout the stylesheet with `@include`."),
|
|
278
|
-
insertText: "@mixin ${1:name} {\n\t$0\n}",
|
|
279
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
280
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
281
|
-
},
|
|
282
|
-
{
|
|
283
|
-
label: "@include",
|
|
284
|
-
documentation: l10n.t("Includes the styles defined by another mixin into the current rule."),
|
|
285
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
label: "@function",
|
|
289
|
-
documentation: l10n.t("Defines complex operations that can be re-used throughout stylesheets."),
|
|
290
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
291
|
-
}
|
|
292
|
-
];
|
|
293
|
-
SCSSCompletion.scssModuleLoaders = [
|
|
294
|
-
{
|
|
295
|
-
label: "@use",
|
|
296
|
-
documentation: l10n.t("Loads mixins, functions, and variables from other Sass stylesheets as 'modules', and combines CSS from multiple stylesheets together."),
|
|
297
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/at-rules/use' }],
|
|
298
|
-
insertText: "@use $0;",
|
|
299
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
300
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
label: "@forward",
|
|
304
|
-
documentation: l10n.t("Loads a Sass stylesheet and makes its mixins, functions, and variables available when this stylesheet is loaded with the @use rule."),
|
|
305
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/at-rules/forward' }],
|
|
306
|
-
insertText: "@forward $0;",
|
|
307
|
-
insertTextFormat: cssLanguageTypes_1.InsertTextFormat.Snippet,
|
|
308
|
-
kind: cssLanguageTypes_1.CompletionItemKind.Keyword
|
|
309
|
-
},
|
|
310
|
-
];
|
|
311
|
-
SCSSCompletion.scssModuleBuiltIns = [
|
|
312
|
-
{
|
|
313
|
-
label: 'sass:math',
|
|
314
|
-
documentation: l10n.t('Provides functions that operate on numbers.'),
|
|
315
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/math' }]
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
label: 'sass:string',
|
|
319
|
-
documentation: l10n.t('Makes it easy to combine, search, or split apart strings.'),
|
|
320
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/string' }]
|
|
321
|
-
},
|
|
322
|
-
{
|
|
323
|
-
label: 'sass:color',
|
|
324
|
-
documentation: l10n.t('Generates new colors based on existing ones, making it easy to build color themes.'),
|
|
325
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/color' }]
|
|
326
|
-
},
|
|
327
|
-
{
|
|
328
|
-
label: 'sass:list',
|
|
329
|
-
documentation: l10n.t('Lets you access and modify values in lists.'),
|
|
330
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/list' }]
|
|
331
|
-
},
|
|
332
|
-
{
|
|
333
|
-
label: 'sass:map',
|
|
334
|
-
documentation: l10n.t('Makes it possible to look up the value associated with a key in a map, and much more.'),
|
|
335
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/map' }]
|
|
336
|
-
},
|
|
337
|
-
{
|
|
338
|
-
label: 'sass:selector',
|
|
339
|
-
documentation: l10n.t('Provides access to Sass’s powerful selector engine.'),
|
|
340
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/selector' }]
|
|
341
|
-
},
|
|
342
|
-
{
|
|
343
|
-
label: 'sass:meta',
|
|
344
|
-
documentation: l10n.t('Exposes the details of Sass’s inner workings.'),
|
|
345
|
-
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/meta' }]
|
|
346
|
-
},
|
|
347
|
-
];
|
|
348
|
-
/**
|
|
349
|
-
* Todo @Pine: Remove this and do it through custom data
|
|
350
|
-
*/
|
|
351
|
-
function addReferencesToDocumentation(items) {
|
|
352
|
-
items.forEach(i => {
|
|
353
|
-
if (i.documentation && i.references && i.references.length > 0) {
|
|
354
|
-
const markdownDoc = typeof i.documentation === 'string'
|
|
355
|
-
? { kind: 'markdown', value: i.documentation }
|
|
356
|
-
: { kind: 'markdown', value: i.documentation.value };
|
|
357
|
-
markdownDoc.value += '\n\n';
|
|
358
|
-
markdownDoc.value += i.references
|
|
359
|
-
.map(r => {
|
|
360
|
-
return `[${r.name}](${r.url})`;
|
|
361
|
-
})
|
|
362
|
-
.join(' | ');
|
|
363
|
-
i.documentation = markdownDoc;
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
});
|
|
@@ -1,169 +0,0 @@
|
|
|
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", "../utils/resources"], 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
|
-
const resources_1 = require("../utils/resources");
|
|
22
|
-
class SCSSNavigation extends cssNavigation_1.CSSNavigation {
|
|
23
|
-
constructor(fileSystemProvider) {
|
|
24
|
-
super(fileSystemProvider, true);
|
|
25
|
-
}
|
|
26
|
-
isRawStringDocumentLinkNode(node) {
|
|
27
|
-
return (super.isRawStringDocumentLinkNode(node) ||
|
|
28
|
-
node.type === nodes.NodeType.Use ||
|
|
29
|
-
node.type === nodes.NodeType.Forward);
|
|
30
|
-
}
|
|
31
|
-
async mapReference(target, isRawLink) {
|
|
32
|
-
if (this.fileSystemProvider && target && isRawLink) {
|
|
33
|
-
const pathVariations = toPathVariations(target);
|
|
34
|
-
for (const variation of pathVariations) {
|
|
35
|
-
if (await this.fileExists(variation)) {
|
|
36
|
-
return variation;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return target;
|
|
41
|
-
}
|
|
42
|
-
async resolveReference(target, documentUri, documentContext, isRawLink = false) {
|
|
43
|
-
if ((0, strings_1.startsWith)(target, 'sass:')) {
|
|
44
|
-
return undefined; // sass library
|
|
45
|
-
}
|
|
46
|
-
// Following the [sass package importer](https://github.com/sass/sass/blob/f6832f974c61e35c42ff08b3640ff155071a02dd/js-api-doc/importer.d.ts#L349),
|
|
47
|
-
// look for the `exports` field of the module and any `sass`, `style` or `default` that matches the import.
|
|
48
|
-
// If it's only `pkg:module`, also look for `sass` and `style` on the root of package.json.
|
|
49
|
-
if (target.startsWith('pkg:')) {
|
|
50
|
-
return this.resolvePkgModulePath(target, documentUri, documentContext);
|
|
51
|
-
}
|
|
52
|
-
return super.resolveReference(target, documentUri, documentContext, isRawLink);
|
|
53
|
-
}
|
|
54
|
-
async resolvePkgModulePath(target, documentUri, documentContext) {
|
|
55
|
-
const bareTarget = target.replace('pkg:', '');
|
|
56
|
-
const moduleName = bareTarget.includes('/') ? (0, cssNavigation_1.getModuleNameFromPath)(bareTarget) : bareTarget;
|
|
57
|
-
const rootFolderUri = documentContext.resolveReference('/', documentUri);
|
|
58
|
-
const documentFolderUri = (0, resources_1.dirname)(documentUri);
|
|
59
|
-
const modulePath = await this.resolvePathToModule(moduleName, documentFolderUri, rootFolderUri);
|
|
60
|
-
if (!modulePath) {
|
|
61
|
-
return undefined;
|
|
62
|
-
}
|
|
63
|
-
// Since submodule exports import strings don't match the file system,
|
|
64
|
-
// we need the contents of `package.json` to look up the correct path.
|
|
65
|
-
let packageJsonContent = await this.getContent((0, resources_1.joinPath)(modulePath, 'package.json'));
|
|
66
|
-
if (!packageJsonContent) {
|
|
67
|
-
return undefined;
|
|
68
|
-
}
|
|
69
|
-
let packageJson;
|
|
70
|
-
try {
|
|
71
|
-
packageJson = JSON.parse(packageJsonContent);
|
|
72
|
-
}
|
|
73
|
-
catch (e) {
|
|
74
|
-
// problems parsing package.json
|
|
75
|
-
return undefined;
|
|
76
|
-
}
|
|
77
|
-
const subpath = bareTarget.substring(moduleName.length + 1);
|
|
78
|
-
if (packageJson.exports) {
|
|
79
|
-
if (!subpath) {
|
|
80
|
-
// exports may look like { "sass": "./_index.scss" } or { ".": { "sass": "./_index.scss" } }
|
|
81
|
-
const rootExport = packageJson.exports["."] || packageJson.exports;
|
|
82
|
-
// look for the default/index export
|
|
83
|
-
// @ts-expect-error If ['.'] is a string this just produces undefined
|
|
84
|
-
const entry = rootExport && (rootExport['sass'] || rootExport['style'] || rootExport['default']);
|
|
85
|
-
// the 'default' entry can be whatever, typically .js – confirm it looks like `scss`
|
|
86
|
-
if (entry && entry.endsWith('.scss')) {
|
|
87
|
-
const entryPath = (0, resources_1.joinPath)(modulePath, entry);
|
|
88
|
-
return entryPath;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
// The import string may be with or without .scss.
|
|
93
|
-
// Likewise the exports entry. Look up both paths.
|
|
94
|
-
// However, they need to be relative (start with ./).
|
|
95
|
-
const lookupSubpath = subpath.endsWith('.scss') ? `./${subpath.replace('.scss', '')}` : `./${subpath}`;
|
|
96
|
-
const lookupSubpathScss = subpath.endsWith('.scss') ? `./${subpath}` : `./${subpath}.scss`;
|
|
97
|
-
const subpathObject = packageJson.exports[lookupSubpathScss] || packageJson.exports[lookupSubpath];
|
|
98
|
-
if (subpathObject) {
|
|
99
|
-
// @ts-expect-error If subpathObject is a string this just produces undefined
|
|
100
|
-
const entry = subpathObject['sass'] || subpathObject['styles'] || subpathObject['default'];
|
|
101
|
-
// the 'default' entry can be whatever, typically .js – confirm it looks like `scss`
|
|
102
|
-
if (entry && entry.endsWith('.scss')) {
|
|
103
|
-
const entryPath = (0, resources_1.joinPath)(modulePath, entry);
|
|
104
|
-
return entryPath;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
// We have a subpath, but found no matches on direct lookup.
|
|
109
|
-
// It may be a [subpath pattern](https://nodejs.org/api/packages.html#subpath-patterns).
|
|
110
|
-
for (const [maybePattern, subpathObject] of Object.entries(packageJson.exports)) {
|
|
111
|
-
if (!maybePattern.includes("*")) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
// Patterns may also be without `.scss` on the left side, so compare without on both sides
|
|
115
|
-
const re = new RegExp((0, strings_1.convertSimple2RegExpPattern)(maybePattern.replace('.scss', '')).replace(/\.\*/g, '(.*)'));
|
|
116
|
-
const match = re.exec(lookupSubpath);
|
|
117
|
-
if (match) {
|
|
118
|
-
// @ts-expect-error If subpathObject is a string this just produces undefined
|
|
119
|
-
const entry = subpathObject['sass'] || subpathObject['styles'] || subpathObject['default'];
|
|
120
|
-
// the 'default' entry can be whatever, typically .js – confirm it looks like `scss`
|
|
121
|
-
if (entry && entry.endsWith('.scss')) {
|
|
122
|
-
// The right-hand side of a subpath pattern is also a pattern.
|
|
123
|
-
// Replace the pattern with the match from our regexp capture group above.
|
|
124
|
-
const expandedPattern = entry.replace('*', match[1]);
|
|
125
|
-
const entryPath = (0, resources_1.joinPath)(modulePath, expandedPattern);
|
|
126
|
-
return entryPath;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
else if (!subpath && (packageJson.sass || packageJson.style)) {
|
|
134
|
-
// Fall back to a direct lookup on `sass` and `style` on package root
|
|
135
|
-
const entry = packageJson.sass || packageJson.style;
|
|
136
|
-
if (entry) {
|
|
137
|
-
const entryPath = (0, resources_1.joinPath)(modulePath, entry);
|
|
138
|
-
return entryPath;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return undefined;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
exports.SCSSNavigation = SCSSNavigation;
|
|
145
|
-
function toPathVariations(target) {
|
|
146
|
-
// No variation for links that ends with .css suffix
|
|
147
|
-
if (target.endsWith('.css')) {
|
|
148
|
-
return [target];
|
|
149
|
-
}
|
|
150
|
-
// If a link is like a/, try resolving a/index.scss and a/_index.scss
|
|
151
|
-
if (target.endsWith('/')) {
|
|
152
|
-
return [target + 'index.scss', target + '_index.scss'];
|
|
153
|
-
}
|
|
154
|
-
const targetUri = vscode_uri_1.URI.parse(target.replace(/\.scss$/, ''));
|
|
155
|
-
const basename = vscode_uri_1.Utils.basename(targetUri);
|
|
156
|
-
const dirname = vscode_uri_1.Utils.dirname(targetUri);
|
|
157
|
-
if (basename.startsWith('_')) {
|
|
158
|
-
// No variation for links such as _a
|
|
159
|
-
return [vscode_uri_1.Utils.joinPath(dirname, basename + '.scss').toString(true)];
|
|
160
|
-
}
|
|
161
|
-
return [
|
|
162
|
-
vscode_uri_1.Utils.joinPath(dirname, basename + '.scss').toString(true),
|
|
163
|
-
vscode_uri_1.Utils.joinPath(dirname, '_' + basename + '.scss').toString(true),
|
|
164
|
-
target + '/index.scss',
|
|
165
|
-
target + '/_index.scss',
|
|
166
|
-
vscode_uri_1.Utils.joinPath(dirname, basename + '.css').toString(true)
|
|
167
|
-
];
|
|
168
|
-
}
|
|
169
|
-
});
|