This commit is contained in:
Matt Bierner 2018-12-07 13:00:18 -08:00
parent 98f236872e
commit a4bed89652

View file

@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import * as Proto from '../protocol';
import { ITypeScriptServiceClient } from '../typescriptService';
import * as typeConverters from '../utils/typeConverters';
@ -20,20 +19,18 @@ export default class TypeScriptDefinitionProviderBase {
position: vscode.Position,
token: vscode.CancellationToken
): Promise<vscode.Location[] | undefined> {
const filepath = this.client.toOpenedFilePath(document);
if (!filepath) {
const file = this.client.toOpenedFilePath(document);
if (!file) {
return undefined;
}
const args = typeConverters.Position.toFileLocationRequestArgs(filepath, position);
const args = typeConverters.Position.toFileLocationRequestArgs(file, position);
const response = await this.client.execute(definitionType, args, token);
if (response.type !== 'response') {
if (response.type !== 'response' || !response.body) {
return undefined;
}
const locations: Proto.FileSpan[] = (response && response.body) || [];
return locations.map(location =>
return response.body.map(location =>
typeConverters.Location.fromTextSpan(this.client.toResource(location.file), location));
}
}