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.
@@ -47,6 +47,10 @@ export var cssWideKeywords = {
47
47
  'inherit': 'Represents the computed value of the property on the element’s parent.',
48
48
  'unset': 'Acts as either `inherit` or `initial`, depending on whether the property is inherited or not.'
49
49
  };
50
+ export var cssWideFunctions = {
51
+ 'var()': 'Evaluates the value of a custom variable.',
52
+ 'calc()': 'Evaluates an mathematical expression. The following operators can be used: + - * /.'
53
+ };
50
54
  export var imageFunctions = {
51
55
  'url()': 'Reference an image file by URL',
52
56
  'image()': 'Provide image fallbacks and annotations.',
@@ -354,6 +354,21 @@ export function getColorValue(node) {
354
354
  var functionNode = node;
355
355
  var name = functionNode.getName();
356
356
  var colorValues = functionNode.getArguments().getChildren();
357
+ if (colorValues.length === 1) {
358
+ var functionArg = colorValues[0].getChildren();
359
+ if (functionArg.length === 1 && functionArg[0].type === nodes.NodeType.Expression) {
360
+ colorValues = functionArg[0].getChildren();
361
+ if (colorValues.length === 3) {
362
+ var lastValue = colorValues[2];
363
+ if (lastValue instanceof nodes.BinaryExpression) {
364
+ var left = lastValue.getLeft(), right = lastValue.getRight(), operator = lastValue.getOperator();
365
+ if (left && right && operator && operator.matches('/')) {
366
+ colorValues = [colorValues[0], colorValues[1], left, right];
367
+ }
368
+ }
369
+ }
370
+ }
371
+ }
357
372
  if (!name || colorValues.length < 3 || colorValues.length > 4) {
358
373
  return null;
359
374
  }
@@ -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',
@@ -86,8 +87,12 @@ 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) + ')';
@@ -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);
@@ -3,6 +3,15 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  'use strict';
6
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
7
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
8
+ if (ar || !(i in from)) {
9
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
10
+ ar[i] = from[i];
11
+ }
12
+ }
13
+ return to.concat(ar || Array.prototype.slice.call(from));
14
+ };
6
15
  import { TokenType, Scanner } from './cssScanner';
7
16
  import * as nodes from './cssNodes';
8
17
  import { ParseError } from './cssErrors';
@@ -33,7 +42,11 @@ var Parser = /** @class */ (function () {
33
42
  Parser.prototype.peek = function (type) {
34
43
  return type === this.token.type;
35
44
  };
36
- Parser.prototype.peekOne = function (types) {
45
+ Parser.prototype.peekOne = function () {
46
+ var types = [];
47
+ for (var _i = 0; _i < arguments.length; _i++) {
48
+ types[_i] = arguments[_i];
49
+ }
37
50
  return types.indexOf(this.token.type) !== -1;
38
51
  };
39
52
  Parser.prototype.peekRegExp = function (type, regEx) {
@@ -442,13 +455,15 @@ var Parser = /** @class */ (function () {
442
455
  }
443
456
  this.restoreAtMark(mark);
444
457
  }
445
- // try tp parse as expression
458
+ // try to parse as expression
446
459
  var expression = this._parseExpr();
447
460
  if (expression && !expression.isErroneous(true)) {
448
461
  this._parsePrio();
449
- if (this.peekOne(stopTokens || [TokenType.SemiColon])) {
462
+ if (this.peekOne.apply(this, __spreadArray(__spreadArray([], (stopTokens || []), false), [TokenType.SemiColon, TokenType.EOF], false))) {
450
463
  node.setValue(expression);
451
- node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
464
+ if (this.peek(TokenType.SemiColon)) {
465
+ node.semicolonPosition = this.token.offset; // not part of the declaration, but useful information for code assist
466
+ }
452
467
  return this.finish(node);
453
468
  }
454
469
  }
@@ -800,66 +815,145 @@ var Parser = /** @class */ (function () {
800
815
  };
801
816
  Parser.prototype._parseMediaQueryList = function () {
802
817
  var node = this.create(nodes.Medialist);
803
- if (!node.addChild(this._parseMediaQuery([TokenType.CurlyL]))) {
818
+ if (!node.addChild(this._parseMediaQuery())) {
804
819
  return this.finish(node, ParseError.MediaQueryExpected);
805
820
  }
806
821
  while (this.accept(TokenType.Comma)) {
807
- if (!node.addChild(this._parseMediaQuery([TokenType.CurlyL]))) {
822
+ if (!node.addChild(this._parseMediaQuery())) {
808
823
  return this.finish(node, ParseError.MediaQueryExpected);
809
824
  }
810
825
  }
811
826
  return this.finish(node);
812
827
  };
813
- Parser.prototype._parseMediaQuery = function (resyncStopToken) {
814
- // http://www.w3.org/TR/css3-mediaqueries/
815
- // media_query : [ONLY | NOT]? S* IDENT S* [ AND S* expression ]* | expression [ AND S* expression ]*
816
- // 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> ]?
817
830
  var node = this.create(nodes.MediaQuery);
818
- var parseExpression = true;
819
- var hasContent = false;
831
+ var pos = this.mark();
832
+ this.acceptIdent('not');
820
833
  if (!this.peek(TokenType.ParenthesisL)) {
821
- if (this.acceptIdent('only') || this.acceptIdent('not')) {
834
+ if (this.acceptIdent('only')) {
822
835
  // optional
823
836
  }
824
837
  if (!node.addChild(this._parseIdent())) {
825
838
  return null;
826
839
  }
827
- hasContent = true;
828
- 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;
859
+ }
860
+ if (!this._parseNumeric()) {
861
+ return this.finish(node, ParseError.NumberExpected);
829
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;
830
874
  while (parseExpression) {
831
- // Allow short-circuting for other language constructs.
832
- if (node.addChild(this._parseMediaContentStart())) {
833
- parseExpression = this.acceptIdent('and');
834
- continue;
835
- }
836
875
  if (!this.accept(TokenType.ParenthesisL)) {
837
- if (hasContent) {
838
- 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('=');
839
905
  }
840
- return null;
906
+ return true;
841
907
  }
842
- if (!node.addChild(this._parseMediaFeatureName())) {
843
- return this.finish(node, ParseError.IdentifierExpected, [], resyncStopToken);
908
+ else if (_this.acceptDelim('=')) {
909
+ return true;
844
910
  }
911
+ return false;
912
+ };
913
+ if (node.addChild(this._parseMediaFeatureName())) {
845
914
  if (this.accept(TokenType.Colon)) {
846
- if (!node.addChild(this._parseExpr())) {
915
+ if (!node.addChild(this._parseMediaFeatureValue())) {
847
916
  return this.finish(node, ParseError.TermExpected, [], resyncStopToken);
848
917
  }
849
918
  }
850
- if (!this.accept(TokenType.ParenthesisR)) {
851
- 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>
852
931
  }
853
- parseExpression = this.acceptIdent('and');
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
+ }
944
+ }
945
+ }
946
+ else {
947
+ return this.finish(node, ParseError.IdentifierExpected, [], resyncStopToken);
854
948
  }
855
949
  return this.finish(node);
856
950
  };
857
- Parser.prototype._parseMediaContentStart = function () {
858
- return null;
859
- };
860
951
  Parser.prototype._parseMediaFeatureName = function () {
861
952
  return this._parseIdent();
862
953
  };
954
+ Parser.prototype._parseMediaFeatureValue = function () {
955
+ return this._parseRatio() || this._parseTermExpression();
956
+ };
863
957
  Parser.prototype._parseMedium = function () {
864
958
  var node = this.create(nodes.Node);
865
959
  if (node.addChild(this._parseIdent())) {
@@ -506,8 +506,8 @@ var Scanner = /** @class */ (function () {
506
506
  Scanner.prototype.ident = function (result) {
507
507
  var pos = this.stream.pos();
508
508
  var hasMinus = this._minus(result);
509
- if (hasMinus && this._minus(result) /* -- */) {
510
- if (this._identFirstChar(result) || this._escape(result)) {
509
+ if (hasMinus) {
510
+ if (this._minus(result) /* -- */ || this._identFirstChar(result) || this._escape(result)) {
511
511
  while (this._identChar(result) || this._escape(result)) {
512
512
  // loop
513
513
  }
@@ -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()
@@ -49,6 +49,10 @@ import { isDefined } from '../utils/objects';
49
49
  import { PathCompletionParticipant } from './pathCompletion';
50
50
  var localize = nls.loadMessageBundle();
51
51
  var SnippetFormat = InsertTextFormat.Snippet;
52
+ var retriggerCommand = {
53
+ title: 'Suggest',
54
+ command: 'editor.action.triggerSuggest'
55
+ };
52
56
  var SortTexts;
53
57
  (function (SortTexts) {
54
58
  // char code 32, comes before everything
@@ -282,10 +286,7 @@ var CSSCompletion = /** @class */ (function () {
282
286
  retrigger = false;
283
287
  }
284
288
  if (triggerPropertyValueCompletion && retrigger) {
285
- item.command = {
286
- title: 'Suggest',
287
- command: 'editor.action.triggerSuggest'
288
- };
289
+ item.command = retriggerCommand;
289
290
  }
290
291
  var relevance = typeof entry.relevance === 'number' ? Math.min(Math.max(entry.relevance, 0), 99) : 50;
291
292
  var sortTextSuffix = (255 - relevance).toString(16);
@@ -433,6 +434,17 @@ var CSSCompletion = /** @class */ (function () {
433
434
  kind: CompletionItemKind.Value
434
435
  });
435
436
  }
437
+ for (var func in languageFacts.cssWideFunctions) {
438
+ var insertText = moveCursorInsideParenthesis(func);
439
+ result.items.push({
440
+ label: func,
441
+ documentation: languageFacts.cssWideFunctions[func],
442
+ textEdit: TextEdit.replace(this.getCompletionRange(existingNode), insertText),
443
+ kind: CompletionItemKind.Function,
444
+ insertTextFormat: SnippetFormat,
445
+ command: strings.startsWith(func, 'var') ? retriggerCommand : undefined
446
+ });
447
+ }
436
448
  return result;
437
449
  };
438
450
  CSSCompletion.prototype.getCompletionsForInterpolation = function (node, result) {
@@ -467,22 +479,35 @@ var CSSCompletion = /** @class */ (function () {
467
479
  return result;
468
480
  };
469
481
  CSSCompletion.prototype.getVariableProposalsForCSSVarFunction = function (result) {
482
+ var allReferencedVariables = new Set();
483
+ this.styleSheet.acceptVisitor(new VariableCollector(allReferencedVariables, this.offset));
470
484
  var symbols = this.getSymbolContext().findSymbolsAtOffset(this.offset, nodes.ReferenceType.Variable);
471
- symbols = symbols.filter(function (symbol) {
472
- return strings.startsWith(symbol.name, '--');
473
- });
474
485
  for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
475
486
  var symbol = symbols_2[_i];
476
- var completionItem = {
477
- label: symbol.name,
478
- documentation: symbol.value ? strings.getLimitedString(symbol.value) : symbol.value,
479
- textEdit: TextEdit.replace(this.getCompletionRange(null), symbol.name),
480
- kind: CompletionItemKind.Variable
481
- };
482
- if (typeof completionItem.documentation === 'string' && isColorString(completionItem.documentation)) {
483
- 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);
484
510
  }
485
- result.items.push(completionItem);
486
511
  }
487
512
  return result;
488
513
  };
@@ -1033,24 +1058,6 @@ function isDeprecated(entry) {
1033
1058
  }
1034
1059
  return false;
1035
1060
  }
1036
- /**
1037
- * Rank number should all be same length strings
1038
- */
1039
- function computeRankNumber(n) {
1040
- var nstr = n.toString();
1041
- switch (nstr.length) {
1042
- case 4:
1043
- return nstr;
1044
- case 3:
1045
- return '0' + nstr;
1046
- case 2:
1047
- return '00' + nstr;
1048
- case 1:
1049
- return '000' + nstr;
1050
- default:
1051
- return '0000';
1052
- }
1053
- }
1054
1061
  var Set = /** @class */ (function () {
1055
1062
  function Set() {
1056
1063
  this.entries = {};
@@ -1058,6 +1065,9 @@ var Set = /** @class */ (function () {
1058
1065
  Set.prototype.add = function (entry) {
1059
1066
  this.entries[entry] = true;
1060
1067
  };
1068
+ Set.prototype.remove = function (entry) {
1069
+ delete this.entries[entry];
1070
+ };
1061
1071
  Set.prototype.getEntries = function () {
1062
1072
  return Object.keys(this.entries);
1063
1073
  };
@@ -1109,6 +1119,22 @@ var ColorValueCollector = /** @class */ (function () {
1109
1119
  };
1110
1120
  return ColorValueCollector;
1111
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
+ }());
1112
1138
  function getCurrentWord(document, offset) {
1113
1139
  var i = offset - 1;
1114
1140
  var text = document.getText();