typescript-language-server 2.0.1 → 2.2.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 +31 -0
- package/README.md +73 -6
- package/lib/calls.d.ts +1 -1
- package/lib/calls.d.ts.map +1 -1
- package/lib/calls.js +4 -3
- package/lib/calls.js.map +1 -1
- package/lib/cli.js +4 -8
- package/lib/cli.js.map +1 -1
- package/lib/commands.d.ts +1 -0
- package/lib/commands.d.ts.map +1 -1
- package/lib/commands.js +1 -0
- package/lib/commands.js.map +1 -1
- package/lib/completion.d.ts +4 -4
- package/lib/completion.d.ts.map +1 -1
- package/lib/completion.js +22 -22
- package/lib/completion.js.map +1 -1
- package/lib/configuration-manager.d.ts +12 -4
- package/lib/configuration-manager.d.ts.map +1 -1
- package/lib/configuration-manager.js +18 -5
- package/lib/configuration-manager.js.map +1 -1
- package/lib/diagnostic-queue.d.ts +1 -2
- package/lib/diagnostic-queue.d.ts.map +1 -1
- package/lib/diagnostic-queue.js.map +1 -1
- package/lib/document-symbol.d.ts +1 -1
- package/lib/document-symbol.d.ts.map +1 -1
- package/lib/document-symbol.js +2 -2
- package/lib/document-symbol.js.map +1 -1
- package/lib/document.d.ts +4 -1
- package/lib/document.d.ts.map +1 -1
- package/lib/document.js +9 -0
- package/lib/document.js.map +1 -1
- package/lib/features/fix-all.d.ts.map +1 -1
- package/lib/features/fix-all.js +8 -6
- package/lib/features/fix-all.js.map +1 -1
- package/lib/features/inlay-hints.d.ts.map +1 -1
- package/lib/features/inlay-hints.js +2 -1
- package/lib/features/inlay-hints.js.map +1 -1
- package/lib/features/source-definition.js +2 -1
- package/lib/features/source-definition.js.map +1 -1
- package/lib/hover.d.ts +3 -2
- package/lib/hover.d.ts.map +1 -1
- package/lib/hover.js +13 -15
- package/lib/hover.js.map +1 -1
- package/lib/lsp-connection.d.ts +2 -2
- package/lib/lsp-connection.d.ts.map +1 -1
- package/lib/lsp-connection.js +3 -2
- package/lib/lsp-connection.js.map +1 -1
- package/lib/lsp-protocol.inlayHints.proposed.d.ts +5 -5
- package/lib/lsp-protocol.inlayHints.proposed.d.ts.map +1 -1
- package/lib/lsp-server.d.ts +9 -5
- package/lib/lsp-server.d.ts.map +1 -1
- package/lib/lsp-server.js +121 -92
- package/lib/lsp-server.js.map +1 -1
- package/lib/lsp-server.spec.js +4 -4
- package/lib/lsp-server.spec.js.map +1 -1
- package/lib/organize-imports.d.ts +1 -1
- package/lib/organize-imports.d.ts.map +1 -1
- package/lib/organize-imports.js.map +1 -1
- package/lib/organize-imports.spec.js.map +1 -1
- package/lib/protocol-translation.d.ts +1 -10
- package/lib/protocol-translation.d.ts.map +1 -1
- package/lib/protocol-translation.js +4 -80
- package/lib/protocol-translation.js.map +1 -1
- package/lib/quickfix.d.ts +1 -1
- package/lib/quickfix.d.ts.map +1 -1
- package/lib/quickfix.js.map +1 -1
- package/lib/refactor.d.ts +1 -2
- package/lib/refactor.d.ts.map +1 -1
- package/lib/refactor.js.map +1 -1
- package/lib/test-utils.js +1 -1
- package/lib/test-utils.js.map +1 -1
- package/lib/ts-protocol.d.ts +43 -15
- package/lib/ts-protocol.d.ts.map +1 -1
- package/lib/ts-protocol.js +50 -13
- package/lib/ts-protocol.js.map +1 -1
- package/lib/tsServer/callbackMap.d.ts +1 -1
- package/lib/tsServer/callbackMap.d.ts.map +1 -1
- package/lib/tsServer/callbackMap.js.map +1 -1
- package/lib/tsServer/requestQueue.d.ts +1 -1
- package/lib/tsServer/requestQueue.d.ts.map +1 -1
- package/lib/tsServer/requests.d.ts +4 -3
- package/lib/tsServer/requests.d.ts.map +1 -1
- package/lib/tsServer/requests.js +2 -0
- package/lib/tsServer/requests.js.map +1 -1
- package/lib/tsServer/server.d.ts +9 -4
- package/lib/tsServer/server.d.ts.map +1 -1
- package/lib/tsServer/server.js +7 -0
- package/lib/tsServer/server.js.map +1 -1
- package/lib/tsServer/serverError.d.ts +1 -1
- package/lib/tsServer/serverError.d.ts.map +1 -1
- package/lib/tsServer/serverError.js +4 -4
- package/lib/tsServer/serverError.js.map +1 -1
- package/lib/tsServer/serverProcess.d.ts.map +1 -1
- package/lib/tsServer/serverProcess.js +8 -1
- package/lib/tsServer/serverProcess.js.map +1 -1
- package/lib/tsServer/tracer.d.ts +2 -2
- package/lib/tsServer/tracer.d.ts.map +1 -1
- package/lib/tsServer/versionProvider.d.ts +3 -7
- package/lib/tsServer/versionProvider.d.ts.map +1 -1
- package/lib/tsServer/versionProvider.js +19 -21
- package/lib/tsServer/versionProvider.js.map +1 -1
- package/lib/tsp-client.d.ts +2 -2
- package/lib/tsp-client.d.ts.map +1 -1
- package/lib/tsp-client.js +18 -13
- package/lib/tsp-client.js.map +1 -1
- package/lib/tsp-client.spec.js +12 -10
- package/lib/tsp-client.spec.js.map +1 -1
- package/lib/utils/MarkdownString.d.ts +15 -0
- package/lib/utils/MarkdownString.d.ts.map +1 -0
- package/lib/utils/MarkdownString.js +45 -0
- package/lib/utils/MarkdownString.js.map +1 -0
- package/lib/utils/SnippetString.js +4 -4
- package/lib/utils/SnippetString.js.map +1 -1
- package/lib/utils/api.d.ts +2 -0
- package/lib/utils/api.d.ts.map +1 -1
- package/lib/utils/api.js +17 -15
- package/lib/utils/api.js.map +1 -1
- package/lib/utils/configuration.d.ts +2 -1
- package/lib/utils/configuration.d.ts.map +1 -1
- package/lib/utils/configuration.js +4 -1
- package/lib/utils/configuration.js.map +1 -1
- package/lib/utils/logger.d.ts +1 -1
- package/lib/utils/logger.d.ts.map +1 -1
- package/lib/utils/previewer.d.ts +15 -0
- package/lib/utils/previewer.d.ts.map +1 -0
- package/lib/utils/previewer.js +185 -0
- package/lib/utils/previewer.js.map +1 -0
- package/lib/utils/previewer.spec.d.ts +2 -0
- package/lib/utils/previewer.spec.d.ts.map +1 -0
- package/lib/utils/previewer.spec.js +123 -0
- package/lib/utils/previewer.spec.js.map +1 -0
- package/lib/utils/tsconfig.d.ts +4 -0
- package/lib/utils/tsconfig.d.ts.map +1 -0
- package/lib/utils/tsconfig.js +41 -0
- package/lib/utils/tsconfig.js.map +1 -0
- package/lib/utils/typeConverters.d.ts +1 -1
- package/lib/utils/typeConverters.d.ts.map +1 -1
- package/package.json +16 -16
- package/lib/tsp-command-types.d.ts +0 -188
- package/lib/tsp-command-types.d.ts.map +0 -1
- package/lib/tsp-command-types.js +0 -99
- package/lib/tsp-command-types.js.map +0 -1
package/lib/lsp-server.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as lsp from 'vscode-languageserver';
|
|
2
2
|
import * as lspcalls from './lsp-protocol.calls.proposed.js';
|
|
3
3
|
import * as lspinlayHints from './lsp-protocol.inlayHints.proposed.js';
|
|
4
|
-
import tsp from 'typescript/lib/protocol.d.js';
|
|
5
4
|
import { LspDocument } from './document.js';
|
|
6
|
-
import { TypeScriptInitializeParams } from './ts-protocol.js';
|
|
5
|
+
import { tsp, TypeScriptInitializeParams } from './ts-protocol.js';
|
|
7
6
|
import { TypeScriptServiceConfiguration } from './utils/configuration.js';
|
|
8
7
|
export declare class LspServer {
|
|
9
8
|
private options;
|
|
@@ -20,9 +19,10 @@ export declare class LspServer {
|
|
|
20
19
|
closeAll(): void;
|
|
21
20
|
shutdown(): void;
|
|
22
21
|
private get tspClient();
|
|
23
|
-
private findTypescriptVersion;
|
|
24
22
|
initialize(params: TypeScriptInitializeParams): Promise<lsp.InitializeResult>;
|
|
23
|
+
private findTypescriptVersion;
|
|
25
24
|
private getLogDirectoryPath;
|
|
25
|
+
private setCompilerOptionsForInferredProjects;
|
|
26
26
|
didChangeConfiguration(params: lsp.DidChangeConfigurationParams): void;
|
|
27
27
|
protected diagnosticsTokenSource: lsp.CancellationTokenSource | undefined;
|
|
28
28
|
protected interuptDiagnostics<R>(f: () => R): R;
|
|
@@ -48,7 +48,11 @@ export declare class LspServer {
|
|
|
48
48
|
completionResolve(item: lsp.CompletionItem): Promise<lsp.CompletionItem>;
|
|
49
49
|
hover(params: lsp.TextDocumentPositionParams): Promise<lsp.Hover>;
|
|
50
50
|
protected getQuickInfo(file: string, position: lsp.Position): Promise<tsp.QuickInfoResponse | undefined>;
|
|
51
|
-
|
|
51
|
+
prepareRename(params: lsp.PrepareRenameParams): Promise<lsp.Range | {
|
|
52
|
+
range: lsp.Range;
|
|
53
|
+
placeholder: string;
|
|
54
|
+
} | undefined | null>;
|
|
55
|
+
rename(params: lsp.RenameParams): Promise<lsp.WorkspaceEdit | undefined | null>;
|
|
52
56
|
references(params: lsp.ReferenceParams): Promise<lsp.Location[]>;
|
|
53
57
|
documentFormatting(params: lsp.DocumentFormattingParams): Promise<lsp.TextEdit[]>;
|
|
54
58
|
documentRangeFormatting(params: lsp.DocumentRangeFormattingParams): Promise<lsp.TextEdit[]>;
|
|
@@ -71,7 +75,7 @@ export declare class LspServer {
|
|
|
71
75
|
foldingRanges(params: lsp.FoldingRangeParams): Promise<lsp.FoldingRange[] | undefined>;
|
|
72
76
|
protected asFoldingRange(span: tsp.OutliningSpan, document: LspDocument): lsp.FoldingRange | undefined;
|
|
73
77
|
protected asFoldingRangeKind(span: tsp.OutliningSpan): lsp.FoldingRangeKind | undefined;
|
|
74
|
-
protected onTsEvent(event:
|
|
78
|
+
protected onTsEvent(event: tsp.Event): Promise<void>;
|
|
75
79
|
calls(params: lspcalls.CallsParams): Promise<lspcalls.CallsResult>;
|
|
76
80
|
inlayHints(params: lsp.InlayHintParams): Promise<lsp.InlayHint[] | undefined>;
|
|
77
81
|
inlayHintsLegacy(params: lspinlayHints.InlayHintsParams): Promise<lspinlayHints.InlayHintsResult>;
|
package/lib/lsp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lsp-server.d.ts","sourceRoot":"","sources":["../src/lsp-server.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,GAAG,MAAM,uBAAuB,CAAC;AAC7C,OAAO,KAAK,QAAQ,MAAM,kCAAkC,CAAC;AAC7D,OAAO,KAAK,aAAa,MAAM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efixingLogger } from './utils/logger.js';
|
|
15
15
|
import { TspClient } from './tsp-client.js';
|
|
16
16
|
import { DiagnosticEventQueue } from './diagnostic-queue.js';
|
|
17
|
-
import { toDocumentHighlight,
|
|
17
|
+
import { toDocumentHighlight, uriToPath, toSymbolKind, toLocation, pathToUri, toTextEdit, normalizePath } from './protocol-translation.js';
|
|
18
18
|
import { LspDocuments } from './document.js';
|
|
19
19
|
import { asCompletionItem, asResolvedCompletionItem, getCompletionTriggerCharacter } from './completion.js';
|
|
20
20
|
import { asSignatureHelp, toTsTriggerReason } from './hover.js';
|
|
@@ -22,17 +22,23 @@ import { Commands } from './commands.js';
|
|
|
22
22
|
import { provideQuickFix } from './quickfix.js';
|
|
23
23
|
import { provideRefactors } from './refactor.js';
|
|
24
24
|
import { provideOrganizeImports } from './organize-imports.js';
|
|
25
|
+
import { tsp } from './ts-protocol.js';
|
|
25
26
|
import { collectDocumentSymbols, collectSymbolInformation } from './document-symbol.js';
|
|
26
27
|
import { computeCallers, computeCallees } from './calls.js';
|
|
28
|
+
import { TsServerLogLevel } from './utils/configuration.js';
|
|
27
29
|
import { TypeScriptAutoFixProvider } from './features/fix-all.js';
|
|
28
30
|
import { TypeScriptInlayHintsProvider } from './features/inlay-hints.js';
|
|
29
31
|
import { SourceDefinitionCommand } from './features/source-definition.js';
|
|
30
32
|
import { LogDirectoryProvider } from './tsServer/logDirectoryProvider.js';
|
|
31
33
|
import { Trace } from './tsServer/tracer.js';
|
|
32
34
|
import { TypeScriptVersionProvider } from './tsServer/versionProvider.js';
|
|
35
|
+
import { MarkdownString } from './utils/MarkdownString.js';
|
|
36
|
+
import * as Previewer from './utils/previewer.js';
|
|
37
|
+
import { getInferredProjectCompilerOptions } from './utils/tsconfig.js';
|
|
33
38
|
import { Position, Range } from './utils/typeConverters.js';
|
|
34
39
|
import { CodeActionKind } from './utils/types.js';
|
|
35
40
|
import { ConfigurationManager } from './configuration-manager.js';
|
|
41
|
+
var CommandTypes = tsp.CommandTypes;
|
|
36
42
|
export class LspServer {
|
|
37
43
|
constructor(options) {
|
|
38
44
|
this.options = options;
|
|
@@ -65,30 +71,6 @@ export class LspServer {
|
|
|
65
71
|
}
|
|
66
72
|
return this._tspClient;
|
|
67
73
|
}
|
|
68
|
-
findTypescriptVersion() {
|
|
69
|
-
const typescriptVersionProvider = new TypeScriptVersionProvider(this.options, this.logger);
|
|
70
|
-
// User-provided tsserver path.
|
|
71
|
-
const userSettingVersion = typescriptVersionProvider.getUserSettingVersion();
|
|
72
|
-
if (userSettingVersion) {
|
|
73
|
-
if (userSettingVersion.isValid) {
|
|
74
|
-
return userSettingVersion;
|
|
75
|
-
}
|
|
76
|
-
this.logger.logIgnoringVerbosity(LogLevel.Warning, `Typescript specified through --tsserver-path ignored due to invalid path "${userSettingVersion.path}"`);
|
|
77
|
-
}
|
|
78
|
-
// Workspace version.
|
|
79
|
-
if (this.workspaceRoot) {
|
|
80
|
-
const workspaceVersion = typescriptVersionProvider.getWorkspaceVersion([this.workspaceRoot]);
|
|
81
|
-
if (workspaceVersion) {
|
|
82
|
-
return workspaceVersion;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
// Bundled version
|
|
86
|
-
const bundledVersion = typescriptVersionProvider.bundledVersion();
|
|
87
|
-
if (bundledVersion && bundledVersion.isValid) {
|
|
88
|
-
return bundledVersion;
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
74
|
async initialize(params) {
|
|
93
75
|
this.logger.log('initialize', params);
|
|
94
76
|
if (this._tspClient) {
|
|
@@ -108,12 +90,12 @@ export class LspServer {
|
|
|
108
90
|
globalPlugins.push(plugin.name);
|
|
109
91
|
pluginProbeLocations.push(plugin.location);
|
|
110
92
|
}
|
|
111
|
-
const typescriptVersion = this.findTypescriptVersion();
|
|
93
|
+
const typescriptVersion = this.findTypescriptVersion(tsserver?.path);
|
|
112
94
|
if (typescriptVersion) {
|
|
113
95
|
this.logger.logIgnoringVerbosity(LogLevel.Info, `Using Typescript version (${typescriptVersion.source}) ${typescriptVersion.versionString} from path "${typescriptVersion.tsServerPath}"`);
|
|
114
96
|
}
|
|
115
97
|
else {
|
|
116
|
-
throw Error('Could not find a valid TypeScript installation. Please ensure that the "typescript" dependency is installed in the workspace or that a valid
|
|
98
|
+
throw Error('Could not find a valid TypeScript installation. Please ensure that the "typescript" dependency is installed in the workspace or that a valid `tsserver.path` is specified. Exiting.');
|
|
117
99
|
}
|
|
118
100
|
this.configurationManager.mergeTsPreferences(userInitializationOptions.preferences || {});
|
|
119
101
|
// Setup supported features.
|
|
@@ -141,12 +123,13 @@ export class LspServer {
|
|
|
141
123
|
useLabelDetailsInCompletionEntries: this.features.completionLabelDetails,
|
|
142
124
|
});
|
|
143
125
|
this.diagnosticQueue = new DiagnosticEventQueue(diagnostics => this.options.lspClient.publishDiagnostics(diagnostics), this.documents, this.features, this.logger);
|
|
126
|
+
const tsserverLogVerbosity = tsserver?.logVerbosity && TsServerLogLevel.fromString(tsserver?.logVerbosity);
|
|
144
127
|
this._tspClient = new TspClient({
|
|
145
128
|
lspClient: this.options.lspClient,
|
|
146
129
|
trace: Trace.fromString(tsserver?.trace || 'off'),
|
|
147
130
|
typescriptVersion,
|
|
148
131
|
logDirectoryProvider: new LogDirectoryProvider(this.getLogDirectoryPath(userInitializationOptions)),
|
|
149
|
-
logVerbosity: this.options.tsserverLogVerbosity,
|
|
132
|
+
logVerbosity: tsserverLogVerbosity ?? this.options.tsserverLogVerbosity,
|
|
150
133
|
disableAutomaticTypingAcquisition,
|
|
151
134
|
maxTsServerMemory,
|
|
152
135
|
npmLocation,
|
|
@@ -156,10 +139,10 @@ export class LspServer {
|
|
|
156
139
|
logger: this.options.logger,
|
|
157
140
|
onEvent: this.onTsEvent.bind(this),
|
|
158
141
|
onExit: (exitCode, signal) => {
|
|
142
|
+
this.shutdown();
|
|
159
143
|
if (exitCode) {
|
|
160
|
-
|
|
144
|
+
throw new Error(`tsserver process has exited (exit code: ${exitCode}, signal: ${signal}). Stopping the server.`);
|
|
161
145
|
}
|
|
162
|
-
this.shutdown();
|
|
163
146
|
},
|
|
164
147
|
});
|
|
165
148
|
const started = this.tspClient.start();
|
|
@@ -173,19 +156,9 @@ export class LspServer {
|
|
|
173
156
|
process.exit();
|
|
174
157
|
});
|
|
175
158
|
this.typeScriptAutoFixProvider = new TypeScriptAutoFixProvider(this.tspClient);
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
options: {
|
|
180
|
-
module: "CommonJS" /* tsp.ModuleKind.CommonJS */,
|
|
181
|
-
target: "ES2016" /* tsp.ScriptTarget.ES2016 */,
|
|
182
|
-
jsx: "Preserve" /* tsp.JsxEmit.Preserve */,
|
|
183
|
-
allowJs: true,
|
|
184
|
-
allowSyntheticDefaultImports: true,
|
|
185
|
-
allowNonTsExtensions: true,
|
|
186
|
-
},
|
|
187
|
-
}),
|
|
188
|
-
]);
|
|
159
|
+
this.configurationManager.setAndConfigureTspClient(this.workspaceRoot, this._tspClient, hostInfo);
|
|
160
|
+
this.setCompilerOptionsForInferredProjects();
|
|
161
|
+
const prepareSupport = textDocument?.rename?.prepareSupport && this.tspClient.apiVersion.gte(API.v310);
|
|
189
162
|
const initializeResult = {
|
|
190
163
|
capabilities: {
|
|
191
164
|
textDocumentSync: lsp.TextDocumentSyncKind.Incremental,
|
|
@@ -210,6 +183,7 @@ export class LspServer {
|
|
|
210
183
|
Commands.APPLY_WORKSPACE_EDIT,
|
|
211
184
|
Commands.APPLY_CODE_ACTION,
|
|
212
185
|
Commands.APPLY_REFACTORING,
|
|
186
|
+
Commands.CONFIGURE_PLUGIN,
|
|
213
187
|
Commands.ORGANIZE_IMPORTS,
|
|
214
188
|
Commands.APPLY_RENAME_FILE,
|
|
215
189
|
Commands.SOURCE_DEFINITION,
|
|
@@ -217,7 +191,7 @@ export class LspServer {
|
|
|
217
191
|
},
|
|
218
192
|
hoverProvider: true,
|
|
219
193
|
inlayHintProvider: true,
|
|
220
|
-
renameProvider: true,
|
|
194
|
+
renameProvider: prepareSupport ? { prepareProvider: true } : true,
|
|
221
195
|
referencesProvider: true,
|
|
222
196
|
signatureHelpProvider: {
|
|
223
197
|
triggerCharacters: ['(', ',', '<'],
|
|
@@ -264,6 +238,30 @@ export class LspServer {
|
|
|
264
238
|
this.logger.log('onInitialize result', initializeResult);
|
|
265
239
|
return initializeResult;
|
|
266
240
|
}
|
|
241
|
+
findTypescriptVersion(userTsserverPath) {
|
|
242
|
+
const typescriptVersionProvider = new TypeScriptVersionProvider(userTsserverPath || this.options.tsserverPath, this.logger);
|
|
243
|
+
// User-provided tsserver path.
|
|
244
|
+
const userSettingVersion = typescriptVersionProvider.getUserSettingVersion();
|
|
245
|
+
if (userSettingVersion) {
|
|
246
|
+
if (userSettingVersion.isValid) {
|
|
247
|
+
return userSettingVersion;
|
|
248
|
+
}
|
|
249
|
+
this.logger.logIgnoringVerbosity(LogLevel.Warning, `Typescript specified through user setting ignored due to invalid path "${userSettingVersion.path}"`);
|
|
250
|
+
}
|
|
251
|
+
// Workspace version.
|
|
252
|
+
if (this.workspaceRoot) {
|
|
253
|
+
const workspaceVersion = typescriptVersionProvider.getWorkspaceVersion([this.workspaceRoot]);
|
|
254
|
+
if (workspaceVersion) {
|
|
255
|
+
return workspaceVersion;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Bundled version
|
|
259
|
+
const bundledVersion = typescriptVersionProvider.bundledVersion();
|
|
260
|
+
if (bundledVersion && bundledVersion.isValid) {
|
|
261
|
+
return bundledVersion;
|
|
262
|
+
}
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
267
265
|
getLogDirectoryPath(initializationOptions) {
|
|
268
266
|
if (initializationOptions.tsserver?.logDirectory) {
|
|
269
267
|
return initializationOptions.tsserver.logDirectory;
|
|
@@ -273,8 +271,21 @@ export class LspServer {
|
|
|
273
271
|
}
|
|
274
272
|
return undefined;
|
|
275
273
|
}
|
|
274
|
+
setCompilerOptionsForInferredProjects() {
|
|
275
|
+
const args = {
|
|
276
|
+
options: {
|
|
277
|
+
...getInferredProjectCompilerOptions(this.configurationManager.workspaceConfiguration.implicitProjectConfiguration),
|
|
278
|
+
allowJs: true,
|
|
279
|
+
allowNonTsExtensions: true,
|
|
280
|
+
allowSyntheticDefaultImports: true,
|
|
281
|
+
resolveJsonModule: true,
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
this.tspClient.executeWithoutWaitingForResponse(CommandTypes.CompilerOptionsForInferredProjects, args);
|
|
285
|
+
}
|
|
276
286
|
didChangeConfiguration(params) {
|
|
277
287
|
this.configurationManager.setWorkspaceConfiguration(params.settings || {});
|
|
288
|
+
this.setCompilerOptionsForInferredProjects();
|
|
278
289
|
const ignoredDiagnosticCodes = this.configurationManager.workspaceConfiguration.diagnostics?.ignoredCodes || [];
|
|
279
290
|
this.diagnosticQueue?.updateIgnoredDiagnosticCodes(ignoredDiagnosticCodes);
|
|
280
291
|
}
|
|
@@ -318,7 +329,7 @@ export class LspServer {
|
|
|
318
329
|
return;
|
|
319
330
|
}
|
|
320
331
|
if (this.documents.open(file, params.textDocument)) {
|
|
321
|
-
this.tspClient.notify(
|
|
332
|
+
this.tspClient.notify(CommandTypes.Open, {
|
|
322
333
|
file,
|
|
323
334
|
fileContent: params.textDocument.text,
|
|
324
335
|
scriptKindName: this.getScriptKindName(params.textDocument.languageId),
|
|
@@ -360,7 +371,7 @@ export class LspServer {
|
|
|
360
371
|
if (!document) {
|
|
361
372
|
return;
|
|
362
373
|
}
|
|
363
|
-
this.tspClient.notify(
|
|
374
|
+
this.tspClient.notify(CommandTypes.Close, { file });
|
|
364
375
|
// We won't be updating diagnostics anymore for that file, so clear them
|
|
365
376
|
// so we don't leave stale ones.
|
|
366
377
|
this.options.lspClient.publishDiagnostics({
|
|
@@ -401,7 +412,7 @@ export class LspServer {
|
|
|
401
412
|
endLine = endPos.line + 1;
|
|
402
413
|
endOffset = endPos.character + 1;
|
|
403
414
|
}
|
|
404
|
-
this.tspClient.notify(
|
|
415
|
+
this.tspClient.notify(CommandTypes.Change, {
|
|
405
416
|
file,
|
|
406
417
|
line,
|
|
407
418
|
offset,
|
|
@@ -418,19 +429,19 @@ export class LspServer {
|
|
|
418
429
|
}
|
|
419
430
|
async definition(params) {
|
|
420
431
|
return this.getDefinition({
|
|
421
|
-
type: this.features.definitionLinkSupport ?
|
|
432
|
+
type: this.features.definitionLinkSupport ? CommandTypes.DefinitionAndBoundSpan : CommandTypes.Definition,
|
|
422
433
|
params,
|
|
423
434
|
});
|
|
424
435
|
}
|
|
425
436
|
async implementation(params) {
|
|
426
437
|
return this.getSymbolLocations({
|
|
427
|
-
type:
|
|
438
|
+
type: CommandTypes.Implementation,
|
|
428
439
|
params,
|
|
429
440
|
});
|
|
430
441
|
}
|
|
431
442
|
async typeDefinition(params) {
|
|
432
443
|
return this.getSymbolLocations({
|
|
433
|
-
type:
|
|
444
|
+
type: CommandTypes.TypeDefinition,
|
|
434
445
|
params,
|
|
435
446
|
});
|
|
436
447
|
}
|
|
@@ -440,7 +451,7 @@ export class LspServer {
|
|
|
440
451
|
if (!file) {
|
|
441
452
|
return undefined;
|
|
442
453
|
}
|
|
443
|
-
if (type ===
|
|
454
|
+
if (type === CommandTypes.DefinitionAndBoundSpan) {
|
|
444
455
|
const args = Position.toFileLocationRequestArgs(file, params.position);
|
|
445
456
|
const response = await this.tspClient.request(type, args);
|
|
446
457
|
if (response.type !== 'response' || !response.body) {
|
|
@@ -462,7 +473,7 @@ export class LspServer {
|
|
|
462
473
|
};
|
|
463
474
|
});
|
|
464
475
|
}
|
|
465
|
-
return this.getSymbolLocations({ type:
|
|
476
|
+
return this.getSymbolLocations({ type: CommandTypes.Definition, params });
|
|
466
477
|
}
|
|
467
478
|
async getSymbolLocations({ type, params }) {
|
|
468
479
|
const file = uriToPath(params.textDocument.uri);
|
|
@@ -483,7 +494,7 @@ export class LspServer {
|
|
|
483
494
|
if (!file) {
|
|
484
495
|
return [];
|
|
485
496
|
}
|
|
486
|
-
const response = await this.tspClient.request(
|
|
497
|
+
const response = await this.tspClient.request(CommandTypes.NavTree, {
|
|
487
498
|
file,
|
|
488
499
|
});
|
|
489
500
|
const tree = response.body;
|
|
@@ -524,7 +535,7 @@ export class LspServer {
|
|
|
524
535
|
}
|
|
525
536
|
const completionOptions = this.configurationManager.workspaceConfiguration.completions || {};
|
|
526
537
|
try {
|
|
527
|
-
const result = await this.interuptDiagnostics(() => this.tspClient.request(
|
|
538
|
+
const result = await this.interuptDiagnostics(() => this.tspClient.request(CommandTypes.CompletionInfo, {
|
|
528
539
|
file,
|
|
529
540
|
line: params.position.line + 1,
|
|
530
541
|
offset: params.position.character + 1,
|
|
@@ -541,7 +552,7 @@ export class LspServer {
|
|
|
541
552
|
if (entry.kind === 'warning') {
|
|
542
553
|
continue;
|
|
543
554
|
}
|
|
544
|
-
const completion = asCompletionItem(entry, optionalReplacementSpan, file, params.position, document, completionOptions, this.features);
|
|
555
|
+
const completion = asCompletionItem(entry, optionalReplacementSpan, file, params.position, document, this.documents, completionOptions, this.features);
|
|
545
556
|
if (!completion) {
|
|
546
557
|
continue;
|
|
547
558
|
}
|
|
@@ -562,12 +573,12 @@ export class LspServer {
|
|
|
562
573
|
async completionResolve(item) {
|
|
563
574
|
this.logger.log('completion/resolve', item);
|
|
564
575
|
await this.configurationManager.configureGloballyFromDocument(item.data.file);
|
|
565
|
-
const { body } = await this.interuptDiagnostics(() => this.tspClient.request(
|
|
576
|
+
const { body } = await this.interuptDiagnostics(() => this.tspClient.request(CommandTypes.CompletionDetails, item.data));
|
|
566
577
|
const details = body && body.length && body[0];
|
|
567
578
|
if (!details) {
|
|
568
579
|
return item;
|
|
569
580
|
}
|
|
570
|
-
return asResolvedCompletionItem(item, details, this.tspClient, this.configurationManager.workspaceConfiguration.completions || {}, this.features);
|
|
581
|
+
return asResolvedCompletionItem(item, details, this.tspClient, this.documents, this.configurationManager.workspaceConfiguration.completions || {}, this.features);
|
|
571
582
|
}
|
|
572
583
|
async hover(params) {
|
|
573
584
|
const file = uriToPath(params.textDocument.uri);
|
|
@@ -579,22 +590,20 @@ export class LspServer {
|
|
|
579
590
|
if (!result || !result.body) {
|
|
580
591
|
return { contents: [] };
|
|
581
592
|
}
|
|
582
|
-
const
|
|
583
|
-
const
|
|
584
|
-
if (
|
|
585
|
-
contents.
|
|
593
|
+
const contents = new MarkdownString();
|
|
594
|
+
const { displayString, documentation, tags } = result.body;
|
|
595
|
+
if (displayString) {
|
|
596
|
+
contents.appendCodeblock('typescript', displayString);
|
|
586
597
|
}
|
|
587
|
-
|
|
588
|
-
const documentation = asPlainText(result.body.documentation);
|
|
589
|
-
contents.push(documentation + (tags ? '\n\n' + tags : ''));
|
|
598
|
+
Previewer.addMarkdownDocumentation(contents, documentation, tags, this.documents);
|
|
590
599
|
return {
|
|
591
|
-
contents,
|
|
592
|
-
range,
|
|
600
|
+
contents: contents.toMarkupContent(),
|
|
601
|
+
range: Range.fromTextSpan(result.body),
|
|
593
602
|
};
|
|
594
603
|
}
|
|
595
604
|
async getQuickInfo(file, position) {
|
|
596
605
|
try {
|
|
597
|
-
return await this.tspClient.request(
|
|
606
|
+
return await this.tspClient.request(CommandTypes.Quickinfo, {
|
|
598
607
|
file,
|
|
599
608
|
line: position.line + 1,
|
|
600
609
|
offset: position.character + 1,
|
|
@@ -604,19 +613,30 @@ export class LspServer {
|
|
|
604
613
|
return undefined;
|
|
605
614
|
}
|
|
606
615
|
}
|
|
616
|
+
async prepareRename(params) {
|
|
617
|
+
const file = uriToPath(params.textDocument.uri);
|
|
618
|
+
if (!file) {
|
|
619
|
+
return null;
|
|
620
|
+
}
|
|
621
|
+
const result = await this.tspClient.request(CommandTypes.Rename, Position.toFileLocationRequestArgs(file, params.position));
|
|
622
|
+
const renameInfo = result.body?.info;
|
|
623
|
+
if (!renameInfo) {
|
|
624
|
+
return null;
|
|
625
|
+
}
|
|
626
|
+
if (!renameInfo.canRename) {
|
|
627
|
+
throw new Error(renameInfo.localizedErrorMessage);
|
|
628
|
+
}
|
|
629
|
+
return Range.fromTextSpan(renameInfo.triggerSpan);
|
|
630
|
+
}
|
|
607
631
|
async rename(params) {
|
|
608
632
|
const file = uriToPath(params.textDocument.uri);
|
|
609
633
|
this.logger.log('onRename', params, file);
|
|
610
634
|
if (!file) {
|
|
611
|
-
return
|
|
635
|
+
return null;
|
|
612
636
|
}
|
|
613
|
-
const result = await this.tspClient.request(
|
|
614
|
-
file,
|
|
615
|
-
line: params.position.line + 1,
|
|
616
|
-
offset: params.position.character + 1,
|
|
617
|
-
});
|
|
637
|
+
const result = await this.tspClient.request(CommandTypes.Rename, Position.toFileLocationRequestArgs(file, params.position));
|
|
618
638
|
if (!result.body || !result.body.info.canRename || result.body.locs.length === 0) {
|
|
619
|
-
return
|
|
639
|
+
return null;
|
|
620
640
|
}
|
|
621
641
|
const workspaceEdit = {};
|
|
622
642
|
result.body.locs
|
|
@@ -644,7 +664,7 @@ export class LspServer {
|
|
|
644
664
|
if (!file) {
|
|
645
665
|
return [];
|
|
646
666
|
}
|
|
647
|
-
const result = await this.tspClient.request(
|
|
667
|
+
const result = await this.tspClient.request(CommandTypes.References, {
|
|
648
668
|
file,
|
|
649
669
|
line: params.position.line + 1,
|
|
650
670
|
offset: params.position.character + 1,
|
|
@@ -664,7 +684,7 @@ export class LspServer {
|
|
|
664
684
|
}
|
|
665
685
|
const formatOptions = params.options;
|
|
666
686
|
await this.configurationManager.configureGloballyFromDocument(file, formatOptions);
|
|
667
|
-
const response = await this.tspClient.request(
|
|
687
|
+
const response = await this.tspClient.request(CommandTypes.Format, {
|
|
668
688
|
file,
|
|
669
689
|
line: 1,
|
|
670
690
|
offset: 1,
|
|
@@ -685,7 +705,7 @@ export class LspServer {
|
|
|
685
705
|
}
|
|
686
706
|
const formatOptions = params.options;
|
|
687
707
|
await this.configurationManager.configureGloballyFromDocument(file, formatOptions);
|
|
688
|
-
const response = await this.tspClient.request(
|
|
708
|
+
const response = await this.tspClient.request(CommandTypes.Format, {
|
|
689
709
|
file,
|
|
690
710
|
line: params.range.start.line + 1,
|
|
691
711
|
offset: params.range.start.character + 1,
|
|
@@ -708,12 +728,12 @@ export class LspServer {
|
|
|
708
728
|
if (!response || !response.body) {
|
|
709
729
|
return undefined;
|
|
710
730
|
}
|
|
711
|
-
return asSignatureHelp(response.body, params.context);
|
|
731
|
+
return asSignatureHelp(response.body, params.context, this.documents);
|
|
712
732
|
}
|
|
713
733
|
async getSignatureHelp(file, params) {
|
|
714
734
|
try {
|
|
715
735
|
const { position, context } = params;
|
|
716
|
-
return await this.tspClient.request(
|
|
736
|
+
return await this.tspClient.request(CommandTypes.SignatureHelp, {
|
|
717
737
|
file,
|
|
718
738
|
line: position.line + 1,
|
|
719
739
|
offset: position.character + 1,
|
|
@@ -772,7 +792,7 @@ export class LspServer {
|
|
|
772
792
|
errorCodes,
|
|
773
793
|
};
|
|
774
794
|
try {
|
|
775
|
-
return await this.tspClient.request(
|
|
795
|
+
return await this.tspClient.request(CommandTypes.GetCodeFixes, args);
|
|
776
796
|
}
|
|
777
797
|
catch (err) {
|
|
778
798
|
return undefined;
|
|
@@ -785,7 +805,7 @@ export class LspServer {
|
|
|
785
805
|
kind: context.only?.length === 1 ? context.only[0] : undefined,
|
|
786
806
|
};
|
|
787
807
|
try {
|
|
788
|
-
return await this.tspClient.request(
|
|
808
|
+
return await this.tspClient.request(CommandTypes.GetApplicableRefactors, args);
|
|
789
809
|
}
|
|
790
810
|
catch (err) {
|
|
791
811
|
return undefined;
|
|
@@ -794,7 +814,7 @@ export class LspServer {
|
|
|
794
814
|
async getOrganizeImports(args) {
|
|
795
815
|
try {
|
|
796
816
|
await this.configurationManager.configureGloballyFromDocument(args.scope.args.file);
|
|
797
|
-
return await this.tspClient.request(
|
|
817
|
+
return await this.tspClient.request(CommandTypes.OrganizeImports, args);
|
|
798
818
|
}
|
|
799
819
|
catch (err) {
|
|
800
820
|
return undefined;
|
|
@@ -813,13 +833,13 @@ export class LspServer {
|
|
|
813
833
|
}
|
|
814
834
|
if (codeAction.commands && codeAction.commands.length) {
|
|
815
835
|
for (const command of codeAction.commands) {
|
|
816
|
-
await this.tspClient.request(
|
|
836
|
+
await this.tspClient.request(CommandTypes.ApplyCodeActionCommand, { command });
|
|
817
837
|
}
|
|
818
838
|
}
|
|
819
839
|
}
|
|
820
840
|
else if (arg.command === Commands.APPLY_REFACTORING && arg.arguments) {
|
|
821
841
|
const args = arg.arguments[0];
|
|
822
|
-
const { body } = await this.tspClient.request(
|
|
842
|
+
const { body } = await this.tspClient.request(CommandTypes.GetEditsForRefactor, args);
|
|
823
843
|
if (!body || !body.edits.length) {
|
|
824
844
|
return;
|
|
825
845
|
}
|
|
@@ -839,11 +859,20 @@ export class LspServer {
|
|
|
839
859
|
});
|
|
840
860
|
}
|
|
841
861
|
}
|
|
862
|
+
else if (arg.command === Commands.CONFIGURE_PLUGIN && arg.arguments) {
|
|
863
|
+
const [pluginName, configuration] = arg.arguments;
|
|
864
|
+
if (this.tspClient?.apiVersion.gte(API.v314)) {
|
|
865
|
+
this.tspClient.executeWithoutWaitingForResponse(CommandTypes.ConfigurePlugin, {
|
|
866
|
+
configuration,
|
|
867
|
+
pluginName,
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
}
|
|
842
871
|
else if (arg.command === Commands.ORGANIZE_IMPORTS && arg.arguments) {
|
|
843
872
|
const file = arg.arguments[0];
|
|
844
873
|
const additionalArguments = arg.arguments[1] || {};
|
|
845
874
|
await this.configurationManager.configureGloballyFromDocument(file);
|
|
846
|
-
const { body } = await this.tspClient.request(
|
|
875
|
+
const { body } = await this.tspClient.request(CommandTypes.OrganizeImports, {
|
|
847
876
|
scope: {
|
|
848
877
|
type: 'file',
|
|
849
878
|
args: { file },
|
|
@@ -862,7 +891,7 @@ export class LspServer {
|
|
|
862
891
|
await this.applyFileCodeEdits(codeAction.changes);
|
|
863
892
|
if (codeAction.commands && codeAction.commands.length) {
|
|
864
893
|
for (const command of codeAction.commands) {
|
|
865
|
-
await this.tspClient.request(
|
|
894
|
+
await this.tspClient.request(CommandTypes.ApplyCodeActionCommand, { command });
|
|
866
895
|
}
|
|
867
896
|
}
|
|
868
897
|
// Execute only the first code action.
|
|
@@ -902,7 +931,7 @@ export class LspServer {
|
|
|
902
931
|
return [];
|
|
903
932
|
}
|
|
904
933
|
try {
|
|
905
|
-
const { body } = await this.tspClient.request(
|
|
934
|
+
const { body } = await this.tspClient.request(CommandTypes.GetEditsForFileRename, {
|
|
906
935
|
oldFilePath,
|
|
907
936
|
newFilePath,
|
|
908
937
|
});
|
|
@@ -920,7 +949,7 @@ export class LspServer {
|
|
|
920
949
|
}
|
|
921
950
|
let response;
|
|
922
951
|
try {
|
|
923
|
-
response = await this.tspClient.request(
|
|
952
|
+
response = await this.tspClient.request(CommandTypes.DocumentHighlights, {
|
|
924
953
|
file,
|
|
925
954
|
line: arg.position.line + 1,
|
|
926
955
|
offset: arg.position.character + 1,
|
|
@@ -948,7 +977,7 @@ export class LspServer {
|
|
|
948
977
|
return this.documents.files[0] || this.workspaceRoot;
|
|
949
978
|
}
|
|
950
979
|
async workspaceSymbol(params) {
|
|
951
|
-
const result = await this.tspClient.request(
|
|
980
|
+
const result = await this.tspClient.request(CommandTypes.Navto, {
|
|
952
981
|
file: this.lastFileOrDummy(),
|
|
953
982
|
searchValue: params.query,
|
|
954
983
|
});
|
|
@@ -982,7 +1011,7 @@ export class LspServer {
|
|
|
982
1011
|
if (!document) {
|
|
983
1012
|
throw new Error("The document should be opened for foldingRanges', file: " + file);
|
|
984
1013
|
}
|
|
985
|
-
const { body } = await this.tspClient.request(
|
|
1014
|
+
const { body } = await this.tspClient.request(CommandTypes.GetOutliningSpans, { file });
|
|
986
1015
|
if (!body) {
|
|
987
1016
|
return undefined;
|
|
988
1017
|
}
|
|
@@ -1071,7 +1100,7 @@ export class LspServer {
|
|
|
1071
1100
|
character: 0,
|
|
1072
1101
|
});
|
|
1073
1102
|
try {
|
|
1074
|
-
const result = await this.tspClient.request(
|
|
1103
|
+
const result = await this.tspClient.request(CommandTypes.ProvideInlayHints, {
|
|
1075
1104
|
file,
|
|
1076
1105
|
start: start,
|
|
1077
1106
|
length: end - start,
|
|
@@ -1128,7 +1157,7 @@ export class LspServer {
|
|
|
1128
1157
|
}
|
|
1129
1158
|
async getSemanticTokens(doc, file, startOffset, endOffset) {
|
|
1130
1159
|
try {
|
|
1131
|
-
const result = await this.tspClient.request(
|
|
1160
|
+
const result = await this.tspClient.request(CommandTypes.EncodedSemanticClassificationsFull, {
|
|
1132
1161
|
file,
|
|
1133
1162
|
start: startOffset,
|
|
1134
1163
|
length: endOffset - startOffset,
|