提交 cc167f63 编写于 作者: M Matt Bierner

Gate some ts code lenses in the providers themselves #24548

上级 505b0644
......@@ -5,7 +5,7 @@
'use strict';
import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionContext, Command, commands, Uri, workspace, WorkspaceEdit, TextEdit, FormattingOptions, window } from 'vscode';
import { CodeActionProvider, TextDocument, Range, CancellationToken, CodeActionContext, Command, commands, Uri, workspace, WorkspaceEdit, TextEdit, FormattingOptions, window, ProviderResult } from 'vscode';
import * as Proto from '../protocol';
import { ITypescriptServiceClient } from '../typescriptService';
......@@ -43,10 +43,14 @@ export default class TypeScriptCodeActionProvider implements CodeActionProvider
commands.registerCommand(this.commandId, this.onCodeAction, this);
}
public provideCodeActions(document: TextDocument, range: Range, context: CodeActionContext, token: CancellationToken): Thenable<Command[]> {
public provideCodeActions(document: TextDocument, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<Command[]> {
if (!this.client.apiVersion.has213Features()) {
return [];
}
const file = this.client.normalizePath(document.uri);
if (!file) {
return Promise.resolve<Command[]>([]);
return [];
}
let formattingOptions: FormattingOptions | undefined = undefined;
for (const editor of window.visibleTextEditors) {
......
......@@ -22,6 +22,13 @@ export default class TypeScriptReferencesCodeLensProvider extends TypeScriptBase
super(client, 'referencesCodeLens.enabled');
}
provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
if (!this.client.apiVersion.has206Features()) {
return Promise.resolve([]);
}
return super.provideCodeLenses(document, token);
}
resolveCodeLens(inputCodeLens: CodeLens, token: CancellationToken): Promise<CodeLens> {
const codeLens = inputCodeLens as ReferencesCodeLens;
const args: Proto.FileLocationRequestArgs = {
......
......@@ -224,19 +224,15 @@ class LanguageProvider {
this.disposables.push(languages.registerSignatureHelpProvider(selector, new SignatureHelpProvider(client), '(', ','));
this.disposables.push(languages.registerRenameProvider(selector, new RenameProvider(client)));
if (client.apiVersion.has206Features()) {
this.referenceCodeLensProvider = new ReferenceCodeLensProvider(client);
this.referenceCodeLensProvider.updateConfiguration();
this.disposables.push(languages.registerCodeLensProvider(selector, this.referenceCodeLensProvider));
this.referenceCodeLensProvider = new ReferenceCodeLensProvider(client);
this.referenceCodeLensProvider.updateConfiguration();
this.disposables.push(languages.registerCodeLensProvider(selector, this.referenceCodeLensProvider));
this.implementationCodeLensProvider = new ImplementationCodeLensProvider(client);
this.implementationCodeLensProvider.updateConfiguration();
this.disposables.push(languages.registerCodeLensProvider(selector, this.implementationCodeLensProvider));
}
this.implementationCodeLensProvider = new ImplementationCodeLensProvider(client);
this.implementationCodeLensProvider.updateConfiguration();
this.disposables.push(languages.registerCodeLensProvider(selector, this.implementationCodeLensProvider));
if (client.apiVersion.has213Features()) {
this.disposables.push(languages.registerCodeActionsProvider(selector, new CodeActionProvider(client, this.description.id)));
}
this.disposables.push(languages.registerCodeActionsProvider(selector, new CodeActionProvider(client, this.description.id)));
if (client.apiVersion.has220Features()) {
this.disposables.push(languages.registerImplementationProvider(selector, new ImplementationProvider(client)));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册