vscode-css-languageservice 5.1.6 → 5.1.10
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/lib/esm/cssLanguageService.js +2 -2
- package/lib/esm/data/webCustomData.js +202 -124
- package/lib/esm/languageFacts/colors.js +30 -2
- package/lib/esm/languageFacts/entry.js +11 -6
- package/lib/esm/parser/cssNodes.js +94 -46
- package/lib/esm/parser/cssParser.js +108 -28
- package/lib/esm/parser/lessParser.js +2 -2
- package/lib/esm/parser/scssParser.js +2 -2
- package/lib/esm/services/cssCompletion.js +45 -31
- package/lib/esm/services/cssNavigation.js +39 -12
- package/lib/esm/services/lint.js +1 -1
- package/lib/esm/services/scssCompletion.js +2 -2
- package/lib/esm/services/scssNavigation.js +1 -1
- package/lib/esm/services/selectorPrinting.js +5 -5
- package/lib/umd/cssLanguageService.js +2 -2
- package/lib/umd/data/webCustomData.js +202 -124
- package/lib/umd/languageFacts/colors.js +30 -2
- package/lib/umd/languageFacts/entry.js +12 -7
- package/lib/umd/parser/cssNodes.js +95 -47
- package/lib/umd/parser/cssParser.js +108 -28
- package/lib/umd/parser/lessParser.js +2 -2
- package/lib/umd/parser/scssParser.js +2 -2
- package/lib/umd/services/cssCompletion.js +45 -31
- package/lib/umd/services/cssNavigation.js +39 -12
- package/lib/umd/services/lint.js +1 -1
- package/lib/umd/services/scssCompletion.js +2 -2
- package/lib/umd/services/scssNavigation.js +1 -1
- package/lib/umd/services/selectorPrinting.js +5 -5
- package/package.json +9 -9
|
@@ -193,9 +193,22 @@
|
|
|
193
193
|
}
|
|
194
194
|
function getAngle(node) {
|
|
195
195
|
var val = node.getText();
|
|
196
|
-
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg)?$/);
|
|
196
|
+
var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg|rad|grad|turn)?$/);
|
|
197
197
|
if (m) {
|
|
198
|
-
|
|
198
|
+
switch (m[2]) {
|
|
199
|
+
case 'deg':
|
|
200
|
+
return parseFloat(val) % 360;
|
|
201
|
+
case 'rad':
|
|
202
|
+
return (parseFloat(val) * 180 / Math.PI) % 360;
|
|
203
|
+
case 'grad':
|
|
204
|
+
return (parseFloat(val) * 0.9) % 360;
|
|
205
|
+
case 'turn':
|
|
206
|
+
return (parseFloat(val) * 360) % 360;
|
|
207
|
+
default:
|
|
208
|
+
if ('undefined' === typeof m[2]) {
|
|
209
|
+
return parseFloat(val) % 360;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
199
212
|
}
|
|
200
213
|
throw new Error();
|
|
201
214
|
}
|
|
@@ -373,6 +386,21 @@
|
|
|
373
386
|
var functionNode = node;
|
|
374
387
|
var name = functionNode.getName();
|
|
375
388
|
var colorValues = functionNode.getArguments().getChildren();
|
|
389
|
+
if (colorValues.length === 1) {
|
|
390
|
+
var functionArg = colorValues[0].getChildren();
|
|
391
|
+
if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
|
|
392
|
+
colorValues = functionArg[0].getChildren();
|
|
393
|
+
if (colorValues.length === 3) {
|
|
394
|
+
var lastValue = colorValues[2];
|
|
395
|
+
if (lastValue instanceof nodes.BinaryExpression) {
|
|
396
|
+
var left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
|
|
397
|
+
if (left && right && operator && operator.matches('/')) {
|
|
398
|
+
colorValues = [colorValues[0], colorValues[1], left, right];
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
376
404
|
if (!name || colorValues.length < 3 || colorValues.length > 4) {
|
|
377
405
|
return null;
|
|
378
406
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
if (v !== undefined) module.exports = v;
|
|
5
5
|
}
|
|
6
6
|
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
7
|
+
define(["require", "exports", "../cssLanguageTypes"], factory);
|
|
8
8
|
}
|
|
9
9
|
})(function (require, exports) {
|
|
10
10
|
/*---------------------------------------------------------------------------------------------
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.getBrowserLabel = exports.textToMarkedString = exports.getEntryDescription = exports.browserNames = void 0;
|
|
17
|
+
var cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
17
18
|
exports.browserNames = {
|
|
18
19
|
E: 'Edge',
|
|
19
20
|
FF: 'Firefox',
|
|
@@ -77,7 +78,7 @@
|
|
|
77
78
|
result += '\n(' + browserLabel + ')';
|
|
78
79
|
}
|
|
79
80
|
if ('syntax' in entry) {
|
|
80
|
-
result += "\n\nSyntax: "
|
|
81
|
+
result += "\n\nSyntax: ".concat(entry.syntax);
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
84
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -85,7 +86,7 @@
|
|
|
85
86
|
result += '\n\n';
|
|
86
87
|
}
|
|
87
88
|
result += entry.references.map(function (r) {
|
|
88
|
-
return r.name
|
|
89
|
+
return "".concat(r.name, ": ").concat(r.url);
|
|
89
90
|
}).join(' | ');
|
|
90
91
|
}
|
|
91
92
|
return result;
|
|
@@ -99,14 +100,18 @@
|
|
|
99
100
|
if (entry.status) {
|
|
100
101
|
result += getEntryStatus(entry.status);
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
if (typeof entry.description === 'string') {
|
|
104
|
+
result += textToMarkedString(entry.description);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
result += entry.description.kind === cssLanguageTypes_1.MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
|
|
108
|
+
}
|
|
104
109
|
var browserLabel = getBrowserLabel(entry.browsers);
|
|
105
110
|
if (browserLabel) {
|
|
106
111
|
result += '\n\n(' + textToMarkedString(browserLabel) + ')';
|
|
107
112
|
}
|
|
108
113
|
if ('syntax' in entry && entry.syntax) {
|
|
109
|
-
result += "\n\nSyntax: "
|
|
114
|
+
result += "\n\nSyntax: ".concat(textToMarkedString(entry.syntax));
|
|
110
115
|
}
|
|
111
116
|
}
|
|
112
117
|
if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
|
|
@@ -114,7 +119,7 @@
|
|
|
114
119
|
result += '\n\n';
|
|
115
120
|
}
|
|
116
121
|
result += entry.references.map(function (r) {
|
|
117
|
-
return "["
|
|
122
|
+
return "[".concat(r.name, "](").concat(r.url, ")");
|
|
118
123
|
}).join(' | ');
|
|
119
124
|
}
|
|
120
125
|
return result;
|
|
@@ -28,7 +28,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
28
28
|
*--------------------------------------------------------------------------------------------*/
|
|
29
29
|
'use strict';
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.ParseErrorCollector = exports.Marker = exports.Level = exports.Module = exports.GuardCondition = exports.LessGuard = exports.ListEntry = exports.UnknownAtRule = exports.MixinDeclaration = exports.MixinReference = exports.MixinContentDeclaration = exports.MixinContentReference = exports.ExtendsReference = exports.Variable = exports.Interpolation = exports.VariableDeclaration = exports.NumericValue = exports.HexColorValue = exports.Operator = exports.AttributeSelector = exports.Term = exports.BinaryExpression = exports.Expression = exports.PageBoxMarginBox = exports.Page = exports.SupportsCondition = exports.MediaQuery = exports.Medialist = exports.Document = exports.Supports = exports.Media = exports.Namespace = exports.ForwardVisibility = exports.Forward = exports.ModuleConfiguration = exports.Use = exports.Import = exports.KeyframeSelector = exports.Keyframe = exports.NestedProperties = exports.FontFace = exports.ViewPort = exports.FunctionDeclaration = exports.ElseStatement = exports.WhileStatement = exports.EachStatement = exports.ForStatement = exports.IfStatement = exports.FunctionArgument = exports.FunctionParameter = exports.Function = exports.Invocation = exports.Property = exports.CustomPropertyDeclaration = exports.Declaration = exports.CustomPropertySet = exports.AbstractDeclaration = exports.AtApplyRule = exports.SimpleSelector = exports.Selector = exports.RuleSet = exports.BodyDeclaration = exports.Declarations = exports.Stylesheet = exports.Identifier = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0;
|
|
31
|
+
exports.ParseErrorCollector = exports.Marker = exports.Level = exports.Module = exports.GuardCondition = exports.LessGuard = exports.ListEntry = exports.UnknownAtRule = exports.MixinDeclaration = exports.MixinReference = exports.MixinContentDeclaration = exports.MixinContentReference = exports.ExtendsReference = exports.Variable = exports.Interpolation = exports.VariableDeclaration = exports.NumericValue = exports.RatioValue = exports.HexColorValue = exports.Operator = exports.AttributeSelector = exports.Term = exports.BinaryExpression = exports.Expression = exports.PageBoxMarginBox = exports.Page = exports.SupportsCondition = exports.MediaFeature = exports.MediaCondition = exports.MediaQuery = exports.Medialist = exports.Document = exports.Supports = exports.Media = exports.Namespace = exports.ForwardVisibility = exports.Forward = exports.ModuleConfiguration = exports.Use = exports.Import = exports.KeyframeSelector = exports.Keyframe = exports.NestedProperties = exports.FontFace = exports.ViewPort = exports.FunctionDeclaration = exports.ElseStatement = exports.WhileStatement = exports.EachStatement = exports.ForStatement = exports.IfStatement = exports.FunctionArgument = exports.FunctionParameter = exports.Function = exports.Invocation = exports.Property = exports.CustomPropertyDeclaration = exports.Declaration = exports.CustomPropertySet = exports.AbstractDeclaration = exports.AtApplyRule = exports.SimpleSelector = exports.Selector = exports.RuleSet = exports.BodyDeclaration = exports.Declarations = exports.Stylesheet = exports.Identifier = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0;
|
|
32
32
|
var strings_1 = require("../utils/strings");
|
|
33
33
|
/// <summary>
|
|
34
34
|
/// Nodes for the css 2.1 specification. See for reference:
|
|
@@ -69,52 +69,55 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
69
69
|
NodeType[NodeType["Function"] = 30] = "Function";
|
|
70
70
|
NodeType[NodeType["NumericValue"] = 31] = "NumericValue";
|
|
71
71
|
NodeType[NodeType["HexColorValue"] = 32] = "HexColorValue";
|
|
72
|
-
NodeType[NodeType["
|
|
73
|
-
NodeType[NodeType["
|
|
74
|
-
NodeType[NodeType["
|
|
75
|
-
NodeType[NodeType["
|
|
76
|
-
NodeType[NodeType["
|
|
77
|
-
NodeType[NodeType["
|
|
78
|
-
NodeType[NodeType["
|
|
79
|
-
NodeType[NodeType["
|
|
80
|
-
NodeType[NodeType["
|
|
81
|
-
NodeType[NodeType["
|
|
82
|
-
NodeType[NodeType["
|
|
83
|
-
NodeType[NodeType["
|
|
84
|
-
NodeType[NodeType["
|
|
85
|
-
NodeType[NodeType["
|
|
86
|
-
NodeType[NodeType["
|
|
87
|
-
NodeType[NodeType["
|
|
88
|
-
NodeType[NodeType["
|
|
89
|
-
NodeType[NodeType["
|
|
90
|
-
NodeType[NodeType["
|
|
91
|
-
NodeType[NodeType["
|
|
92
|
-
NodeType[NodeType["
|
|
93
|
-
NodeType[NodeType["
|
|
94
|
-
NodeType[NodeType["
|
|
95
|
-
NodeType[NodeType["
|
|
96
|
-
NodeType[NodeType["
|
|
97
|
-
NodeType[NodeType["
|
|
98
|
-
NodeType[NodeType["
|
|
99
|
-
NodeType[NodeType["
|
|
100
|
-
NodeType[NodeType["
|
|
101
|
-
NodeType[NodeType["
|
|
102
|
-
NodeType[NodeType["
|
|
103
|
-
NodeType[NodeType["
|
|
104
|
-
NodeType[NodeType["
|
|
105
|
-
NodeType[NodeType["
|
|
106
|
-
NodeType[NodeType["
|
|
107
|
-
NodeType[NodeType["
|
|
108
|
-
NodeType[NodeType["
|
|
109
|
-
NodeType[NodeType["
|
|
110
|
-
NodeType[NodeType["
|
|
111
|
-
NodeType[NodeType["
|
|
112
|
-
NodeType[NodeType["
|
|
113
|
-
NodeType[NodeType["
|
|
114
|
-
NodeType[NodeType["
|
|
115
|
-
NodeType[NodeType["
|
|
116
|
-
NodeType[NodeType["
|
|
117
|
-
NodeType[NodeType["
|
|
72
|
+
NodeType[NodeType["RatioValue"] = 33] = "RatioValue";
|
|
73
|
+
NodeType[NodeType["MixinDeclaration"] = 34] = "MixinDeclaration";
|
|
74
|
+
NodeType[NodeType["MixinReference"] = 35] = "MixinReference";
|
|
75
|
+
NodeType[NodeType["VariableName"] = 36] = "VariableName";
|
|
76
|
+
NodeType[NodeType["VariableDeclaration"] = 37] = "VariableDeclaration";
|
|
77
|
+
NodeType[NodeType["Prio"] = 38] = "Prio";
|
|
78
|
+
NodeType[NodeType["Interpolation"] = 39] = "Interpolation";
|
|
79
|
+
NodeType[NodeType["NestedProperties"] = 40] = "NestedProperties";
|
|
80
|
+
NodeType[NodeType["ExtendsReference"] = 41] = "ExtendsReference";
|
|
81
|
+
NodeType[NodeType["SelectorPlaceholder"] = 42] = "SelectorPlaceholder";
|
|
82
|
+
NodeType[NodeType["Debug"] = 43] = "Debug";
|
|
83
|
+
NodeType[NodeType["If"] = 44] = "If";
|
|
84
|
+
NodeType[NodeType["Else"] = 45] = "Else";
|
|
85
|
+
NodeType[NodeType["For"] = 46] = "For";
|
|
86
|
+
NodeType[NodeType["Each"] = 47] = "Each";
|
|
87
|
+
NodeType[NodeType["While"] = 48] = "While";
|
|
88
|
+
NodeType[NodeType["MixinContentReference"] = 49] = "MixinContentReference";
|
|
89
|
+
NodeType[NodeType["MixinContentDeclaration"] = 50] = "MixinContentDeclaration";
|
|
90
|
+
NodeType[NodeType["Media"] = 51] = "Media";
|
|
91
|
+
NodeType[NodeType["Keyframe"] = 52] = "Keyframe";
|
|
92
|
+
NodeType[NodeType["FontFace"] = 53] = "FontFace";
|
|
93
|
+
NodeType[NodeType["Import"] = 54] = "Import";
|
|
94
|
+
NodeType[NodeType["Namespace"] = 55] = "Namespace";
|
|
95
|
+
NodeType[NodeType["Invocation"] = 56] = "Invocation";
|
|
96
|
+
NodeType[NodeType["FunctionDeclaration"] = 57] = "FunctionDeclaration";
|
|
97
|
+
NodeType[NodeType["ReturnStatement"] = 58] = "ReturnStatement";
|
|
98
|
+
NodeType[NodeType["MediaQuery"] = 59] = "MediaQuery";
|
|
99
|
+
NodeType[NodeType["MediaCondition"] = 60] = "MediaCondition";
|
|
100
|
+
NodeType[NodeType["MediaFeature"] = 61] = "MediaFeature";
|
|
101
|
+
NodeType[NodeType["FunctionParameter"] = 62] = "FunctionParameter";
|
|
102
|
+
NodeType[NodeType["FunctionArgument"] = 63] = "FunctionArgument";
|
|
103
|
+
NodeType[NodeType["KeyframeSelector"] = 64] = "KeyframeSelector";
|
|
104
|
+
NodeType[NodeType["ViewPort"] = 65] = "ViewPort";
|
|
105
|
+
NodeType[NodeType["Document"] = 66] = "Document";
|
|
106
|
+
NodeType[NodeType["AtApplyRule"] = 67] = "AtApplyRule";
|
|
107
|
+
NodeType[NodeType["CustomPropertyDeclaration"] = 68] = "CustomPropertyDeclaration";
|
|
108
|
+
NodeType[NodeType["CustomPropertySet"] = 69] = "CustomPropertySet";
|
|
109
|
+
NodeType[NodeType["ListEntry"] = 70] = "ListEntry";
|
|
110
|
+
NodeType[NodeType["Supports"] = 71] = "Supports";
|
|
111
|
+
NodeType[NodeType["SupportsCondition"] = 72] = "SupportsCondition";
|
|
112
|
+
NodeType[NodeType["NamespacePrefix"] = 73] = "NamespacePrefix";
|
|
113
|
+
NodeType[NodeType["GridLine"] = 74] = "GridLine";
|
|
114
|
+
NodeType[NodeType["Plugin"] = 75] = "Plugin";
|
|
115
|
+
NodeType[NodeType["UnknownAtRule"] = 76] = "UnknownAtRule";
|
|
116
|
+
NodeType[NodeType["Use"] = 77] = "Use";
|
|
117
|
+
NodeType[NodeType["ModuleConfiguration"] = 78] = "ModuleConfiguration";
|
|
118
|
+
NodeType[NodeType["Forward"] = 79] = "Forward";
|
|
119
|
+
NodeType[NodeType["ForwardVisibility"] = 80] = "ForwardVisibility";
|
|
120
|
+
NodeType[NodeType["Module"] = 81] = "Module";
|
|
118
121
|
})(NodeType = exports.NodeType || (exports.NodeType = {}));
|
|
119
122
|
var ReferenceType;
|
|
120
123
|
(function (ReferenceType) {
|
|
@@ -1210,6 +1213,36 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1210
1213
|
return MediaQuery;
|
|
1211
1214
|
}(Node));
|
|
1212
1215
|
exports.MediaQuery = MediaQuery;
|
|
1216
|
+
var MediaCondition = /** @class */ (function (_super) {
|
|
1217
|
+
__extends(MediaCondition, _super);
|
|
1218
|
+
function MediaCondition(offset, length) {
|
|
1219
|
+
return _super.call(this, offset, length) || this;
|
|
1220
|
+
}
|
|
1221
|
+
Object.defineProperty(MediaCondition.prototype, "type", {
|
|
1222
|
+
get: function () {
|
|
1223
|
+
return NodeType.MediaCondition;
|
|
1224
|
+
},
|
|
1225
|
+
enumerable: false,
|
|
1226
|
+
configurable: true
|
|
1227
|
+
});
|
|
1228
|
+
return MediaCondition;
|
|
1229
|
+
}(Node));
|
|
1230
|
+
exports.MediaCondition = MediaCondition;
|
|
1231
|
+
var MediaFeature = /** @class */ (function (_super) {
|
|
1232
|
+
__extends(MediaFeature, _super);
|
|
1233
|
+
function MediaFeature(offset, length) {
|
|
1234
|
+
return _super.call(this, offset, length) || this;
|
|
1235
|
+
}
|
|
1236
|
+
Object.defineProperty(MediaFeature.prototype, "type", {
|
|
1237
|
+
get: function () {
|
|
1238
|
+
return NodeType.MediaFeature;
|
|
1239
|
+
},
|
|
1240
|
+
enumerable: false,
|
|
1241
|
+
configurable: true
|
|
1242
|
+
});
|
|
1243
|
+
return MediaFeature;
|
|
1244
|
+
}(Node));
|
|
1245
|
+
exports.MediaFeature = MediaFeature;
|
|
1213
1246
|
var SupportsCondition = /** @class */ (function (_super) {
|
|
1214
1247
|
__extends(SupportsCondition, _super);
|
|
1215
1248
|
function SupportsCondition(offset, length) {
|
|
@@ -1399,6 +1432,21 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
1399
1432
|
return HexColorValue;
|
|
1400
1433
|
}(Node));
|
|
1401
1434
|
exports.HexColorValue = HexColorValue;
|
|
1435
|
+
var RatioValue = /** @class */ (function (_super) {
|
|
1436
|
+
__extends(RatioValue, _super);
|
|
1437
|
+
function RatioValue(offset, length) {
|
|
1438
|
+
return _super.call(this, offset, length) || this;
|
|
1439
|
+
}
|
|
1440
|
+
Object.defineProperty(RatioValue.prototype, "type", {
|
|
1441
|
+
get: function () {
|
|
1442
|
+
return NodeType.RatioValue;
|
|
1443
|
+
},
|
|
1444
|
+
enumerable: false,
|
|
1445
|
+
configurable: true
|
|
1446
|
+
});
|
|
1447
|
+
return RatioValue;
|
|
1448
|
+
}(Node));
|
|
1449
|
+
exports.RatioValue = RatioValue;
|
|
1402
1450
|
var _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0);
|
|
1403
1451
|
var NumericValue = /** @class */ (function (_super) {
|
|
1404
1452
|
__extends(NumericValue, _super);
|
|
@@ -826,66 +826,145 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
826
826
|
};
|
|
827
827
|
Parser.prototype._parseMediaQueryList = function () {
|
|
828
828
|
var node = this.create(nodes.Medialist);
|
|
829
|
-
if (!node.addChild(this._parseMediaQuery(
|
|
829
|
+
if (!node.addChild(this._parseMediaQuery())) {
|
|
830
830
|
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected);
|
|
831
831
|
}
|
|
832
832
|
while (this.accept(cssScanner_1.TokenType.Comma)) {
|
|
833
|
-
if (!node.addChild(this._parseMediaQuery(
|
|
833
|
+
if (!node.addChild(this._parseMediaQuery())) {
|
|
834
834
|
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected);
|
|
835
835
|
}
|
|
836
836
|
}
|
|
837
837
|
return this.finish(node);
|
|
838
838
|
};
|
|
839
|
-
Parser.prototype._parseMediaQuery = function (
|
|
840
|
-
//
|
|
841
|
-
// media_query : [ONLY | NOT]? S* IDENT S* [ AND S* expression ]* | expression [ AND S* expression ]*
|
|
842
|
-
// expression : '(' S* IDENT S* [ ':' S* expr ]? ')' S*
|
|
839
|
+
Parser.prototype._parseMediaQuery = function () {
|
|
840
|
+
// <media-query> = <media-condition> | [ not | only ]? <media-type> [ and <media-condition-without-or> ]?
|
|
843
841
|
var node = this.create(nodes.MediaQuery);
|
|
844
|
-
var
|
|
845
|
-
|
|
842
|
+
var pos = this.mark();
|
|
843
|
+
this.acceptIdent('not');
|
|
846
844
|
if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) {
|
|
847
|
-
if (this.acceptIdent('only')
|
|
845
|
+
if (this.acceptIdent('only')) {
|
|
848
846
|
// optional
|
|
849
847
|
}
|
|
850
848
|
if (!node.addChild(this._parseIdent())) {
|
|
851
849
|
return null;
|
|
852
850
|
}
|
|
853
|
-
|
|
854
|
-
|
|
851
|
+
if (this.acceptIdent('and')) {
|
|
852
|
+
node.addChild(this._parseMediaCondition());
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
this.restoreAtMark(pos); // 'not' is part of the MediaCondition
|
|
857
|
+
node.addChild(this._parseMediaCondition());
|
|
858
|
+
}
|
|
859
|
+
return this.finish(node);
|
|
860
|
+
};
|
|
861
|
+
Parser.prototype._parseRatio = function () {
|
|
862
|
+
var pos = this.mark();
|
|
863
|
+
var node = this.create(nodes.RatioValue);
|
|
864
|
+
if (!this._parseNumeric()) {
|
|
865
|
+
return null;
|
|
866
|
+
}
|
|
867
|
+
if (!this.acceptDelim('/')) {
|
|
868
|
+
this.restoreAtMark(pos);
|
|
869
|
+
return null;
|
|
855
870
|
}
|
|
871
|
+
if (!this._parseNumeric()) {
|
|
872
|
+
return this.finish(node, cssErrors_1.ParseError.NumberExpected);
|
|
873
|
+
}
|
|
874
|
+
return this.finish(node);
|
|
875
|
+
};
|
|
876
|
+
Parser.prototype._parseMediaCondition = function () {
|
|
877
|
+
// <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens>
|
|
878
|
+
// <media-not> = not <media-in-parens>
|
|
879
|
+
// <media-and> = <media-in-parens> [ and <media-in-parens> ]+
|
|
880
|
+
// <media-or> = <media-in-parens> [ or <media-in-parens> ]+
|
|
881
|
+
// <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>
|
|
882
|
+
var node = this.create(nodes.MediaCondition);
|
|
883
|
+
this.acceptIdent('not');
|
|
884
|
+
var parseExpression = true;
|
|
856
885
|
while (parseExpression) {
|
|
857
|
-
// Allow short-circuting for other language constructs.
|
|
858
|
-
if (node.addChild(this._parseMediaContentStart())) {
|
|
859
|
-
parseExpression = this.acceptIdent('and');
|
|
860
|
-
continue;
|
|
861
|
-
}
|
|
862
886
|
if (!this.accept(cssScanner_1.TokenType.ParenthesisL)) {
|
|
863
|
-
|
|
864
|
-
|
|
887
|
+
return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
|
|
888
|
+
}
|
|
889
|
+
if (this.peek(cssScanner_1.TokenType.ParenthesisL) || this.peekIdent('not')) {
|
|
890
|
+
// <media-condition>
|
|
891
|
+
node.addChild(this._parseMediaCondition());
|
|
892
|
+
}
|
|
893
|
+
else {
|
|
894
|
+
node.addChild(this._parseMediaFeature());
|
|
895
|
+
}
|
|
896
|
+
// not yet implemented: general enclosed
|
|
897
|
+
if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
|
|
898
|
+
return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
|
|
899
|
+
}
|
|
900
|
+
parseExpression = this.acceptIdent('and') || this.acceptIdent('or');
|
|
901
|
+
}
|
|
902
|
+
return this.finish(node);
|
|
903
|
+
};
|
|
904
|
+
Parser.prototype._parseMediaFeature = function () {
|
|
905
|
+
var _this = this;
|
|
906
|
+
var resyncStopToken = [cssScanner_1.TokenType.ParenthesisR];
|
|
907
|
+
var node = this.create(nodes.MediaFeature);
|
|
908
|
+
// <media-feature> = ( [ <mf-plain> | <mf-boolean> | <mf-range> ] )
|
|
909
|
+
// <mf-plain> = <mf-name> : <mf-value>
|
|
910
|
+
// <mf-boolean> = <mf-name>
|
|
911
|
+
// <mf-range> = <mf-name> [ '<' | '>' ]? '='? <mf-value> | <mf-value> [ '<' | '>' ]? '='? <mf-name> | <mf-value> '<' '='? <mf-name> '<' '='? <mf-value> | <mf-value> '>' '='? <mf-name> '>' '='? <mf-value>
|
|
912
|
+
var parseRangeOperator = function () {
|
|
913
|
+
if (_this.acceptDelim('<') || _this.acceptDelim('>')) {
|
|
914
|
+
if (!_this.hasWhitespace()) {
|
|
915
|
+
_this.acceptDelim('=');
|
|
865
916
|
}
|
|
866
|
-
return
|
|
917
|
+
return true;
|
|
867
918
|
}
|
|
868
|
-
if (
|
|
869
|
-
return
|
|
919
|
+
else if (_this.acceptDelim('=')) {
|
|
920
|
+
return true;
|
|
870
921
|
}
|
|
922
|
+
return false;
|
|
923
|
+
};
|
|
924
|
+
if (node.addChild(this._parseMediaFeatureName())) {
|
|
871
925
|
if (this.accept(cssScanner_1.TokenType.Colon)) {
|
|
872
|
-
if (!node.addChild(this.
|
|
926
|
+
if (!node.addChild(this._parseMediaFeatureValue())) {
|
|
873
927
|
return this.finish(node, cssErrors_1.ParseError.TermExpected, [], resyncStopToken);
|
|
874
928
|
}
|
|
875
929
|
}
|
|
876
|
-
if (
|
|
877
|
-
|
|
930
|
+
else if (parseRangeOperator()) {
|
|
931
|
+
if (!node.addChild(this._parseMediaFeatureValue())) {
|
|
932
|
+
return this.finish(node, cssErrors_1.ParseError.TermExpected, [], resyncStopToken);
|
|
933
|
+
}
|
|
934
|
+
if (parseRangeOperator()) {
|
|
935
|
+
if (!node.addChild(this._parseMediaFeatureValue())) {
|
|
936
|
+
return this.finish(node, cssErrors_1.ParseError.TermExpected, [], resyncStopToken);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
else {
|
|
941
|
+
// <mf-boolean> = <mf-name>
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
else if (node.addChild(this._parseMediaFeatureValue())) {
|
|
945
|
+
if (!parseRangeOperator()) {
|
|
946
|
+
return this.finish(node, cssErrors_1.ParseError.OperatorExpected, [], resyncStopToken);
|
|
947
|
+
}
|
|
948
|
+
if (!node.addChild(this._parseMediaFeatureName())) {
|
|
949
|
+
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [], resyncStopToken);
|
|
950
|
+
}
|
|
951
|
+
if (parseRangeOperator()) {
|
|
952
|
+
if (!node.addChild(this._parseMediaFeatureValue())) {
|
|
953
|
+
return this.finish(node, cssErrors_1.ParseError.TermExpected, [], resyncStopToken);
|
|
954
|
+
}
|
|
878
955
|
}
|
|
879
|
-
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [], resyncStopToken);
|
|
880
959
|
}
|
|
881
960
|
return this.finish(node);
|
|
882
961
|
};
|
|
883
|
-
Parser.prototype._parseMediaContentStart = function () {
|
|
884
|
-
return null;
|
|
885
|
-
};
|
|
886
962
|
Parser.prototype._parseMediaFeatureName = function () {
|
|
887
963
|
return this._parseIdent();
|
|
888
964
|
};
|
|
965
|
+
Parser.prototype._parseMediaFeatureValue = function () {
|
|
966
|
+
return this._parseRatio() || this._parseTermExpression();
|
|
967
|
+
};
|
|
889
968
|
Parser.prototype._parseMedium = function () {
|
|
890
969
|
var node = this.create(nodes.Node);
|
|
891
970
|
if (node.addChild(this._parseIdent())) {
|
|
@@ -1191,6 +1270,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
1191
1270
|
if (node.setOperator(this._parseOperator())) {
|
|
1192
1271
|
node.setValue(this._parseBinaryExpr());
|
|
1193
1272
|
this.acceptIdent('i'); // case insensitive matching
|
|
1273
|
+
this.acceptIdent('s'); // case sensitive matching
|
|
1194
1274
|
}
|
|
1195
1275
|
if (!this.accept(cssScanner_1.TokenType.BracketR)) {
|
|
1196
1276
|
return this.finish(node, cssErrors_1.ParseError.RightSquareBracketExpected);
|
|
@@ -97,8 +97,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
97
97
|
}
|
|
98
98
|
return this.finish(node);
|
|
99
99
|
};
|
|
100
|
-
LESSParser.prototype._parseMediaQuery = function (
|
|
101
|
-
var node = _super.prototype._parseMediaQuery.call(this
|
|
100
|
+
LESSParser.prototype._parseMediaQuery = function () {
|
|
101
|
+
var node = _super.prototype._parseMediaQuery.call(this);
|
|
102
102
|
if (!node) {
|
|
103
103
|
var node_1 = this.create(nodes.MediaQuery);
|
|
104
104
|
if (node_1.addChild(this._parseVariable())) {
|
|
@@ -115,8 +115,8 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
115
115
|
}
|
|
116
116
|
return this.finish(node);
|
|
117
117
|
};
|
|
118
|
-
SCSSParser.prototype.
|
|
119
|
-
return this._parseInterpolation();
|
|
118
|
+
SCSSParser.prototype._parseMediaCondition = function () {
|
|
119
|
+
return this._parseInterpolation() || _super.prototype._parseMediaCondition.call(this);
|
|
120
120
|
};
|
|
121
121
|
SCSSParser.prototype._parseMediaFeatureName = function () {
|
|
122
122
|
return this._parseModuleMember()
|
|
@@ -468,7 +468,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
468
468
|
var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
|
|
469
469
|
for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
|
|
470
470
|
var symbol = symbols_1[_i];
|
|
471
|
-
var insertText = strings.startsWith(symbol.name, '--') ? "var("
|
|
471
|
+
var insertText = strings.startsWith(symbol.name, '--') ? "var(".concat(symbol.name, ")") : symbol.name;
|
|
472
472
|
var completionItem = {
|
|
473
473
|
label: symbol.name,
|
|
474
474
|
documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
|
|
@@ -490,22 +490,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
490
490
|
return result;
|
|
491
491
|
};
|
|
492
492
|
CSSCompletion.prototype.getVariableProposalsForCSSVarFunction = function (result) {
|
|
493
|
+
var allReferencedVariables = new Set();
|
|
494
|
+
this.styleSheet.acceptVisitor(new VariableCollector(allReferencedVariables, this.offset));
|
|
493
495
|
var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
|
|
494
|
-
symbols = symbols.filter(function (symbol) {
|
|
495
|
-
return strings.startsWith(symbol.name, '--');
|
|
496
|
-
});
|
|
497
496
|
for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
|
|
498
497
|
var symbol = symbols_2[_i];
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
completionItem.
|
|
498
|
+
if (strings.startsWith(symbol.name, '--')) {
|
|
499
|
+
var completionItem = {
|
|
500
|
+
label: symbol.name,
|
|
501
|
+
documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
|
|
502
|
+
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), symbol.name),
|
|
503
|
+
kind: cssLanguageTypes_1.CompletionItemKind.Variable
|
|
504
|
+
};
|
|
505
|
+
if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
|
|
506
|
+
completionItem.kind = cssLanguageTypes_1.CompletionItemKind.Color;
|
|
507
|
+
}
|
|
508
|
+
result.items.push(completionItem);
|
|
509
|
+
}
|
|
510
|
+
allReferencedVariables.remove(symbol.name);
|
|
511
|
+
}
|
|
512
|
+
for (var _a = 0, _b = allReferencedVariables.getEntries(); _a < _b.length; _a++) {
|
|
513
|
+
var name = _b[_a];
|
|
514
|
+
if (strings.startsWith(name, '--')) {
|
|
515
|
+
var completionItem = {
|
|
516
|
+
label: name,
|
|
517
|
+
textEdit: cssLanguageTypes_1.TextEdit.replace(this.getCompletionRange(null), name),
|
|
518
|
+
kind: cssLanguageTypes_1.CompletionItemKind.Variable
|
|
519
|
+
};
|
|
520
|
+
result.items.push(completionItem);
|
|
507
521
|
}
|
|
508
|
-
result.items.push(completionItem);
|
|
509
522
|
}
|
|
510
523
|
return result;
|
|
511
524
|
};
|
|
@@ -1056,24 +1069,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
1056
1069
|
}
|
|
1057
1070
|
return false;
|
|
1058
1071
|
}
|
|
1059
|
-
/**
|
|
1060
|
-
* Rank number should all be same length strings
|
|
1061
|
-
*/
|
|
1062
|
-
function computeRankNumber(n) {
|
|
1063
|
-
var nstr = n.toString();
|
|
1064
|
-
switch (nstr.length) {
|
|
1065
|
-
case 4:
|
|
1066
|
-
return nstr;
|
|
1067
|
-
case 3:
|
|
1068
|
-
return '0' + nstr;
|
|
1069
|
-
case 2:
|
|
1070
|
-
return '00' + nstr;
|
|
1071
|
-
case 1:
|
|
1072
|
-
return '000' + nstr;
|
|
1073
|
-
default:
|
|
1074
|
-
return '0000';
|
|
1075
|
-
}
|
|
1076
|
-
}
|
|
1077
1072
|
var Set = /** @class */ (function () {
|
|
1078
1073
|
function Set() {
|
|
1079
1074
|
this.entries = {};
|
|
@@ -1081,6 +1076,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
1081
1076
|
Set.prototype.add = function (entry) {
|
|
1082
1077
|
this.entries[entry] = true;
|
|
1083
1078
|
};
|
|
1079
|
+
Set.prototype.remove = function (entry) {
|
|
1080
|
+
delete this.entries[entry];
|
|
1081
|
+
};
|
|
1084
1082
|
Set.prototype.getEntries = function () {
|
|
1085
1083
|
return Object.keys(this.entries);
|
|
1086
1084
|
};
|
|
@@ -1132,6 +1130,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
1132
1130
|
};
|
|
1133
1131
|
return ColorValueCollector;
|
|
1134
1132
|
}());
|
|
1133
|
+
var VariableCollector = /** @class */ (function () {
|
|
1134
|
+
function VariableCollector(entries, currentOffset) {
|
|
1135
|
+
this.entries = entries;
|
|
1136
|
+
this.currentOffset = currentOffset;
|
|
1137
|
+
// nothing to do
|
|
1138
|
+
}
|
|
1139
|
+
VariableCollector.prototype.visitNode = function (node) {
|
|
1140
|
+
if (node instanceof nodes.Identifier && node.isCustomProperty) {
|
|
1141
|
+
if (this.currentOffset < node.offset || node.end < this.currentOffset) {
|
|
1142
|
+
this.entries.add(node.getText());
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
return true;
|
|
1146
|
+
};
|
|
1147
|
+
return VariableCollector;
|
|
1148
|
+
}());
|
|
1135
1149
|
function getCurrentWord(document, offset) {
|
|
1136
1150
|
var i = offset - 1;
|
|
1137
1151
|
var text = document.getText();
|