Allow to cancel resolveMainMethod codelens command (#881)

This commit is contained in:
Jinbo Wang 2020-09-11 11:07:44 +08:00 committed by GitHub
parent e6de5b3ad6
commit e1c3d0682b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -102,7 +102,7 @@ class DebugCodeLensProvider implements vscode.CodeLensProvider {
public async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.CodeLens[]> { public async provideCodeLenses(document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.CodeLens[]> {
try { try {
const mainMethods: IMainMethod[] = await resolveMainMethod(document.uri); const mainMethods: IMainMethod[] = await resolveMainMethod(document.uri, token);
return _.flatten(mainMethods.map((method) => { return _.flatten(mainMethods.map((method) => {
return [ return [
new vscode.CodeLens(method.range, { new vscode.CodeLens(method.range, {

View File

@ -33,7 +33,11 @@ export interface ILaunchValidationResponse {
readonly proposals?: IMainClassOption[]; readonly proposals?: IMainClassOption[];
} }
export async function resolveMainMethod(uri: vscode.Uri): Promise<IMainMethod[]> { export async function resolveMainMethod(uri: vscode.Uri, token?: vscode.CancellationToken): Promise<IMainMethod[]> {
if (token) {
return <IMainMethod[]> await commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_MAINMETHOD, uri.toString(), token);
}
return <IMainMethod[]> await commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_MAINMETHOD, uri.toString()); return <IMainMethod[]> await commands.executeJavaLanguageServerCommand(commands.JAVA_RESOLVE_MAINMETHOD, uri.toString());
} }