vscode-css-languageservice 5.1.5 → 5.1.9
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/data/webCustomData.js +202 -124
- package/lib/esm/languageFacts/builtinData.js +4 -0
- package/lib/esm/languageFacts/colors.js +15 -0
- package/lib/esm/languageFacts/entry.js +7 -2
- package/lib/esm/parser/cssNodes.js +94 -46
- package/lib/esm/parser/cssParser.js +126 -32
- package/lib/esm/parser/cssScanner.js +2 -2
- package/lib/esm/parser/lessParser.js +2 -2
- package/lib/esm/parser/scssParser.js +2 -2
- package/lib/esm/services/cssCompletion.js +60 -34
- package/lib/umd/data/webCustomData.js +202 -124
- package/lib/umd/languageFacts/builtinData.js +5 -1
- package/lib/umd/languageFacts/colors.js +15 -0
- package/lib/umd/languageFacts/entry.js +8 -3
- package/lib/umd/parser/cssNodes.js +95 -47
- package/lib/umd/parser/cssParser.js +126 -32
- package/lib/umd/parser/cssScanner.js +2 -2
- package/lib/umd/parser/lessParser.js +2 -2
- package/lib/umd/parser/scssParser.js +2 -2
- package/lib/umd/services/cssCompletion.js +60 -34
- package/package.json +5 -5
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*--------------------------------------------------------------------------------------------*/
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.pageBoxDirectives = exports.svgElements = exports.html5Tags = exports.units = exports.basicShapeFunctions = exports.transitionTimingFunctions = exports.imageFunctions = exports.cssWideKeywords = exports.geometryBoxKeywords = exports.boxKeywords = exports.lineWidthKeywords = exports.lineStyleKeywords = exports.repeatStyleKeywords = exports.positionKeywords = void 0;
|
|
16
|
+
exports.pageBoxDirectives = exports.svgElements = exports.html5Tags = exports.units = exports.basicShapeFunctions = exports.transitionTimingFunctions = exports.imageFunctions = exports.cssWideFunctions = exports.cssWideKeywords = exports.geometryBoxKeywords = exports.boxKeywords = exports.lineWidthKeywords = exports.lineStyleKeywords = exports.repeatStyleKeywords = exports.positionKeywords = void 0;
|
|
17
17
|
exports.positionKeywords = {
|
|
18
18
|
'bottom': 'Computes to ‘100%’ for the vertical position if one or two values are given, otherwise specifies the bottom edge as the origin for the next offset.',
|
|
19
19
|
'center': 'Computes to ‘50%’ (‘left 50%’) for the horizontal position if the horizontal position is not otherwise specified, or ‘50%’ (‘top 50%’) for the vertical position if it is.',
|
|
@@ -58,6 +58,10 @@
|
|
|
58
58
|
'inherit': 'Represents the computed value of the property on the element’s parent.',
|
|
59
59
|
'unset': 'Acts as either `inherit` or `initial`, depending on whether the property is inherited or not.'
|
|
60
60
|
};
|
|
61
|
+
exports.cssWideFunctions = {
|
|
62
|
+
'var()': 'Evaluates the value of a custom variable.',
|
|
63
|
+
'calc()': 'Evaluates an mathematical expression. The following operators can be used: + - * /.'
|
|
64
|
+
};
|
|
61
65
|
exports.imageFunctions = {
|
|
62
66
|
'url()': 'Reference an image file by URL',
|
|
63
67
|
'image()': 'Provide image fallbacks and annotations.',
|
|
@@ -373,6 +373,21 @@
|
|
|
373
373
|
var functionNode = node;
|
|
374
374
|
var name = functionNode.getName();
|
|
375
375
|
var colorValues = functionNode.getArguments().getChildren();
|
|
376
|
+
if (colorValues.length === 1) {
|
|
377
|
+
var functionArg = colorValues[0].getChildren();
|
|
378
|
+
if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
|
|
379
|
+
colorValues = functionArg[0].getChildren();
|
|
380
|
+
if (colorValues.length === 3) {
|
|
381
|
+
var lastValue = colorValues[2];
|
|
382
|
+
if (lastValue instanceof nodes.BinaryExpression) {
|
|
383
|
+
var left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
|
|
384
|
+
if (left && right && operator && operator.matches('/')) {
|
|
385
|
+
colorValues = [colorValues[0], colorValues[1], left, right];
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
}
|
|
376
391
|
if (!name || colorValues.length < 3 || colorValues.length > 4) {
|
|
377
392
|
return null;
|
|
378
393
|
}
|
|
@@ -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',
|
|
@@ -99,8 +100,12 @@
|
|
|
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) + ')';
|
|
@@ -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);
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
1
10
|
(function (factory) {
|
|
2
11
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
12
|
var v = factory(require, exports);
|
|
@@ -44,7 +53,11 @@
|
|
|
44
53
|
Parser.prototype.peek = function (type) {
|
|
45
54
|
return type === this.token.type;
|
|
46
55
|
};
|
|
47
|
-
Parser.prototype.peekOne = function (
|
|
56
|
+
Parser.prototype.peekOne = function () {
|
|
57
|
+
var types = [];
|
|
58
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
59
|
+
types[_i] = arguments[_i];
|
|
60
|
+
}
|
|
48
61
|
return types.indexOf(this.token.type) !== -1;
|
|
49
62
|
};
|
|
50
63
|
Parser.prototype.peekRegExp = function (type, regEx) {
|
|
@@ -453,13 +466,15 @@
|
|
|
453
466
|
}
|
|
454
467
|
this.restoreAtMark(mark);
|
|
455
468
|
}
|
|
456
|
-
// try
|
|
469
|
+
// try to parse as expression
|
|
457
470
|
var expression = this._parseExpr();
|
|
458
471
|
if (expression && !expression.isErroneous(true)) {
|
|
459
472
|
this._parsePrio();
|
|
460
|
-
if (this.peekOne(stopTokens || [cssScanner_1.TokenType.SemiColon])) {
|
|
473
|
+
if (this.peekOne.apply(this, __spreadArray(__spreadArray([], (stopTokens || []), false), [cssScanner_1.TokenType.SemiColon, cssScanner_1.TokenType.EOF], false))) {
|
|
461
474
|
node.setValue(expression);
|
|
462
|
-
|
|
475
|
+
if (this.peek(cssScanner_1.TokenType.SemiColon)) {
|
|
476
|
+
node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
|
|
477
|
+
}
|
|
463
478
|
return this.finish(node);
|
|
464
479
|
}
|
|
465
480
|
}
|
|
@@ -811,66 +826,145 @@
|
|
|
811
826
|
};
|
|
812
827
|
Parser.prototype._parseMediaQueryList = function () {
|
|
813
828
|
var node = this.create(nodes.Medialist);
|
|
814
|
-
if (!node.addChild(this._parseMediaQuery(
|
|
829
|
+
if (!node.addChild(this._parseMediaQuery())) {
|
|
815
830
|
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected);
|
|
816
831
|
}
|
|
817
832
|
while (this.accept(cssScanner_1.TokenType.Comma)) {
|
|
818
|
-
if (!node.addChild(this._parseMediaQuery(
|
|
833
|
+
if (!node.addChild(this._parseMediaQuery())) {
|
|
819
834
|
return this.finish(node, cssErrors_1.ParseError.MediaQueryExpected);
|
|
820
835
|
}
|
|
821
836
|
}
|
|
822
837
|
return this.finish(node);
|
|
823
838
|
};
|
|
824
|
-
Parser.prototype._parseMediaQuery = function (
|
|
825
|
-
//
|
|
826
|
-
// media_query : [ONLY | NOT]? S* IDENT S* [ AND S* expression ]* | expression [ AND S* expression ]*
|
|
827
|
-
// 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> ]?
|
|
828
841
|
var node = this.create(nodes.MediaQuery);
|
|
829
|
-
var
|
|
830
|
-
|
|
842
|
+
var pos = this.mark();
|
|
843
|
+
this.acceptIdent('not');
|
|
831
844
|
if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) {
|
|
832
|
-
if (this.acceptIdent('only')
|
|
845
|
+
if (this.acceptIdent('only')) {
|
|
833
846
|
// optional
|
|
834
847
|
}
|
|
835
848
|
if (!node.addChild(this._parseIdent())) {
|
|
836
849
|
return null;
|
|
837
850
|
}
|
|
838
|
-
|
|
839
|
-
|
|
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;
|
|
870
|
+
}
|
|
871
|
+
if (!this._parseNumeric()) {
|
|
872
|
+
return this.finish(node, cssErrors_1.ParseError.NumberExpected);
|
|
840
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;
|
|
841
885
|
while (parseExpression) {
|
|
842
|
-
// Allow short-circuting for other language constructs.
|
|
843
|
-
if (node.addChild(this._parseMediaContentStart())) {
|
|
844
|
-
parseExpression = this.acceptIdent('and');
|
|
845
|
-
continue;
|
|
846
|
-
}
|
|
847
886
|
if (!this.accept(cssScanner_1.TokenType.ParenthesisL)) {
|
|
848
|
-
|
|
849
|
-
|
|
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('=');
|
|
850
916
|
}
|
|
851
|
-
return
|
|
917
|
+
return true;
|
|
852
918
|
}
|
|
853
|
-
if (
|
|
854
|
-
return
|
|
919
|
+
else if (_this.acceptDelim('=')) {
|
|
920
|
+
return true;
|
|
855
921
|
}
|
|
922
|
+
return false;
|
|
923
|
+
};
|
|
924
|
+
if (node.addChild(this._parseMediaFeatureName())) {
|
|
856
925
|
if (this.accept(cssScanner_1.TokenType.Colon)) {
|
|
857
|
-
if (!node.addChild(this.
|
|
926
|
+
if (!node.addChild(this._parseMediaFeatureValue())) {
|
|
858
927
|
return this.finish(node, cssErrors_1.ParseError.TermExpected, [], resyncStopToken);
|
|
859
928
|
}
|
|
860
929
|
}
|
|
861
|
-
if (
|
|
862
|
-
|
|
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>
|
|
863
942
|
}
|
|
864
|
-
|
|
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
|
+
}
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
else {
|
|
958
|
+
return this.finish(node, cssErrors_1.ParseError.IdentifierExpected, [], resyncStopToken);
|
|
865
959
|
}
|
|
866
960
|
return this.finish(node);
|
|
867
961
|
};
|
|
868
|
-
Parser.prototype._parseMediaContentStart = function () {
|
|
869
|
-
return null;
|
|
870
|
-
};
|
|
871
962
|
Parser.prototype._parseMediaFeatureName = function () {
|
|
872
963
|
return this._parseIdent();
|
|
873
964
|
};
|
|
965
|
+
Parser.prototype._parseMediaFeatureValue = function () {
|
|
966
|
+
return this._parseRatio() || this._parseTermExpression();
|
|
967
|
+
};
|
|
874
968
|
Parser.prototype._parseMedium = function () {
|
|
875
969
|
var node = this.create(nodes.Node);
|
|
876
970
|
if (node.addChild(this._parseIdent())) {
|
|
@@ -517,8 +517,8 @@
|
|
|
517
517
|
Scanner.prototype.ident = function (result) {
|
|
518
518
|
var pos = this.stream.pos();
|
|
519
519
|
var hasMinus = this._minus(result);
|
|
520
|
-
if (hasMinus
|
|
521
|
-
if (this._identFirstChar(result) || this._escape(result)) {
|
|
520
|
+
if (hasMinus) {
|
|
521
|
+
if (this._minus(result) /* -- */ || this._identFirstChar(result) || this._escape(result)) {
|
|
522
522
|
while (this._identChar(result) || this._escape(result)) {
|
|
523
523
|
// loop
|
|
524
524
|
}
|
|
@@ -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()
|