vscode-css-languageservice 6.2.11 → 6.2.13

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.
@@ -285,6 +285,7 @@
285
285
  || this._parseSupports(true) // @supports
286
286
  || this._parseLayer() // @layer
287
287
  || this._parsePropertyAtRule() // @property
288
+ || this._parseContainer() // @container
288
289
  || this._parseDetachedRuleSetMixin() // less detached ruleset mixin
289
290
  || this._parseVariableDeclaration() // Variable declarations
290
291
  || this._parseRuleSetDeclarationAtStatement();
@@ -654,7 +655,6 @@
654
655
  }
655
656
  const node = this.create(nodes.LessGuard);
656
657
  this.consumeToken(); // when
657
- node.isNegated = this.acceptIdent('not');
658
658
  if (!node.getConditions().addChild(this._parseGuardCondition())) {
659
659
  return this.finish(node, cssErrors_1.ParseError.ConditionExpected);
660
660
  }
@@ -666,11 +666,14 @@
666
666
  return this.finish(node);
667
667
  }
668
668
  _parseGuardCondition() {
669
- if (!this.peek(cssScanner_1.TokenType.ParenthesisL)) {
669
+ const node = this.create(nodes.GuardCondition);
670
+ node.isNegated = this.acceptIdent('not');
671
+ if (!this.accept(cssScanner_1.TokenType.ParenthesisL)) {
672
+ if (node.isNegated) {
673
+ return this.finish(node, cssErrors_1.ParseError.LeftParenthesisExpected);
674
+ }
670
675
  return null;
671
676
  }
672
- const node = this.create(nodes.GuardCondition);
673
- this.consumeToken(); // ParenthesisL
674
677
  if (!node.addChild(this._parseExpr())) {
675
678
  // empty (?)
676
679
  }
@@ -230,6 +230,7 @@
230
230
  || this._parseSupports(true) // @supports
231
231
  || this._parseLayer() // @layer
232
232
  || this._parsePropertyAtRule() // @property
233
+ || this._parseContainer() // @container
233
234
  || this._parseRuleSetDeclarationAtStatement();
234
235
  }
235
236
  return this._parseVariableDeclaration() // variable declaration
@@ -812,7 +813,7 @@
812
813
  // Consume all variables and idents ahead.
813
814
  this.accept(cssScanner_1.TokenType.Comma);
814
815
  }
815
- // More than just identifier
816
+ // More than just identifier
816
817
  return node.getChildren().length > 1 ? node : null;
817
818
  }
818
819
  _parseSupportsCondition() {
@@ -40,12 +40,21 @@
40
40
  * Build up the hover by appending inner node's information
41
41
  */
42
42
  let hover = null;
43
+ let flagOpts;
43
44
  for (let i = 0; i < nodepath.length; i++) {
44
45
  const node = nodepath[i];
46
+ if (node instanceof nodes.Media) {
47
+ const regex = /@media[^\{]+/g;
48
+ const matches = node.getText().match(regex);
49
+ flagOpts = {
50
+ isMedia: true,
51
+ text: matches?.[0],
52
+ };
53
+ }
45
54
  if (node instanceof nodes.Selector) {
46
55
  hover = {
47
- contents: this.selectorPrinting.selectorToMarkedString(node),
48
- range: getRange(node)
56
+ contents: this.selectorPrinting.selectorToMarkedString(node, flagOpts),
57
+ range: getRange(node),
49
58
  };
50
59
  break;
51
60
  }
@@ -56,7 +65,7 @@
56
65
  if (!(0, strings_1.startsWith)(node.getText(), '@')) {
57
66
  hover = {
58
67
  contents: this.selectorPrinting.simpleSelectorToMarkedString(node),
59
- range: getRange(node)
68
+ range: getRange(node),
60
69
  };
61
70
  }
62
71
  break;
@@ -69,7 +78,7 @@
69
78
  if (contents) {
70
79
  hover = {
71
80
  contents,
72
- range: getRange(node)
81
+ range: getRange(node),
73
82
  };
74
83
  }
75
84
  else {
@@ -86,7 +95,7 @@
86
95
  if (contents) {
87
96
  hover = {
88
97
  contents,
89
- range: getRange(node)
98
+ range: getRange(node),
90
99
  };
91
100
  }
92
101
  else {
@@ -97,15 +106,13 @@
97
106
  }
98
107
  if (node instanceof nodes.Node && node.type === nodes.NodeType.PseudoSelector) {
99
108
  const selectorName = node.getText();
100
- const entry = selectorName.slice(0, 2) === '::'
101
- ? this.cssDataManager.getPseudoElement(selectorName)
102
- : this.cssDataManager.getPseudoClass(selectorName);
109
+ const entry = selectorName.slice(0, 2) === '::' ? this.cssDataManager.getPseudoElement(selectorName) : this.cssDataManager.getPseudoClass(selectorName);
103
110
  if (entry) {
104
111
  const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
105
112
  if (contents) {
106
113
  hover = {
107
114
  contents,
108
- range: getRange(node)
115
+ range: getRange(node),
109
116
  };
110
117
  }
111
118
  else {
@@ -129,12 +136,12 @@
129
136
  else if ('kind' in contents) {
130
137
  return {
131
138
  kind: 'plaintext',
132
- value: contents.value
139
+ value: contents.value,
133
140
  };
134
141
  }
135
142
  // MarkedString[]
136
143
  else if (Array.isArray(contents)) {
137
- return contents.map(c => {
144
+ return contents.map((c) => {
138
145
  return typeof c === 'string' ? c : c.value;
139
146
  });
140
147
  }
@@ -126,7 +126,7 @@
126
126
  this.result = [];
127
127
  // empty
128
128
  }
129
- print(element) {
129
+ print(element, flagOpts) {
130
130
  this.result = [];
131
131
  if (element instanceof RootElement) {
132
132
  if (element.children) {
@@ -136,7 +136,13 @@
136
136
  else {
137
137
  this.doPrint([element], 0);
138
138
  }
139
- const value = this.result.join('\n');
139
+ let value;
140
+ if (flagOpts) {
141
+ value = `${flagOpts.text}\n … ` + this.result.join('\n');
142
+ }
143
+ else {
144
+ value = this.result.join('\n');
145
+ }
140
146
  return [{ language: 'html', value }];
141
147
  }
142
148
  doPrint(elements, indent) {
@@ -313,10 +319,10 @@
313
319
  constructor(cssDataManager) {
314
320
  this.cssDataManager = cssDataManager;
315
321
  }
316
- selectorToMarkedString(node) {
322
+ selectorToMarkedString(node, flagOpts) {
317
323
  const root = selectorToElement(node);
318
324
  if (root) {
319
- const markedStrings = new MarkedStringPrinter('"').print(root);
325
+ const markedStrings = new MarkedStringPrinter('"').print(root, flagOpts);
320
326
  markedStrings.push(this.selectorToSpecificityMarkedString(node));
321
327
  return markedStrings;
322
328
  }
@@ -335,7 +341,7 @@
335
341
  if (!match) {
336
342
  return false;
337
343
  }
338
- return !!this.cssDataManager.getPseudoElement("::" + match[1]);
344
+ return !!this.cssDataManager.getPseudoElement('::' + match[1]);
339
345
  }
340
346
  selectorToSpecificityMarkedString(node) {
341
347
  const calculateMostSpecificListItem = (childElements) => {
@@ -383,7 +389,7 @@
383
389
  break;
384
390
  case nodes.NodeType.ElementNameSelector:
385
391
  //ignore universal selector
386
- if (element.matches("*")) {
392
+ if (element.matches('*')) {
387
393
  break;
388
394
  }
389
395
  specificity.tag++;
@@ -432,7 +438,7 @@
432
438
  /* The specificity of the :nth-child(An+B [of S]?) pseudo-class is the specificity of a single pseudo-class plus, if S is specified, the specificity of the most specific complex selector in S */
433
439
  // https://www.w3.org/TR/selectors-4/#the-nth-child-pseudo
434
440
  specificity.attr++;
435
- // 23 = Binary Expression.
441
+ // 23 = Binary Expression.
436
442
  if (childElements.length === 3 && childElements[1].type === 23) {
437
443
  let mostSpecificListItem = calculateMostSpecificListItem(childElements[2].getChildren());
438
444
  specificity.id += mostSpecificListItem.id;
@@ -446,7 +452,7 @@
446
452
  parser.scanner.setSource(pseudoSelectorText);
447
453
  const firstToken = parser.scanner.scan();
448
454
  const secondToken = parser.scanner.scan();
449
- if (firstToken.text === 'n' || firstToken.text === '-n' && secondToken.text === 'of') {
455
+ if (firstToken.text === 'n' || (firstToken.text === '-n' && secondToken.text === 'of')) {
450
456
  const complexSelectorListNodes = [];
451
457
  const complexSelectorText = pseudoSelectorText.slice(secondToken.offset + 2);
452
458
  const complexSelectorArray = complexSelectorText.split(',');
@@ -477,7 +483,7 @@
477
483
  return specificity;
478
484
  };
479
485
  const specificity = calculateScore(node);
480
- return `[${l10n.t("Selector Specificity")}](https://developer.mozilla.org/docs/Web/CSS/Specificity): (${specificity.id}, ${specificity.attr}, ${specificity.tag})`;
486
+ return `[${l10n.t('Selector Specificity')}](https://developer.mozilla.org/docs/Web/CSS/Specificity): (${specificity.id}, ${specificity.attr}, ${specificity.tag})`;
481
487
  }
482
488
  }
483
489
  exports.SelectorPrinting = SelectorPrinting;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-css-languageservice",
3
- "version": "6.2.11",
3
+ "version": "6.2.13",
4
4
  "description": "Language service for CSS, LESS and SCSS",
5
5
  "main": "./lib/umd/cssLanguageService.js",
6
6
  "typings": "./lib/umd/cssLanguageService",
@@ -17,18 +17,18 @@
17
17
  "devDependencies": {
18
18
  "@types/mocha": "^10.0.6",
19
19
  "@types/node": "16.x",
20
- "@typescript-eslint/eslint-plugin": "^6.13.0",
21
- "@typescript-eslint/parser": "^6.13.0",
22
- "@vscode/web-custom-data": "^0.4.8",
23
- "eslint": "^8.54.0",
24
- "js-beautify": "^1.14.11",
25
- "mocha": "^10.2.0",
20
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
21
+ "@typescript-eslint/parser": "^6.21.0",
22
+ "@vscode/web-custom-data": "^0.4.9",
23
+ "eslint": "^8.57.0",
24
+ "js-beautify": "^1.15.1",
25
+ "mocha": "^10.3.0",
26
26
  "rimraf": "^5.0.5",
27
27
  "source-map-support": "^0.5.21",
28
- "typescript": "^5.2.2"
28
+ "typescript": "^5.3.3"
29
29
  },
30
30
  "dependencies": {
31
- "@vscode/l10n": "^0.0.16",
31
+ "@vscode/l10n": "^0.0.18",
32
32
  "vscode-languageserver-textdocument": "^1.0.11",
33
33
  "vscode-languageserver-types": "3.17.5",
34
34
  "vscode-uri": "^3.0.8"