提交 63b103c6 编写于 作者: M Matt Bierner

Switch a few more TS providers to async

上级 f2c538b8
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { CodeLensProvider, CodeLens, CancellationToken, TextDocument, Range, Uri, Position, Event, EventEmitter, ProviderResult, } from 'vscode';
import { CodeLensProvider, CodeLens, CancellationToken, TextDocument, Range, Uri, Position, Event, EventEmitter } from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
......@@ -38,7 +38,7 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
}
}
provideCodeLenses(document: TextDocument, token: CancellationToken): ProviderResult<CodeLens[]> {
async provideCodeLenses(document: TextDocument, token: CancellationToken): Promise<CodeLens[]> {
if (!this.enabled) {
return [];
}
......@@ -47,7 +47,8 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
if (!filepath) {
return [];
}
return this.client.execute('navtree', { file: filepath }, token).then(response => {
try {
const response = await this.client.execute('navtree', { file: filepath }, token);
if (!response) {
return [];
}
......@@ -57,9 +58,9 @@ export abstract class TypeScriptBaseCodeLensProvider implements CodeLensProvider
tree.childItems.forEach(item => this.walkNavTree(document, item, null, referenceableSpans));
}
return referenceableSpans.map(span => new ReferencesCodeLens(document.uri, filepath, span));
}, () => {
} catch {
return [];
});
}
}
protected abstract extractSymbol(
......
......@@ -12,10 +12,10 @@ export default class TypeScriptReferenceSupport implements ReferenceProvider {
public constructor(
private client: ITypeScriptServiceClient) { }
public provideReferences(document: TextDocument, position: Position, options: { includeDeclaration: boolean }, token: CancellationToken): Promise<Location[]> {
public async provideReferences(document: TextDocument, position: Position, options: { includeDeclaration: boolean }, token: CancellationToken): Promise<Location[]> {
const filepath = this.client.normalizePath(document.uri);
if (!filepath) {
return Promise.resolve<Location[]>([]);
return [];
}
const args = vsPositionToTsFileLocation(filepath, position);
const apiVersion = this.client.apiVersion;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册