vscode-css-languageservice 5.1.7 → 5.1.11

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.
@@ -181,9 +181,22 @@ function getNumericValue(node, factor) {
181
181
  }
182
182
  function getAngle(node) {
183
183
  var val = node.getText();
184
- var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg)?$/);
184
+ var m = val.match(/^([-+]?[0-9]*\.?[0-9]+)(deg|rad|grad|turn)?$/);
185
185
  if (m) {
186
- return parseFloat(val) % 360;
186
+ switch (m[2]) {
187
+ case 'deg':
188
+ return parseFloat(val) % 360;
189
+ case 'rad':
190
+ return (parseFloat(val) * 180 / Math.PI) % 360;
191
+ case 'grad':
192
+ return (parseFloat(val) * 0.9) % 360;
193
+ case 'turn':
194
+ return (parseFloat(val) * 360) % 360;
195
+ default:
196
+ if ('undefined' === typeof m[2]) {
197
+ return parseFloat(val) % 360;
198
+ }
199
+ }
187
200
  }
188
201
  throw new Error();
189
202
  }
@@ -354,6 +367,21 @@ export function getColorValue(node) {
354
367
  var functionNode = node;
355
368
  var name = functionNode.getName();
356
369
  var colorValues = functionNode.getArguments().getChildren();
370
+ if (colorValues.length === 1) {
371
+ var functionArg = colorValues[0].getChildren();
372
+ if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
373
+ colorValues = functionArg[0].getChildren();
374
+ if (colorValues.length === 3) {
375
+ var lastValue = colorValues[2];
376
+ if (lastValue instanceof nodes.BinaryExpression) {
377
+ var left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
378
+ if (left && right && operator && operator.matches('/')) {
379
+ colorValues = [colorValues[0], colorValues[1], left, right];
380
+ }
381
+ }
382
+ }
383
+ }
384
+ }
357
385
  if (!name || colorValues.length < 3 || colorValues.length > 4) {
358
386
  return null;
359
387
  }
@@ -3,6 +3,7 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  'use strict';
6
+ import { MarkupKind } from '../cssLanguageTypes';
6
7
  export var browserNames = {
7
8
  E: 'Edge',
8
9
  FF: 'Firefox',
@@ -64,7 +65,7 @@ function getEntryStringDescription(entry, settings) {
64
65
  result += '\n(' + browserLabel + ')';
65
66
  }
66
67
  if ('syntax' in entry) {
67
- result += "\n\nSyntax: " + entry.syntax;
68
+ result += "\n\nSyntax: ".concat(entry.syntax);
68
69
  }
69
70
  }
70
71
  if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
@@ -72,7 +73,7 @@ function getEntryStringDescription(entry, settings) {
72
73
  result += '\n\n';
73
74
  }
74
75
  result += entry.references.map(function (r) {
75
- return r.name + ": " + r.url;
76
+ return "".concat(r.name, ": ").concat(r.url);
76
77
  }).join(' | ');
77
78
  }
78
79
  return result;
@@ -86,14 +87,18 @@ function getEntryMarkdownDescription(entry, settings) {
86
87
  if (entry.status) {
87
88
  result += getEntryStatus(entry.status);
88
89
  }
89
- var description = typeof entry.description === 'string' ? entry.description : entry.description.value;
90
- result += textToMarkedString(description);
90
+ if (typeof entry.description === 'string') {
91
+ result += textToMarkedString(entry.description);
92
+ }
93
+ else {
94
+ result += entry.description.kind === MarkupKind.Markdown ? entry.description.value : textToMarkedString(entry.description.value);
95
+ }
91
96
  var browserLabel = getBrowserLabel(entry.browsers);
92
97
  if (browserLabel) {
93
98
  result += '\n\n(' + textToMarkedString(browserLabel) + ')';
94
99
  }
95
100
  if ('syntax' in entry && entry.syntax) {
96
- result += "\n\nSyntax: " + textToMarkedString(entry.syntax);
101
+ result += "\n\nSyntax: ".concat(textToMarkedString(entry.syntax));
97
102
  }
98
103
  }
99
104
  if (entry.references && entry.references.length > 0 && (settings === null || settings === void 0 ? void 0 : settings.references) !== false) {
@@ -101,7 +106,7 @@ function getEntryMarkdownDescription(entry, settings) {
101
106
  result += '\n\n';
102
107
  }
103
108
  result += entry.references.map(function (r) {
104
- return "[" + r.name + "](" + r.url + ")";
109
+ return "[".concat(r.name, "](").concat(r.url, ")");
105
110
  }).join(' | ');
106
111
  }
107
112
  return result;
@@ -58,52 +58,55 @@ export var NodeType;
58
58
  NodeType[NodeType["Function"] = 30] = "Function";
59
59
  NodeType[NodeType["NumericValue"] = 31] = "NumericValue";
60
60
  NodeType[NodeType["HexColorValue"] = 32] = "HexColorValue";
61
- NodeType[NodeType["MixinDeclaration"] = 33] = "MixinDeclaration";
62
- NodeType[NodeType["MixinReference"] = 34] = "MixinReference";
63
- NodeType[NodeType["VariableName"] = 35] = "VariableName";
64
- NodeType[NodeType["VariableDeclaration"] = 36] = "VariableDeclaration";
65
- NodeType[NodeType["Prio"] = 37] = "Prio";
66
- NodeType[NodeType["Interpolation"] = 38] = "Interpolation";
67
- NodeType[NodeType["NestedProperties"] = 39] = "NestedProperties";
68
- NodeType[NodeType["ExtendsReference"] = 40] = "ExtendsReference";
69
- NodeType[NodeType["SelectorPlaceholder"] = 41] = "SelectorPlaceholder";
70
- NodeType[NodeType["Debug"] = 42] = "Debug";
71
- NodeType[NodeType["If"] = 43] = "If";
72
- NodeType[NodeType["Else"] = 44] = "Else";
73
- NodeType[NodeType["For"] = 45] = "For";
74
- NodeType[NodeType["Each"] = 46] = "Each";
75
- NodeType[NodeType["While"] = 47] = "While";
76
- NodeType[NodeType["MixinContentReference"] = 48] = "MixinContentReference";
77
- NodeType[NodeType["MixinContentDeclaration"] = 49] = "MixinContentDeclaration";
78
- NodeType[NodeType["Media"] = 50] = "Media";
79
- NodeType[NodeType["Keyframe"] = 51] = "Keyframe";
80
- NodeType[NodeType["FontFace"] = 52] = "FontFace";
81
- NodeType[NodeType["Import"] = 53] = "Import";
82
- NodeType[NodeType["Namespace"] = 54] = "Namespace";
83
- NodeType[NodeType["Invocation"] = 55] = "Invocation";
84
- NodeType[NodeType["FunctionDeclaration"] = 56] = "FunctionDeclaration";
85
- NodeType[NodeType["ReturnStatement"] = 57] = "ReturnStatement";
86
- NodeType[NodeType["MediaQuery"] = 58] = "MediaQuery";
87
- NodeType[NodeType["FunctionParameter"] = 59] = "FunctionParameter";
88
- NodeType[NodeType["FunctionArgument"] = 60] = "FunctionArgument";
89
- NodeType[NodeType["KeyframeSelector"] = 61] = "KeyframeSelector";
90
- NodeType[NodeType["ViewPort"] = 62] = "ViewPort";
91
- NodeType[NodeType["Document"] = 63] = "Document";
92
- NodeType[NodeType["AtApplyRule"] = 64] = "AtApplyRule";
93
- NodeType[NodeType["CustomPropertyDeclaration"] = 65] = "CustomPropertyDeclaration";
94
- NodeType[NodeType["CustomPropertySet"] = 66] = "CustomPropertySet";
95
- NodeType[NodeType["ListEntry"] = 67] = "ListEntry";
96
- NodeType[NodeType["Supports"] = 68] = "Supports";
97
- NodeType[NodeType["SupportsCondition"] = 69] = "SupportsCondition";
98
- NodeType[NodeType["NamespacePrefix"] = 70] = "NamespacePrefix";
99
- NodeType[NodeType["GridLine"] = 71] = "GridLine";
100
- NodeType[NodeType["Plugin"] = 72] = "Plugin";
101
- NodeType[NodeType["UnknownAtRule"] = 73] = "UnknownAtRule";
102
- NodeType[NodeType["Use"] = 74] = "Use";
103
- NodeType[NodeType["ModuleConfiguration"] = 75] = "ModuleConfiguration";
104
- NodeType[NodeType["Forward"] = 76] = "Forward";
105
- NodeType[NodeType["ForwardVisibility"] = 77] = "ForwardVisibility";
106
- NodeType[NodeType["Module"] = 78] = "Module";
61
+ NodeType[NodeType["RatioValue"] = 33] = "RatioValue";
62
+ NodeType[NodeType["MixinDeclaration"] = 34] = "MixinDeclaration";
63
+ NodeType[NodeType["MixinReference"] = 35] = "MixinReference";
64
+ NodeType[NodeType["VariableName"] = 36] = "VariableName";
65
+ NodeType[NodeType["VariableDeclaration"] = 37] = "VariableDeclaration";
66
+ NodeType[NodeType["Prio"] = 38] = "Prio";
67
+ NodeType[NodeType["Interpolation"] = 39] = "Interpolation";
68
+ NodeType[NodeType["NestedProperties"] = 40] = "NestedProperties";
69
+ NodeType[NodeType["ExtendsReference"] = 41] = "ExtendsReference";
70
+ NodeType[NodeType["SelectorPlaceholder"] = 42] = "SelectorPlaceholder";
71
+ NodeType[NodeType["Debug"] = 43] = "Debug";
72
+ NodeType[NodeType["If"] = 44] = "If";
73
+ NodeType[NodeType["Else"] = 45] = "Else";
74
+ NodeType[NodeType["For"] = 46] = "For";
75
+ NodeType[NodeType["Each"] = 47] = "Each";
76
+ NodeType[NodeType["While"] = 48] = "While";
77
+ NodeType[NodeType["MixinContentReference"] = 49] = "MixinContentReference";
78
+ NodeType[NodeType["MixinContentDeclaration"] = 50] = "MixinContentDeclaration";
79
+ NodeType[NodeType["Media"] = 51] = "Media";
80
+ NodeType[NodeType["Keyframe"] = 52] = "Keyframe";
81
+ NodeType[NodeType["FontFace"] = 53] = "FontFace";
82
+ NodeType[NodeType["Import"] = 54] = "Import";
83
+ NodeType[NodeType["Namespace"] = 55] = "Namespace";
84
+ NodeType[NodeType["Invocation"] = 56] = "Invocation";
85
+ NodeType[NodeType["FunctionDeclaration"] = 57] = "FunctionDeclaration";
86
+ NodeType[NodeType["ReturnStatement"] = 58] = "ReturnStatement";
87
+ NodeType[NodeType["MediaQuery"] = 59] = "MediaQuery";
88
+ NodeType[NodeType["MediaCondition"] = 60] = "MediaCondition";
89
+ NodeType[NodeType["MediaFeature"] = 61] = "MediaFeature";
90
+ NodeType[NodeType["FunctionParameter"] = 62] = "FunctionParameter";
91
+ NodeType[NodeType["FunctionArgument"] = 63] = "FunctionArgument";
92
+ NodeType[NodeType["KeyframeSelector"] = 64] = "KeyframeSelector";
93
+ NodeType[NodeType["ViewPort"] = 65] = "ViewPort";
94
+ NodeType[NodeType["Document"] = 66] = "Document";
95
+ NodeType[NodeType["AtApplyRule"] = 67] = "AtApplyRule";
96
+ NodeType[NodeType["CustomPropertyDeclaration"] = 68] = "CustomPropertyDeclaration";
97
+ NodeType[NodeType["CustomPropertySet"] = 69] = "CustomPropertySet";
98
+ NodeType[NodeType["ListEntry"] = 70] = "ListEntry";
99
+ NodeType[NodeType["Supports"] = 71] = "Supports";
100
+ NodeType[NodeType["SupportsCondition"] = 72] = "SupportsCondition";
101
+ NodeType[NodeType["NamespacePrefix"] = 73] = "NamespacePrefix";
102
+ NodeType[NodeType["GridLine"] = 74] = "GridLine";
103
+ NodeType[NodeType["Plugin"] = 75] = "Plugin";
104
+ NodeType[NodeType["UnknownAtRule"] = 76] = "UnknownAtRule";
105
+ NodeType[NodeType["Use"] = 77] = "Use";
106
+ NodeType[NodeType["ModuleConfiguration"] = 78] = "ModuleConfiguration";
107
+ NodeType[NodeType["Forward"] = 79] = "Forward";
108
+ NodeType[NodeType["ForwardVisibility"] = 80] = "ForwardVisibility";
109
+ NodeType[NodeType["Module"] = 81] = "Module";
107
110
  })(NodeType || (NodeType = {}));
108
111
  export var ReferenceType;
109
112
  (function (ReferenceType) {
@@ -1196,6 +1199,36 @@ var MediaQuery = /** @class */ (function (_super) {
1196
1199
  return MediaQuery;
1197
1200
  }(Node));
1198
1201
  export { MediaQuery };
1202
+ var MediaCondition = /** @class */ (function (_super) {
1203
+ __extends(MediaCondition, _super);
1204
+ function MediaCondition(offset, length) {
1205
+ return _super.call(this, offset, length) || this;
1206
+ }
1207
+ Object.defineProperty(MediaCondition.prototype, "type", {
1208
+ get: function () {
1209
+ return NodeType.MediaCondition;
1210
+ },
1211
+ enumerable: false,
1212
+ configurable: true
1213
+ });
1214
+ return MediaCondition;
1215
+ }(Node));
1216
+ export { MediaCondition };
1217
+ var MediaFeature = /** @class */ (function (_super) {
1218
+ __extends(MediaFeature, _super);
1219
+ function MediaFeature(offset, length) {
1220
+ return _super.call(this, offset, length) || this;
1221
+ }
1222
+ Object.defineProperty(MediaFeature.prototype, "type", {
1223
+ get: function () {
1224
+ return NodeType.MediaFeature;
1225
+ },
1226
+ enumerable: false,
1227
+ configurable: true
1228
+ });
1229
+ return MediaFeature;
1230
+ }(Node));
1231
+ export { MediaFeature };
1199
1232
  var SupportsCondition = /** @class */ (function (_super) {
1200
1233
  __extends(SupportsCondition, _super);
1201
1234
  function SupportsCondition(offset, length) {
@@ -1385,6 +1418,21 @@ var HexColorValue = /** @class */ (function (_super) {
1385
1418
  return HexColorValue;
1386
1419
  }(Node));
1387
1420
  export { HexColorValue };
1421
+ var RatioValue = /** @class */ (function (_super) {
1422
+ __extends(RatioValue, _super);
1423
+ function RatioValue(offset, length) {
1424
+ return _super.call(this, offset, length) || this;
1425
+ }
1426
+ Object.defineProperty(RatioValue.prototype, "type", {
1427
+ get: function () {
1428
+ return NodeType.RatioValue;
1429
+ },
1430
+ enumerable: false,
1431
+ configurable: true
1432
+ });
1433
+ return RatioValue;
1434
+ }(Node));
1435
+ export { RatioValue };
1388
1436
  var _dot = '.'.charCodeAt(0), _0 = '0'.charCodeAt(0), _9 = '9'.charCodeAt(0);
1389
1437
  var NumericValue = /** @class */ (function (_super) {
1390
1438
  __extends(NumericValue, _super);
@@ -815,66 +815,145 @@ var Parser = /** @class */ (function () {
815
815
  };
816
816
  Parser.prototype._parseMediaQueryList = function () {
817
817
  var node = this.create(nodes.Medialist);
818
- if (!node.addChild(this._parseMediaQuery([TokenType.CurlyL]))) {
818
+ if (!node.addChild(this._parseMediaQuery())) {
819
819
  return this.finish(node, ParseError.MediaQueryExpected);
820
820
  }
821
821
  while (this.accept(TokenType.Comma)) {
822
- if (!node.addChild(this._parseMediaQuery([TokenType.CurlyL]))) {
822
+ if (!node.addChild(this._parseMediaQuery())) {
823
823
  return this.finish(node, ParseError.MediaQueryExpected);
824
824
  }
825
825
  }
826
826
  return this.finish(node);
827
827
  };
828
- Parser.prototype._parseMediaQuery = function (resyncStopToken) {
829
- // http://www.w3.org/TR/css3-mediaqueries/
830
- // media_query : [ONLY | NOT]? S* IDENT S* [ AND S* expression ]* | expression [ AND S* expression ]*
831
- // expression : '(' S* IDENT S* [ ':' S* expr ]? ')' S*
828
+ Parser.prototype._parseMediaQuery = function () {
829
+ // <media-query> = <media-condition> | [ not | only ]? <media-type> [ and <media-condition-without-or> ]?
832
830
  var node = this.create(nodes.MediaQuery);
833
- var parseExpression = true;
834
- var hasContent = false;
831
+ var pos = this.mark();
832
+ this.acceptIdent('not');
835
833
  if (!this.peek(TokenType.ParenthesisL)) {
836
- if (this.acceptIdent('only') || this.acceptIdent('not')) {
834
+ if (this.acceptIdent('only')) {
837
835
  // optional
838
836
  }
839
837
  if (!node.addChild(this._parseIdent())) {
840
838
  return null;
841
839
  }
842
- hasContent = true;
843
- parseExpression = this.acceptIdent('and');
840
+ if (this.acceptIdent('and')) {
841
+ node.addChild(this._parseMediaCondition());
842
+ }
843
+ }
844
+ else {
845
+ this.restoreAtMark(pos); // 'not' is part of the MediaCondition
846
+ node.addChild(this._parseMediaCondition());
847
+ }
848
+ return this.finish(node);
849
+ };
850
+ Parser.prototype._parseRatio = function () {
851
+ var pos = this.mark();
852
+ var node = this.create(nodes.RatioValue);
853
+ if (!this._parseNumeric()) {
854
+ return null;
855
+ }
856
+ if (!this.acceptDelim('/')) {
857
+ this.restoreAtMark(pos);
858
+ return null;
844
859
  }
860
+ if (!this._parseNumeric()) {
861
+ return this.finish(node, ParseError.NumberExpected);
862
+ }
863
+ return this.finish(node);
864
+ };
865
+ Parser.prototype._parseMediaCondition = function () {
866
+ // <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens>
867
+ // <media-not> = not <media-in-parens>
868
+ // <media-and> = <media-in-parens> [ and <media-in-parens> ]+
869
+ // <media-or> = <media-in-parens> [ or <media-in-parens> ]+
870
+ // <media-in-parens> = ( <media-condition> ) | <media-feature> | <general-enclosed>
871
+ var node = this.create(nodes.MediaCondition);
872
+ this.acceptIdent('not');
873
+ var parseExpression = true;
845
874
  while (parseExpression) {
846
- // Allow short-circuting for other language constructs.
847
- if (node.addChild(this._parseMediaContentStart())) {
848
- parseExpression = this.acceptIdent('and');
849
- continue;
850
- }
851
875
  if (!this.accept(TokenType.ParenthesisL)) {
852
- if (hasContent) {
853
- return this.finish(node, ParseError.LeftParenthesisExpected, [], resyncStopToken);
876
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.CurlyL]);
877
+ }
878
+ if (this.peek(TokenType.ParenthesisL) || this.peekIdent('not')) {
879
+ // <media-condition>
880
+ node.addChild(this._parseMediaCondition());
881
+ }
882
+ else {
883
+ node.addChild(this._parseMediaFeature());
884
+ }
885
+ // not yet implemented: general enclosed
886
+ if (!this.accept(TokenType.ParenthesisR)) {
887
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.CurlyL]);
888
+ }
889
+ parseExpression = this.acceptIdent('and') || this.acceptIdent('or');
890
+ }
891
+ return this.finish(node);
892
+ };
893
+ Parser.prototype._parseMediaFeature = function () {
894
+ var _this = this;
895
+ var resyncStopToken = [TokenType.ParenthesisR];
896
+ var node = this.create(nodes.MediaFeature);
897
+ // <media-feature> = ( [ <mf-plain> | <mf-boolean> | <mf-range> ] )
898
+ // <mf-plain> = <mf-name> : <mf-value>
899
+ // <mf-boolean> = <mf-name>
900
+ // <mf-range> = <mf-name> [ '<' | '>' ]? '='? <mf-value> | <mf-value> [ '<' | '>' ]? '='? <mf-name> | <mf-value> '<' '='? <mf-name> '<' '='? <mf-value> | <mf-value> '>' '='? <mf-name> '>' '='? <mf-value>
901
+ var parseRangeOperator = function () {
902
+ if (_this.acceptDelim('<') || _this.acceptDelim('>')) {
903
+ if (!_this.hasWhitespace()) {
904
+ _this.acceptDelim('=');
854
905
  }
855
- return null;
906
+ return true;
856
907
  }
857
- if (!node.addChild(this._parseMediaFeatureName())) {
858
- return this.finish(node, ParseError.IdentifierExpected, [], resyncStopToken);
908
+ else if (_this.acceptDelim('=')) {
909
+ return true;
859
910
  }
911
+ return false;
912
+ };
913
+ if (node.addChild(this._parseMediaFeatureName())) {
860
914
  if (this.accept(TokenType.Colon)) {
861
- if (!node.addChild(this._parseExpr())) {
915
+ if (!node.addChild(this._parseMediaFeatureValue())) {
862
916
  return this.finish(node, ParseError.TermExpected, [], resyncStopToken);
863
917
  }
864
918
  }
865
- if (!this.accept(TokenType.ParenthesisR)) {
866
- return this.finish(node, ParseError.RightParenthesisExpected, [], resyncStopToken);
919
+ else if (parseRangeOperator()) {
920
+ if (!node.addChild(this._parseMediaFeatureValue())) {
921
+ return this.finish(node, ParseError.TermExpected, [], resyncStopToken);
922
+ }
923
+ if (parseRangeOperator()) {
924
+ if (!node.addChild(this._parseMediaFeatureValue())) {
925
+ return this.finish(node, ParseError.TermExpected, [], resyncStopToken);
926
+ }
927
+ }
928
+ }
929
+ else {
930
+ // <mf-boolean> = <mf-name>
931
+ }
932
+ }
933
+ else if (node.addChild(this._parseMediaFeatureValue())) {
934
+ if (!parseRangeOperator()) {
935
+ return this.finish(node, ParseError.OperatorExpected, [], resyncStopToken);
936
+ }
937
+ if (!node.addChild(this._parseMediaFeatureName())) {
938
+ return this.finish(node, ParseError.IdentifierExpected, [], resyncStopToken);
939
+ }
940
+ if (parseRangeOperator()) {
941
+ if (!node.addChild(this._parseMediaFeatureValue())) {
942
+ return this.finish(node, ParseError.TermExpected, [], resyncStopToken);
943
+ }
867
944
  }
868
- parseExpression = this.acceptIdent('and');
945
+ }
946
+ else {
947
+ return this.finish(node, ParseError.IdentifierExpected, [], resyncStopToken);
869
948
  }
870
949
  return this.finish(node);
871
950
  };
872
- Parser.prototype._parseMediaContentStart = function () {
873
- return null;
874
- };
875
951
  Parser.prototype._parseMediaFeatureName = function () {
876
952
  return this._parseIdent();
877
953
  };
954
+ Parser.prototype._parseMediaFeatureValue = function () {
955
+ return this._parseRatio() || this._parseTermExpression();
956
+ };
878
957
  Parser.prototype._parseMedium = function () {
879
958
  var node = this.create(nodes.Node);
880
959
  if (node.addChild(this._parseIdent())) {
@@ -1180,6 +1259,7 @@ var Parser = /** @class */ (function () {
1180
1259
  if (node.setOperator(this._parseOperator())) {
1181
1260
  node.setValue(this._parseBinaryExpr());
1182
1261
  this.acceptIdent('i'); // case insensitive matching
1262
+ this.acceptIdent('s'); // case sensitive matching
1183
1263
  }
1184
1264
  if (!this.accept(TokenType.BracketR)) {
1185
1265
  return this.finish(node, ParseError.RightSquareBracketExpected);
@@ -86,8 +86,8 @@ var LESSParser = /** @class */ (function (_super) {
86
86
  }
87
87
  return this.finish(node);
88
88
  };
89
- LESSParser.prototype._parseMediaQuery = function (resyncStopToken) {
90
- var node = _super.prototype._parseMediaQuery.call(this, resyncStopToken);
89
+ LESSParser.prototype._parseMediaQuery = function () {
90
+ var node = _super.prototype._parseMediaQuery.call(this);
91
91
  if (!node) {
92
92
  var node_1 = this.create(nodes.MediaQuery);
93
93
  if (node_1.addChild(this._parseVariable())) {
@@ -104,8 +104,8 @@ var SCSSParser = /** @class */ (function (_super) {
104
104
  }
105
105
  return this.finish(node);
106
106
  };
107
- SCSSParser.prototype._parseMediaContentStart = function () {
108
- return this._parseInterpolation();
107
+ SCSSParser.prototype._parseMediaCondition = function () {
108
+ return this._parseInterpolation() || _super.prototype._parseMediaCondition.call(this);
109
109
  };
110
110
  SCSSParser.prototype._parseMediaFeatureName = function () {
111
111
  return this._parseModuleMember()
@@ -457,7 +457,7 @@ var CSSCompletion = /** @class */ (function () {
457
457
  var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
458
458
  for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
459
459
  var symbol = symbols_1[_i];
460
- var insertText = strings.startsWith(symbol.name, '--') ? "var(" + symbol.name + ")" : symbol.name;
460
+ var insertText = strings.startsWith(symbol.name, '--') ? "var(".concat(symbol.name, ")") : symbol.name;
461
461
  var completionItem = {
462
462
  label: symbol.name,
463
463
  documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
@@ -479,22 +479,35 @@ var CSSCompletion = /** @class */ (function () {
479
479
  return result;
480
480
  };
481
481
  CSSCompletion.prototype.getVariableProposalsForCSSVarFunction = function (result) {
482
+ var allReferencedVariables = new Set();
483
+ this.styleSheet.acceptVisitor(new VariableCollector(allReferencedVariables, this.offset));
482
484
  var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
483
- symbols = symbols.filter(function (symbol) {
484
- return strings.startsWith(symbol.name, '--');
485
- });
486
485
  for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
487
486
  var symbol = symbols_2[_i];
488
- var completionItem = {
489
- label: symbol.name,
490
- documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
491
- textEdit: TextEdit.replace(this.getCompletionRange(null), symbol.name),
492
- kind: CompletionItemKind.Variable
493
- };
494
- if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
495
- completionItem.kind = CompletionItemKind.Color;
487
+ if (strings.startsWith(symbol.name, '--')) {
488
+ var completionItem = {
489
+ label: symbol.name,
490
+ documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
491
+ textEdit: TextEdit.replace(this.getCompletionRange(null), symbol.name),
492
+ kind: CompletionItemKind.Variable
493
+ };
494
+ if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
495
+ completionItem.kind = CompletionItemKind.Color;
496
+ }
497
+ result.items.push(completionItem);
498
+ }
499
+ allReferencedVariables.remove(symbol.name);
500
+ }
501
+ for (var _a = 0, _b = allReferencedVariables.getEntries(); _a < _b.length; _a++) {
502
+ var name = _b[_a];
503
+ if (strings.startsWith(name, '--')) {
504
+ var completionItem = {
505
+ label: name,
506
+ textEdit: TextEdit.replace(this.getCompletionRange(null), name),
507
+ kind: CompletionItemKind.Variable
508
+ };
509
+ result.items.push(completionItem);
496
510
  }
497
- result.items.push(completionItem);
498
511
  }
499
512
  return result;
500
513
  };
@@ -1045,24 +1058,6 @@ function isDeprecated(entry) {
1045
1058
  }
1046
1059
  return false;
1047
1060
  }
1048
- /**
1049
- * Rank number should all be same length strings
1050
- */
1051
- function computeRankNumber(n) {
1052
- var nstr = n.toString();
1053
- switch (nstr.length) {
1054
- case 4:
1055
- return nstr;
1056
- case 3:
1057
- return '0' + nstr;
1058
- case 2:
1059
- return '00' + nstr;
1060
- case 1:
1061
- return '000' + nstr;
1062
- default:
1063
- return '0000';
1064
- }
1065
- }
1066
1061
  var Set = /** @class */ (function () {
1067
1062
  function Set() {
1068
1063
  this.entries = {};
@@ -1070,6 +1065,9 @@ var Set = /** @class */ (function () {
1070
1065
  Set.prototype.add = function (entry) {
1071
1066
  this.entries[entry] = true;
1072
1067
  };
1068
+ Set.prototype.remove = function (entry) {
1069
+ delete this.entries[entry];
1070
+ };
1073
1071
  Set.prototype.getEntries = function () {
1074
1072
  return Object.keys(this.entries);
1075
1073
  };
@@ -1121,6 +1119,22 @@ var ColorValueCollector = /** @class */ (function () {
1121
1119
  };
1122
1120
  return ColorValueCollector;
1123
1121
  }());
1122
+ var VariableCollector = /** @class */ (function () {
1123
+ function VariableCollector(entries, currentOffset) {
1124
+ this.entries = entries;
1125
+ this.currentOffset = currentOffset;
1126
+ // nothing to do
1127
+ }
1128
+ VariableCollector.prototype.visitNode = function (node) {
1129
+ if (node instanceof nodes.Identifier && node.isCustomProperty) {
1130
+ if (this.currentOffset < node.offset || node.end < this.currentOffset) {
1131
+ this.entries.add(node.getText());
1132
+ }
1133
+ }
1134
+ return true;
1135
+ };
1136
+ return VariableCollector;
1137
+ }());
1124
1138
  function getCurrentWord(document, offset) {
1125
1139
  var i = offset - 1;
1126
1140
  var text = document.getText();