@astrojs/language-server 0.23.2 → 0.24.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.
- package/CHANGELOG.md +23 -0
- package/dist/browser.js +8 -1
- package/dist/check.d.ts +2 -1
- package/dist/check.js +8 -2
- package/dist/core/DiagnosticsManager.d.ts +2 -2
- package/dist/core/config/ConfigManager.d.ts +5 -6
- package/dist/core/config/ConfigManager.js +2 -9
- package/dist/core/documents/AstroDocument.d.ts +1 -1
- package/dist/core/documents/AstroDocument.js +1 -1
- package/dist/core/documents/DocumentBase.d.ts +2 -2
- package/dist/core/documents/DocumentManager.d.ts +1 -1
- package/dist/core/documents/DocumentManager.js +1 -1
- package/dist/core/documents/DocumentMapper.d.ts +2 -2
- package/dist/core/documents/parseHtml.d.ts +3 -2
- package/dist/core/documents/parseHtml.js +12 -5
- package/dist/core/documents/utils.d.ts +3 -3
- package/dist/core/documents/utils.js +1 -2
- package/dist/node.js +15 -1
- package/dist/plugins/PluginHost.d.ts +2 -2
- package/dist/plugins/PluginHost.js +1 -1
- package/dist/plugins/astro/AstroPlugin.d.ts +6 -5
- package/dist/plugins/astro/AstroPlugin.js +1 -0
- package/dist/plugins/astro/features/CompletionsProvider.d.ts +4 -3
- package/dist/plugins/astro/features/CompletionsProvider.js +12 -15
- package/dist/plugins/css/CSSDocument.d.ts +2 -2
- package/dist/plugins/css/CSSDocument.js +1 -1
- package/dist/plugins/css/CSSPlugin.d.ts +1 -1
- package/dist/plugins/css/CSSPlugin.js +3 -3
- package/dist/plugins/css/StyleAttributeDocument.d.ts +2 -2
- package/dist/plugins/css/StyleAttributeDocument.js +1 -1
- package/dist/plugins/css/features/astro-selectors.d.ts +1 -1
- package/dist/plugins/css/features/getIdClassCompletions.d.ts +2 -2
- package/dist/plugins/html/HTMLPlugin.d.ts +3 -3
- package/dist/plugins/html/HTMLPlugin.js +1 -1
- package/dist/plugins/html/utils.d.ts +1 -1
- package/dist/plugins/index.d.ts +4 -4
- package/dist/plugins/index.js +4 -4
- package/dist/plugins/interfaces.d.ts +2 -2
- package/dist/plugins/typescript/LanguageServiceManager.d.ts +8 -9
- package/dist/plugins/typescript/LanguageServiceManager.js +5 -3
- package/dist/plugins/typescript/TypeScriptPlugin.d.ts +7 -6
- package/dist/plugins/typescript/TypeScriptPlugin.js +15 -15
- package/dist/plugins/typescript/astro-sys.d.ts +2 -3
- package/dist/plugins/typescript/astro-sys.js +7 -11
- package/dist/plugins/typescript/astro2tsx.js +3 -4
- package/dist/plugins/typescript/features/CodeActionsProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/CodeActionsProvider.js +6 -9
- package/dist/plugins/typescript/features/CompletionsProvider.d.ts +9 -7
- package/dist/plugins/typescript/features/CompletionsProvider.js +56 -80
- package/dist/plugins/typescript/features/DefinitionsProvider.d.ts +4 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.d.ts +6 -4
- package/dist/plugins/typescript/features/DiagnosticsProvider.js +29 -19
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.d.ts +3 -2
- package/dist/plugins/typescript/features/DocumentSymbolsProvider.js +3 -4
- package/dist/plugins/typescript/features/FoldingRangesProvider.d.ts +7 -4
- package/dist/plugins/typescript/features/FoldingRangesProvider.js +12 -15
- package/dist/plugins/typescript/features/HoverProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/HoverProvider.js +3 -6
- package/dist/plugins/typescript/features/InlayHintsProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/InlayHintsProvider.js +5 -8
- package/dist/plugins/typescript/features/SemanticTokenProvider.d.ts +3 -2
- package/dist/plugins/typescript/features/SemanticTokenProvider.js +4 -7
- package/dist/plugins/typescript/features/SignatureHelpProvider.d.ts +5 -4
- package/dist/plugins/typescript/features/SignatureHelpProvider.js +7 -10
- package/dist/plugins/typescript/features/TypeDefinitionsProvider.d.ts +3 -3
- package/dist/plugins/typescript/features/utils.d.ts +3 -3
- package/dist/plugins/typescript/language-service.d.ts +7 -6
- package/dist/plugins/typescript/language-service.js +29 -30
- package/dist/plugins/typescript/module-loader.d.ts +2 -2
- package/dist/plugins/typescript/module-loader.js +12 -16
- package/dist/plugins/typescript/previewer.d.ts +3 -7
- package/dist/plugins/typescript/previewer.js +13 -17
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.d.ts +4 -5
- package/dist/plugins/typescript/snapshots/DocumentSnapshot.js +2 -7
- package/dist/plugins/typescript/snapshots/SnapshotManager.d.ts +5 -2
- package/dist/plugins/typescript/snapshots/SnapshotManager.js +15 -17
- package/dist/plugins/typescript/snapshots/utils.d.ts +7 -7
- package/dist/plugins/typescript/snapshots/utils.js +28 -29
- package/dist/plugins/typescript/utils.d.ts +8 -10
- package/dist/plugins/typescript/utils.js +90 -107
- package/dist/server.d.ts +5 -1
- package/dist/server.js +27 -17
- package/dist/utils.d.ts +1 -1
- package/package.json +5 -4
|
@@ -1,47 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
3
|
exports.codeActionChangeToTextEdit = exports.CompletionsProviderImpl = void 0;
|
|
27
4
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
28
5
|
const vscode_languageserver_protocol_1 = require("vscode-languageserver-protocol");
|
|
29
|
-
const utils_1 = require("../../../core/documents/utils");
|
|
30
6
|
const documents_1 = require("../../../core/documents");
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const utils_2 = require("../utils");
|
|
34
|
-
const utils_3 = require("../../../utils");
|
|
7
|
+
const utils_1 = require("../../../core/documents/utils");
|
|
8
|
+
const utils_2 = require("../../../utils");
|
|
35
9
|
const previewer_1 = require("../previewer");
|
|
10
|
+
const utils_3 = require("../utils");
|
|
36
11
|
const utils_4 = require("./utils");
|
|
37
12
|
// `import {...} from '..'` or `import ... from '..'`
|
|
38
13
|
// Note: Does not take into account if import is within a comment.
|
|
39
14
|
const scriptImportRegex = /\bimport\s+{([^}]*?)}\s+?from\s+['"`].+?['"`]|\bimport\s+(\w+?)\s+from\s+['"`].+?['"`]/g;
|
|
15
|
+
// When Svelte components are imported, we have to reference the svelte2tsx's types to properly type the component
|
|
16
|
+
// An unfortunate downside of this is that it polutes completions, so let's filter those internal types manually
|
|
17
|
+
const svelte2tsxTypes = new Set([
|
|
18
|
+
'Svelte2TsxComponent',
|
|
19
|
+
'Svelte2TsxComponentConstructorParameters',
|
|
20
|
+
'SvelteComponentConstructor',
|
|
21
|
+
'SvelteActionReturnType',
|
|
22
|
+
'SvelteTransitionConfig',
|
|
23
|
+
'SvelteTransitionReturnType',
|
|
24
|
+
'SvelteAnimationReturnType',
|
|
25
|
+
'SvelteWithOptionalProps',
|
|
26
|
+
'SvelteAllProps',
|
|
27
|
+
'SveltePropsAnyFallback',
|
|
28
|
+
'SvelteSlotsAnyFallback',
|
|
29
|
+
'SvelteRestProps',
|
|
30
|
+
'SvelteSlots',
|
|
31
|
+
'SvelteStore',
|
|
32
|
+
]);
|
|
40
33
|
class CompletionsProviderImpl {
|
|
41
34
|
constructor(languageServiceManager, configManager) {
|
|
42
35
|
this.languageServiceManager = languageServiceManager;
|
|
43
36
|
this.configManager = configManager;
|
|
44
37
|
this.validTriggerCharacters = ['.', '"', "'", '`', '/', '@', '<', '#'];
|
|
38
|
+
this.ts = languageServiceManager.docContext.ts;
|
|
45
39
|
}
|
|
46
40
|
isValidTriggerCharacter(character) {
|
|
47
41
|
return this.validTriggerCharacters.includes(character);
|
|
@@ -65,7 +59,7 @@ class CompletionsProviderImpl {
|
|
|
65
59
|
const offset = document.offsetAt(position);
|
|
66
60
|
const node = html.findNodeAt(offset);
|
|
67
61
|
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
68
|
-
let filePath = (0,
|
|
62
|
+
let filePath = (0, utils_3.toVirtualAstroFilePath)(tsDoc.filePath);
|
|
69
63
|
let completions;
|
|
70
64
|
const isCompletionInsideFrontmatter = (0, utils_1.isInsideFrontmatter)(document.getText(), offset);
|
|
71
65
|
const isCompletionInsideExpression = (0, utils_1.isInsideExpression)(document.getText(), node.start, offset);
|
|
@@ -73,7 +67,7 @@ class CompletionsProviderImpl {
|
|
|
73
67
|
const formatOptions = await this.configManager.getTSFormatConfig(document);
|
|
74
68
|
let scriptTagIndex = undefined;
|
|
75
69
|
if (node.tag === 'script') {
|
|
76
|
-
const { filePath: scriptFilePath, offset: scriptOffset, index: scriptIndex, } = (0,
|
|
70
|
+
const { filePath: scriptFilePath, offset: scriptOffset, index: scriptIndex, } = (0, utils_3.getScriptTagSnapshot)(tsDoc, document, node, position);
|
|
77
71
|
filePath = scriptFilePath;
|
|
78
72
|
scriptTagIndex = scriptIndex;
|
|
79
73
|
completions = lang.getCompletionsAtPosition(scriptFilePath, scriptOffset, {
|
|
@@ -114,11 +108,11 @@ class CompletionsProviderImpl {
|
|
|
114
108
|
const fragment = await tsDoc.createFragment();
|
|
115
109
|
const existingImports = this.getExistingImports(document);
|
|
116
110
|
const completionItems = completions.entries
|
|
117
|
-
.filter(isValidCompletion)
|
|
111
|
+
.filter((completion) => this.isValidCompletion(completion, this.ts))
|
|
118
112
|
.map((entry) => this.toCompletionItem(fragment, entry, filePath, offset, isCompletionInsideFrontmatter, scriptTagIndex, existingImports))
|
|
119
|
-
.filter(
|
|
113
|
+
.filter(utils_2.isNotNullOrUndefined)
|
|
120
114
|
.map((comp) => this.fixTextEditRange(wordRangeStartPosition, comp));
|
|
121
|
-
const completionList =
|
|
115
|
+
const completionList = vscode_languageserver_1.CompletionList.create(completionItems, true);
|
|
122
116
|
this.lastCompletion = { key: document.getFilePath() || '', position, completionList };
|
|
123
117
|
return completionList;
|
|
124
118
|
}
|
|
@@ -151,7 +145,7 @@ class CompletionsProviderImpl {
|
|
|
151
145
|
const isInsideScriptTag = data.scriptTagIndex !== undefined;
|
|
152
146
|
let scriptTagSnapshot;
|
|
153
147
|
if (isInsideScriptTag) {
|
|
154
|
-
const { snapshot } = (0,
|
|
148
|
+
const { snapshot } = (0, utils_3.getScriptTagSnapshot)(tsDoc, document, document.scriptTags[data.scriptTagIndex].container);
|
|
155
149
|
scriptTagSnapshot = snapshot;
|
|
156
150
|
}
|
|
157
151
|
if (actions) {
|
|
@@ -163,7 +157,7 @@ class CompletionsProviderImpl {
|
|
|
163
157
|
textChange.span.start = fragment.offsetAt(scriptTagSnapshot.getOriginalPosition(scriptTagSnapshot.positionAt(textChange.span.start)));
|
|
164
158
|
});
|
|
165
159
|
}
|
|
166
|
-
edit.push(...change.textChanges.map((textChange) => codeActionChangeToTextEdit(document, fragment, isInsideScriptTag, textChange)));
|
|
160
|
+
edit.push(...change.textChanges.map((textChange) => codeActionChangeToTextEdit(document, fragment, isInsideScriptTag, textChange, this.ts)));
|
|
167
161
|
}
|
|
168
162
|
}
|
|
169
163
|
item.additionalTextEdits = (item.additionalTextEdits ?? []).concat(edit);
|
|
@@ -179,13 +173,13 @@ class CompletionsProviderImpl {
|
|
|
179
173
|
return null;
|
|
180
174
|
}
|
|
181
175
|
if (isAstroComponent) {
|
|
182
|
-
item.label = (0,
|
|
176
|
+
item.label = (0, utils_3.removeAstroComponentSuffix)(comp.name);
|
|
183
177
|
// Set component imports as file completion, that way we get cool icons
|
|
184
178
|
item.kind = vscode_languageserver_protocol_1.CompletionItemKind.File;
|
|
185
179
|
item.detail = comp.data?.moduleSpecifier;
|
|
186
180
|
}
|
|
187
181
|
else {
|
|
188
|
-
item.kind = (0,
|
|
182
|
+
item.kind = (0, utils_3.scriptElementKindToCompletionItemKind)(comp.kind, this.ts);
|
|
189
183
|
}
|
|
190
184
|
// TS may suggest another component even if there already exists an import with the same.
|
|
191
185
|
// This happens because internally, components get suffixed with __AstroComponent_
|
|
@@ -194,7 +188,7 @@ class CompletionsProviderImpl {
|
|
|
194
188
|
}
|
|
195
189
|
if (comp.kindModifiers) {
|
|
196
190
|
const kindModifiers = new Set(comp.kindModifiers.split(/,|\s+/g));
|
|
197
|
-
if (kindModifiers.has(
|
|
191
|
+
if (kindModifiers.has(this.ts.ScriptElementKindModifier.optionalModifier)) {
|
|
198
192
|
if (!item.insertText) {
|
|
199
193
|
item.insertText = item.label;
|
|
200
194
|
}
|
|
@@ -203,7 +197,7 @@ class CompletionsProviderImpl {
|
|
|
203
197
|
}
|
|
204
198
|
item.label += '?';
|
|
205
199
|
}
|
|
206
|
-
if (kindModifiers.has(
|
|
200
|
+
if (kindModifiers.has(this.ts.ScriptElementKindModifier.deprecatedModifier)) {
|
|
207
201
|
item.tags = [vscode_languageserver_1.CompletionItemTag.Deprecated];
|
|
208
202
|
}
|
|
209
203
|
}
|
|
@@ -211,14 +205,14 @@ class CompletionsProviderImpl {
|
|
|
211
205
|
// if (comp.sourceDisplay) {
|
|
212
206
|
// item.labelDetails = { description: ts.displayPartsToString(comp.sourceDisplay) };
|
|
213
207
|
// }
|
|
214
|
-
item.commitCharacters = (0,
|
|
208
|
+
item.commitCharacters = (0, utils_3.getCommitCharactersForScriptElement)(comp.kind, this.ts);
|
|
215
209
|
item.sortText = comp.sortText;
|
|
216
210
|
item.preselect = comp.isRecommended;
|
|
217
211
|
if (comp.replacementSpan) {
|
|
218
|
-
item.insertText = comp.insertText ? (0,
|
|
212
|
+
item.insertText = comp.insertText ? (0, utils_3.removeAstroComponentSuffix)(comp.insertText) : undefined;
|
|
219
213
|
item.insertTextFormat = comp.isSnippet ? vscode_languageserver_1.InsertTextFormat.Snippet : vscode_languageserver_1.InsertTextFormat.PlainText;
|
|
220
214
|
item.textEdit = comp.replacementSpan
|
|
221
|
-
? vscode_languageserver_1.TextEdit.replace((0,
|
|
215
|
+
? vscode_languageserver_1.TextEdit.replace((0, utils_3.convertRange)(fragment, comp.replacementSpan), item.insertText ?? item.label)
|
|
222
216
|
: undefined;
|
|
223
217
|
}
|
|
224
218
|
return {
|
|
@@ -234,14 +228,14 @@ class CompletionsProviderImpl {
|
|
|
234
228
|
}
|
|
235
229
|
getCompletionDocument(compDetail) {
|
|
236
230
|
const { sourceDisplay, documentation: tsDocumentation, displayParts } = compDetail;
|
|
237
|
-
let detail = (0,
|
|
231
|
+
let detail = (0, utils_3.removeAstroComponentSuffix)(this.ts.displayPartsToString(displayParts));
|
|
238
232
|
if (sourceDisplay) {
|
|
239
|
-
const importPath =
|
|
233
|
+
const importPath = this.ts.displayPartsToString(sourceDisplay);
|
|
240
234
|
detail = importPath;
|
|
241
235
|
}
|
|
242
236
|
const documentation = {
|
|
243
237
|
kind: 'markdown',
|
|
244
|
-
value: (0, previewer_1.getMarkdownDocumentation)(tsDocumentation, compDetail.tags),
|
|
238
|
+
value: (0, previewer_1.getMarkdownDocumentation)(tsDocumentation, compDetail.tags, this.ts),
|
|
245
239
|
};
|
|
246
240
|
return {
|
|
247
241
|
documentation,
|
|
@@ -290,29 +284,39 @@ class CompletionsProviderImpl {
|
|
|
290
284
|
(triggerCharacter === '.' && (0, utils_4.isPartOfImportStatement)(document.getText(), position))));
|
|
291
285
|
}
|
|
292
286
|
getExistingImports(document) {
|
|
293
|
-
const rawImports = (0,
|
|
287
|
+
const rawImports = (0, utils_2.getRegExpMatches)(scriptImportRegex, document.getText()).map((match) => (match[1] ?? match[2]).split(','));
|
|
294
288
|
const tidiedImports = rawImports.flat().map((match) => match.trim());
|
|
295
289
|
return new Set(tidiedImports);
|
|
296
290
|
}
|
|
297
291
|
isAstroComponentImport(className) {
|
|
298
292
|
return className.endsWith('__AstroComponent_');
|
|
299
293
|
}
|
|
294
|
+
isValidCompletion(completion, ts) {
|
|
295
|
+
// Remove completion for default exported function
|
|
296
|
+
const isDefaultExport = completion.name === 'default' && completion.kindModifiers == ts.ScriptElementKindModifier.exportedModifier;
|
|
297
|
+
// Remove completion for svelte2tsx internal types
|
|
298
|
+
const isSvelte2tsxCompletion = completion.name.startsWith('__sveltets_') || svelte2tsxTypes.has(completion.name);
|
|
299
|
+
if (isDefaultExport || isSvelte2tsxCompletion) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
return true;
|
|
303
|
+
}
|
|
300
304
|
}
|
|
301
305
|
exports.CompletionsProviderImpl = CompletionsProviderImpl;
|
|
302
|
-
function codeActionChangeToTextEdit(document, fragment, isInsideScriptTag, change) {
|
|
303
|
-
change.newText = (0,
|
|
306
|
+
function codeActionChangeToTextEdit(document, fragment, isInsideScriptTag, change, ts) {
|
|
307
|
+
change.newText = (0, utils_3.removeAstroComponentSuffix)(change.newText);
|
|
304
308
|
const { span } = change;
|
|
305
309
|
let range;
|
|
306
|
-
const virtualRange = (0,
|
|
310
|
+
const virtualRange = (0, utils_3.convertRange)(fragment, span);
|
|
307
311
|
range = (0, documents_1.mapRangeToOriginal)(fragment, virtualRange);
|
|
308
312
|
if (!isInsideScriptTag) {
|
|
309
313
|
// If we don't have a frontmatter already, create one with the import
|
|
310
314
|
const frontmatterState = document.astroMeta.frontmatter.state;
|
|
311
315
|
if (frontmatterState === null) {
|
|
312
|
-
return vscode_languageserver_1.TextEdit.replace(vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(0, 0), vscode_languageserver_1.Position.create(0, 0)), `---${
|
|
316
|
+
return vscode_languageserver_1.TextEdit.replace(vscode_languageserver_1.Range.create(vscode_languageserver_1.Position.create(0, 0), vscode_languageserver_1.Position.create(0, 0)), `---${ts.sys.newLine}${change.newText}---${ts.sys.newLine}${ts.sys.newLine}`);
|
|
313
317
|
}
|
|
314
318
|
if (!(0, utils_1.isInsideFrontmatter)(document.getText(), document.offsetAt(range.start))) {
|
|
315
|
-
range = (0,
|
|
319
|
+
range = (0, utils_3.ensureFrontmatterInsert)(range, document);
|
|
316
320
|
}
|
|
317
321
|
// First import in a file will wrongly have a newline before it due to how the frontmatter is replaced by a comment
|
|
318
322
|
if (range.start.line === 1 && (change.newText.startsWith('\n') || change.newText.startsWith('\r\n'))) {
|
|
@@ -324,37 +328,9 @@ function codeActionChangeToTextEdit(document, fragment, isInsideScriptTag, chang
|
|
|
324
328
|
const isNewImport = !existingLine.trim().startsWith('import');
|
|
325
329
|
// Avoid putting new imports on the same line as the script tag opening
|
|
326
330
|
if (!(change.newText.startsWith('\n') || change.newText.startsWith('\r\n')) && isNewImport) {
|
|
327
|
-
change.newText =
|
|
331
|
+
change.newText = ts.sys.newLine + change.newText;
|
|
328
332
|
}
|
|
329
333
|
}
|
|
330
334
|
return vscode_languageserver_1.TextEdit.replace(range, change.newText);
|
|
331
335
|
}
|
|
332
336
|
exports.codeActionChangeToTextEdit = codeActionChangeToTextEdit;
|
|
333
|
-
// When Svelte components are imported, we have to reference the svelte2tsx's types to properly type the component
|
|
334
|
-
// An unfortunate downside of this is that it polutes completions, so let's filter those internal types manually
|
|
335
|
-
const svelte2tsxTypes = new Set([
|
|
336
|
-
'Svelte2TsxComponent',
|
|
337
|
-
'Svelte2TsxComponentConstructorParameters',
|
|
338
|
-
'SvelteComponentConstructor',
|
|
339
|
-
'SvelteActionReturnType',
|
|
340
|
-
'SvelteTransitionConfig',
|
|
341
|
-
'SvelteTransitionReturnType',
|
|
342
|
-
'SvelteAnimationReturnType',
|
|
343
|
-
'SvelteWithOptionalProps',
|
|
344
|
-
'SvelteAllProps',
|
|
345
|
-
'SveltePropsAnyFallback',
|
|
346
|
-
'SvelteSlotsAnyFallback',
|
|
347
|
-
'SvelteRestProps',
|
|
348
|
-
'SvelteSlots',
|
|
349
|
-
'SvelteStore',
|
|
350
|
-
]);
|
|
351
|
-
function isValidCompletion(completion) {
|
|
352
|
-
// Remove completion for default exported function
|
|
353
|
-
const isDefaultExport = completion.name === 'default' && completion.kindModifiers == typescript_1.ScriptElementKindModifier.exportedModifier;
|
|
354
|
-
// Remove completion for svelte2tsx internal types
|
|
355
|
-
const isSvelte2tsxCompletion = completion.name.startsWith('__sveltets_') || svelte2tsxTypes.has(completion.name);
|
|
356
|
-
if (isDefaultExport || isSvelte2tsxCompletion) {
|
|
357
|
-
return false;
|
|
358
|
-
}
|
|
359
|
-
return true;
|
|
360
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import { DefinitionsProvider } from '../../interfaces';
|
|
4
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
1
|
+
import { LocationLink, Position } from 'vscode-languageserver-types';
|
|
2
|
+
import type { AstroDocument } from '../../../core/documents';
|
|
3
|
+
import type { DefinitionsProvider } from '../../interfaces';
|
|
4
|
+
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
5
|
export declare class DefinitionsProviderImpl implements DefinitionsProvider {
|
|
6
6
|
private languageServiceManager;
|
|
7
7
|
constructor(languageServiceManager: LanguageServiceManager);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CancellationToken } from 'vscode-languageserver';
|
|
1
|
+
import { CancellationToken, DiagnosticSeverity } from 'vscode-languageserver';
|
|
2
2
|
import { Diagnostic } from 'vscode-languageserver-types';
|
|
3
3
|
import { AstroDocument } from '../../../core/documents';
|
|
4
|
-
import { DiagnosticsProvider } from '../../interfaces';
|
|
5
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
4
|
+
import type { DiagnosticsProvider } from '../../interfaces';
|
|
5
|
+
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
6
6
|
export declare enum DiagnosticCodes {
|
|
7
7
|
SPREAD_EXPECTED = 1005,
|
|
8
8
|
IS_NOT_A_MODULE = 2306,
|
|
@@ -15,8 +15,10 @@ export declare enum DiagnosticCodes {
|
|
|
15
15
|
JSX_ELEMENT_NO_CALL = 2604
|
|
16
16
|
}
|
|
17
17
|
export declare class DiagnosticsProviderImpl implements DiagnosticsProvider {
|
|
18
|
-
private
|
|
18
|
+
private languageServiceManager;
|
|
19
|
+
private ts;
|
|
19
20
|
constructor(languageServiceManager: LanguageServiceManager);
|
|
20
21
|
getDiagnostics(document: AstroDocument, _cancellationToken?: CancellationToken): Promise<Diagnostic[]>;
|
|
21
22
|
private getTagBoundaries;
|
|
23
|
+
mapSeverity(category: ts.DiagnosticCategory): DiagnosticSeverity;
|
|
22
24
|
}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.DiagnosticsProviderImpl = exports.DiagnosticCodes = void 0;
|
|
7
|
-
const
|
|
4
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
8
5
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
9
6
|
const documents_1 = require("../../../core/documents");
|
|
10
7
|
const utils_1 = require("../utils");
|
|
@@ -25,6 +22,7 @@ var DiagnosticCodes;
|
|
|
25
22
|
class DiagnosticsProviderImpl {
|
|
26
23
|
constructor(languageServiceManager) {
|
|
27
24
|
this.languageServiceManager = languageServiceManager;
|
|
25
|
+
this.ts = languageServiceManager.docContext.ts;
|
|
28
26
|
}
|
|
29
27
|
async getDiagnostics(document, _cancellationToken) {
|
|
30
28
|
// Don't return diagnostics for files inside node_modules. These are considered read-only
|
|
@@ -47,9 +45,9 @@ class DiagnosticsProviderImpl {
|
|
|
47
45
|
// file due to some internal cache inside TS that would cause it to being mapped twice in some cases
|
|
48
46
|
.map((diagnostic) => ({
|
|
49
47
|
range: (0, utils_1.convertRange)(scriptTagSnapshot, diagnostic),
|
|
50
|
-
severity:
|
|
48
|
+
severity: this.mapSeverity(diagnostic.category),
|
|
51
49
|
source: 'ts',
|
|
52
|
-
message:
|
|
50
|
+
message: this.ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
|
|
53
51
|
code: diagnostic.code,
|
|
54
52
|
tags: getDiagnosticTag(diagnostic),
|
|
55
53
|
}))
|
|
@@ -62,15 +60,15 @@ class DiagnosticsProviderImpl {
|
|
|
62
60
|
...lang.getSuggestionDiagnostics(filePath),
|
|
63
61
|
...lang.getSemanticDiagnostics(filePath),
|
|
64
62
|
].filter((diag) => {
|
|
65
|
-
return isNoWithinBoundary(scriptBoundaries, diag);
|
|
63
|
+
return isNoWithinBoundary(scriptBoundaries, diag, this.ts);
|
|
66
64
|
});
|
|
67
65
|
return [
|
|
68
66
|
...diagnostics
|
|
69
67
|
.map((diagnostic) => ({
|
|
70
68
|
range: (0, utils_1.convertRange)(tsDoc, diagnostic),
|
|
71
|
-
severity:
|
|
69
|
+
severity: this.mapSeverity(diagnostic.category),
|
|
72
70
|
source: 'ts',
|
|
73
|
-
message:
|
|
71
|
+
message: this.ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n'),
|
|
74
72
|
code: diagnostic.code,
|
|
75
73
|
tags: getDiagnosticTag(diagnostic),
|
|
76
74
|
}))
|
|
@@ -99,24 +97,36 @@ class DiagnosticsProviderImpl {
|
|
|
99
97
|
if (!sourceFile) {
|
|
100
98
|
return boundaries;
|
|
101
99
|
}
|
|
102
|
-
function findTags(parent) {
|
|
103
|
-
|
|
104
|
-
if (
|
|
100
|
+
function findTags(parent, ts) {
|
|
101
|
+
ts.forEachChild(parent, (node) => {
|
|
102
|
+
if (ts.isJsxElement(node)) {
|
|
105
103
|
let tagName = node.openingElement.tagName.getText();
|
|
106
104
|
switch (tagName) {
|
|
107
105
|
case 'script': {
|
|
108
|
-
|
|
106
|
+
ts.getLineAndCharacterOfPosition(sourceFile, node.getStart());
|
|
109
107
|
boundaries.script.push([node.getStart(), node.getEnd()]);
|
|
110
108
|
break;
|
|
111
109
|
}
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
|
-
findTags(node);
|
|
112
|
+
findTags(node, ts);
|
|
115
113
|
});
|
|
116
114
|
}
|
|
117
|
-
findTags(sourceFile);
|
|
115
|
+
findTags(sourceFile, this.ts);
|
|
118
116
|
return boundaries;
|
|
119
117
|
}
|
|
118
|
+
mapSeverity(category) {
|
|
119
|
+
switch (category) {
|
|
120
|
+
case this.ts.DiagnosticCategory.Error:
|
|
121
|
+
return vscode_languageserver_1.DiagnosticSeverity.Error;
|
|
122
|
+
case this.ts.DiagnosticCategory.Warning:
|
|
123
|
+
return vscode_languageserver_1.DiagnosticSeverity.Warning;
|
|
124
|
+
case this.ts.DiagnosticCategory.Suggestion:
|
|
125
|
+
return vscode_languageserver_1.DiagnosticSeverity.Hint;
|
|
126
|
+
case this.ts.DiagnosticCategory.Message:
|
|
127
|
+
return vscode_languageserver_1.DiagnosticSeverity.Information;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
120
130
|
}
|
|
121
131
|
exports.DiagnosticsProviderImpl = DiagnosticsProviderImpl;
|
|
122
132
|
function isWithinBoundaries(boundaries, start) {
|
|
@@ -127,7 +137,7 @@ function isWithinBoundaries(boundaries, start) {
|
|
|
127
137
|
}
|
|
128
138
|
return false;
|
|
129
139
|
}
|
|
130
|
-
function diagnosticIsWithinBoundaries(sourceFile, boundaries, diagnostic) {
|
|
140
|
+
function diagnosticIsWithinBoundaries(sourceFile, boundaries, diagnostic, ts) {
|
|
131
141
|
if ('start' in diagnostic) {
|
|
132
142
|
if (diagnostic.start == null)
|
|
133
143
|
return false;
|
|
@@ -136,11 +146,11 @@ function diagnosticIsWithinBoundaries(sourceFile, boundaries, diagnostic) {
|
|
|
136
146
|
if (!sourceFile)
|
|
137
147
|
return false;
|
|
138
148
|
let startRange = diagnostic.range.start;
|
|
139
|
-
let pos =
|
|
149
|
+
let pos = ts.getPositionOfLineAndCharacter(sourceFile, startRange.line, startRange.character);
|
|
140
150
|
return isWithinBoundaries(boundaries, pos);
|
|
141
151
|
}
|
|
142
|
-
function isNoWithinBoundary(boundaries, diagnostic) {
|
|
143
|
-
return !diagnosticIsWithinBoundaries(undefined, boundaries, diagnostic);
|
|
152
|
+
function isNoWithinBoundary(boundaries, diagnostic, ts) {
|
|
153
|
+
return !diagnosticIsWithinBoundaries(undefined, boundaries, diagnostic, ts);
|
|
144
154
|
}
|
|
145
155
|
function mapRange(fragment, _document) {
|
|
146
156
|
return (diagnostic) => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { SymbolInformation } from 'vscode-languageserver-types';
|
|
2
2
|
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import { DocumentSymbolsProvider } from '../../interfaces';
|
|
4
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
3
|
+
import type { DocumentSymbolsProvider } from '../../interfaces';
|
|
4
|
+
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
5
|
export declare class DocumentSymbolsProviderImpl implements DocumentSymbolsProvider {
|
|
6
6
|
private languageServiceManager;
|
|
7
|
+
private ts;
|
|
7
8
|
constructor(languageServiceManager: LanguageServiceManager);
|
|
8
9
|
getDocumentSymbols(document: AstroDocument): Promise<SymbolInformation[]>;
|
|
9
10
|
private collectSymbols;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentSymbolsProviderImpl = void 0;
|
|
4
|
-
const typescript_1 = require("typescript");
|
|
5
4
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
6
5
|
const documents_1 = require("../../../core/documents");
|
|
7
6
|
const utils_1 = require("../utils");
|
|
8
|
-
const vscode_languageserver_types_2 = require("vscode-languageserver-types");
|
|
9
7
|
class DocumentSymbolsProviderImpl {
|
|
10
8
|
constructor(languageServiceManager) {
|
|
11
9
|
this.languageServiceManager = languageServiceManager;
|
|
10
|
+
this.ts = languageServiceManager.docContext.ts;
|
|
12
11
|
}
|
|
13
12
|
async getDocumentSymbols(document) {
|
|
14
13
|
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
@@ -54,10 +53,10 @@ class DocumentSymbolsProviderImpl {
|
|
|
54
53
|
const symbol = vscode_languageserver_types_1.SymbolInformation.create(item.text, (0, utils_1.symbolKindFromString)(item.kind), vscode_languageserver_types_1.Range.create(fragment.positionAt(span.start), fragment.positionAt(span.start + span.length)), fragment.getURL(), container);
|
|
55
54
|
// TypeScript gives us kind modifiers as a string instead of an array
|
|
56
55
|
const kindModifiers = new Set(item.kindModifiers.split(/,|\s+/g));
|
|
57
|
-
if (kindModifiers.has(
|
|
56
|
+
if (kindModifiers.has(this.ts.ScriptElementKindModifier.deprecatedModifier)) {
|
|
58
57
|
if (!symbol.tags)
|
|
59
58
|
symbol.tags = [];
|
|
60
|
-
symbol.tags.push(
|
|
59
|
+
symbol.tags.push(vscode_languageserver_types_1.SymbolTag.Deprecated);
|
|
61
60
|
}
|
|
62
61
|
cb(symbol);
|
|
63
62
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import type ts from 'typescript';
|
|
1
2
|
import { FoldingRange } from 'vscode-languageserver';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import { FoldingRangesProvider } from '../../interfaces';
|
|
4
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
3
|
+
import type { AstroDocument } from '../../../core/documents';
|
|
4
|
+
import type { FoldingRangesProvider } from '../../interfaces';
|
|
5
|
+
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
6
|
export declare class FoldingRangesProviderImpl implements FoldingRangesProvider {
|
|
6
|
-
private
|
|
7
|
+
private languageServiceManager;
|
|
8
|
+
private ts;
|
|
7
9
|
constructor(languageServiceManager: LanguageServiceManager);
|
|
8
10
|
getFoldingRanges(document: AstroDocument): Promise<FoldingRange[] | null>;
|
|
11
|
+
transformFoldingRangeKind(tsKind: ts.OutliningSpanKind): "imports" | "comment" | "region" | undefined;
|
|
9
12
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.FoldingRangesProviderImpl = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
4
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
9
5
|
const utils_1 = require("../utils");
|
|
10
6
|
class FoldingRangesProviderImpl {
|
|
11
7
|
constructor(languageServiceManager) {
|
|
12
8
|
this.languageServiceManager = languageServiceManager;
|
|
9
|
+
this.ts = languageServiceManager.docContext.ts;
|
|
13
10
|
}
|
|
14
11
|
async getFoldingRanges(document) {
|
|
15
12
|
const html = document.html;
|
|
@@ -38,22 +35,22 @@ class FoldingRangesProviderImpl {
|
|
|
38
35
|
if (start.line === end.line && start.character === end.character) {
|
|
39
36
|
continue;
|
|
40
37
|
}
|
|
41
|
-
foldingRanges.push(vscode_languageserver_1.FoldingRange.create(start.line, end.line, start.character, end.character, transformFoldingRangeKind(span.kind)));
|
|
38
|
+
foldingRanges.push(vscode_languageserver_1.FoldingRange.create(start.line, end.line, start.character, end.character, this.transformFoldingRangeKind(span.kind)));
|
|
42
39
|
}
|
|
43
40
|
return foldingRanges;
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return vscode_languageserver_1.FoldingRangeKind.Region;
|
|
42
|
+
transformFoldingRangeKind(tsKind) {
|
|
43
|
+
switch (tsKind) {
|
|
44
|
+
case this.ts.OutliningSpanKind.Comment:
|
|
45
|
+
return vscode_languageserver_1.FoldingRangeKind.Comment;
|
|
46
|
+
case this.ts.OutliningSpanKind.Imports:
|
|
47
|
+
return vscode_languageserver_1.FoldingRangeKind.Imports;
|
|
48
|
+
case this.ts.OutliningSpanKind.Region:
|
|
49
|
+
return vscode_languageserver_1.FoldingRangeKind.Region;
|
|
50
|
+
}
|
|
55
51
|
}
|
|
56
52
|
}
|
|
53
|
+
exports.FoldingRangesProviderImpl = FoldingRangesProviderImpl;
|
|
57
54
|
// https://github.com/microsoft/vscode/blob/bed61166fb604e519e82e4d1d1ed839bc45d65f8/extensions/typescript-language-features/src/languageFeatures/folding.ts#L61-L73
|
|
58
55
|
function adjustFoldingEnd(start, end, document) {
|
|
59
56
|
// workaround for #47240
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { Hover, Position } from 'vscode-languageserver';
|
|
1
|
+
import type { Hover, Position } from 'vscode-languageserver';
|
|
3
2
|
import { AstroDocument } from '../../../core/documents';
|
|
4
|
-
import { HoverProvider } from '../../interfaces';
|
|
3
|
+
import type { HoverProvider } from '../../interfaces';
|
|
4
|
+
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
5
|
export declare class HoverProviderImpl implements HoverProvider {
|
|
6
|
-
private
|
|
6
|
+
private languageServiceManager;
|
|
7
|
+
private ts;
|
|
7
8
|
constructor(languageServiceManager: LanguageServiceManager);
|
|
8
9
|
doHover(document: AstroDocument, position: Position): Promise<Hover | null>;
|
|
9
10
|
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.HoverProviderImpl = void 0;
|
|
7
|
-
const typescript_1 = __importDefault(require("typescript"));
|
|
8
4
|
const documents_1 = require("../../../core/documents");
|
|
9
5
|
const previewer_1 = require("../previewer");
|
|
10
6
|
const utils_1 = require("../utils");
|
|
@@ -12,6 +8,7 @@ const partsMap = new Map([['JSX attribute', 'HTML attribute']]);
|
|
|
12
8
|
class HoverProviderImpl {
|
|
13
9
|
constructor(languageServiceManager) {
|
|
14
10
|
this.languageServiceManager = languageServiceManager;
|
|
11
|
+
this.ts = languageServiceManager.docContext.ts;
|
|
15
12
|
}
|
|
16
13
|
async doHover(document, position) {
|
|
17
14
|
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
@@ -40,8 +37,8 @@ class HoverProviderImpl {
|
|
|
40
37
|
text: partsMap.has(value.text) ? partsMap.get(value.text) : value.text,
|
|
41
38
|
kind: value.kind,
|
|
42
39
|
}));
|
|
43
|
-
const declaration =
|
|
44
|
-
const documentation = (0, previewer_1.getMarkdownDocumentation)(info.documentation, info.tags);
|
|
40
|
+
const declaration = this.ts.displayPartsToString(displayParts);
|
|
41
|
+
const documentation = (0, previewer_1.getMarkdownDocumentation)(info.documentation, info.tags, this.ts);
|
|
45
42
|
// https://microsoft.github.io/language-server-protocol/specification#textDocument_hover
|
|
46
43
|
const contents = ['```typescript', declaration, '```']
|
|
47
44
|
.concat(documentation ? ['---', documentation] : [])
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { InlayHint } from 'vscode-languageserver';
|
|
2
|
-
import { AstroDocument } from '../../../core/documents';
|
|
3
|
-
import { InlayHintsProvider } from '../../interfaces';
|
|
4
|
-
import { LanguageServiceManager } from '../LanguageServiceManager';
|
|
5
2
|
import { Range } from 'vscode-languageserver-types';
|
|
6
|
-
import { ConfigManager } from '../../../core/config';
|
|
3
|
+
import type { ConfigManager } from '../../../core/config';
|
|
4
|
+
import type { AstroDocument } from '../../../core/documents';
|
|
5
|
+
import type { InlayHintsProvider } from '../../interfaces';
|
|
6
|
+
import type { LanguageServiceManager } from '../LanguageServiceManager';
|
|
7
7
|
export declare class InlayHintsProviderImpl implements InlayHintsProvider {
|
|
8
8
|
private languageServiceManager;
|
|
9
9
|
private configManager;
|
|
10
|
+
private ts;
|
|
10
11
|
constructor(languageServiceManager: LanguageServiceManager, configManager: ConfigManager);
|
|
11
12
|
getInlayHints(document: AstroDocument, range: Range): Promise<InlayHint[]>;
|
|
12
13
|
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.InlayHintsProviderImpl = void 0;
|
|
7
4
|
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
5
|
const vscode_languageserver_types_1 = require("vscode-languageserver-types");
|
|
10
|
-
const
|
|
6
|
+
const utils_1 = require("../utils");
|
|
11
7
|
class InlayHintsProviderImpl {
|
|
12
8
|
constructor(languageServiceManager, configManager) {
|
|
13
9
|
this.languageServiceManager = languageServiceManager;
|
|
14
10
|
this.configManager = configManager;
|
|
11
|
+
this.ts = languageServiceManager.docContext.ts;
|
|
15
12
|
}
|
|
16
13
|
async getInlayHints(document, range) {
|
|
17
14
|
const { lang, tsDoc } = await this.languageServiceManager.getLSAndTSDoc(document);
|
|
@@ -19,12 +16,12 @@ class InlayHintsProviderImpl {
|
|
|
19
16
|
const fragment = await tsDoc.createFragment();
|
|
20
17
|
const start = fragment.offsetAt(fragment.getGeneratedPosition(range.start));
|
|
21
18
|
const end = fragment.offsetAt(fragment.getGeneratedPosition(range.end));
|
|
22
|
-
const tsPreferences = await this.configManager.
|
|
19
|
+
const tsPreferences = await this.configManager.getTSPreferences(document);
|
|
23
20
|
const inlayHints = lang.provideInlayHints(filePath, { start, length: end - start }, tsPreferences);
|
|
24
21
|
return inlayHints.map((hint) => {
|
|
25
|
-
const result = vscode_languageserver_1.InlayHint.create(fragment.getOriginalPosition(fragment.positionAt(hint.position)), hint.text, hint.kind ===
|
|
22
|
+
const result = vscode_languageserver_1.InlayHint.create(fragment.getOriginalPosition(fragment.positionAt(hint.position)), hint.text, hint.kind === this.ts.InlayHintKind.Type
|
|
26
23
|
? vscode_languageserver_types_1.InlayHintKind.Type
|
|
27
|
-
: hint.kind ===
|
|
24
|
+
: hint.kind === this.ts.InlayHintKind.Parameter
|
|
28
25
|
? vscode_languageserver_types_1.InlayHintKind.Parameter
|
|
29
26
|
: undefined);
|
|
30
27
|
result.paddingLeft = hint.whitespaceBefore;
|