vscode-css-languageservice 5.4.2 → 6.1.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.
- package/CHANGELOG.md +7 -1
- package/SECURITY.md +41 -0
- package/lib/esm/beautify/beautify-css.js +11 -4
- package/lib/esm/cssLanguageService.d.ts +2 -1
- package/lib/esm/cssLanguageService.js +15 -17
- package/lib/esm/cssLanguageTypes.js +2 -2
- package/lib/esm/data/webCustomData.js +356 -232
- package/lib/esm/languageFacts/builtinData.js +15 -15
- package/lib/esm/languageFacts/colors.js +66 -69
- package/lib/esm/languageFacts/dataManager.js +38 -42
- package/lib/esm/languageFacts/dataProvider.js +17 -23
- package/lib/esm/languageFacts/entry.js +22 -23
- package/lib/esm/parser/cssErrors.js +5 -7
- package/lib/esm/parser/cssNodes.js +869 -1377
- package/lib/esm/parser/cssParser.js +419 -376
- package/lib/esm/parser/cssScanner.js +168 -175
- package/lib/esm/parser/cssSymbolScope.js +107 -137
- package/lib/esm/parser/lessParser.js +177 -202
- package/lib/esm/parser/lessScanner.js +22 -43
- package/lib/esm/parser/scssErrors.js +5 -7
- package/lib/esm/parser/scssParser.js +196 -208
- package/lib/esm/parser/scssScanner.js +33 -54
- package/lib/esm/services/cssCodeActions.js +36 -40
- package/lib/esm/services/cssCompletion.js +300 -395
- package/lib/esm/services/cssFolding.js +32 -35
- package/lib/esm/services/cssFormatter.js +22 -22
- package/lib/esm/services/cssHover.js +30 -33
- package/lib/esm/services/cssNavigation.js +260 -289
- package/lib/esm/services/cssSelectionRange.js +6 -6
- package/lib/esm/services/cssValidation.js +13 -16
- package/lib/esm/services/lessCompletion.js +351 -370
- package/lib/esm/services/lint.js +161 -175
- package/lib/esm/services/lintRules.js +20 -27
- package/lib/esm/services/lintUtil.js +19 -28
- package/lib/esm/services/pathCompletion.js +84 -158
- package/lib/esm/services/scssCompletion.js +283 -307
- package/lib/esm/services/scssNavigation.js +65 -137
- package/lib/esm/services/selectorPrinting.js +131 -175
- package/lib/esm/utils/arrays.js +6 -12
- package/lib/esm/utils/objects.js +1 -1
- package/lib/esm/utils/resources.js +3 -16
- package/lib/esm/utils/strings.js +10 -12
- package/lib/umd/beautify/beautify-css.js +11 -4
- package/lib/umd/cssLanguageService.d.ts +2 -1
- package/lib/umd/cssLanguageService.js +34 -32
- package/lib/umd/cssLanguageTypes.js +4 -3
- package/lib/umd/data/webCustomData.js +355 -231
- package/lib/umd/languageFacts/colors.js +65 -68
- package/lib/umd/languageFacts/dataManager.js +41 -44
- package/lib/umd/languageFacts/dataProvider.js +17 -22
- package/lib/umd/languageFacts/entry.js +22 -23
- package/lib/umd/languageFacts/facts.js +5 -1
- package/lib/umd/parser/cssErrors.js +5 -6
- package/lib/umd/parser/cssNodes.js +870 -1307
- package/lib/umd/parser/cssParser.js +424 -380
- package/lib/umd/parser/cssScanner.js +168 -173
- package/lib/umd/parser/cssSymbolScope.js +109 -134
- package/lib/umd/parser/lessParser.js +182 -206
- package/lib/umd/parser/lessScanner.js +22 -42
- package/lib/umd/parser/scssErrors.js +5 -6
- package/lib/umd/parser/scssParser.js +202 -213
- package/lib/umd/parser/scssScanner.js +25 -45
- package/lib/umd/services/cssCodeActions.js +41 -44
- package/lib/umd/services/cssCompletion.js +308 -402
- package/lib/umd/services/cssFolding.js +35 -38
- package/lib/umd/services/cssFormatter.js +25 -25
- package/lib/umd/services/cssHover.js +36 -38
- package/lib/umd/services/cssNavigation.js +267 -295
- package/lib/umd/services/cssSelectionRange.js +8 -8
- package/lib/umd/services/cssValidation.js +17 -19
- package/lib/umd/services/lessCompletion.js +354 -372
- package/lib/umd/services/lint.js +167 -180
- package/lib/umd/services/lintRules.js +20 -24
- package/lib/umd/services/lintUtil.js +20 -28
- package/lib/umd/services/pathCompletion.js +87 -160
- package/lib/umd/services/scssCompletion.js +287 -310
- package/lib/umd/services/scssNavigation.js +69 -140
- package/lib/umd/services/selectorPrinting.js +134 -174
- package/lib/umd/utils/arrays.js +6 -12
- package/lib/umd/utils/objects.js +1 -1
- package/lib/umd/utils/resources.js +4 -17
- package/lib/umd/utils/strings.js +10 -12
- package/package.json +16 -15
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.getFoldingRanges = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const cssScanner_1 = require("../parser/cssScanner");
|
|
18
|
+
const scssScanner_1 = require("../parser/scssScanner");
|
|
19
|
+
const lessScanner_1 = require("../parser/lessScanner");
|
|
20
20
|
function getFoldingRanges(document, context) {
|
|
21
|
-
|
|
21
|
+
const ranges = computeFoldingRanges(document);
|
|
22
22
|
return limitFoldingRanges(ranges, context);
|
|
23
23
|
}
|
|
24
24
|
exports.getFoldingRanges = getFoldingRanges;
|
|
@@ -40,27 +40,27 @@
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
function tokenToRange(t, kind) {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
const startLine = getStartLine(t);
|
|
44
|
+
const endLine = getEndLine(t);
|
|
45
45
|
if (startLine !== endLine) {
|
|
46
46
|
return {
|
|
47
|
-
startLine
|
|
48
|
-
endLine
|
|
49
|
-
kind
|
|
47
|
+
startLine,
|
|
48
|
+
endLine,
|
|
49
|
+
kind
|
|
50
50
|
};
|
|
51
51
|
}
|
|
52
52
|
else {
|
|
53
53
|
return null;
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const ranges = [];
|
|
57
|
+
const delimiterStack = [];
|
|
58
|
+
const scanner = getScanner();
|
|
59
59
|
scanner.ignoreComment = false;
|
|
60
60
|
scanner.setSource(document.getText());
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
61
|
+
let token = scanner.scan();
|
|
62
|
+
let prevToken = null;
|
|
63
|
+
while (token.type !== cssScanner_1.TokenType.EOF) {
|
|
64
64
|
switch (token.type) {
|
|
65
65
|
case cssScanner_1.TokenType.CurlyL:
|
|
66
66
|
case scssScanner_1.InterpolationFunction:
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
}
|
|
71
71
|
case cssScanner_1.TokenType.CurlyR: {
|
|
72
72
|
if (delimiterStack.length !== 0) {
|
|
73
|
-
|
|
73
|
+
const prevDelimiter = popPrevStartDelimiterOfType(delimiterStack, 'brace');
|
|
74
74
|
if (!prevDelimiter) {
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
let endLine = getEndLine(token);
|
|
78
78
|
if (prevDelimiter.type === 'brace') {
|
|
79
79
|
/**
|
|
80
80
|
* Other than the case when curly brace is not on a new line by itself, for example
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
if (prevDelimiter.line !== endLine) {
|
|
89
89
|
ranges.push({
|
|
90
90
|
startLine: prevDelimiter.line,
|
|
91
|
-
endLine
|
|
91
|
+
endLine,
|
|
92
92
|
kind: undefined
|
|
93
93
|
});
|
|
94
94
|
}
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
* All comments are marked as `Comment`
|
|
102
102
|
*/
|
|
103
103
|
case cssScanner_1.TokenType.Comment: {
|
|
104
|
-
|
|
104
|
+
const commentRegionMarkerToDelimiter = (marker) => {
|
|
105
105
|
if (marker === '#region') {
|
|
106
106
|
return { line: getStartLine(token), type: 'comment', isStart: true };
|
|
107
107
|
}
|
|
@@ -109,20 +109,20 @@
|
|
|
109
109
|
return { line: getEndLine(token), type: 'comment', isStart: false };
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
const getCurrDelimiter = (token) => {
|
|
113
|
+
const matches = token.text.match(/^\s*\/\*\s*(#region|#endregion)\b\s*(.*?)\s*\*\//);
|
|
114
114
|
if (matches) {
|
|
115
|
-
return
|
|
115
|
+
return commentRegionMarkerToDelimiter(matches[1]);
|
|
116
116
|
}
|
|
117
117
|
else if (document.languageId === 'scss' || document.languageId === 'less') {
|
|
118
|
-
|
|
119
|
-
if (
|
|
120
|
-
return
|
|
118
|
+
const matches = token.text.match(/^\s*\/\/\s*(#region|#endregion)\b\s*(.*?)\s*/);
|
|
119
|
+
if (matches) {
|
|
120
|
+
return commentRegionMarkerToDelimiter(matches[1]);
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
return null;
|
|
124
124
|
};
|
|
125
|
-
|
|
125
|
+
const currDelimiter = getCurrDelimiter(token);
|
|
126
126
|
// /* */ comment region folding
|
|
127
127
|
// All #region and #endregion cases
|
|
128
128
|
if (currDelimiter) {
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
delimiterStack.push(currDelimiter);
|
|
131
131
|
}
|
|
132
132
|
else {
|
|
133
|
-
|
|
133
|
+
const prevDelimiter = popPrevStartDelimiterOfType(delimiterStack, 'comment');
|
|
134
134
|
if (!prevDelimiter) {
|
|
135
135
|
break;
|
|
136
136
|
}
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
}
|
|
148
148
|
// Multiline comment case
|
|
149
149
|
else {
|
|
150
|
-
|
|
150
|
+
const range = tokenToRange(token, 'comment');
|
|
151
151
|
if (range) {
|
|
152
152
|
ranges.push(range);
|
|
153
153
|
}
|
|
@@ -157,9 +157,6 @@
|
|
|
157
157
|
}
|
|
158
158
|
prevToken = token;
|
|
159
159
|
token = scanner.scan();
|
|
160
|
-
};
|
|
161
|
-
while (token.type !== cssScanner_1.TokenType.EOF) {
|
|
162
|
-
_loop_1();
|
|
163
160
|
}
|
|
164
161
|
return ranges;
|
|
165
162
|
}
|
|
@@ -167,7 +164,7 @@
|
|
|
167
164
|
if (stack.length === 0) {
|
|
168
165
|
return null;
|
|
169
166
|
}
|
|
170
|
-
for (
|
|
167
|
+
for (let i = stack.length - 1; i >= 0; i--) {
|
|
171
168
|
if (stack[i].type === type && stack[i].isStart) {
|
|
172
169
|
return stack.splice(i, 1)[0];
|
|
173
170
|
}
|
|
@@ -180,17 +177,17 @@
|
|
|
180
177
|
* - If limit exceeds, only return `rangeLimit` amount of ranges
|
|
181
178
|
*/
|
|
182
179
|
function limitFoldingRanges(ranges, context) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
180
|
+
const maxRanges = context && context.rangeLimit || Number.MAX_VALUE;
|
|
181
|
+
const sortedRanges = ranges.sort((r1, r2) => {
|
|
182
|
+
let diff = r1.startLine - r2.startLine;
|
|
186
183
|
if (diff === 0) {
|
|
187
184
|
diff = r1.endLine - r2.endLine;
|
|
188
185
|
}
|
|
189
186
|
return diff;
|
|
190
187
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
sortedRanges.forEach(
|
|
188
|
+
const validRanges = [];
|
|
189
|
+
let prevEndLine = -1;
|
|
190
|
+
sortedRanges.forEach(r => {
|
|
194
191
|
if (!(r.startLine < prevEndLine && prevEndLine < r.endLine)) {
|
|
195
192
|
validRanges.push(r);
|
|
196
193
|
prevEndLine = r.endLine;
|
|
@@ -14,19 +14,19 @@
|
|
|
14
14
|
"use strict";
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.format = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
const cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
18
|
+
const beautify_css_1 = require("../beautify/beautify-css");
|
|
19
|
+
const strings_1 = require("../utils/strings");
|
|
20
20
|
function format(document, range, options) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
21
|
+
let value = document.getText();
|
|
22
|
+
let includesEnd = true;
|
|
23
|
+
let initialIndentLevel = 0;
|
|
24
|
+
let inRule = false;
|
|
25
|
+
const tabSize = options.tabSize || 4;
|
|
26
26
|
if (range) {
|
|
27
|
-
|
|
27
|
+
let startOffset = document.offsetAt(range.start);
|
|
28
28
|
// include all leading whitespace iff at the beginning of the line
|
|
29
|
-
|
|
29
|
+
let extendedStart = startOffset;
|
|
30
30
|
while (extendedStart > 0 && isWhitespace(value, extendedStart - 1)) {
|
|
31
31
|
extendedStart--;
|
|
32
32
|
}
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
// include all following whitespace until the end of the line
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
let endOffset = document.offsetAt(range.end);
|
|
44
|
+
let extendedEnd = endOffset;
|
|
45
45
|
while (extendedEnd < value.length && isWhitespace(value, extendedEnd)) {
|
|
46
46
|
extendedEnd++;
|
|
47
47
|
}
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
includesEnd = endOffset === value.length;
|
|
55
55
|
value = value.substring(startOffset, endOffset);
|
|
56
56
|
if (startOffset !== 0) {
|
|
57
|
-
|
|
57
|
+
const startOfLineOffset = document.offsetAt(cssLanguageTypes_1.Position.create(range.start.line, 0));
|
|
58
58
|
initialIndentLevel = computeIndentLevel(document.getText(), startOfLineOffset, options);
|
|
59
59
|
}
|
|
60
60
|
if (inRule) {
|
|
61
|
-
value =
|
|
61
|
+
value = `{\n${trimLeft(value)}`;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
65
|
range = cssLanguageTypes_1.Range.create(cssLanguageTypes_1.Position.create(0, 0), document.positionAt(value.length));
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
const cssOptions = {
|
|
68
68
|
indent_size: tabSize,
|
|
69
69
|
indent_char: options.insertSpaces ? ' ' : '\t',
|
|
70
70
|
end_with_newline: includesEnd && getFormatOption(options, 'insertFinalNewline', false),
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
wrap_line_length: getFormatOption(options, 'wrapLineLength', undefined),
|
|
79
79
|
eol: '\n'
|
|
80
80
|
};
|
|
81
|
-
|
|
81
|
+
let result = (0, beautify_css_1.css_beautify)(value, cssOptions);
|
|
82
82
|
if (inRule) {
|
|
83
83
|
result = trimLeft(result.substring(2));
|
|
84
84
|
}
|
|
85
85
|
if (initialIndentLevel > 0) {
|
|
86
|
-
|
|
86
|
+
const indent = options.insertSpaces ? (0, strings_1.repeat)(' ', tabSize * initialIndentLevel) : (0, strings_1.repeat)('\t', initialIndentLevel);
|
|
87
87
|
result = result.split('\n').join('\n' + indent);
|
|
88
88
|
if (range.start.character === 0) {
|
|
89
89
|
result = indent + result; // keep the indent
|
|
@@ -98,11 +98,11 @@
|
|
|
98
98
|
function trimLeft(str) {
|
|
99
99
|
return str.replace(/^\s+/, '');
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
101
|
+
const _CUL = '{'.charCodeAt(0);
|
|
102
|
+
const _CUR = '}'.charCodeAt(0);
|
|
103
103
|
function isInRule(str, offset) {
|
|
104
104
|
while (offset >= 0) {
|
|
105
|
-
|
|
105
|
+
const ch = str.charCodeAt(offset);
|
|
106
106
|
if (ch === _CUL) {
|
|
107
107
|
return true;
|
|
108
108
|
}
|
|
@@ -115,7 +115,7 @@
|
|
|
115
115
|
}
|
|
116
116
|
function getFormatOption(options, key, dflt) {
|
|
117
117
|
if (options && options.hasOwnProperty(key)) {
|
|
118
|
-
|
|
118
|
+
const value = options[key];
|
|
119
119
|
if (value !== null) {
|
|
120
120
|
return value;
|
|
121
121
|
}
|
|
@@ -123,11 +123,11 @@
|
|
|
123
123
|
return dflt;
|
|
124
124
|
}
|
|
125
125
|
function computeIndentLevel(content, offset, options) {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
let i = offset;
|
|
127
|
+
let nChars = 0;
|
|
128
|
+
const tabSize = options.tabSize || 4;
|
|
129
129
|
while (i < content.length) {
|
|
130
|
-
|
|
130
|
+
const ch = content.charAt(i);
|
|
131
131
|
if (ch === ' ') {
|
|
132
132
|
nChars++;
|
|
133
133
|
}
|
|
@@ -14,35 +14,34 @@
|
|
|
14
14
|
'use strict';
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.CSSHover = void 0;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
const nodes = require("../parser/cssNodes");
|
|
18
|
+
const languageFacts = require("../languageFacts/facts");
|
|
19
|
+
const selectorPrinting_1 = require("./selectorPrinting");
|
|
20
|
+
const strings_1 = require("../utils/strings");
|
|
21
|
+
const cssLanguageTypes_1 = require("../cssLanguageTypes");
|
|
22
|
+
const objects_1 = require("../utils/objects");
|
|
23
|
+
class CSSHover {
|
|
24
|
+
constructor(clientCapabilities, cssDataManager) {
|
|
25
25
|
this.clientCapabilities = clientCapabilities;
|
|
26
26
|
this.cssDataManager = cssDataManager;
|
|
27
27
|
this.selectorPrinting = new selectorPrinting_1.SelectorPrinting(cssDataManager);
|
|
28
28
|
}
|
|
29
|
-
|
|
29
|
+
configure(settings) {
|
|
30
30
|
this.defaultSettings = settings;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (settings === void 0) { settings = this.defaultSettings; }
|
|
31
|
+
}
|
|
32
|
+
doHover(document, position, stylesheet, settings = this.defaultSettings) {
|
|
34
33
|
function getRange(node) {
|
|
35
34
|
return cssLanguageTypes_1.Range.create(document.positionAt(node.offset), document.positionAt(node.end));
|
|
36
35
|
}
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
const offset = document.offsetAt(position);
|
|
37
|
+
const nodepath = nodes.getNodePath(stylesheet, offset);
|
|
39
38
|
/**
|
|
40
39
|
* nodepath is top-down
|
|
41
40
|
* Build up the hover by appending inner node's information
|
|
42
41
|
*/
|
|
43
|
-
|
|
44
|
-
for (
|
|
45
|
-
|
|
42
|
+
let hover = null;
|
|
43
|
+
for (let i = 0; i < nodepath.length; i++) {
|
|
44
|
+
const node = nodepath[i];
|
|
46
45
|
if (node instanceof nodes.Selector) {
|
|
47
46
|
hover = {
|
|
48
47
|
contents: this.selectorPrinting.selectorToMarkedString(node),
|
|
@@ -63,13 +62,13 @@
|
|
|
63
62
|
break;
|
|
64
63
|
}
|
|
65
64
|
if (node instanceof nodes.Declaration) {
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const propertyName = node.getFullPropertyName();
|
|
66
|
+
const entry = this.cssDataManager.getProperty(propertyName);
|
|
68
67
|
if (entry) {
|
|
69
|
-
|
|
68
|
+
const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
|
|
70
69
|
if (contents) {
|
|
71
70
|
hover = {
|
|
72
|
-
contents
|
|
71
|
+
contents,
|
|
73
72
|
range: getRange(node)
|
|
74
73
|
};
|
|
75
74
|
}
|
|
@@ -80,13 +79,13 @@
|
|
|
80
79
|
continue;
|
|
81
80
|
}
|
|
82
81
|
if (node instanceof nodes.UnknownAtRule) {
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const atRuleName = node.getText();
|
|
83
|
+
const entry = this.cssDataManager.getAtDirective(atRuleName);
|
|
85
84
|
if (entry) {
|
|
86
|
-
|
|
85
|
+
const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
|
|
87
86
|
if (contents) {
|
|
88
87
|
hover = {
|
|
89
|
-
contents
|
|
88
|
+
contents,
|
|
90
89
|
range: getRange(node)
|
|
91
90
|
};
|
|
92
91
|
}
|
|
@@ -97,15 +96,15 @@
|
|
|
97
96
|
continue;
|
|
98
97
|
}
|
|
99
98
|
if (node instanceof nodes.Node && node.type === nodes.NodeType.PseudoSelector) {
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
const selectorName = node.getText();
|
|
100
|
+
const entry = selectorName.slice(0, 2) === '::'
|
|
102
101
|
? this.cssDataManager.getPseudoElement(selectorName)
|
|
103
102
|
: this.cssDataManager.getPseudoClass(selectorName);
|
|
104
103
|
if (entry) {
|
|
105
|
-
|
|
104
|
+
const contents = languageFacts.getEntryDescription(entry, this.doesSupportMarkdown(), settings);
|
|
106
105
|
if (contents) {
|
|
107
106
|
hover = {
|
|
108
|
-
contents
|
|
107
|
+
contents,
|
|
109
108
|
range: getRange(node)
|
|
110
109
|
};
|
|
111
110
|
}
|
|
@@ -120,8 +119,8 @@
|
|
|
120
119
|
hover.contents = this.convertContents(hover.contents);
|
|
121
120
|
}
|
|
122
121
|
return hover;
|
|
123
|
-
}
|
|
124
|
-
|
|
122
|
+
}
|
|
123
|
+
convertContents(contents) {
|
|
125
124
|
if (!this.doesSupportMarkdown()) {
|
|
126
125
|
if (typeof contents === 'string') {
|
|
127
126
|
return contents;
|
|
@@ -135,7 +134,7 @@
|
|
|
135
134
|
}
|
|
136
135
|
// MarkedString[]
|
|
137
136
|
else if (Array.isArray(contents)) {
|
|
138
|
-
return contents.map(
|
|
137
|
+
return contents.map(c => {
|
|
139
138
|
return typeof c === 'string' ? c : c.value;
|
|
140
139
|
});
|
|
141
140
|
}
|
|
@@ -145,19 +144,18 @@
|
|
|
145
144
|
}
|
|
146
145
|
}
|
|
147
146
|
return contents;
|
|
148
|
-
}
|
|
149
|
-
|
|
147
|
+
}
|
|
148
|
+
doesSupportMarkdown() {
|
|
150
149
|
if (!(0, objects_1.isDefined)(this.supportsMarkdown)) {
|
|
151
150
|
if (!(0, objects_1.isDefined)(this.clientCapabilities)) {
|
|
152
151
|
this.supportsMarkdown = true;
|
|
153
152
|
return this.supportsMarkdown;
|
|
154
153
|
}
|
|
155
|
-
|
|
154
|
+
const hover = this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.hover;
|
|
156
155
|
this.supportsMarkdown = hover && hover.contentFormat && Array.isArray(hover.contentFormat) && hover.contentFormat.indexOf(cssLanguageTypes_1.MarkupKind.Markdown) !== -1;
|
|
157
156
|
}
|
|
158
157
|
return this.supportsMarkdown;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
}());
|
|
158
|
+
}
|
|
159
|
+
}
|
|
162
160
|
exports.CSSHover = CSSHover;
|
|
163
161
|
});
|