Skip to content

Commit

Permalink
Use more explicit names for definition link type
Browse files Browse the repository at this point in the history
Part of #54101
  • Loading branch information
mjbvz committed Jul 16, 2018
1 parent 2e8414c commit eb2c1e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,11 @@ export default class TypeScriptDefinitionProvider extends DefinitionProviderBase
const span = response.body.textSpan ? typeConverters.Range.fromTextSpan(response.body.textSpan) : undefined;
return locations
.map(location => {
const loc = typeConverters.Location.fromTextSpan(this.client.toResource(location.file), location);
return {
origin: span,
...loc,
const target = typeConverters.Location.fromTextSpan(this.client.toResource(location.file), location);
return <vscode.DefinitionLink>{
originSelectionRange: span,
targetRange: target.range,
targetUri: target.uri,
};
});
} catch {
Expand Down
8 changes: 4 additions & 4 deletions src/vs/vscode.proposed.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,26 +1070,26 @@ declare module 'vscode' {
* Used as the underlined span for mouse definition hover. Defaults to the word range at
* the definition position.
*/
origin?: Range;
originSelectionRange?: Range;

/**
* The resource identifier of the definition.
*/
uri: Uri;
targetUri: Uri;

/**
* The full range of the definition.
*
* For a class definition for example, this would be the entire body of the class definition.
*/
range: Range;
targetRange: Range;

/**
* The span of the symbol definition.
*
* For a class definition, this would be the class name itself in the class definition.
*/
selectionRange?: Range;
targetSelectionRange?: Range;
}

export interface DefinitionProvider {
Expand Down
13 changes: 7 additions & 6 deletions src/vs/workbench/api/node/extHostLanguageFeatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,15 @@ class DefinitionAdapter {

private static convertDefinitionLink(value: vscode.Location | vscode.DefinitionLink): modes.DefinitionLink {
const definitionLink = <vscode.DefinitionLink>value;
const location = <vscode.Location>value;
return {
origin: definitionLink.origin
? typeConvert.Range.from(definitionLink.origin)
origin: definitionLink.originSelectionRange
? typeConvert.Range.from(definitionLink.originSelectionRange)
: undefined,
uri: value.uri,
range: typeConvert.Range.from(value.range),
selectionRange: definitionLink.selectionRange
? typeConvert.Range.from(definitionLink.selectionRange)
uri: definitionLink.targetUri ? definitionLink.targetUri : location.uri,
range: typeConvert.Range.from(definitionLink.targetRange ? definitionLink.targetRange : location.range),
selectionRange: definitionLink.targetSelectionRange
? typeConvert.Range.from(definitionLink.targetSelectionRange)
: undefined,
};
}
Expand Down

0 comments on commit eb2c1e4

Please sign in to comment.