mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Clean up definition provider
This commit is contained in:
@@ -5,16 +5,11 @@
|
|||||||
|
|
||||||
import { DefinitionProvider, TextDocument, Position, CancellationToken, Definition } from 'vscode';
|
import { DefinitionProvider, TextDocument, Position, CancellationToken, Definition } from 'vscode';
|
||||||
|
|
||||||
import { ITypescriptServiceClient } from '../typescriptService';
|
|
||||||
import DefinitionProviderBase from './definitionProviderBase';
|
import DefinitionProviderBase from './definitionProviderBase';
|
||||||
|
|
||||||
export default class TypeScriptDefinitionProvider extends DefinitionProviderBase implements DefinitionProvider {
|
export default class TypeScriptDefinitionProvider extends DefinitionProviderBase implements DefinitionProvider {
|
||||||
|
|
||||||
constructor(client: ITypescriptServiceClient) {
|
public provideDefinition(document: TextDocument, position: Position, token: CancellationToken | boolean): Promise<Definition | undefined> {
|
||||||
super(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public provideDefinition(document: TextDocument, position: Position, token: CancellationToken | boolean): Promise<Definition | null> {
|
|
||||||
return this.getSymbolLocations('definition', document, position, token);
|
return this.getSymbolLocations('definition', document, position, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,10 +18,10 @@ export default class TypeScriptDefinitionProviderBase {
|
|||||||
document: TextDocument,
|
document: TextDocument,
|
||||||
position: Position,
|
position: Position,
|
||||||
token: CancellationToken | boolean
|
token: CancellationToken | boolean
|
||||||
): Promise<Location[] | null> {
|
): Promise<Location[] | undefined> {
|
||||||
const filepath = this.client.normalizePath(document.uri);
|
const filepath = this.client.normalizePath(document.uri);
|
||||||
if (!filepath) {
|
if (!filepath) {
|
||||||
return null;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = vsPositionToTsFileLocation(filepath, position);
|
const args = vsPositionToTsFileLocation(filepath, position);
|
||||||
@@ -33,9 +33,9 @@ export default class TypeScriptDefinitionProviderBase {
|
|||||||
}
|
}
|
||||||
return locations.map(location => {
|
return locations.map(location => {
|
||||||
const resource = this.client.asUrl(location.file);
|
const resource = this.client.asUrl(location.file);
|
||||||
return !resource
|
return resource
|
||||||
? null
|
? new Location(resource, tsTextSpanToVsRange(location))
|
||||||
: new Location(resource, tsTextSpanToVsRange(location));
|
: undefined;
|
||||||
}).filter(x => x) as Location[];
|
}).filter(x => x) as Location[];
|
||||||
} catch {
|
} catch {
|
||||||
return [];
|
return [];
|
||||||
|
|||||||
@@ -5,16 +5,11 @@
|
|||||||
|
|
||||||
import { ImplementationProvider, TextDocument, Position, CancellationToken, Definition } from 'vscode';
|
import { ImplementationProvider, TextDocument, Position, CancellationToken, Definition } from 'vscode';
|
||||||
|
|
||||||
import { ITypescriptServiceClient } from '../typescriptService';
|
|
||||||
import DefinitionProviderBase from './definitionProviderBase';
|
import DefinitionProviderBase from './definitionProviderBase';
|
||||||
|
|
||||||
export default class TypeScriptImplementationProvider extends DefinitionProviderBase implements ImplementationProvider {
|
export default class TypeScriptImplementationProvider extends DefinitionProviderBase implements ImplementationProvider {
|
||||||
|
|
||||||
constructor(client: ITypescriptServiceClient) {
|
public provideImplementation(document: TextDocument, position: Position, token: CancellationToken | boolean): Promise<Definition | undefined> {
|
||||||
super(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public provideImplementation(document: TextDocument, position: Position, token: CancellationToken | boolean): Promise<Definition | null> {
|
|
||||||
return this.getSymbolLocations('implementation', document, position, token);
|
return this.getSymbolLocations('implementation', document, position, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,15 +5,11 @@
|
|||||||
|
|
||||||
import { TypeDefinitionProvider, TextDocument, Position, CancellationToken, Definition } from 'vscode';
|
import { TypeDefinitionProvider, TextDocument, Position, CancellationToken, Definition } from 'vscode';
|
||||||
|
|
||||||
import { ITypescriptServiceClient } from '../typescriptService';
|
|
||||||
import DefinitionProviderBase from './definitionProviderBase';
|
import DefinitionProviderBase from './definitionProviderBase';
|
||||||
|
|
||||||
export default class TypeScriptTypeDefinitionProvider extends DefinitionProviderBase implements TypeDefinitionProvider {
|
export default class TypeScriptTypeDefinitionProvider extends DefinitionProviderBase implements TypeDefinitionProvider {
|
||||||
constructor(client: ITypescriptServiceClient) {
|
|
||||||
super(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public provideTypeDefinition(document: TextDocument, position: Position, token: CancellationToken | boolean): Promise<Definition | null> {
|
public provideTypeDefinition(document: TextDocument, position: Position, token: CancellationToken | boolean): Promise<Definition | undefined> {
|
||||||
return this.getSymbolLocations('typeDefinition', document, position, token);
|
return this.getSymbolLocations('typeDefinition', document, position, token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user