vscode-css-languageservice 6.3.9 → 7.0.0-next.1

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/lib/esm/beautify/beautify-css.js +1437 -1606
  3. package/lib/esm/cssLanguageService.d.ts +2 -2
  4. package/lib/esm/cssLanguageService.js +18 -18
  5. package/lib/esm/data/webCustomData.js +13251 -2444
  6. package/lib/esm/languageFacts/builtinData.js +2 -1
  7. package/lib/esm/languageFacts/colors.js +1 -1
  8. package/lib/esm/languageFacts/dataManager.js +3 -3
  9. package/lib/esm/languageFacts/entry.js +1 -1
  10. package/lib/esm/languageFacts/facts.js +3 -3
  11. package/lib/esm/parser/cssErrors.js +1 -0
  12. package/lib/esm/parser/cssNodes.js +1 -1
  13. package/lib/esm/parser/cssParser.js +164 -17
  14. package/lib/esm/parser/cssSymbolScope.js +2 -2
  15. package/lib/esm/parser/lessParser.js +5 -5
  16. package/lib/esm/parser/lessScanner.js +1 -1
  17. package/lib/esm/parser/scssParser.js +64 -6
  18. package/lib/esm/parser/scssScanner.js +1 -1
  19. package/lib/esm/services/cssCodeActions.js +4 -4
  20. package/lib/esm/services/cssCompletion.js +7 -7
  21. package/lib/esm/services/cssFolding.js +3 -3
  22. package/lib/esm/services/cssFormatter.js +3 -3
  23. package/lib/esm/services/cssHover.js +6 -6
  24. package/lib/esm/services/cssNavigation.js +6 -6
  25. package/lib/esm/services/cssSelectionRange.js +2 -2
  26. package/lib/esm/services/cssValidation.js +4 -4
  27. package/lib/esm/services/lessCompletion.js +2 -2
  28. package/lib/esm/services/lint.js +5 -5
  29. package/lib/esm/services/lintRules.js +1 -1
  30. package/lib/esm/services/lintUtil.js +1 -1
  31. package/lib/esm/services/pathCompletion.js +3 -3
  32. package/lib/esm/services/scssCompletion.js +3 -3
  33. package/lib/esm/services/scssNavigation.js +4 -4
  34. package/lib/esm/services/selectorPrinting.js +3 -3
  35. package/package.json +20 -20
  36. package/lib/umd/beautify/beautify-css.js +0 -1695
  37. package/lib/umd/cssLanguageService.d.ts +0 -39
  38. package/lib/umd/cssLanguageService.js +0 -105
  39. package/lib/umd/cssLanguageTypes.d.ts +0 -267
  40. package/lib/umd/cssLanguageTypes.js +0 -89
  41. package/lib/umd/data/webCustomData.js +0 -33806
  42. package/lib/umd/languageFacts/builtinData.js +0 -154
  43. package/lib/umd/languageFacts/colors.js +0 -949
  44. package/lib/umd/languageFacts/dataManager.js +0 -101
  45. package/lib/umd/languageFacts/dataProvider.js +0 -86
  46. package/lib/umd/languageFacts/entry.js +0 -217
  47. package/lib/umd/languageFacts/facts.js +0 -33
  48. package/lib/umd/parser/cssErrors.js +0 -60
  49. package/lib/umd/parser/cssNodes.js +0 -1676
  50. package/lib/umd/parser/cssParser.js +0 -1888
  51. package/lib/umd/parser/cssScanner.js +0 -619
  52. package/lib/umd/parser/cssSymbolScope.js +0 -328
  53. package/lib/umd/parser/lessParser.js +0 -732
  54. package/lib/umd/parser/lessScanner.js +0 -70
  55. package/lib/umd/parser/scssErrors.js +0 -30
  56. package/lib/umd/parser/scssParser.js +0 -816
  57. package/lib/umd/parser/scssScanner.js +0 -108
  58. package/lib/umd/services/cssCodeActions.js +0 -89
  59. package/lib/umd/services/cssCompletion.js +0 -1109
  60. package/lib/umd/services/cssFolding.js +0 -202
  61. package/lib/umd/services/cssFormatter.js +0 -149
  62. package/lib/umd/services/cssHover.js +0 -174
  63. package/lib/umd/services/cssNavigation.js +0 -539
  64. package/lib/umd/services/cssSelectionRange.js +0 -59
  65. package/lib/umd/services/cssValidation.js +0 -54
  66. package/lib/umd/services/lessCompletion.js +0 -390
  67. package/lib/umd/services/lint.js +0 -577
  68. package/lib/umd/services/lintRules.js +0 -90
  69. package/lib/umd/services/lintUtil.js +0 -210
  70. package/lib/umd/services/pathCompletion.js +0 -171
  71. package/lib/umd/services/scssCompletion.js +0 -367
  72. package/lib/umd/services/scssNavigation.js +0 -169
  73. package/lib/umd/services/selectorPrinting.js +0 -575
  74. package/lib/umd/utils/arrays.js +0 -54
  75. package/lib/umd/utils/objects.js +0 -24
  76. package/lib/umd/utils/resources.js +0 -25
  77. package/lib/umd/utils/strings.js +0 -123
@@ -49,7 +49,8 @@ export const cssWideKeywords = {
49
49
  };
50
50
  export const cssWideFunctions = {
51
51
  'var()': 'Evaluates the value of a custom variable.',
52
- 'calc()': 'Evaluates an mathematical expression. The following operators can be used: + - * /.'
52
+ 'calc()': 'Evaluates an mathematical expression. The following operators can be used: + - * /.',
53
+ 'if()': 'Evaluates a conditional expression.'
53
54
  };
54
55
  export const imageFunctions = {
55
56
  'url()': 'Reference an image file by URL',
@@ -2,7 +2,7 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import * as nodes from '../parser/cssNodes';
5
+ import * as nodes from '../parser/cssNodes.js';
6
6
  import * as l10n from '@vscode/l10n';
7
7
  const hexColorRegExp = /(^#([0-9A-F]{3}){1,2}$)|(^#([0-9A-F]{4}){1,2}$)/i;
8
8
  export const colorFunctions = [
@@ -3,9 +3,9 @@
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 * as objects from '../utils/objects';
7
- import { cssData } from '../data/webCustomData';
8
- import { CSSDataProvider } from './dataProvider';
6
+ import * as objects from '../utils/objects.js';
7
+ import { cssData } from '../data/webCustomData.js';
8
+ import { CSSDataProvider } from './dataProvider.js';
9
9
  export class CSSDataManager {
10
10
  constructor(options) {
11
11
  this.dataProviders = [];
@@ -3,7 +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
+ import { MarkupKind } from '../cssLanguageTypes.js';
7
7
  export const browserNames = {
8
8
  'C': {
9
9
  name: 'Chrome',
@@ -3,6 +3,6 @@
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
5
  'use strict';
6
- export * from './entry';
7
- export * from './colors';
8
- export * from './builtinData';
6
+ export * from './entry.js';
7
+ export * from './colors.js';
8
+ export * from './builtinData.js';
@@ -44,4 +44,5 @@ export const ParseError = {
44
44
  IdentifierOrWildcardExpected: new CSSIssueType('css-idorwildcardexpected', l10n.t("identifier or wildcard expected")),
45
45
  WildcardExpected: new CSSIssueType('css-wildcardexpected', l10n.t("wildcard expected")),
46
46
  IdentifierOrVariableExpected: new CSSIssueType('css-idorvarexpected', l10n.t("identifier or variable expected")),
47
+ IfConditionExpected: new CSSIssueType('css-ifconditionexpected', l10n.t("if condition expected")),
47
48
  };
@@ -3,7 +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 { trim } from "../utils/strings";
6
+ import { trim } from "../utils/strings.js";
7
7
  /// <summary>
8
8
  /// Nodes for the css 2.1 specification. See for reference:
9
9
  /// http://www.w3.org/TR/CSS21/grammar.html#grammar
@@ -3,11 +3,11 @@
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 { TokenType, Scanner } from './cssScanner';
7
- import * as nodes from './cssNodes';
8
- import { ParseError } from './cssErrors';
9
- import * as languageFacts from '../languageFacts/facts';
10
- import { isDefined } from '../utils/objects';
6
+ import { TokenType, Scanner } from './cssScanner.js';
7
+ import * as nodes from './cssNodes.js';
8
+ import { ParseError } from './cssErrors.js';
9
+ import * as languageFacts from '../languageFacts/facts.js';
10
+ import { isDefined } from '../utils/objects.js';
11
11
  /// <summary>
12
12
  /// A parser for the css core specification. See for reference:
13
13
  /// https://www.w3.org/TR/CSS21/grammar.html
@@ -407,8 +407,8 @@ export class Parser {
407
407
  }
408
408
  return hasContent ? this.finish(node) : null;
409
409
  }
410
- _parseDeclaration(stopTokens) {
411
- const customProperty = this._tryParseCustomPropertyDeclaration(stopTokens);
410
+ _parseDeclaration(stopTokens, standaloneCustomPropertyValid = false) {
411
+ const customProperty = this._tryParseCustomPropertyDeclaration(stopTokens, standaloneCustomPropertyValid);
412
412
  if (customProperty) {
413
413
  return customProperty;
414
414
  }
@@ -431,7 +431,7 @@ export class Parser {
431
431
  }
432
432
  return this.finish(node);
433
433
  }
434
- _tryParseCustomPropertyDeclaration(stopTokens) {
434
+ _tryParseCustomPropertyDeclaration(stopTokens, standaloneCustomPropertyValid = false) {
435
435
  if (!this.peekRegExp(TokenType.Ident, /^--/)) {
436
436
  return null;
437
437
  }
@@ -440,6 +440,9 @@ export class Parser {
440
440
  return null;
441
441
  }
442
442
  if (!this.accept(TokenType.Colon)) {
443
+ if (standaloneCustomPropertyValid) {
444
+ return this.finish(node);
445
+ }
443
446
  return this.finish(node, ParseError.ColonExpected, [TokenType.Colon]);
444
447
  }
445
448
  if (this.prevToken) {
@@ -1006,6 +1009,56 @@ export class Parser {
1006
1009
  }
1007
1010
  return this.finish(node);
1008
1011
  }
1012
+ _parseBooleanExpression(parseTest) {
1013
+ // <boolean-expr[ <test> ]> = not <boolean-expr-group> | <boolean-expr-group>
1014
+ // [ [ and <boolean-expr-group> ]*
1015
+ // | [ or <boolean-expr-group> ]* ]
1016
+ const node = this.create(nodes.Node);
1017
+ if (this.acceptIdent('not')) {
1018
+ if (!node.addChild(this._parseBooleanExpressionGroup(parseTest))) {
1019
+ return null;
1020
+ }
1021
+ }
1022
+ else {
1023
+ if (!node.addChild(this._parseBooleanExpressionGroup(parseTest))) {
1024
+ return null;
1025
+ }
1026
+ if (this.peekIdent('and')) {
1027
+ while (this.acceptIdent('and')) {
1028
+ if (!node.addChild(this._parseBooleanExpressionGroup(parseTest))) {
1029
+ return null;
1030
+ }
1031
+ }
1032
+ }
1033
+ else if (this.peekIdent('or')) {
1034
+ while (this.acceptIdent('or')) {
1035
+ if (!node.addChild(this._parseBooleanExpressionGroup(parseTest))) {
1036
+ return null;
1037
+ }
1038
+ }
1039
+ }
1040
+ }
1041
+ return this.finish(node);
1042
+ }
1043
+ _parseBooleanExpressionGroup(parseTest) {
1044
+ // <boolean-expr-group> = <test> | ( <boolean-expr[ <test> ]> ) | <general-enclosed>
1045
+ const node = this.create(nodes.Node);
1046
+ const pos = this.mark();
1047
+ if (this.accept(TokenType.ParenthesisL)) {
1048
+ if (node.addChild(this._parseBooleanExpression(parseTest))) {
1049
+ if (!this.accept(TokenType.ParenthesisR)) {
1050
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.CurlyL]);
1051
+ }
1052
+ return this.finish(node);
1053
+ }
1054
+ this.restoreAtMark(pos);
1055
+ }
1056
+ if (!node.addChild(parseTest())) {
1057
+ return null;
1058
+ }
1059
+ ;
1060
+ return this.finish(node);
1061
+ }
1009
1062
  _parseMediaCondition() {
1010
1063
  // <media-condition> = <media-not> | <media-and> | <media-or> | <media-in-parens>
1011
1064
  // <media-not> = not <media-in-parens>
@@ -1125,7 +1178,7 @@ export class Parser {
1125
1178
  if (this.accept(TokenType.ParenthesisL)) {
1126
1179
  // scope-start selector can start with a combinator as it defaults to :scope
1127
1180
  // Treat as nested
1128
- if (!node.setScopeStart(this._parseSelector(true))) {
1181
+ if (!node.setScopeStart(this._parseScopeSelectorList())) {
1129
1182
  return this.finish(node, ParseError.SelectorExpected, [], [TokenType.ParenthesisR]);
1130
1183
  }
1131
1184
  if (!this.accept(TokenType.ParenthesisR)) {
@@ -1139,7 +1192,7 @@ export class Parser {
1139
1192
  }
1140
1193
  // 'to' selector can start with a combinator as it defaults to :scope
1141
1194
  // Treat as nested
1142
- if (!node.setScopeEnd(this._parseSelector(true))) {
1195
+ if (!node.setScopeEnd(this._parseScopeSelectorList())) {
1143
1196
  return this.finish(node, ParseError.SelectorExpected, [], [TokenType.ParenthesisR]);
1144
1197
  }
1145
1198
  if (!this.accept(TokenType.ParenthesisR)) {
@@ -1148,6 +1201,16 @@ export class Parser {
1148
1201
  }
1149
1202
  return this.finish(node);
1150
1203
  }
1204
+ _parseScopeSelectorList() {
1205
+ const selectors = this.createNode(nodes.NodeType.SelectorList);
1206
+ if (!selectors.addChild(this._parseSelector(true))) {
1207
+ return null;
1208
+ }
1209
+ while (this.accept(TokenType.Comma) && selectors.addChild(this._parseSelector(true))) {
1210
+ // loop
1211
+ }
1212
+ return this.finish(selectors);
1213
+ }
1151
1214
  _parseMedium() {
1152
1215
  const node = this.create(nodes.Node);
1153
1216
  if (node.addChild(this._parseIdent())) {
@@ -1228,7 +1291,15 @@ export class Parser {
1228
1291
  const node = this.create(nodes.Container);
1229
1292
  this.consumeToken(); // @container
1230
1293
  node.addChild(this._parseIdent()); // optional container name
1231
- node.addChild(this._parseContainerQuery());
1294
+ if (node.addChild(this._parseContainerQuery())) {
1295
+ while (this.accept(TokenType.Comma)) {
1296
+ if (this.peek(TokenType.CurlyL)) {
1297
+ break;
1298
+ }
1299
+ node.addChild(this._parseIdent()); // optional container name
1300
+ node.addChild(this._parseContainerQuery());
1301
+ }
1302
+ }
1232
1303
  return this._parseBody(node, this._parseContainerDeclaration.bind(this, isNested));
1233
1304
  }
1234
1305
  _parseContainerQuery() {
@@ -1239,7 +1310,7 @@ export class Parser {
1239
1310
  node.addChild(this._parseContainerQueryInParens());
1240
1311
  }
1241
1312
  else {
1242
- node.addChild(this._parseContainerQueryInParens());
1313
+ node.addChild(this._parseContainerQueryInParens(true));
1243
1314
  if (this.peekIdent('and')) {
1244
1315
  while (this.acceptIdent('and')) {
1245
1316
  node.addChild(this._parseContainerQueryInParens());
@@ -1253,7 +1324,7 @@ export class Parser {
1253
1324
  }
1254
1325
  return this.finish(node);
1255
1326
  }
1256
- _parseContainerQueryInParens() {
1327
+ _parseContainerQueryInParens(optional = false) {
1257
1328
  // <query-in-parens> = ( <container-query> )
1258
1329
  // | ( <size-feature> )
1259
1330
  // | style( <style-query> )
@@ -1280,6 +1351,9 @@ export class Parser {
1280
1351
  }
1281
1352
  }
1282
1353
  else {
1354
+ if (optional) {
1355
+ return null;
1356
+ }
1283
1357
  return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.CurlyL]);
1284
1358
  }
1285
1359
  return this.finish(node);
@@ -1309,7 +1383,7 @@ export class Parser {
1309
1383
  }
1310
1384
  }
1311
1385
  else {
1312
- node.addChild(this._parseDeclaration([TokenType.ParenthesisR]));
1386
+ node.addChild(this._parseDeclaration([TokenType.ParenthesisR], true));
1313
1387
  }
1314
1388
  return this.finish(node);
1315
1389
  }
@@ -1815,6 +1889,12 @@ export class Parser {
1815
1889
  _parseFunction() {
1816
1890
  const pos = this.mark();
1817
1891
  const node = this.create(nodes.Function);
1892
+ let parseArgument = this._parseFunctionArgument.bind(this);
1893
+ let separator = TokenType.Comma;
1894
+ if (this.peekIdent("if")) {
1895
+ parseArgument = this._parseIfBranch.bind(this);
1896
+ separator = TokenType.SemiColon;
1897
+ }
1818
1898
  if (!node.setIdentifier(this._parseFunctionIdentifier())) {
1819
1899
  return null;
1820
1900
  }
@@ -1822,12 +1902,12 @@ export class Parser {
1822
1902
  this.restoreAtMark(pos);
1823
1903
  return null;
1824
1904
  }
1825
- if (node.getArguments().addChild(this._parseFunctionArgument())) {
1826
- while (this.accept(TokenType.Comma)) {
1905
+ if (node.getArguments().addChild(parseArgument())) {
1906
+ while (this.accept(separator)) {
1827
1907
  if (this.peek(TokenType.ParenthesisR)) {
1828
1908
  break;
1829
1909
  }
1830
- if (!node.getArguments().addChild(this._parseFunctionArgument())) {
1910
+ if (!node.getArguments().addChild(parseArgument())) {
1831
1911
  this.markError(node, ParseError.ExpressionExpected);
1832
1912
  }
1833
1913
  }
@@ -1862,6 +1942,73 @@ export class Parser {
1862
1942
  }
1863
1943
  return null;
1864
1944
  }
1945
+ _parseIfBranch() {
1946
+ // <if-branch> = <if-condition> : <declaration-value>?
1947
+ const node = this.create(nodes.Node);
1948
+ if (!node.addChild(this._parseIfCondition())) {
1949
+ return this.finish(node, ParseError.IfConditionExpected, [], [TokenType.SemiColon]);
1950
+ }
1951
+ if (!this.accept(TokenType.Colon)) {
1952
+ return this.finish(node, ParseError.ColonExpected, [], [TokenType.SemiColon]);
1953
+ }
1954
+ node.addChild(this._parseExpr());
1955
+ return this.finish(node);
1956
+ }
1957
+ _parseIfCondition() {
1958
+ // <if-condition> = <boolean-expr[ <if-test> ]> | else
1959
+ const node = this.create(nodes.Node);
1960
+ if (this.peekIdent("else")) {
1961
+ node.addChild(this._parseIdent());
1962
+ return this.finish(node);
1963
+ }
1964
+ return this._parseBooleanExpression(this._parseIfTest.bind(this));
1965
+ }
1966
+ _parseIfTest() {
1967
+ // <if-test> =
1968
+ // supports( [ <ident> : <declaration-value> ] | <supports-condition> ) |
1969
+ // media( <media-feature> | <media-condition> ) |
1970
+ // style( <style-query> )
1971
+ const node = this.create(nodes.Node);
1972
+ if (this.acceptIdent('supports')) {
1973
+ if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) {
1974
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.Colon]);
1975
+ }
1976
+ node.addChild(this._tryToParseDeclaration() || this._parseSupportsCondition());
1977
+ if (!this.accept(TokenType.ParenthesisR)) {
1978
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.Colon]);
1979
+ }
1980
+ return this.finish(node);
1981
+ }
1982
+ if (this.acceptIdent('media')) {
1983
+ if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) {
1984
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.Colon]);
1985
+ }
1986
+ const pos = this.mark();
1987
+ const condition = this._parseMediaCondition();
1988
+ if (condition && !condition.isErroneous()) {
1989
+ node.addChild(condition);
1990
+ }
1991
+ else {
1992
+ this.restoreAtMark(pos);
1993
+ node.addChild(this._parseMediaFeature());
1994
+ }
1995
+ if (!this.accept(TokenType.ParenthesisR)) {
1996
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.Colon]);
1997
+ }
1998
+ return this.finish(node);
1999
+ }
2000
+ if (this.acceptIdent('style')) {
2001
+ if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) {
2002
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.Colon]);
2003
+ }
2004
+ node.addChild(this._parseStyleQuery());
2005
+ if (!this.accept(TokenType.ParenthesisR)) {
2006
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.Colon]);
2007
+ }
2008
+ return this.finish(node);
2009
+ }
2010
+ return null;
2011
+ }
1865
2012
  _parseHexColor() {
1866
2013
  if (this.peekRegExp(TokenType.Hash, /^#([A-Fa-f0-9]{3}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{8})$/g)) {
1867
2014
  const node = this.create(nodes.HexColorValue);
@@ -3,8 +3,8 @@
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 * as nodes from './cssNodes';
7
- import { findFirst } from '../utils/arrays';
6
+ import * as nodes from './cssNodes.js';
7
+ import { findFirst } from '../utils/arrays.js';
8
8
  export class Scope {
9
9
  constructor(offset, length) {
10
10
  this.offset = offset;
@@ -3,11 +3,11 @@
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 * as lessScanner from './lessScanner';
7
- import { TokenType } from './cssScanner';
8
- import * as cssParser from './cssParser';
9
- import * as nodes from './cssNodes';
10
- import { ParseError } from './cssErrors';
6
+ import * as lessScanner from './lessScanner.js';
7
+ import { TokenType } from './cssScanner.js';
8
+ import * as cssParser from './cssParser.js';
9
+ import * as nodes from './cssNodes.js';
10
+ import { ParseError } from './cssErrors.js';
11
11
  /// <summary>
12
12
  /// A parser for LESS
13
13
  /// http://lesscss.org/
@@ -3,7 +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 * as scanner from './cssScanner';
6
+ import * as scanner from './cssScanner.js';
7
7
  const _FSL = '/'.charCodeAt(0);
8
8
  const _NWL = '\n'.charCodeAt(0);
9
9
  const _CAR = '\r'.charCodeAt(0);
@@ -3,12 +3,12 @@
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 * as scssScanner from './scssScanner';
7
- import { TokenType } from './cssScanner';
8
- import * as cssParser from './cssParser';
9
- import * as nodes from './cssNodes';
10
- import { SCSSParseError } from './scssErrors';
11
- import { ParseError } from './cssErrors';
6
+ import * as scssScanner from './scssScanner.js';
7
+ import { TokenType } from './cssScanner.js';
8
+ import * as cssParser from './cssParser.js';
9
+ import * as nodes from './cssNodes.js';
10
+ import { SCSSParseError } from './scssErrors.js';
11
+ import { ParseError } from './cssErrors.js';
12
12
  /// <summary>
13
13
  /// A parser for scss
14
14
  /// http://sass-lang.com/documentation/file.SASS_REFERENCE.html
@@ -616,6 +616,64 @@ export class SCSSParser extends cssParser.Parser {
616
616
  _parseMixinReferenceBodyStatement() {
617
617
  return this._tryParseKeyframeSelector() || this._parseRuleSetDeclaration();
618
618
  }
619
+ _parseIfTest() {
620
+ const node = this.create(nodes.Node);
621
+ if (this.acceptIdent('sass')) {
622
+ if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) {
623
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.CurlyL]);
624
+ }
625
+ node.addChild(this._parseExpr());
626
+ if (!this.accept(TokenType.ParenthesisR)) {
627
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.CurlyL]);
628
+ }
629
+ return this.finish(node);
630
+ }
631
+ return super._parseIfTest();
632
+ }
633
+ _parseFunction() {
634
+ const pos = this.mark();
635
+ const node = this.create(nodes.Function);
636
+ let isIf = this.peekIdent('if');
637
+ if (!node.setIdentifier(this._parseFunctionIdentifier())) {
638
+ return null;
639
+ }
640
+ if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) {
641
+ this.restoreAtMark(pos);
642
+ return null;
643
+ }
644
+ let firstArgument;
645
+ let parseArgument = this._parseFunctionArgument.bind(this);
646
+ let separator = TokenType.Comma;
647
+ if (!isIf) {
648
+ firstArgument = this._parseFunctionArgument();
649
+ }
650
+ else {
651
+ const pos = this.mark();
652
+ firstArgument = this._parseIfBranch();
653
+ if (firstArgument && !firstArgument.isErroneous()) {
654
+ parseArgument = this._parseIfBranch.bind(this);
655
+ separator = TokenType.SemiColon;
656
+ }
657
+ else {
658
+ this.restoreAtMark(pos);
659
+ firstArgument = this._parseFunctionArgument();
660
+ }
661
+ }
662
+ if (node.getArguments().addChild(firstArgument)) {
663
+ while (this.accept(separator)) {
664
+ if (this.peek(TokenType.ParenthesisR)) {
665
+ break;
666
+ }
667
+ if (!node.getArguments().addChild(parseArgument())) {
668
+ this.markError(node, ParseError.ExpressionExpected);
669
+ }
670
+ }
671
+ }
672
+ if (!this.accept(TokenType.ParenthesisR)) {
673
+ return this.finish(node, ParseError.RightParenthesisExpected);
674
+ }
675
+ return this.finish(node);
676
+ }
619
677
  _parseFunctionArgument() {
620
678
  // [variableName ':'] expression | variableName '...'
621
679
  const node = this.create(nodes.FunctionArgument);
@@ -3,7 +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 { TokenType, Scanner } from './cssScanner';
6
+ import { TokenType, Scanner } from './cssScanner.js';
7
7
  const _FSL = '/'.charCodeAt(0);
8
8
  const _NWL = '\n'.charCodeAt(0);
9
9
  const _CAR = '\r'.charCodeAt(0);
@@ -3,10 +3,10 @@
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 * as nodes from '../parser/cssNodes';
7
- import { difference } from '../utils/strings';
8
- import { Rules } from '../services/lintRules';
9
- import { Command, TextEdit, CodeAction, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier } from '../cssLanguageTypes';
6
+ import * as nodes from '../parser/cssNodes.js';
7
+ import { difference } from '../utils/strings.js';
8
+ import { Rules } from '../services/lintRules.js';
9
+ import { Command, TextEdit, CodeAction, CodeActionKind, TextDocumentEdit, VersionedTextDocumentIdentifier } from '../cssLanguageTypes.js';
10
10
  import * as l10n from '@vscode/l10n';
11
11
  export class CSSCodeActions {
12
12
  constructor(cssDataManager) {
@@ -3,14 +3,14 @@
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 * as nodes from '../parser/cssNodes';
7
- import { Symbols } from '../parser/cssSymbolScope';
8
- import * as languageFacts from '../languageFacts/facts';
9
- import * as strings from '../utils/strings';
10
- import { Position, CompletionItemKind, Range, TextEdit, InsertTextFormat, MarkupKind, CompletionItemTag } from '../cssLanguageTypes';
6
+ import * as nodes from '../parser/cssNodes.js';
7
+ import { Symbols } from '../parser/cssSymbolScope.js';
8
+ import * as languageFacts from '../languageFacts/facts.js';
9
+ import * as strings from '../utils/strings.js';
10
+ import { Position, CompletionItemKind, Range, TextEdit, InsertTextFormat, MarkupKind, CompletionItemTag } from '../cssLanguageTypes.js';
11
11
  import * as l10n from '@vscode/l10n';
12
- import { isDefined } from '../utils/objects';
13
- import { PathCompletionParticipant } from './pathCompletion';
12
+ import { isDefined } from '../utils/objects.js';
13
+ import { PathCompletionParticipant } from './pathCompletion.js';
14
14
  const SnippetFormat = InsertTextFormat.Snippet;
15
15
  const retriggerCommand = {
16
16
  title: 'Suggest',
@@ -3,9 +3,9 @@
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 { TokenType, Scanner } from '../parser/cssScanner';
7
- import { SCSSScanner, InterpolationFunction } from '../parser/scssScanner';
8
- import { LESSScanner } from '../parser/lessScanner';
6
+ import { TokenType, Scanner } from '../parser/cssScanner.js';
7
+ import { SCSSScanner, InterpolationFunction } from '../parser/scssScanner.js';
8
+ import { LESSScanner } from '../parser/lessScanner.js';
9
9
  export function getFoldingRanges(document, context) {
10
10
  const ranges = computeFoldingRanges(document);
11
11
  return limitFoldingRanges(ranges, context);
@@ -2,9 +2,9 @@
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
3
  * Licensed under the MIT License. See License.txt in the project root for license information.
4
4
  *--------------------------------------------------------------------------------------------*/
5
- import { Range, Position } from '../cssLanguageTypes';
6
- import { css_beautify } from '../beautify/beautify-css';
7
- import { repeat } from '../utils/strings';
5
+ import { Range, Position } from '../cssLanguageTypes.js';
6
+ import { css_beautify } from '../beautify/beautify-css.js';
7
+ import { repeat } from '../utils/strings.js';
8
8
  export function format(document, range, options) {
9
9
  let value = document.getText();
10
10
  let includesEnd = true;
@@ -3,12 +3,12 @@
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 * as nodes from '../parser/cssNodes';
7
- import * as languageFacts from '../languageFacts/facts';
8
- import { SelectorPrinting } from './selectorPrinting';
9
- import { startsWith } from '../utils/strings';
10
- import { Range, MarkupKind } from '../cssLanguageTypes';
11
- import { isDefined } from '../utils/objects';
6
+ import * as nodes from '../parser/cssNodes.js';
7
+ import * as languageFacts from '../languageFacts/facts.js';
8
+ import { SelectorPrinting } from './selectorPrinting.js';
9
+ import { startsWith } from '../utils/strings.js';
10
+ import { Range, MarkupKind } from '../cssLanguageTypes.js';
11
+ import { isDefined } from '../utils/objects.js';
12
12
  export class CSSHover {
13
13
  constructor(clientCapabilities, cssDataManager) {
14
14
  this.clientCapabilities = clientCapabilities;
@@ -3,13 +3,13 @@
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 { DocumentHighlightKind, Location, Range, SymbolKind, TextEdit, FileType } from '../cssLanguageTypes';
6
+ import { DocumentHighlightKind, Location, Range, SymbolKind, TextEdit, FileType } from '../cssLanguageTypes.js';
7
7
  import * as l10n from '@vscode/l10n';
8
- import * as nodes from '../parser/cssNodes';
9
- import { Symbols } from '../parser/cssSymbolScope';
10
- import { getColorValue, hslFromColor, hwbFromColor, labFromColor, lchFromColor, oklabFromColor, oklchFromColor, } from '../languageFacts/facts';
11
- import { startsWith } from '../utils/strings';
12
- import { dirname, joinPath } from '../utils/resources';
8
+ import * as nodes from '../parser/cssNodes.js';
9
+ import { Symbols } from '../parser/cssSymbolScope.js';
10
+ import { getColorValue, hslFromColor, hwbFromColor, labFromColor, lchFromColor, oklabFromColor, oklchFromColor, } from '../languageFacts/facts.js';
11
+ import { startsWith } from '../utils/strings.js';
12
+ import { dirname, joinPath } from '../utils/resources.js';
13
13
  const startsWithSchemeRegex = /^\w+:\/\//;
14
14
  const startsWithData = /^data:/;
15
15
  export class CSSNavigation {
@@ -3,8 +3,8 @@
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 { Range, SelectionRange } from '../cssLanguageTypes';
7
- import { NodeType } from '../parser/cssNodes';
6
+ import { Range, SelectionRange } from '../cssLanguageTypes.js';
7
+ import { NodeType } from '../parser/cssNodes.js';
8
8
  export function getSelectionRanges(document, positions, stylesheet) {
9
9
  function getSelectionRange(position) {
10
10
  const applicableRanges = getApplicableRanges(position);
@@ -3,10 +3,10 @@
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 * as nodes from '../parser/cssNodes';
7
- import { LintConfigurationSettings, Rules } from './lintRules';
8
- import { LintVisitor } from './lint';
9
- import { Range, DiagnosticSeverity } from '../cssLanguageTypes';
6
+ import * as nodes from '../parser/cssNodes.js';
7
+ import { LintConfigurationSettings, Rules } from './lintRules.js';
8
+ import { LintVisitor } from './lint.js';
9
+ import { Range, DiagnosticSeverity } from '../cssLanguageTypes.js';
10
10
  export class CSSValidation {
11
11
  constructor(cssDataManager) {
12
12
  this.cssDataManager = cssDataManager;
@@ -3,8 +3,8 @@
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 { CSSCompletion } from './cssCompletion';
7
- import { CompletionItemKind, InsertTextFormat, TextEdit } from '../cssLanguageTypes';
6
+ import { CSSCompletion } from './cssCompletion.js';
7
+ import { CompletionItemKind, InsertTextFormat, TextEdit } from '../cssLanguageTypes.js';
8
8
  import * as l10n from '@vscode/l10n';
9
9
  export class LESSCompletion extends CSSCompletion {
10
10
  constructor(lsOptions, cssDataManager) {