vscode-css-languageservice 6.0.1 → 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 (87) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/SECURITY.md +41 -0
  3. package/lib/esm/beautify/beautify-css.js +11 -4
  4. package/lib/esm/cssLanguageService.d.ts +38 -37
  5. package/lib/esm/cssLanguageService.js +73 -72
  6. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  7. package/lib/esm/cssLanguageTypes.js +42 -42
  8. package/lib/esm/data/webCustomData.js +22089 -21959
  9. package/lib/esm/languageFacts/builtinData.js +142 -142
  10. package/lib/esm/languageFacts/colors.js +469 -469
  11. package/lib/esm/languageFacts/dataManager.js +88 -88
  12. package/lib/esm/languageFacts/dataProvider.js +73 -73
  13. package/lib/esm/languageFacts/entry.js +137 -137
  14. package/lib/esm/languageFacts/facts.js +8 -8
  15. package/lib/esm/parser/cssErrors.js +48 -48
  16. package/lib/esm/parser/cssNodes.js +1511 -1502
  17. package/lib/esm/parser/cssParser.js +1606 -1534
  18. package/lib/esm/parser/cssScanner.js +592 -592
  19. package/lib/esm/parser/cssSymbolScope.js +311 -311
  20. package/lib/esm/parser/lessParser.js +715 -714
  21. package/lib/esm/parser/lessScanner.js +57 -57
  22. package/lib/esm/parser/scssErrors.js +18 -18
  23. package/lib/esm/parser/scssParser.js +806 -796
  24. package/lib/esm/parser/scssScanner.js +95 -95
  25. package/lib/esm/services/cssCodeActions.js +77 -77
  26. package/lib/esm/services/cssCompletion.js +1054 -1054
  27. package/lib/esm/services/cssFolding.js +190 -190
  28. package/lib/esm/services/cssFormatter.js +136 -136
  29. package/lib/esm/services/cssHover.js +148 -148
  30. package/lib/esm/services/cssNavigation.js +441 -378
  31. package/lib/esm/services/cssSelectionRange.js +47 -47
  32. package/lib/esm/services/cssValidation.js +41 -41
  33. package/lib/esm/services/lessCompletion.js +378 -378
  34. package/lib/esm/services/lint.js +518 -518
  35. package/lib/esm/services/lintRules.js +76 -76
  36. package/lib/esm/services/lintUtil.js +196 -196
  37. package/lib/esm/services/pathCompletion.js +157 -157
  38. package/lib/esm/services/scssCompletion.js +354 -354
  39. package/lib/esm/services/scssNavigation.js +82 -82
  40. package/lib/esm/services/selectorPrinting.js +492 -492
  41. package/lib/esm/utils/arrays.js +40 -40
  42. package/lib/esm/utils/objects.js +11 -11
  43. package/lib/esm/utils/resources.js +11 -11
  44. package/lib/esm/utils/strings.js +102 -102
  45. package/lib/umd/beautify/beautify-css.js +11 -4
  46. package/lib/umd/cssLanguageService.d.ts +38 -37
  47. package/lib/umd/cssLanguageService.js +104 -99
  48. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  49. package/lib/umd/cssLanguageTypes.js +89 -89
  50. package/lib/umd/data/webCustomData.js +22102 -21972
  51. package/lib/umd/languageFacts/builtinData.js +154 -154
  52. package/lib/umd/languageFacts/colors.js +492 -492
  53. package/lib/umd/languageFacts/dataManager.js +101 -101
  54. package/lib/umd/languageFacts/dataProvider.js +86 -86
  55. package/lib/umd/languageFacts/entry.js +152 -152
  56. package/lib/umd/languageFacts/facts.js +33 -29
  57. package/lib/umd/parser/cssErrors.js +61 -61
  58. package/lib/umd/parser/cssNodes.js +1597 -1587
  59. package/lib/umd/parser/cssParser.js +1619 -1547
  60. package/lib/umd/parser/cssScanner.js +606 -606
  61. package/lib/umd/parser/cssSymbolScope.js +328 -328
  62. package/lib/umd/parser/lessParser.js +728 -727
  63. package/lib/umd/parser/lessScanner.js +70 -70
  64. package/lib/umd/parser/scssErrors.js +31 -31
  65. package/lib/umd/parser/scssParser.js +819 -809
  66. package/lib/umd/parser/scssScanner.js +108 -108
  67. package/lib/umd/services/cssCodeActions.js +90 -90
  68. package/lib/umd/services/cssCompletion.js +1067 -1067
  69. package/lib/umd/services/cssFolding.js +203 -203
  70. package/lib/umd/services/cssFormatter.js +150 -150
  71. package/lib/umd/services/cssHover.js +161 -161
  72. package/lib/umd/services/cssNavigation.js +454 -391
  73. package/lib/umd/services/cssSelectionRange.js +60 -60
  74. package/lib/umd/services/cssValidation.js +54 -54
  75. package/lib/umd/services/lessCompletion.js +391 -391
  76. package/lib/umd/services/lint.js +531 -531
  77. package/lib/umd/services/lintRules.js +91 -91
  78. package/lib/umd/services/lintUtil.js +210 -210
  79. package/lib/umd/services/pathCompletion.js +171 -171
  80. package/lib/umd/services/scssCompletion.js +367 -367
  81. package/lib/umd/services/scssNavigation.js +95 -95
  82. package/lib/umd/services/selectorPrinting.js +510 -510
  83. package/lib/umd/utils/arrays.js +55 -55
  84. package/lib/umd/utils/objects.js +25 -25
  85. package/lib/umd/utils/resources.js +26 -26
  86. package/lib/umd/utils/strings.js +120 -120
  87. package/package.json +13 -12
@@ -1,367 +1,367 @@
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-nls"], 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 nls = require("vscode-nls");
21
- const localize = nls.loadMessageBundle();
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: localize('scss.builtin.red', 'Gets the red component of a color.') },
141
- { func: 'green($color)', desc: localize('scss.builtin.green', 'Gets the green component of a color.') },
142
- { func: 'blue($color)', desc: localize('scss.builtin.blue', 'Gets the blue component of a color.') },
143
- { func: 'mix($color, $color, [$weight])', desc: localize('scss.builtin.mix', 'Mixes two colors together.') },
144
- { func: 'hue($color)', desc: localize('scss.builtin.hue', 'Gets the hue component of a color.') },
145
- { func: 'saturation($color)', desc: localize('scss.builtin.saturation', 'Gets the saturation component of a color.') },
146
- { func: 'lightness($color)', desc: localize('scss.builtin.lightness', 'Gets the lightness component of a color.') },
147
- { func: 'adjust-hue($color, $degrees)', desc: localize('scss.builtin.adjust-hue', 'Changes the hue of a color.') },
148
- { func: 'lighten($color, $amount)', desc: localize('scss.builtin.lighten', 'Makes a color lighter.') },
149
- { func: 'darken($color, $amount)', desc: localize('scss.builtin.darken', 'Makes a color darker.') },
150
- { func: 'saturate($color, $amount)', desc: localize('scss.builtin.saturate', 'Makes a color more saturated.') },
151
- { func: 'desaturate($color, $amount)', desc: localize('scss.builtin.desaturate', 'Makes a color less saturated.') },
152
- { func: 'grayscale($color)', desc: localize('scss.builtin.grayscale', 'Converts a color to grayscale.') },
153
- { func: 'complement($color)', desc: localize('scss.builtin.complement', 'Returns the complement of a color.') },
154
- { func: 'invert($color)', desc: localize('scss.builtin.invert', 'Returns the inverse of a color.') },
155
- { func: 'alpha($color)', desc: localize('scss.builtin.alpha', '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: localize('scss.builtin.rgba', 'Changes the alpha component for a color.') },
158
- { func: 'opacify($color, $amount)', desc: localize('scss.builtin.opacify', 'Makes a color more opaque.') },
159
- { func: 'fade-in($color, $amount)', desc: localize('scss.builtin.fade-in', 'Makes a color more opaque.') },
160
- { func: 'transparentize($color, $amount)', desc: localize('scss.builtin.transparentize', 'Makes a color more transparent.') },
161
- { func: 'fade-out($color, $amount)', desc: localize('scss.builtin.fade-out', 'Makes a color more transparent.') },
162
- { func: 'adjust-color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])', desc: localize('scss.builtin.adjust-color', 'Increases or decreases one or more components of a color.') },
163
- { func: 'scale-color($color, [$red], [$green], [$blue], [$saturation], [$lightness], [$alpha])', desc: localize('scss.builtin.scale-color', 'Fluidly scales one or more properties of a color.') },
164
- { func: 'change-color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])', desc: localize('scss.builtin.change-color', 'Changes one or more properties of a color.') },
165
- { func: 'ie-hex-str($color)', desc: localize('scss.builtin.ie-hex-str', 'Converts a color into the format understood by IE filters.') }
166
- ];
167
- SCSSCompletion.selectorFuncs = [
168
- { func: 'selector-nest($selectors…)', desc: localize('scss.builtin.selector-nest', 'Nests selector beneath one another like they would be nested in the stylesheet.') },
169
- { func: 'selector-append($selectors…)', desc: localize('scss.builtin.selector-append', 'Appends selectors to one another without spaces in between.') },
170
- { func: 'selector-extend($selector, $extendee, $extender)', desc: localize('scss.builtin.selector-extend', 'Extends $extendee with $extender within $selector.') },
171
- { func: 'selector-replace($selector, $original, $replacement)', desc: localize('scss.builtin.selector-replace', 'Replaces $original with $replacement within $selector.') },
172
- { func: 'selector-unify($selector1, $selector2)', desc: localize('scss.builtin.selector-unify', 'Unifies two selectors to produce a selector that matches elements matched by both.') },
173
- { func: 'is-superselector($super, $sub)', desc: localize('scss.builtin.is-superselector', 'Returns whether $super matches all the elements $sub does, and possibly more.') },
174
- { func: 'simple-selectors($selector)', desc: localize('scss.builtin.simple-selectors', 'Returns the simple selectors that comprise a compound selector.') },
175
- { func: 'selector-parse($selector)', desc: localize('scss.builtin.selector-parse', 'Parses a selector into the format returned by &.') }
176
- ];
177
- SCSSCompletion.builtInFuncs = [
178
- { func: 'unquote($string)', desc: localize('scss.builtin.unquote', 'Removes quotes from a string.') },
179
- { func: 'quote($string)', desc: localize('scss.builtin.quote', 'Adds quotes to a string.') },
180
- { func: 'str-length($string)', desc: localize('scss.builtin.str-length', 'Returns the number of characters in a string.') },
181
- { func: 'str-insert($string, $insert, $index)', desc: localize('scss.builtin.str-insert', 'Inserts $insert into $string at $index.') },
182
- { func: 'str-index($string, $substring)', desc: localize('scss.builtin.str-index', 'Returns the index of the first occurance of $substring in $string.') },
183
- { func: 'str-slice($string, $start-at, [$end-at])', desc: localize('scss.builtin.str-slice', 'Extracts a substring from $string.') },
184
- { func: 'to-upper-case($string)', desc: localize('scss.builtin.to-upper-case', 'Converts a string to upper case.') },
185
- { func: 'to-lower-case($string)', desc: localize('scss.builtin.to-lower-case', 'Converts a string to lower case.') },
186
- { func: 'percentage($number)', desc: localize('scss.builtin.percentage', 'Converts a unitless number to a percentage.'), type: 'percentage' },
187
- { func: 'round($number)', desc: localize('scss.builtin.round', 'Rounds a number to the nearest whole number.') },
188
- { func: 'ceil($number)', desc: localize('scss.builtin.ceil', 'Rounds a number up to the next whole number.') },
189
- { func: 'floor($number)', desc: localize('scss.builtin.floor', 'Rounds a number down to the previous whole number.') },
190
- { func: 'abs($number)', desc: localize('scss.builtin.abs', 'Returns the absolute value of a number.') },
191
- { func: 'min($numbers)', desc: localize('scss.builtin.min', 'Finds the minimum of several numbers.') },
192
- { func: 'max($numbers)', desc: localize('scss.builtin.max', 'Finds the maximum of several numbers.') },
193
- { func: 'random([$limit])', desc: localize('scss.builtin.random', 'Returns a random number.') },
194
- { func: 'length($list)', desc: localize('scss.builtin.length', 'Returns the length of a list.') },
195
- { func: 'nth($list, $n)', desc: localize('scss.builtin.nth', 'Returns a specific item in a list.') },
196
- { func: 'set-nth($list, $n, $value)', desc: localize('scss.builtin.set-nth', 'Replaces the nth item in a list.') },
197
- { func: 'join($list1, $list2, [$separator])', desc: localize('scss.builtin.join', 'Joins together two lists into one.') },
198
- { func: 'append($list1, $val, [$separator])', desc: localize('scss.builtin.append', 'Appends a single value onto the end of a list.') },
199
- { func: 'zip($lists)', desc: localize('scss.builtin.zip', 'Combines several lists into a single multidimensional list.') },
200
- { func: 'index($list, $value)', desc: localize('scss.builtin.index', 'Returns the position of a value within a list.') },
201
- { func: 'list-separator(#list)', desc: localize('scss.builtin.list-separator', 'Returns the separator of a list.') },
202
- { func: 'map-get($map, $key)', desc: localize('scss.builtin.map-get', 'Returns the value in a map associated with a given key.') },
203
- { func: 'map-merge($map1, $map2)', desc: localize('scss.builtin.map-merge', 'Merges two maps together into a new map.') },
204
- { func: 'map-remove($map, $keys)', desc: localize('scss.builtin.map-remove', 'Returns a new map with keys removed.') },
205
- { func: 'map-keys($map)', desc: localize('scss.builtin.map-keys', 'Returns a list of all keys in a map.') },
206
- { func: 'map-values($map)', desc: localize('scss.builtin.map-values', 'Returns a list of all values in a map.') },
207
- { func: 'map-has-key($map, $key)', desc: localize('scss.builtin.map-has-key', 'Returns whether a map has a value associated with a given key.') },
208
- { func: 'keywords($args)', desc: localize('scss.builtin.keywords', 'Returns the keywords passed to a function that takes variable arguments.') },
209
- { func: 'feature-exists($feature)', desc: localize('scss.builtin.feature-exists', 'Returns whether a feature exists in the current Sass runtime.') },
210
- { func: 'variable-exists($name)', desc: localize('scss.builtin.variable-exists', 'Returns whether a variable with the given name exists in the current scope.') },
211
- { func: 'global-variable-exists($name)', desc: localize('scss.builtin.global-variable-exists', 'Returns whether a variable with the given name exists in the global scope.') },
212
- { func: 'function-exists($name)', desc: localize('scss.builtin.function-exists', 'Returns whether a function with the given name exists.') },
213
- { func: 'mixin-exists($name)', desc: localize('scss.builtin.mixin-exists', 'Returns whether a mixin with the given name exists.') },
214
- { func: 'inspect($value)', desc: localize('scss.builtin.inspect', 'Returns the string representation of a value as it would be represented in Sass.') },
215
- { func: 'type-of($value)', desc: localize('scss.builtin.type-of', 'Returns the type of a value.') },
216
- { func: 'unit($number)', desc: localize('scss.builtin.unit', 'Returns the unit(s) associated with a number.') },
217
- { func: 'unitless($number)', desc: localize('scss.builtin.unitless', 'Returns whether a number has units.') },
218
- { func: 'comparable($number1, $number2)', desc: localize('scss.builtin.comparable', 'Returns whether two numbers can be added, subtracted, or compared.') },
219
- { func: 'call($name, $args…)', desc: localize('scss.builtin.call', 'Dynamically calls a Sass function.') }
220
- ];
221
- SCSSCompletion.scssAtDirectives = [
222
- {
223
- label: "@extend",
224
- documentation: localize("scss.builtin.@extend", "Inherits the styles of another selector."),
225
- kind: cssLanguageTypes_1.CompletionItemKind.Keyword
226
- },
227
- {
228
- label: "@at-root",
229
- documentation: localize("scss.builtin.@at-root", "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: localize("scss.builtin.@debug", "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: localize("scss.builtin.@warn", "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: localize("scss.builtin.@error", "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: localize("scss.builtin.@if", "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: localize("scss.builtin.@for", "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: localize("scss.builtin.@each", "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: localize("scss.builtin.@while", "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: localize("scss.builtin.@mixin", "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: localize("scss.builtin.@include", "Includes the styles defined by another mixin into the current rule."),
285
- kind: cssLanguageTypes_1.CompletionItemKind.Keyword
286
- },
287
- {
288
- label: "@function",
289
- documentation: localize("scss.builtin.@function", "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: localize("scss.builtin.@use", "Loads mixins, functions, and variables from other Sass stylesheets as 'modules', and combines CSS from multiple stylesheets together."),
297
- references: [{ name: 'Sass documentation', 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: localize("scss.builtin.@forward", "Loads a Sass stylesheet and makes its mixins, functions, and variables available when this stylesheet is loaded with the @use rule."),
305
- references: [{ name: 'Sass documentation', 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: localize('scss.builtin.sass:math', 'Provides functions that operate on numbers.'),
315
- references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/math' }]
316
- },
317
- {
318
- label: 'sass:string',
319
- documentation: localize('scss.builtin.sass:string', 'Makes it easy to combine, search, or split apart strings.'),
320
- references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/string' }]
321
- },
322
- {
323
- label: 'sass:color',
324
- documentation: localize('scss.builtin.sass:color', 'Generates new colors based on existing ones, making it easy to build color themes.'),
325
- references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/color' }]
326
- },
327
- {
328
- label: 'sass:list',
329
- documentation: localize('scss.builtin.sass:list', 'Lets you access and modify values in lists.'),
330
- references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/list' }]
331
- },
332
- {
333
- label: 'sass:map',
334
- documentation: localize('scss.builtin.sass:map', 'Makes it possible to look up the value associated with a key in a map, and much more.'),
335
- references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/map' }]
336
- },
337
- {
338
- label: 'sass:selector',
339
- documentation: localize('scss.builtin.sass:selector', 'Provides access to Sass’s powerful selector engine.'),
340
- references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/selector' }]
341
- },
342
- {
343
- label: 'sass:meta',
344
- documentation: localize('scss.builtin.sass:meta', 'Exposes the details of Sass’s inner workings.'),
345
- references: [{ name: 'Sass documentation', 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
+ (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-nls"], 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 nls = require("vscode-nls");
21
+ const localize = nls.loadMessageBundle();
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: localize('scss.builtin.red', 'Gets the red component of a color.') },
141
+ { func: 'green($color)', desc: localize('scss.builtin.green', 'Gets the green component of a color.') },
142
+ { func: 'blue($color)', desc: localize('scss.builtin.blue', 'Gets the blue component of a color.') },
143
+ { func: 'mix($color, $color, [$weight])', desc: localize('scss.builtin.mix', 'Mixes two colors together.') },
144
+ { func: 'hue($color)', desc: localize('scss.builtin.hue', 'Gets the hue component of a color.') },
145
+ { func: 'saturation($color)', desc: localize('scss.builtin.saturation', 'Gets the saturation component of a color.') },
146
+ { func: 'lightness($color)', desc: localize('scss.builtin.lightness', 'Gets the lightness component of a color.') },
147
+ { func: 'adjust-hue($color, $degrees)', desc: localize('scss.builtin.adjust-hue', 'Changes the hue of a color.') },
148
+ { func: 'lighten($color, $amount)', desc: localize('scss.builtin.lighten', 'Makes a color lighter.') },
149
+ { func: 'darken($color, $amount)', desc: localize('scss.builtin.darken', 'Makes a color darker.') },
150
+ { func: 'saturate($color, $amount)', desc: localize('scss.builtin.saturate', 'Makes a color more saturated.') },
151
+ { func: 'desaturate($color, $amount)', desc: localize('scss.builtin.desaturate', 'Makes a color less saturated.') },
152
+ { func: 'grayscale($color)', desc: localize('scss.builtin.grayscale', 'Converts a color to grayscale.') },
153
+ { func: 'complement($color)', desc: localize('scss.builtin.complement', 'Returns the complement of a color.') },
154
+ { func: 'invert($color)', desc: localize('scss.builtin.invert', 'Returns the inverse of a color.') },
155
+ { func: 'alpha($color)', desc: localize('scss.builtin.alpha', '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: localize('scss.builtin.rgba', 'Changes the alpha component for a color.') },
158
+ { func: 'opacify($color, $amount)', desc: localize('scss.builtin.opacify', 'Makes a color more opaque.') },
159
+ { func: 'fade-in($color, $amount)', desc: localize('scss.builtin.fade-in', 'Makes a color more opaque.') },
160
+ { func: 'transparentize($color, $amount)', desc: localize('scss.builtin.transparentize', 'Makes a color more transparent.') },
161
+ { func: 'fade-out($color, $amount)', desc: localize('scss.builtin.fade-out', 'Makes a color more transparent.') },
162
+ { func: 'adjust-color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])', desc: localize('scss.builtin.adjust-color', 'Increases or decreases one or more components of a color.') },
163
+ { func: 'scale-color($color, [$red], [$green], [$blue], [$saturation], [$lightness], [$alpha])', desc: localize('scss.builtin.scale-color', 'Fluidly scales one or more properties of a color.') },
164
+ { func: 'change-color($color, [$red], [$green], [$blue], [$hue], [$saturation], [$lightness], [$alpha])', desc: localize('scss.builtin.change-color', 'Changes one or more properties of a color.') },
165
+ { func: 'ie-hex-str($color)', desc: localize('scss.builtin.ie-hex-str', 'Converts a color into the format understood by IE filters.') }
166
+ ];
167
+ SCSSCompletion.selectorFuncs = [
168
+ { func: 'selector-nest($selectors…)', desc: localize('scss.builtin.selector-nest', 'Nests selector beneath one another like they would be nested in the stylesheet.') },
169
+ { func: 'selector-append($selectors…)', desc: localize('scss.builtin.selector-append', 'Appends selectors to one another without spaces in between.') },
170
+ { func: 'selector-extend($selector, $extendee, $extender)', desc: localize('scss.builtin.selector-extend', 'Extends $extendee with $extender within $selector.') },
171
+ { func: 'selector-replace($selector, $original, $replacement)', desc: localize('scss.builtin.selector-replace', 'Replaces $original with $replacement within $selector.') },
172
+ { func: 'selector-unify($selector1, $selector2)', desc: localize('scss.builtin.selector-unify', 'Unifies two selectors to produce a selector that matches elements matched by both.') },
173
+ { func: 'is-superselector($super, $sub)', desc: localize('scss.builtin.is-superselector', 'Returns whether $super matches all the elements $sub does, and possibly more.') },
174
+ { func: 'simple-selectors($selector)', desc: localize('scss.builtin.simple-selectors', 'Returns the simple selectors that comprise a compound selector.') },
175
+ { func: 'selector-parse($selector)', desc: localize('scss.builtin.selector-parse', 'Parses a selector into the format returned by &.') }
176
+ ];
177
+ SCSSCompletion.builtInFuncs = [
178
+ { func: 'unquote($string)', desc: localize('scss.builtin.unquote', 'Removes quotes from a string.') },
179
+ { func: 'quote($string)', desc: localize('scss.builtin.quote', 'Adds quotes to a string.') },
180
+ { func: 'str-length($string)', desc: localize('scss.builtin.str-length', 'Returns the number of characters in a string.') },
181
+ { func: 'str-insert($string, $insert, $index)', desc: localize('scss.builtin.str-insert', 'Inserts $insert into $string at $index.') },
182
+ { func: 'str-index($string, $substring)', desc: localize('scss.builtin.str-index', 'Returns the index of the first occurance of $substring in $string.') },
183
+ { func: 'str-slice($string, $start-at, [$end-at])', desc: localize('scss.builtin.str-slice', 'Extracts a substring from $string.') },
184
+ { func: 'to-upper-case($string)', desc: localize('scss.builtin.to-upper-case', 'Converts a string to upper case.') },
185
+ { func: 'to-lower-case($string)', desc: localize('scss.builtin.to-lower-case', 'Converts a string to lower case.') },
186
+ { func: 'percentage($number)', desc: localize('scss.builtin.percentage', 'Converts a unitless number to a percentage.'), type: 'percentage' },
187
+ { func: 'round($number)', desc: localize('scss.builtin.round', 'Rounds a number to the nearest whole number.') },
188
+ { func: 'ceil($number)', desc: localize('scss.builtin.ceil', 'Rounds a number up to the next whole number.') },
189
+ { func: 'floor($number)', desc: localize('scss.builtin.floor', 'Rounds a number down to the previous whole number.') },
190
+ { func: 'abs($number)', desc: localize('scss.builtin.abs', 'Returns the absolute value of a number.') },
191
+ { func: 'min($numbers)', desc: localize('scss.builtin.min', 'Finds the minimum of several numbers.') },
192
+ { func: 'max($numbers)', desc: localize('scss.builtin.max', 'Finds the maximum of several numbers.') },
193
+ { func: 'random([$limit])', desc: localize('scss.builtin.random', 'Returns a random number.') },
194
+ { func: 'length($list)', desc: localize('scss.builtin.length', 'Returns the length of a list.') },
195
+ { func: 'nth($list, $n)', desc: localize('scss.builtin.nth', 'Returns a specific item in a list.') },
196
+ { func: 'set-nth($list, $n, $value)', desc: localize('scss.builtin.set-nth', 'Replaces the nth item in a list.') },
197
+ { func: 'join($list1, $list2, [$separator])', desc: localize('scss.builtin.join', 'Joins together two lists into one.') },
198
+ { func: 'append($list1, $val, [$separator])', desc: localize('scss.builtin.append', 'Appends a single value onto the end of a list.') },
199
+ { func: 'zip($lists)', desc: localize('scss.builtin.zip', 'Combines several lists into a single multidimensional list.') },
200
+ { func: 'index($list, $value)', desc: localize('scss.builtin.index', 'Returns the position of a value within a list.') },
201
+ { func: 'list-separator(#list)', desc: localize('scss.builtin.list-separator', 'Returns the separator of a list.') },
202
+ { func: 'map-get($map, $key)', desc: localize('scss.builtin.map-get', 'Returns the value in a map associated with a given key.') },
203
+ { func: 'map-merge($map1, $map2)', desc: localize('scss.builtin.map-merge', 'Merges two maps together into a new map.') },
204
+ { func: 'map-remove($map, $keys)', desc: localize('scss.builtin.map-remove', 'Returns a new map with keys removed.') },
205
+ { func: 'map-keys($map)', desc: localize('scss.builtin.map-keys', 'Returns a list of all keys in a map.') },
206
+ { func: 'map-values($map)', desc: localize('scss.builtin.map-values', 'Returns a list of all values in a map.') },
207
+ { func: 'map-has-key($map, $key)', desc: localize('scss.builtin.map-has-key', 'Returns whether a map has a value associated with a given key.') },
208
+ { func: 'keywords($args)', desc: localize('scss.builtin.keywords', 'Returns the keywords passed to a function that takes variable arguments.') },
209
+ { func: 'feature-exists($feature)', desc: localize('scss.builtin.feature-exists', 'Returns whether a feature exists in the current Sass runtime.') },
210
+ { func: 'variable-exists($name)', desc: localize('scss.builtin.variable-exists', 'Returns whether a variable with the given name exists in the current scope.') },
211
+ { func: 'global-variable-exists($name)', desc: localize('scss.builtin.global-variable-exists', 'Returns whether a variable with the given name exists in the global scope.') },
212
+ { func: 'function-exists($name)', desc: localize('scss.builtin.function-exists', 'Returns whether a function with the given name exists.') },
213
+ { func: 'mixin-exists($name)', desc: localize('scss.builtin.mixin-exists', 'Returns whether a mixin with the given name exists.') },
214
+ { func: 'inspect($value)', desc: localize('scss.builtin.inspect', 'Returns the string representation of a value as it would be represented in Sass.') },
215
+ { func: 'type-of($value)', desc: localize('scss.builtin.type-of', 'Returns the type of a value.') },
216
+ { func: 'unit($number)', desc: localize('scss.builtin.unit', 'Returns the unit(s) associated with a number.') },
217
+ { func: 'unitless($number)', desc: localize('scss.builtin.unitless', 'Returns whether a number has units.') },
218
+ { func: 'comparable($number1, $number2)', desc: localize('scss.builtin.comparable', 'Returns whether two numbers can be added, subtracted, or compared.') },
219
+ { func: 'call($name, $args…)', desc: localize('scss.builtin.call', 'Dynamically calls a Sass function.') }
220
+ ];
221
+ SCSSCompletion.scssAtDirectives = [
222
+ {
223
+ label: "@extend",
224
+ documentation: localize("scss.builtin.@extend", "Inherits the styles of another selector."),
225
+ kind: cssLanguageTypes_1.CompletionItemKind.Keyword
226
+ },
227
+ {
228
+ label: "@at-root",
229
+ documentation: localize("scss.builtin.@at-root", "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: localize("scss.builtin.@debug", "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: localize("scss.builtin.@warn", "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: localize("scss.builtin.@error", "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: localize("scss.builtin.@if", "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: localize("scss.builtin.@for", "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: localize("scss.builtin.@each", "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: localize("scss.builtin.@while", "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: localize("scss.builtin.@mixin", "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: localize("scss.builtin.@include", "Includes the styles defined by another mixin into the current rule."),
285
+ kind: cssLanguageTypes_1.CompletionItemKind.Keyword
286
+ },
287
+ {
288
+ label: "@function",
289
+ documentation: localize("scss.builtin.@function", "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: localize("scss.builtin.@use", "Loads mixins, functions, and variables from other Sass stylesheets as 'modules', and combines CSS from multiple stylesheets together."),
297
+ references: [{ name: 'Sass documentation', 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: localize("scss.builtin.@forward", "Loads a Sass stylesheet and makes its mixins, functions, and variables available when this stylesheet is loaded with the @use rule."),
305
+ references: [{ name: 'Sass documentation', 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: localize('scss.builtin.sass:math', 'Provides functions that operate on numbers.'),
315
+ references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/math' }]
316
+ },
317
+ {
318
+ label: 'sass:string',
319
+ documentation: localize('scss.builtin.sass:string', 'Makes it easy to combine, search, or split apart strings.'),
320
+ references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/string' }]
321
+ },
322
+ {
323
+ label: 'sass:color',
324
+ documentation: localize('scss.builtin.sass:color', 'Generates new colors based on existing ones, making it easy to build color themes.'),
325
+ references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/color' }]
326
+ },
327
+ {
328
+ label: 'sass:list',
329
+ documentation: localize('scss.builtin.sass:list', 'Lets you access and modify values in lists.'),
330
+ references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/list' }]
331
+ },
332
+ {
333
+ label: 'sass:map',
334
+ documentation: localize('scss.builtin.sass:map', 'Makes it possible to look up the value associated with a key in a map, and much more.'),
335
+ references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/map' }]
336
+ },
337
+ {
338
+ label: 'sass:selector',
339
+ documentation: localize('scss.builtin.sass:selector', 'Provides access to Sass’s powerful selector engine.'),
340
+ references: [{ name: 'Sass documentation', url: 'https://sass-lang.com/documentation/modules/selector' }]
341
+ },
342
+ {
343
+ label: 'sass:meta',
344
+ documentation: localize('scss.builtin.sass:meta', 'Exposes the details of Sass’s inner workings.'),
345
+ references: [{ name: 'Sass documentation', 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
+ });