vscode-css-languageservice 5.4.2 → 6.0.0

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 (84) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/lib/esm/cssLanguageService.d.ts +37 -37
  3. package/lib/esm/cssLanguageService.js +72 -75
  4. package/lib/esm/cssLanguageTypes.d.ts +238 -238
  5. package/lib/esm/cssLanguageTypes.js +42 -42
  6. package/lib/esm/data/webCustomData.js +21965 -21965
  7. package/lib/esm/languageFacts/builtinData.js +142 -142
  8. package/lib/esm/languageFacts/colors.js +469 -472
  9. package/lib/esm/languageFacts/dataManager.js +88 -92
  10. package/lib/esm/languageFacts/dataProvider.js +73 -79
  11. package/lib/esm/languageFacts/entry.js +137 -138
  12. package/lib/esm/languageFacts/facts.js +8 -8
  13. package/lib/esm/parser/cssErrors.js +48 -50
  14. package/lib/esm/parser/cssNodes.js +1502 -2019
  15. package/lib/esm/parser/cssParser.js +1534 -1563
  16. package/lib/esm/parser/cssScanner.js +592 -599
  17. package/lib/esm/parser/cssSymbolScope.js +311 -341
  18. package/lib/esm/parser/lessParser.js +714 -740
  19. package/lib/esm/parser/lessScanner.js +57 -78
  20. package/lib/esm/parser/scssErrors.js +18 -20
  21. package/lib/esm/parser/scssParser.js +796 -818
  22. package/lib/esm/parser/scssScanner.js +95 -116
  23. package/lib/esm/services/cssCodeActions.js +77 -81
  24. package/lib/esm/services/cssCompletion.js +1054 -1149
  25. package/lib/esm/services/cssFolding.js +190 -193
  26. package/lib/esm/services/cssFormatter.js +136 -136
  27. package/lib/esm/services/cssHover.js +148 -151
  28. package/lib/esm/services/cssNavigation.js +378 -470
  29. package/lib/esm/services/cssSelectionRange.js +47 -47
  30. package/lib/esm/services/cssValidation.js +41 -44
  31. package/lib/esm/services/lessCompletion.js +378 -397
  32. package/lib/esm/services/lint.js +518 -532
  33. package/lib/esm/services/lintRules.js +76 -83
  34. package/lib/esm/services/lintUtil.js +196 -205
  35. package/lib/esm/services/pathCompletion.js +157 -231
  36. package/lib/esm/services/scssCompletion.js +354 -378
  37. package/lib/esm/services/scssNavigation.js +82 -154
  38. package/lib/esm/services/selectorPrinting.js +492 -536
  39. package/lib/esm/utils/arrays.js +40 -46
  40. package/lib/esm/utils/objects.js +11 -11
  41. package/lib/esm/utils/resources.js +11 -24
  42. package/lib/esm/utils/strings.js +102 -104
  43. package/lib/umd/cssLanguageService.d.ts +37 -37
  44. package/lib/umd/cssLanguageService.js +99 -102
  45. package/lib/umd/cssLanguageTypes.d.ts +238 -238
  46. package/lib/umd/cssLanguageTypes.js +89 -88
  47. package/lib/umd/data/webCustomData.js +21978 -21978
  48. package/lib/umd/languageFacts/builtinData.js +154 -154
  49. package/lib/umd/languageFacts/colors.js +492 -495
  50. package/lib/umd/languageFacts/dataManager.js +101 -104
  51. package/lib/umd/languageFacts/dataProvider.js +86 -91
  52. package/lib/umd/languageFacts/entry.js +152 -153
  53. package/lib/umd/languageFacts/facts.js +29 -29
  54. package/lib/umd/parser/cssErrors.js +61 -62
  55. package/lib/umd/parser/cssNodes.js +1587 -2034
  56. package/lib/umd/parser/cssParser.js +1547 -1575
  57. package/lib/umd/parser/cssScanner.js +606 -611
  58. package/lib/umd/parser/cssSymbolScope.js +328 -353
  59. package/lib/umd/parser/lessParser.js +727 -752
  60. package/lib/umd/parser/lessScanner.js +70 -90
  61. package/lib/umd/parser/scssErrors.js +31 -32
  62. package/lib/umd/parser/scssParser.js +809 -830
  63. package/lib/umd/parser/scssScanner.js +108 -128
  64. package/lib/umd/services/cssCodeActions.js +90 -93
  65. package/lib/umd/services/cssCompletion.js +1067 -1161
  66. package/lib/umd/services/cssFolding.js +203 -206
  67. package/lib/umd/services/cssFormatter.js +150 -150
  68. package/lib/umd/services/cssHover.js +161 -163
  69. package/lib/umd/services/cssNavigation.js +391 -482
  70. package/lib/umd/services/cssSelectionRange.js +60 -60
  71. package/lib/umd/services/cssValidation.js +54 -56
  72. package/lib/umd/services/lessCompletion.js +391 -409
  73. package/lib/umd/services/lint.js +531 -544
  74. package/lib/umd/services/lintRules.js +91 -95
  75. package/lib/umd/services/lintUtil.js +210 -218
  76. package/lib/umd/services/pathCompletion.js +171 -244
  77. package/lib/umd/services/scssCompletion.js +367 -390
  78. package/lib/umd/services/scssNavigation.js +95 -166
  79. package/lib/umd/services/selectorPrinting.js +510 -550
  80. package/lib/umd/utils/arrays.js +55 -61
  81. package/lib/umd/utils/objects.js +25 -25
  82. package/lib/umd/utils/resources.js +26 -39
  83. package/lib/umd/utils/strings.js +120 -122
  84. package/package.json +10 -10
@@ -1,151 +1,148 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * Licensed under the MIT License. See License.txt in the project root for license information.
4
- *--------------------------------------------------------------------------------------------*/
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';
12
- var CSSHover = /** @class */ (function () {
13
- function CSSHover(clientCapabilities, cssDataManager) {
14
- this.clientCapabilities = clientCapabilities;
15
- this.cssDataManager = cssDataManager;
16
- this.selectorPrinting = new SelectorPrinting(cssDataManager);
17
- }
18
- CSSHover.prototype.configure = function (settings) {
19
- this.defaultSettings = settings;
20
- };
21
- CSSHover.prototype.doHover = function (document, position, stylesheet, settings) {
22
- if (settings === void 0) { settings = this.defaultSettings; }
23
- function getRange(node) {
24
- return Range.create(document.positionAt(node.offset), document.positionAt(node.end));
25
- }
26
- var offset = document.offsetAt(position);
27
- var nodepath = nodes.getNodePath(stylesheet, offset);
28
- /**
29
- * nodepath is top-down
30
- * Build up the hover by appending inner node's information
31
- */
32
- var hover = null;
33
- for (var i = 0; i < nodepath.length; i++) {
34
- var node = nodepath[i];
35
- if (node instanceof nodes.Selector) {
36
- hover = {
37
- contents: this.selectorPrinting.selectorToMarkedString(node),
38
- range: getRange(node)
39
- };
40
- break;
41
- }
42
- if (node instanceof nodes.SimpleSelector) {
43
- /**
44
- * Some sass specific at rules such as `@at-root` are parsed as `SimpleSelector`
45
- */
46
- if (!startsWith(node.getText(), '@')) {
47
- hover = {
48
- contents: this.selectorPrinting.simpleSelectorToMarkedString(node),
49
- range: getRange(node)
50
- };
51
- }
52
- break;
53
- }
54
- if (node instanceof nodes.Declaration) {
55
- var propertyName = node.getFullPropertyName();
56
- var entry = this.cssDataManager.getProperty(propertyName);
57
- if (entry) {
58
- var contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
59
- if (contents) {
60
- hover = {
61
- contents: contents,
62
- range: getRange(node)
63
- };
64
- }
65
- else {
66
- hover = null;
67
- }
68
- }
69
- continue;
70
- }
71
- if (node instanceof nodes.UnknownAtRule) {
72
- var atRuleName = node.getText();
73
- var entry = this.cssDataManager.getAtDirective(atRuleName);
74
- if (entry) {
75
- var contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
76
- if (contents) {
77
- hover = {
78
- contents: contents,
79
- range: getRange(node)
80
- };
81
- }
82
- else {
83
- hover = null;
84
- }
85
- }
86
- continue;
87
- }
88
- if (node instanceof nodes.Node && node.type === nodes.NodeType.PseudoSelector) {
89
- var selectorName = node.getText();
90
- var entry = selectorName.slice(0, 2) === '::'
91
- ? this.cssDataManager.getPseudoElement(selectorName)
92
- : this.cssDataManager.getPseudoClass(selectorName);
93
- if (entry) {
94
- var contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
95
- if (contents) {
96
- hover = {
97
- contents: contents,
98
- range: getRange(node)
99
- };
100
- }
101
- else {
102
- hover = null;
103
- }
104
- }
105
- continue;
106
- }
107
- }
108
- if (hover) {
109
- hover.contents = this.convertContents(hover.contents);
110
- }
111
- return hover;
112
- };
113
- CSSHover.prototype.convertContents = function (contents) {
114
- if (!this.doesSupportMarkdown()) {
115
- if (typeof contents === 'string') {
116
- return contents;
117
- }
118
- // MarkupContent
119
- else if ('kind' in contents) {
120
- return {
121
- kind: 'plaintext',
122
- value: contents.value
123
- };
124
- }
125
- // MarkedString[]
126
- else if (Array.isArray(contents)) {
127
- return contents.map(function (c) {
128
- return typeof c === 'string' ? c : c.value;
129
- });
130
- }
131
- // MarkedString
132
- else {
133
- return contents.value;
134
- }
135
- }
136
- return contents;
137
- };
138
- CSSHover.prototype.doesSupportMarkdown = function () {
139
- if (!isDefined(this.supportsMarkdown)) {
140
- if (!isDefined(this.clientCapabilities)) {
141
- this.supportsMarkdown = true;
142
- return this.supportsMarkdown;
143
- }
144
- var hover = this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover;
145
- this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(MarkupKind.Markdown) !== -1;
146
- }
147
- return this.supportsMarkdown;
148
- };
149
- return CSSHover;
150
- }());
151
- export { CSSHover };
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
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';
12
+ export class CSSHover {
13
+ constructor(clientCapabilities, cssDataManager) {
14
+ this.clientCapabilities = clientCapabilities;
15
+ this.cssDataManager = cssDataManager;
16
+ this.selectorPrinting = new SelectorPrinting(cssDataManager);
17
+ }
18
+ configure(settings) {
19
+ this.defaultSettings = settings;
20
+ }
21
+ doHover(document, position, stylesheet, settings = this.defaultSettings) {
22
+ function getRange(node) {
23
+ return Range.create(document.positionAt(node.offset), document.positionAt(node.end));
24
+ }
25
+ const offset = document.offsetAt(position);
26
+ const nodepath = nodes.getNodePath(stylesheet, offset);
27
+ /**
28
+ * nodepath is top-down
29
+ * Build up the hover by appending inner node's information
30
+ */
31
+ let hover = null;
32
+ for (let i = 0; i < nodepath.length; i++) {
33
+ const node = nodepath[i];
34
+ if (node instanceof nodes.Selector) {
35
+ hover = {
36
+ contents: this.selectorPrinting.selectorToMarkedString(node),
37
+ range: getRange(node)
38
+ };
39
+ break;
40
+ }
41
+ if (node instanceof nodes.SimpleSelector) {
42
+ /**
43
+ * Some sass specific at rules such as `@at-root` are parsed as `SimpleSelector`
44
+ */
45
+ if (!startsWith(node.getText(), '@')) {
46
+ hover = {
47
+ contents: this.selectorPrinting.simpleSelectorToMarkedString(node),
48
+ range: getRange(node)
49
+ };
50
+ }
51
+ break;
52
+ }
53
+ if (node instanceof nodes.Declaration) {
54
+ const propertyName = node.getFullPropertyName();
55
+ const entry = this.cssDataManager.getProperty(propertyName);
56
+ if (entry) {
57
+ const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
58
+ if (contents) {
59
+ hover = {
60
+ contents,
61
+ range: getRange(node)
62
+ };
63
+ }
64
+ else {
65
+ hover = null;
66
+ }
67
+ }
68
+ continue;
69
+ }
70
+ if (node instanceof nodes.UnknownAtRule) {
71
+ const atRuleName = node.getText();
72
+ const entry = this.cssDataManager.getAtDirective(atRuleName);
73
+ if (entry) {
74
+ const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
75
+ if (contents) {
76
+ hover = {
77
+ contents,
78
+ range: getRange(node)
79
+ };
80
+ }
81
+ else {
82
+ hover = null;
83
+ }
84
+ }
85
+ continue;
86
+ }
87
+ if (node instanceof nodes.Node && node.type === nodes.NodeType.PseudoSelector) {
88
+ const selectorName = node.getText();
89
+ const entry = selectorName.slice(0, 2) === '::'
90
+ ? this.cssDataManager.getPseudoElement(selectorName)
91
+ : this.cssDataManager.getPseudoClass(selectorName);
92
+ if (entry) {
93
+ const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
94
+ if (contents) {
95
+ hover = {
96
+ contents,
97
+ range: getRange(node)
98
+ };
99
+ }
100
+ else {
101
+ hover = null;
102
+ }
103
+ }
104
+ continue;
105
+ }
106
+ }
107
+ if (hover) {
108
+ hover.contents = this.convertContents(hover.contents);
109
+ }
110
+ return hover;
111
+ }
112
+ convertContents(contents) {
113
+ if (!this.doesSupportMarkdown()) {
114
+ if (typeof contents === 'string') {
115
+ return contents;
116
+ }
117
+ // MarkupContent
118
+ else if ('kind' in contents) {
119
+ return {
120
+ kind: 'plaintext',
121
+ value: contents.value
122
+ };
123
+ }
124
+ // MarkedString[]
125
+ else if (Array.isArray(contents)) {
126
+ return contents.map(c => {
127
+ return typeof c === 'string' ? c : c.value;
128
+ });
129
+ }
130
+ // MarkedString
131
+ else {
132
+ return contents.value;
133
+ }
134
+ }
135
+ return contents;
136
+ }
137
+ doesSupportMarkdown() {
138
+ if (!isDefined(this.supportsMarkdown)) {
139
+ if (!isDefined(this.clientCapabilities)) {
140
+ this.supportsMarkdown = true;
141
+ return this.supportsMarkdown;
142
+ }
143
+ const hover = this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover;
144
+ this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(MarkupKind.Markdown) !== -1;
145
+ }
146
+ return this.supportsMarkdown;
147
+ }
148
+ }