vscode-css-languageservice 6.2.4 → 6.2.6
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/README.md +1 -1
- package/lib/esm/data/webCustomData.js +112 -116
- package/lib/esm/languageFacts/builtinData.js +1 -1
- package/lib/esm/languageFacts/colors.js +128 -6
- package/lib/esm/parser/cssNodes.js +1 -1
- package/lib/esm/parser/cssParser.js +32 -9
- package/lib/esm/parser/lessParser.js +6 -6
- package/lib/esm/parser/scssParser.js +6 -6
- package/lib/esm/services/cssCompletion.js +4 -11
- package/lib/esm/services/cssNavigation.js +6 -3
- package/lib/esm/services/lessCompletion.js +2 -1
- package/lib/esm/services/lint.js +2 -1
- package/lib/esm/services/scssCompletion.js +2 -1
- package/lib/esm/services/selectorPrinting.js +1 -2
- package/lib/umd/data/webCustomData.js +112 -116
- package/lib/umd/languageFacts/builtinData.js +1 -1
- package/lib/umd/languageFacts/colors.js +130 -7
- package/lib/umd/parser/cssNodes.js +1 -1
- package/lib/umd/parser/cssParser.js +32 -9
- package/lib/umd/parser/lessParser.js +6 -6
- package/lib/umd/parser/scssParser.js +6 -6
- package/lib/umd/services/cssCompletion.js +4 -11
- package/lib/umd/services/cssNavigation.js +6 -3
- package/lib/umd/services/lessCompletion.js +1 -1
- package/lib/umd/services/lint.js +1 -1
- package/lib/umd/services/scssCompletion.js +1 -1
- package/lib/umd/services/selectorPrinting.js +1 -2
- package/package.json +8 -8
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
'polygon()': 'Defines a polygon.'
|
|
129
129
|
};
|
|
130
130
|
exports.units = {
|
|
131
|
-
'length': ['cap', 'ch', 'cm', 'cqb', 'cqh', 'cqi', 'cqmax', 'cqmin', 'cqw', 'dvb', 'dvh', 'dvi', 'dvw', 'em', 'ex', 'ic', 'in', 'lh', 'lvb', 'lvh', 'lvi', 'lvw', 'mm', 'pc', 'pt', 'px', 'q', 'rem', 'svb', 'svh', 'svi', 'svw', 'vb', 'vh', 'vi', 'vmax', 'vmin', 'vw'],
|
|
131
|
+
'length': ['cap', 'ch', 'cm', 'cqb', 'cqh', 'cqi', 'cqmax', 'cqmin', 'cqw', 'dvb', 'dvh', 'dvi', 'dvw', 'em', 'ex', 'ic', 'in', 'lh', 'lvb', 'lvh', 'lvi', 'lvw', 'mm', 'pc', 'pt', 'px', 'q', 'rcap', 'rch', 'rem', 'rex', 'ric', 'rlh', 'svb', 'svh', 'svi', 'svw', 'vb', 'vh', 'vi', 'vmax', 'vmin', 'vw'],
|
|
132
132
|
'angle': ['deg', 'rad', 'grad', 'turn'],
|
|
133
133
|
'time': ['ms', 's'],
|
|
134
134
|
'frequency': ['Hz', 'kHz'],
|
|
@@ -13,16 +13,133 @@
|
|
|
13
13
|
})(function (require, exports) {
|
|
14
14
|
"use strict";
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.getColorValue = exports.hwbFromColor = exports.colorFromHWB = exports.hslFromColor = exports.colorFromHSL = exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = exports.isColorValue = exports.isColorConstructor = exports.colorKeywords = exports.colors = exports.colorFunctions = void 0;
|
|
16
|
+
exports.getColorValue = exports.hwbFromColor = exports.colorFromHWB = exports.hslFromColor = exports.colorFromHSL = exports.colorFrom256RGB = exports.colorFromHex = exports.hexDigit = exports.isColorValue = exports.isColorString = exports.isColorConstructor = exports.colorKeywords = exports.colors = exports.colorFunctions = void 0;
|
|
17
17
|
const nodes = require("../parser/cssNodes");
|
|
18
18
|
const l10n = require("@vscode/l10n");
|
|
19
|
+
const hexColorRegExp = /(^#([0-9A-F]{3}){1,2}$)|(^#([0-9A-F]{4}){1,2}$)/i;
|
|
19
20
|
exports.colorFunctions = [
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
{
|
|
22
|
+
label: 'rgb',
|
|
23
|
+
func: 'rgb($red, $green, $blue)',
|
|
24
|
+
insertText: 'rgb(${1:red}, ${2:green}, ${3:blue})',
|
|
25
|
+
desc: l10n.t('Creates a Color from red, green, and blue values.')
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
label: 'rgba',
|
|
29
|
+
func: 'rgba($red, $green, $blue, $alpha)',
|
|
30
|
+
insertText: 'rgba(${1:red}, ${2:green}, ${3:blue}, ${4:alpha})',
|
|
31
|
+
desc: l10n.t('Creates a Color from red, green, blue, and alpha values.')
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
label: 'rgb relative',
|
|
35
|
+
func: 'rgb(from $color $red $green $blue)',
|
|
36
|
+
insertText: 'rgb(from ${1:color} ${2:r} ${3:g} ${4:b})',
|
|
37
|
+
desc: l10n.t('Creates a Color from the red, green, and blue values of another Color.')
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: 'hsl',
|
|
41
|
+
func: 'hsl($hue, $saturation, $lightness)',
|
|
42
|
+
insertText: 'hsl(${1:hue}, ${2:saturation}, ${3:lightness})',
|
|
43
|
+
desc: l10n.t('Creates a Color from hue, saturation, and lightness values.')
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
label: 'hsla',
|
|
47
|
+
func: 'hsla($hue, $saturation, $lightness, $alpha)',
|
|
48
|
+
insertText: 'hsla(${1:hue}, ${2:saturation}, ${3:lightness}, ${4:alpha})',
|
|
49
|
+
desc: l10n.t('Creates a Color from hue, saturation, lightness, and alpha values.')
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
label: 'hsl relative',
|
|
53
|
+
func: 'hsl(from $color $hue $saturation $lightness)',
|
|
54
|
+
insertText: 'hsl(from ${1:color} ${2:h} ${3:s} ${4:l})',
|
|
55
|
+
desc: l10n.t('Creates a Color from the hue, saturation, and lightness values of another Color.')
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
label: 'hwb',
|
|
59
|
+
func: 'hwb($hue $white $black)',
|
|
60
|
+
insertText: 'hwb(${1:hue} ${2:white} ${3:black})',
|
|
61
|
+
desc: l10n.t('Creates a Color from hue, white, and black values.')
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
label: 'hwb relative',
|
|
65
|
+
func: 'hwb(from $color $hue $white $black)',
|
|
66
|
+
insertText: 'hwb(from ${1:color} ${2:h} ${3:w} ${4:b})',
|
|
67
|
+
desc: l10n.t('Creates a Color from the hue, white, and black values of another Color.')
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: 'lab',
|
|
71
|
+
func: 'lab($lightness $a $b)',
|
|
72
|
+
insertText: 'lab(${1:lightness} ${2:a} ${3:b})',
|
|
73
|
+
desc: l10n.t('Creates a Color from lightness, a, and b values.')
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
label: 'lab relative',
|
|
77
|
+
func: 'lab(from $color $lightness $a $b)',
|
|
78
|
+
insertText: 'lab(from ${1:color} ${2:l} ${3:a} ${4:b})',
|
|
79
|
+
desc: l10n.t('Creates a Color from the lightness, a, and b values of another Color.')
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: 'oklab',
|
|
83
|
+
func: 'oklab($lightness $a $b)',
|
|
84
|
+
insertText: 'oklab(${1:lightness} ${2:a} ${3:b})',
|
|
85
|
+
desc: l10n.t('Creates a Color from lightness, a, and b values.')
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
label: 'oklab relative',
|
|
89
|
+
func: 'oklab(from $color $lightness $a $b)',
|
|
90
|
+
insertText: 'oklab(from ${1:color} ${2:l} ${3:a} ${4:b})',
|
|
91
|
+
desc: l10n.t('Creates a Color from the lightness, a, and b values of another Color.')
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: 'lch',
|
|
95
|
+
func: 'lch($lightness $chroma $hue)',
|
|
96
|
+
insertText: 'lch(${1:lightness} ${2:chroma} ${3:hue})',
|
|
97
|
+
desc: l10n.t('Creates a Color from lightness, chroma, and hue values.')
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
label: 'lch relative',
|
|
101
|
+
func: 'lch(from $color $lightness $chroma $hue)',
|
|
102
|
+
insertText: 'lch(from ${1:color} ${2:l} ${3:c} ${4:h})',
|
|
103
|
+
desc: l10n.t('Creates a Color from the lightness, chroma, and hue values of another Color.')
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
label: 'oklch',
|
|
107
|
+
func: 'oklch($lightness $chroma $hue)',
|
|
108
|
+
insertText: 'oklch(${1:lightness} ${2:chroma} ${3:hue})',
|
|
109
|
+
desc: l10n.t('Creates a Color from lightness, chroma, and hue values.')
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
label: 'oklch relative',
|
|
113
|
+
func: 'oklch(from $color $lightness $chroma $hue)',
|
|
114
|
+
insertText: 'oklch(from ${1:color} ${2:l} ${3:c} ${4:h})',
|
|
115
|
+
desc: l10n.t('Creates a Color from the lightness, chroma, and hue values of another Color.')
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
label: 'color',
|
|
119
|
+
func: 'color($color-space $red $green $blue)',
|
|
120
|
+
insertText: 'color(${1|srgb,srgb-linear,display-p3,a98-rgb,prophoto-rgb,rec2020,xyx,xyz-d50,xyz-d65|} ${2:red} ${3:green} ${4:blue})',
|
|
121
|
+
desc: l10n.t('Creates a Color in a specific color space from red, green, and blue values.')
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
label: 'color relative',
|
|
125
|
+
func: 'color(from $color $color-space $red $green $blue)',
|
|
126
|
+
insertText: 'color(from ${1:color} ${2|srgb,srgb-linear,display-p3,a98-rgb,prophoto-rgb,rec2020,xyx,xyz-d50,xyz-d65|} ${3:r} ${4:g} ${5:b})',
|
|
127
|
+
desc: l10n.t('Creates a Color in a specific color space from the red, green, and blue values of another Color.')
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
label: 'color-mix',
|
|
131
|
+
func: 'color-mix(in $color-space, $color $percentage, $color $percentage)',
|
|
132
|
+
insertText: 'color-mix(in ${1|srgb,srgb-linear,lab,oklab,xyz,xyz-d50,xyz-d65|}, ${3:color} ${4:percentage}, ${5:color} ${6:percentage})',
|
|
133
|
+
desc: l10n.t('Mix two colors together in a rectangular color space.')
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
label: 'color-mix hue',
|
|
137
|
+
func: 'color-mix(in $color-space $interpolation-method hue, $color $percentage, $color $percentage)',
|
|
138
|
+
insertText: 'color-mix(in ${1|hsl,hwb,lch,oklch|} ${2|shorter hue,longer hue,increasing hue,decreasing hue|}, ${3:color} ${4:percentage}, ${5:color} ${6:percentage})',
|
|
139
|
+
desc: l10n.t('Mix two colors together in a polar color space.')
|
|
140
|
+
},
|
|
25
141
|
];
|
|
142
|
+
const colorFunctionNameRegExp = /^(rgb|rgba|hsl|hsla|hwb)$/i;
|
|
26
143
|
exports.colors = {
|
|
27
144
|
aliceblue: '#f0f8ff',
|
|
28
145
|
antiquewhite: '#faebd7',
|
|
@@ -173,10 +290,12 @@
|
|
|
173
290
|
yellow: '#ffff00',
|
|
174
291
|
yellowgreen: '#9acd32'
|
|
175
292
|
};
|
|
293
|
+
const colorsRegExp = new RegExp(`^(${Object.keys(exports.colors).join('|')})$`, "i");
|
|
176
294
|
exports.colorKeywords = {
|
|
177
295
|
'currentColor': 'The value of the \'color\' property. The computed value of the \'currentColor\' keyword is the computed value of the \'color\' property. If the \'currentColor\' keyword is set on the \'color\' property itself, it is treated as \'color:inherit\' at parse time.',
|
|
178
296
|
'transparent': 'Fully transparent. This keyword can be considered a shorthand for rgba(0,0,0,0) which is its computed value.',
|
|
179
297
|
};
|
|
298
|
+
const colorKeywordsRegExp = new RegExp(`^(${Object.keys(exports.colorKeywords).join('|')})$`, "i");
|
|
180
299
|
function getNumericValue(node, factor) {
|
|
181
300
|
const val = node.getText();
|
|
182
301
|
const m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(%?)$/);
|
|
@@ -217,9 +336,13 @@
|
|
|
217
336
|
if (!name) {
|
|
218
337
|
return false;
|
|
219
338
|
}
|
|
220
|
-
return
|
|
339
|
+
return colorFunctionNameRegExp.test(name);
|
|
221
340
|
}
|
|
222
341
|
exports.isColorConstructor = isColorConstructor;
|
|
342
|
+
function isColorString(s) {
|
|
343
|
+
return hexColorRegExp.test(s) || colorsRegExp.test(s) || colorKeywordsRegExp.test(s);
|
|
344
|
+
}
|
|
345
|
+
exports.isColorString = isColorString;
|
|
223
346
|
/**
|
|
224
347
|
* Returns true if the node is a color value - either
|
|
225
348
|
* defined a hex number, as rgb or rgba function, or
|
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
|| this._parseFontFace()
|
|
283
283
|
|| this._parseKeyframe()
|
|
284
284
|
|| this._parseSupports(isNested)
|
|
285
|
-
|| this._parseLayer()
|
|
285
|
+
|| this._parseLayer(isNested)
|
|
286
286
|
|| this._parsePropertyAtRule()
|
|
287
287
|
|| this._parseViewPort()
|
|
288
288
|
|| this._parseNamespace()
|
|
@@ -317,14 +317,20 @@
|
|
|
317
317
|
return this._parseBody(node, this._parseRuleSetDeclaration.bind(this));
|
|
318
318
|
}
|
|
319
319
|
_parseRuleSetDeclarationAtStatement() {
|
|
320
|
-
return this.
|
|
320
|
+
return this._parseMedia(true)
|
|
321
|
+
|| this._parseSupports(true)
|
|
322
|
+
|| this._parseLayer(true)
|
|
323
|
+
|| this._parseUnknownAtRule();
|
|
321
324
|
}
|
|
322
325
|
_parseRuleSetDeclaration() {
|
|
323
326
|
// https://www.w3.org/TR/css-syntax-3/#consume-a-list-of-declarations
|
|
324
327
|
if (this.peek(cssScanner_1.TokenType.AtKeyword)) {
|
|
325
328
|
return this._parseRuleSetDeclarationAtStatement();
|
|
326
329
|
}
|
|
327
|
-
|
|
330
|
+
if (!this.peek(cssScanner_1.TokenType.Ident)) {
|
|
331
|
+
return this._parseRuleset(true);
|
|
332
|
+
}
|
|
333
|
+
return this._tryParseRuleset(true) || this._parseDeclaration();
|
|
328
334
|
}
|
|
329
335
|
_needsSemicolonAfter(node) {
|
|
330
336
|
switch (node.type) {
|
|
@@ -406,9 +412,9 @@
|
|
|
406
412
|
return hasContent ? this.finish(node) : null;
|
|
407
413
|
}
|
|
408
414
|
_parseDeclaration(stopTokens) {
|
|
409
|
-
const
|
|
410
|
-
if (
|
|
411
|
-
return
|
|
415
|
+
const customProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
|
|
416
|
+
if (customProperty) {
|
|
417
|
+
return customProperty;
|
|
412
418
|
}
|
|
413
419
|
const node = this.create(nodes.Declaration);
|
|
414
420
|
if (!node.setProperty(this._parseProperty())) {
|
|
@@ -743,7 +749,7 @@
|
|
|
743
749
|
}
|
|
744
750
|
return this._parseBody(node, this._parseDeclaration.bind(this));
|
|
745
751
|
}
|
|
746
|
-
_parseLayer() {
|
|
752
|
+
_parseLayer(isNested = false) {
|
|
747
753
|
// @layer layer-name {rules}
|
|
748
754
|
// @layer layer-name;
|
|
749
755
|
// @layer layer-name, layer-name, layer-name;
|
|
@@ -758,13 +764,22 @@
|
|
|
758
764
|
node.setNames(names);
|
|
759
765
|
}
|
|
760
766
|
if ((!names || names.getChildren().length === 1) && this.peek(cssScanner_1.TokenType.CurlyL)) {
|
|
761
|
-
return this._parseBody(node, this.
|
|
767
|
+
return this._parseBody(node, this._parseLayerDeclaration.bind(this, isNested));
|
|
762
768
|
}
|
|
763
769
|
if (!this.accept(cssScanner_1.TokenType.SemiColon)) {
|
|
764
770
|
return this.finish(node, cssErrors_1.ParseError.SemiColonExpected);
|
|
765
771
|
}
|
|
766
772
|
return this.finish(node);
|
|
767
773
|
}
|
|
774
|
+
_parseLayerDeclaration(isNested = false) {
|
|
775
|
+
if (isNested) {
|
|
776
|
+
// if nested, the body can contain rulesets, but also declarations
|
|
777
|
+
return this._tryParseRuleset(true)
|
|
778
|
+
|| this._tryToParseDeclaration()
|
|
779
|
+
|| this._parseStylesheetStatement(true);
|
|
780
|
+
}
|
|
781
|
+
return this._parseStylesheetStatement(false);
|
|
782
|
+
}
|
|
768
783
|
_parseLayerNameList() {
|
|
769
784
|
const node = this.createNode(nodes.NodeType.LayerNameList);
|
|
770
785
|
if (!node.addChild(this._parseLayerName())) {
|
|
@@ -1262,7 +1277,7 @@
|
|
|
1262
1277
|
// : element_name [ HASH | class | attrib | pseudo ]* | [ HASH | class | attrib | pseudo ]+ ;
|
|
1263
1278
|
const node = this.create(nodes.SimpleSelector);
|
|
1264
1279
|
let c = 0;
|
|
1265
|
-
if (node.addChild(this._parseElementName())) {
|
|
1280
|
+
if (node.addChild(this._parseElementName() || this._parseNestingSelector())) {
|
|
1266
1281
|
c++;
|
|
1267
1282
|
}
|
|
1268
1283
|
while ((c === 0 || !this.hasWhitespace()) && node.addChild(this._parseSimpleSelectorBody())) {
|
|
@@ -1270,6 +1285,14 @@
|
|
|
1270
1285
|
}
|
|
1271
1286
|
return c > 0 ? this.finish(node) : null;
|
|
1272
1287
|
}
|
|
1288
|
+
_parseNestingSelector() {
|
|
1289
|
+
if (this.peekDelim('&')) {
|
|
1290
|
+
const node = this.createNode(nodes.NodeType.SelectorCombinator);
|
|
1291
|
+
this.consumeToken();
|
|
1292
|
+
return this.finish(node);
|
|
1293
|
+
}
|
|
1294
|
+
return null;
|
|
1295
|
+
}
|
|
1273
1296
|
_parseSimpleSelectorBody() {
|
|
1274
1297
|
return this._parsePseudo() || this._parseHash() || this._parseClass() || this._parseAttrib();
|
|
1275
1298
|
}
|
|
@@ -287,14 +287,14 @@
|
|
|
287
287
|
|| this._parsePropertyAtRule() // @property
|
|
288
288
|
|| this._parseDetachedRuleSetMixin() // less detached ruleset mixin
|
|
289
289
|
|| this._parseVariableDeclaration() // Variable declarations
|
|
290
|
-
||
|
|
290
|
+
|| this._parseRuleSetDeclarationAtStatement();
|
|
291
291
|
}
|
|
292
292
|
return this._tryParseMixinDeclaration()
|
|
293
293
|
|| this._tryParseRuleset(true) // nested ruleset
|
|
294
294
|
|| this._tryParseMixinReference() // less mixin reference
|
|
295
295
|
|| this._parseFunction()
|
|
296
296
|
|| this._parseExtend() // less extend declaration
|
|
297
|
-
||
|
|
297
|
+
|| this._parseDeclaration(); // try css ruleset declaration as the last option
|
|
298
298
|
}
|
|
299
299
|
_parseKeyframeIdent() {
|
|
300
300
|
return this._parseIdent([nodes.ReferenceType.Keyframe]) || this._parseVariable();
|
|
@@ -303,9 +303,9 @@
|
|
|
303
303
|
return this._parseDetachedRuleSetMixin() // less detached ruleset mixin
|
|
304
304
|
|| super._parseKeyframeSelector();
|
|
305
305
|
}
|
|
306
|
-
_parseSimpleSelectorBody() {
|
|
307
|
-
|
|
308
|
-
}
|
|
306
|
+
// public _parseSimpleSelectorBody(): nodes.Node | null {
|
|
307
|
+
// return this._parseNestingSelector() || super._parseSimpleSelectorBody();
|
|
308
|
+
// }
|
|
309
309
|
_parseSelector(isNested) {
|
|
310
310
|
// CSS Guards
|
|
311
311
|
const node = this.create(nodes.Selector);
|
|
@@ -325,7 +325,7 @@
|
|
|
325
325
|
}
|
|
326
326
|
return hasContent ? this.finish(node) : null;
|
|
327
327
|
}
|
|
328
|
-
|
|
328
|
+
_parseNestingSelector() {
|
|
329
329
|
if (this.peekDelim('&')) {
|
|
330
330
|
const node = this.createNode(nodes.NodeType.SelectorCombinator);
|
|
331
331
|
this.consumeToken();
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
_parseTermExpression() {
|
|
173
173
|
return this._parseModuleMember() ||
|
|
174
174
|
this._parseVariable() ||
|
|
175
|
-
this.
|
|
175
|
+
this._parseNestingSelector() ||
|
|
176
176
|
//this._tryParsePrio() ||
|
|
177
177
|
super._parseTermExpression();
|
|
178
178
|
}
|
|
@@ -180,7 +180,7 @@
|
|
|
180
180
|
if (this.peek(scssScanner.InterpolationFunction)) {
|
|
181
181
|
const node = this.create(nodes.Interpolation);
|
|
182
182
|
this.consumeToken();
|
|
183
|
-
if (!node.addChild(this._parseExpr()) && !this.
|
|
183
|
+
if (!node.addChild(this._parseExpr()) && !this._parseNestingSelector()) {
|
|
184
184
|
if (this.accept(cssScanner_1.TokenType.CurlyR)) {
|
|
185
185
|
return this.finish(node);
|
|
186
186
|
}
|
|
@@ -230,11 +230,11 @@
|
|
|
230
230
|
|| this._parseSupports(true) // @supports
|
|
231
231
|
|| this._parseLayer() // @layer
|
|
232
232
|
|| this._parsePropertyAtRule() // @property
|
|
233
|
-
||
|
|
233
|
+
|| this._parseRuleSetDeclarationAtStatement();
|
|
234
234
|
}
|
|
235
235
|
return this._parseVariableDeclaration() // variable declaration
|
|
236
236
|
|| this._tryParseRuleset(true) // nested ruleset
|
|
237
|
-
||
|
|
237
|
+
|| this._parseDeclaration(); // try css ruleset declaration as last so in the error case, the ast will contain a declaration
|
|
238
238
|
}
|
|
239
239
|
_parseDeclaration(stopTokens) {
|
|
240
240
|
const custonProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
|
|
@@ -293,9 +293,9 @@
|
|
|
293
293
|
return null;
|
|
294
294
|
}
|
|
295
295
|
_parseSimpleSelectorBody() {
|
|
296
|
-
return this.
|
|
296
|
+
return this._parseSelectorPlaceholder() || super._parseSimpleSelectorBody();
|
|
297
297
|
}
|
|
298
|
-
|
|
298
|
+
_parseNestingSelector() {
|
|
299
299
|
if (this.peekDelim('&')) {
|
|
300
300
|
const node = this.createNode(nodes.NodeType.SelectorCombinator);
|
|
301
301
|
this.consumeToken();
|
|
@@ -415,7 +415,7 @@
|
|
|
415
415
|
kind: cssLanguageTypes_1.CompletionItemKind.Variable,
|
|
416
416
|
sortText: SortTexts.Variable
|
|
417
417
|
};
|
|
418
|
-
if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
|
|
418
|
+
if (typeof completionItem.documentation === 'string' && languageFacts.isColorString(completionItem.documentation)) {
|
|
419
419
|
completionItem.kind = cssLanguageTypes_1.CompletionItemKind.Color;
|
|
420
420
|
}
|
|
421
421
|
if (symbol.node.type === nodes.NodeType.FunctionParameter) {
|
|
@@ -440,7 +440,7 @@
|
|
|
440
440
|
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), symbol.name),
|
|
441
441
|
kind: cssLanguageTypes_1.CompletionItemKind.Variable
|
|
442
442
|
};
|
|
443
|
-
if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
|
|
443
|
+
if (typeof completionItem.documentation === 'string' && languageFacts.isColorString(completionItem.documentation)) {
|
|
444
444
|
completionItem.kind = cssLanguageTypes_1.CompletionItemKind.Color;
|
|
445
445
|
}
|
|
446
446
|
result.items.push(completionItem);
|
|
@@ -528,14 +528,11 @@
|
|
|
528
528
|
});
|
|
529
529
|
}
|
|
530
530
|
for (const p of languageFacts.colorFunctions) {
|
|
531
|
-
let tabStop = 1;
|
|
532
|
-
const replaceFunction = (_match, p1) => '${' + tabStop++ + ':' + p1 + '}';
|
|
533
|
-
const insertText = p.func.replace(/\[?\$(\w+)\]?/g, replaceFunction);
|
|
534
531
|
result.items.push({
|
|
535
|
-
label: p.
|
|
532
|
+
label: p.label,
|
|
536
533
|
detail: p.func,
|
|
537
534
|
documentation: p.desc,
|
|
538
|
-
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), insertText),
|
|
535
|
+
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(existingNode), p.insertText),
|
|
539
536
|
insertTextFormat: SnippetFormat,
|
|
540
537
|
kind: cssLanguageTypes_1.CompletionItemKind.Function
|
|
541
538
|
});
|
|
@@ -1069,8 +1066,4 @@
|
|
|
1069
1066
|
}
|
|
1070
1067
|
return text.substring(i + 1, offset);
|
|
1071
1068
|
}
|
|
1072
|
-
function isColorString(s) {
|
|
1073
|
-
// From https://stackoverflow.com/questions/8027423/how-to-check-if-a-string-is-a-valid-hex-color-representation/8027444
|
|
1074
|
-
return (s.toLowerCase() in languageFacts.colors) || /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(s);
|
|
1075
|
-
}
|
|
1076
1069
|
});
|
|
@@ -184,7 +184,7 @@
|
|
|
184
184
|
const addSymbolInformation = (name, kind, symbolNodeOrRange) => {
|
|
185
185
|
const range = symbolNodeOrRange instanceof nodes.Node ? getRange(symbolNodeOrRange, document) : symbolNodeOrRange;
|
|
186
186
|
const entry = {
|
|
187
|
-
name,
|
|
187
|
+
name: name || l10n.t('<undefined>'),
|
|
188
188
|
kind,
|
|
189
189
|
location: cssLanguageTypes_1.Location.create(document.uri, range)
|
|
190
190
|
};
|
|
@@ -198,9 +198,12 @@
|
|
|
198
198
|
const parents = [];
|
|
199
199
|
const addDocumentSymbol = (name, kind, symbolNodeOrRange, nameNodeOrRange, bodyNode) => {
|
|
200
200
|
const range = symbolNodeOrRange instanceof nodes.Node ? getRange(symbolNodeOrRange, document) : symbolNodeOrRange;
|
|
201
|
-
|
|
201
|
+
let selectionRange = nameNodeOrRange instanceof nodes.Node ? getRange(nameNodeOrRange, document) : nameNodeOrRange;
|
|
202
|
+
if (!selectionRange || !containsRange(range, selectionRange)) {
|
|
203
|
+
selectionRange = cssLanguageTypes_1.Range.create(range.start, range.start);
|
|
204
|
+
}
|
|
202
205
|
const entry = {
|
|
203
|
-
name,
|
|
206
|
+
name: name || l10n.t('<undefined>'),
|
|
204
207
|
kind,
|
|
205
208
|
range,
|
|
206
209
|
selectionRange
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
return super.getCompletionsForDeclarationProperty(declaration, result);
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
exports.LESSCompletion = LESSCompletion;
|
|
59
58
|
LESSCompletion.builtInProposals = [
|
|
60
59
|
// Boolean functions
|
|
61
60
|
{
|
|
@@ -387,4 +386,5 @@
|
|
|
387
386
|
'example': 'negation(@color1, @color2);'
|
|
388
387
|
}
|
|
389
388
|
];
|
|
389
|
+
exports.LESSCompletion = LESSCompletion;
|
|
390
390
|
});
|
package/lib/umd/services/lint.js
CHANGED
|
@@ -569,9 +569,9 @@
|
|
|
569
569
|
return true;
|
|
570
570
|
}
|
|
571
571
|
}
|
|
572
|
-
exports.LintVisitor = LintVisitor;
|
|
573
572
|
LintVisitor.prefixes = [
|
|
574
573
|
'-ms-', '-moz-', '-o-', '-webkit-', // Quite common
|
|
575
574
|
// '-xv-', '-atsc-', '-wap-', '-khtml-', 'mso-', 'prince-', '-ah-', '-hp-', '-ro-', '-rim-', '-tc-' // Quite un-common
|
|
576
575
|
];
|
|
576
|
+
exports.LintVisitor = LintVisitor;
|
|
577
577
|
});
|
|
@@ -118,7 +118,6 @@
|
|
|
118
118
|
return result;
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
|
-
exports.SCSSCompletion = SCSSCompletion;
|
|
122
121
|
SCSSCompletion.variableDefaults = {
|
|
123
122
|
'$red': '1',
|
|
124
123
|
'$green': '2',
|
|
@@ -345,6 +344,7 @@
|
|
|
345
344
|
references: [{ name: sassDocumentationName, url: 'https://sass-lang.com/documentation/modules/meta' }]
|
|
346
345
|
},
|
|
347
346
|
];
|
|
347
|
+
exports.SCSSCompletion = SCSSCompletion;
|
|
348
348
|
/**
|
|
349
349
|
* Todo @Pine: Remove this and do it through custom data
|
|
350
350
|
*/
|
|
@@ -417,8 +417,7 @@
|
|
|
417
417
|
return specificity;
|
|
418
418
|
};
|
|
419
419
|
const specificity = calculateScore(node);
|
|
420
|
-
|
|
421
|
-
return l10n.t("[Selector Specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity): ({0}, {1}, {2})", specificity.id, specificity.attr, specificity.tag);
|
|
420
|
+
return `[${l10n.t("Selector Specificity")}](https://developer.mozilla.org/docs/Web/CSS/Specificity): (${specificity.id}, ${specificity.attr}, ${specificity.tag})`;
|
|
422
421
|
}
|
|
423
422
|
}
|
|
424
423
|
exports.SelectorPrinting = SelectorPrinting;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vscode-css-languageservice",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.6",
|
|
4
4
|
"description": "Language service for CSS, LESS and SCSS",
|
|
5
5
|
"main": "./lib/umd/cssLanguageService.js",
|
|
6
6
|
"typings": "./lib/umd/cssLanguageService",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/mocha": "^10.0.1",
|
|
19
19
|
"@types/node": "16.x",
|
|
20
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
21
|
-
"@typescript-eslint/parser": "^5.
|
|
22
|
-
"@vscode/web-custom-data": "^0.4.
|
|
23
|
-
"eslint": "^8.
|
|
20
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
21
|
+
"@typescript-eslint/parser": "^5.59.7",
|
|
22
|
+
"@vscode/web-custom-data": "^0.4.6",
|
|
23
|
+
"eslint": "^8.41.0",
|
|
24
24
|
"js-beautify": "^1.14.7",
|
|
25
25
|
"mocha": "^10.2.0",
|
|
26
|
-
"rimraf": "^
|
|
26
|
+
"rimraf": "^5.0.1",
|
|
27
27
|
"source-map-support": "^0.5.21",
|
|
28
|
-
"typescript": "^
|
|
28
|
+
"typescript": "^5.0.4"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@vscode/l10n": "^0.0.
|
|
31
|
+
"@vscode/l10n": "^0.0.14",
|
|
32
32
|
"vscode-languageserver-textdocument": "^1.0.8",
|
|
33
33
|
"vscode-languageserver-types": "^3.17.3",
|
|
34
34
|
"vscode-uri": "^3.0.7"
|