vscode-css-languageservice 6.2.8 → 6.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,6 +97,7 @@ export var NodeType;
97
97
  NodeType[NodeType["LayerNameList"] = 84] = "LayerNameList";
98
98
  NodeType[NodeType["LayerName"] = 85] = "LayerName";
99
99
  NodeType[NodeType["PropertyAtRule"] = 86] = "PropertyAtRule";
100
+ NodeType[NodeType["Container"] = 87] = "Container";
100
101
  })(NodeType || (NodeType = {}));
101
102
  export var ReferenceType;
102
103
  (function (ReferenceType) {
@@ -922,6 +923,14 @@ export class Document extends BodyDeclaration {
922
923
  return NodeType.Document;
923
924
  }
924
925
  }
926
+ export class Container extends BodyDeclaration {
927
+ constructor(offset, length) {
928
+ super(offset, length);
929
+ }
930
+ get type() {
931
+ return NodeType.Container;
932
+ }
933
+ }
925
934
  export class Medialist extends Node {
926
935
  constructor(offset, length) {
927
936
  super(offset, length);
@@ -276,6 +276,7 @@ export class Parser {
276
276
  || this._parseViewPort()
277
277
  || this._parseNamespace()
278
278
  || this._parseDocument()
279
+ || this._parseContainer()
279
280
  || this._parseUnknownAtRule();
280
281
  }
281
282
  _tryParseRuleset(isNested) {
@@ -1134,6 +1135,111 @@ export class Parser {
1134
1135
  this.resync([], [TokenType.CurlyL]); // ignore all the rules
1135
1136
  return this._parseBody(node, this._parseStylesheetStatement.bind(this));
1136
1137
  }
1138
+ _parseContainer() {
1139
+ if (!this.peekKeyword('@container')) {
1140
+ return null;
1141
+ }
1142
+ const node = this.create(nodes.Container);
1143
+ this.consumeToken(); // @container
1144
+ node.addChild(this._parseIdent()); // optional container name
1145
+ node.addChild(this._parseContainerQuery());
1146
+ return this._parseBody(node, this._parseStylesheetStatement.bind(this));
1147
+ }
1148
+ _parseContainerQuery() {
1149
+ // <container-query> = not <query-in-parens>
1150
+ // | <query-in-parens> [ [ and <query-in-parens> ]* | [ or <query-in-parens> ]* ]
1151
+ const node = this.create(nodes.Node);
1152
+ if (this.acceptIdent('not')) {
1153
+ node.addChild(this._parseContainerQueryInParens());
1154
+ }
1155
+ else {
1156
+ node.addChild(this._parseContainerQueryInParens());
1157
+ if (this.peekIdent('and')) {
1158
+ while (this.acceptIdent('and')) {
1159
+ node.addChild(this._parseContainerQueryInParens());
1160
+ }
1161
+ }
1162
+ else if (this.peekIdent('or')) {
1163
+ while (this.acceptIdent('or')) {
1164
+ node.addChild(this._parseContainerQueryInParens());
1165
+ }
1166
+ }
1167
+ }
1168
+ return this.finish(node);
1169
+ }
1170
+ _parseContainerQueryInParens() {
1171
+ // <query-in-parens> = ( <container-query> )
1172
+ // | ( <size-feature> )
1173
+ // | style( <style-query> )
1174
+ // | <general-enclosed>
1175
+ const node = this.create(nodes.Node);
1176
+ if (this.accept(TokenType.ParenthesisL)) {
1177
+ if (this.peekIdent('not') || this.peek(TokenType.ParenthesisL)) {
1178
+ node.addChild(this._parseContainerQuery());
1179
+ }
1180
+ else {
1181
+ node.addChild(this._parseMediaFeature());
1182
+ }
1183
+ if (!this.accept(TokenType.ParenthesisR)) {
1184
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.CurlyL]);
1185
+ }
1186
+ }
1187
+ else if (this.acceptIdent('style')) {
1188
+ if (this.hasWhitespace() || !this.accept(TokenType.ParenthesisL)) {
1189
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.CurlyL]);
1190
+ }
1191
+ node.addChild(this._parseStyleQuery());
1192
+ if (!this.accept(TokenType.ParenthesisR)) {
1193
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.CurlyL]);
1194
+ }
1195
+ }
1196
+ else {
1197
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.CurlyL]);
1198
+ }
1199
+ return this.finish(node);
1200
+ }
1201
+ _parseStyleQuery() {
1202
+ // <style-query> = not <style-in-parens>
1203
+ // | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ]
1204
+ // | <style-feature>
1205
+ // <style-in-parens> = ( <style-query> )
1206
+ // | ( <style-feature> )
1207
+ // | <general-enclosed>
1208
+ const node = this.create(nodes.Node);
1209
+ if (this.acceptIdent('not')) {
1210
+ node.addChild(this._parseStyleInParens());
1211
+ }
1212
+ else if (this.peek(TokenType.ParenthesisL)) {
1213
+ node.addChild(this._parseStyleInParens());
1214
+ if (this.peekIdent('and')) {
1215
+ while (this.acceptIdent('and')) {
1216
+ node.addChild(this._parseStyleInParens());
1217
+ }
1218
+ }
1219
+ else if (this.peekIdent('or')) {
1220
+ while (this.acceptIdent('or')) {
1221
+ node.addChild(this._parseStyleInParens());
1222
+ }
1223
+ }
1224
+ }
1225
+ else {
1226
+ node.addChild(this._parseDeclaration([TokenType.ParenthesisR]));
1227
+ }
1228
+ return this.finish(node);
1229
+ }
1230
+ _parseStyleInParens() {
1231
+ const node = this.create(nodes.Node);
1232
+ if (this.accept(TokenType.ParenthesisL)) {
1233
+ node.addChild(this._parseStyleQuery());
1234
+ if (!this.accept(TokenType.ParenthesisR)) {
1235
+ return this.finish(node, ParseError.RightParenthesisExpected, [], [TokenType.CurlyL]);
1236
+ }
1237
+ }
1238
+ else {
1239
+ return this.finish(node, ParseError.LeftParenthesisExpected, [], [TokenType.CurlyL]);
1240
+ }
1241
+ return this.finish(node);
1242
+ }
1137
1243
  // https://www.w3.org/TR/css-syntax-3/#consume-an-at-rule
1138
1244
  _parseUnknownAtRule() {
1139
1245
  if (!this.peek(TokenType.AtKeyword)) {
@@ -1562,6 +1668,7 @@ export class Parser {
1562
1668
  this.peek(TokenType.Angle) ||
1563
1669
  this.peek(TokenType.Time) ||
1564
1670
  this.peek(TokenType.Dimension) ||
1671
+ this.peek(TokenType.ContainerQueryLength) ||
1565
1672
  this.peek(TokenType.Freq)) {
1566
1673
  const node = this.create(nodes.NumericValue);
1567
1674
  this.consumeToken();
@@ -48,6 +48,7 @@ export var TokenType;
48
48
  TokenType[TokenType["SingleLineComment"] = 40] = "SingleLineComment";
49
49
  TokenType[TokenType["EOF"] = 41] = "EOF";
50
50
  TokenType[TokenType["CustomToken"] = 42] = "CustomToken";
51
+ TokenType[TokenType["ContainerQueryLength"] = 43] = "ContainerQueryLength";
51
52
  })(TokenType || (TokenType = {}));
52
53
  export class MultiLineStream {
53
54
  constructor(source) {
@@ -184,6 +185,12 @@ staticUnitTable['%'] = TokenType.Percentage;
184
185
  staticUnitTable['fr'] = TokenType.Percentage;
185
186
  staticUnitTable['dpi'] = TokenType.Resolution;
186
187
  staticUnitTable['dpcm'] = TokenType.Resolution;
188
+ staticUnitTable['cqw'] = TokenType.ContainerQueryLength;
189
+ staticUnitTable['cqh'] = TokenType.ContainerQueryLength;
190
+ staticUnitTable['cqi'] = TokenType.ContainerQueryLength;
191
+ staticUnitTable['cqb'] = TokenType.ContainerQueryLength;
192
+ staticUnitTable['cqmin'] = TokenType.ContainerQueryLength;
193
+ staticUnitTable['cqmax'] = TokenType.ContainerQueryLength;
187
194
  export class Scanner {
188
195
  constructor() {
189
196
  this.stream = new MultiLineStream('');
@@ -13,7 +13,7 @@
13
13
  *--------------------------------------------------------------------------------------------*/
14
14
  'use strict';
15
15
  Object.defineProperty(exports, "__esModule", { value: true });
16
- 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.PropertyAtRule = exports.Layer = 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.UnicodeRange = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0;
16
+ 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.Container = exports.Document = exports.PropertyAtRule = exports.Layer = 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.UnicodeRange = exports.Nodelist = exports.Node = exports.getParentDeclaration = exports.getNodePath = exports.getNodeAtOffset = exports.ReferenceType = exports.NodeType = void 0;
17
17
  const strings_1 = require("../utils/strings");
18
18
  /// <summary>
19
19
  /// Nodes for the css 2.1 specification. See for reference:
@@ -108,6 +108,7 @@
108
108
  NodeType[NodeType["LayerNameList"] = 84] = "LayerNameList";
109
109
  NodeType[NodeType["LayerName"] = 85] = "LayerName";
110
110
  NodeType[NodeType["PropertyAtRule"] = 86] = "PropertyAtRule";
111
+ NodeType[NodeType["Container"] = 87] = "Container";
111
112
  })(NodeType || (exports.NodeType = NodeType = {}));
112
113
  var ReferenceType;
113
114
  (function (ReferenceType) {
@@ -978,6 +979,15 @@
978
979
  }
979
980
  }
980
981
  exports.Document = Document;
982
+ class Container extends BodyDeclaration {
983
+ constructor(offset, length) {
984
+ super(offset, length);
985
+ }
986
+ get type() {
987
+ return NodeType.Container;
988
+ }
989
+ }
990
+ exports.Container = Container;
981
991
  class Medialist extends Node {
982
992
  constructor(offset, length) {
983
993
  super(offset, length);
@@ -287,6 +287,7 @@
287
287
  || this._parseViewPort()
288
288
  || this._parseNamespace()
289
289
  || this._parseDocument()
290
+ || this._parseContainer()
290
291
  || this._parseUnknownAtRule();
291
292
  }
292
293
  _tryParseRuleset(isNested) {
@@ -1145,6 +1146,111 @@
1145
1146
  this.resync([], [cssScanner_1.TokenType.CurlyL]); // ignore all the rules
1146
1147
  return this._parseBody(node, this._parseStylesheetStatement.bind(this));
1147
1148
  }
1149
+ _parseContainer() {
1150
+ if (!this.peekKeyword('@container')) {
1151
+ return null;
1152
+ }
1153
+ const node = this.create(nodes.Container);
1154
+ this.consumeToken(); // @container
1155
+ node.addChild(this._parseIdent()); // optional container name
1156
+ node.addChild(this._parseContainerQuery());
1157
+ return this._parseBody(node, this._parseStylesheetStatement.bind(this));
1158
+ }
1159
+ _parseContainerQuery() {
1160
+ // <container-query> = not <query-in-parens>
1161
+ // | <query-in-parens> [ [ and <query-in-parens> ]* | [ or <query-in-parens> ]* ]
1162
+ const node = this.create(nodes.Node);
1163
+ if (this.acceptIdent('not')) {
1164
+ node.addChild(this._parseContainerQueryInParens());
1165
+ }
1166
+ else {
1167
+ node.addChild(this._parseContainerQueryInParens());
1168
+ if (this.peekIdent('and')) {
1169
+ while (this.acceptIdent('and')) {
1170
+ node.addChild(this._parseContainerQueryInParens());
1171
+ }
1172
+ }
1173
+ else if (this.peekIdent('or')) {
1174
+ while (this.acceptIdent('or')) {
1175
+ node.addChild(this._parseContainerQueryInParens());
1176
+ }
1177
+ }
1178
+ }
1179
+ return this.finish(node);
1180
+ }
1181
+ _parseContainerQueryInParens() {
1182
+ // <query-in-parens> = ( <container-query> )
1183
+ // | ( <size-feature> )
1184
+ // | style( <style-query> )
1185
+ // | <general-enclosed>
1186
+ const node = this.create(nodes.Node);
1187
+ if (this.accept(cssScanner_1.TokenType.ParenthesisL)) {
1188
+ if (this.peekIdent('not') || this.peek(cssScanner_1.TokenType.ParenthesisL)) {
1189
+ node.addChild(this._parseContainerQuery());
1190
+ }
1191
+ else {
1192
+ node.addChild(this._parseMediaFeature());
1193
+ }
1194
+ if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
1195
+ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
1196
+ }
1197
+ }
1198
+ else if (this.acceptIdent('style')) {
1199
+ if (this.hasWhitespace() || !this.accept(cssScanner_1.TokenType.ParenthesisL)) {
1200
+ return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
1201
+ }
1202
+ node.addChild(this._parseStyleQuery());
1203
+ if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
1204
+ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
1205
+ }
1206
+ }
1207
+ else {
1208
+ return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
1209
+ }
1210
+ return this.finish(node);
1211
+ }
1212
+ _parseStyleQuery() {
1213
+ // <style-query> = not <style-in-parens>
1214
+ // | <style-in-parens> [ [ and <style-in-parens> ]* | [ or <style-in-parens> ]* ]
1215
+ // | <style-feature>
1216
+ // <style-in-parens> = ( <style-query> )
1217
+ // | ( <style-feature> )
1218
+ // | <general-enclosed>
1219
+ const node = this.create(nodes.Node);
1220
+ if (this.acceptIdent('not')) {
1221
+ node.addChild(this._parseStyleInParens());
1222
+ }
1223
+ else if (this.peek(cssScanner_1.TokenType.ParenthesisL)) {
1224
+ node.addChild(this._parseStyleInParens());
1225
+ if (this.peekIdent('and')) {
1226
+ while (this.acceptIdent('and')) {
1227
+ node.addChild(this._parseStyleInParens());
1228
+ }
1229
+ }
1230
+ else if (this.peekIdent('or')) {
1231
+ while (this.acceptIdent('or')) {
1232
+ node.addChild(this._parseStyleInParens());
1233
+ }
1234
+ }
1235
+ }
1236
+ else {
1237
+ node.addChild(this._parseDeclaration([cssScanner_1.TokenType.ParenthesisR]));
1238
+ }
1239
+ return this.finish(node);
1240
+ }
1241
+ _parseStyleInParens() {
1242
+ const node = this.create(nodes.Node);
1243
+ if (this.accept(cssScanner_1.TokenType.ParenthesisL)) {
1244
+ node.addChild(this._parseStyleQuery());
1245
+ if (!this.accept(cssScanner_1.TokenType.ParenthesisR)) {
1246
+ return this.finish(node, cssErrors_1.ParseError.RightParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
1247
+ }
1248
+ }
1249
+ else {
1250
+ return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected, [], [cssScanner_1.TokenType.CurlyL]);
1251
+ }
1252
+ return this.finish(node);
1253
+ }
1148
1254
  // https://www.w3.org/TR/css-syntax-3/#consume-an-at-rule
1149
1255
  _parseUnknownAtRule() {
1150
1256
  if (!this.peek(cssScanner_1.TokenType.AtKeyword)) {
@@ -1573,6 +1679,7 @@
1573
1679
  this.peek(cssScanner_1.TokenType.Angle) ||
1574
1680
  this.peek(cssScanner_1.TokenType.Time) ||
1575
1681
  this.peek(cssScanner_1.TokenType.Dimension) ||
1682
+ this.peek(cssScanner_1.TokenType.ContainerQueryLength) ||
1576
1683
  this.peek(cssScanner_1.TokenType.Freq)) {
1577
1684
  const node = this.create(nodes.NumericValue);
1578
1685
  this.consumeToken();
@@ -59,6 +59,7 @@
59
59
  TokenType[TokenType["SingleLineComment"] = 40] = "SingleLineComment";
60
60
  TokenType[TokenType["EOF"] = 41] = "EOF";
61
61
  TokenType[TokenType["CustomToken"] = 42] = "CustomToken";
62
+ TokenType[TokenType["ContainerQueryLength"] = 43] = "ContainerQueryLength";
62
63
  })(TokenType || (exports.TokenType = TokenType = {}));
63
64
  class MultiLineStream {
64
65
  constructor(source) {
@@ -196,6 +197,12 @@
196
197
  staticUnitTable['fr'] = TokenType.Percentage;
197
198
  staticUnitTable['dpi'] = TokenType.Resolution;
198
199
  staticUnitTable['dpcm'] = TokenType.Resolution;
200
+ staticUnitTable['cqw'] = TokenType.ContainerQueryLength;
201
+ staticUnitTable['cqh'] = TokenType.ContainerQueryLength;
202
+ staticUnitTable['cqi'] = TokenType.ContainerQueryLength;
203
+ staticUnitTable['cqb'] = TokenType.ContainerQueryLength;
204
+ staticUnitTable['cqmin'] = TokenType.ContainerQueryLength;
205
+ staticUnitTable['cqmax'] = TokenType.ContainerQueryLength;
199
206
  class Scanner {
200
207
  constructor() {
201
208
  this.stream = new MultiLineStream('');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-css-languageservice",
3
- "version": "6.2.8",
3
+ "version": "6.2.10",
4
4
  "description": "Language service for CSS, LESS and SCSS",
5
5
  "main": "./lib/umd/cssLanguageService.js",
6
6
  "typings": "./lib/umd/cssLanguageService",
@@ -15,23 +15,23 @@
15
15
  "url": "https://github.com/Microsoft/vscode-css-languageservice"
16
16
  },
17
17
  "devDependencies": {
18
- "@types/mocha": "^10.0.1",
18
+ "@types/mocha": "^10.0.2",
19
19
  "@types/node": "16.x",
20
- "@typescript-eslint/eslint-plugin": "^6.7.3",
21
- "@typescript-eslint/parser": "^6.7.3",
20
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
21
+ "@typescript-eslint/parser": "^6.7.4",
22
22
  "@vscode/web-custom-data": "^0.4.8",
23
23
  "eslint": "^8.50.0",
24
24
  "js-beautify": "^1.14.9",
25
25
  "mocha": "^10.2.0",
26
- "rimraf": "^5.0.1",
26
+ "rimraf": "^5.0.5",
27
27
  "source-map-support": "^0.5.21",
28
28
  "typescript": "^5.2.2"
29
29
  },
30
30
  "dependencies": {
31
31
  "@vscode/l10n": "^0.0.16",
32
- "vscode-languageserver-textdocument": "^1.0.8",
33
- "vscode-languageserver-types": "^3.17.4",
34
- "vscode-uri": "^3.0.7"
32
+ "vscode-languageserver-textdocument": "^1.0.11",
33
+ "vscode-languageserver-types": "3.17.5",
34
+ "vscode-uri": "^3.0.8"
35
35
  },
36
36
  "scripts": {
37
37
  "prepack": "npm run clean && npm run compile-esm && npm run test && npm run remove-sourcemap-refs",