-
Notifications
You must be signed in to change notification settings - Fork 27.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Definition link API #52230
Definition link API #52230
Conversation
src/vs/vscode.proposed.d.ts
Outdated
origin?: Range; | ||
uri: Uri; | ||
range: Range; | ||
selectionRange?: Range; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using these field names make DefinitionLink
compatible with Location
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sneaky... we could also make origin
mandatory and use the position
of the request as origin
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or did you plan that as non-breaking API evolution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Main reason for making it optional is that I think it makes sense for implementers:
- When
origin
is provided: always use this value. - When
origin
is undefined: use the word range at the request position as theorigin
If origin
is not optional, I believe many extensions would have to compute the word range themselves
@mjbvz Please fix merge conflicts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nits - feel free to merge
} | ||
return undefined; | ||
}); | ||
} | ||
|
||
private static convertDefinitionLink(position: IPosition, value: vscode.Location | vscode.DefinitionLink): modes.DefinitionLink { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
position
is unused. move to extHostTypeConverter?
src/vs/vscode.proposed.d.ts
Outdated
origin?: Range; | ||
uri: Uri; | ||
range: Range; | ||
selectionRange?: Range; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One a second thought I wonder if defaulting DefinitionLink.range
to Location.range
is the right thing... It feels more like the selectionRange
cos that's how it is currently used. It's also OK to leave this out of this PR but something we should likely do when we optimise how the preview hover is computed.
let wordRange: Range; | ||
if (result.origin) { | ||
const range = result.origin; | ||
wordRange = new Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi - Range.lift
does the job
Add a new `DefinitionLink` type. This type allows definition providers to return additional metadata about a definition, such as the defining span. Hook up this new provider for typescript This PR replaces microsoft#48001
- Use lift - Remove unused param
@jrieken Thanks. I've made the suggested changes and will merge this into proposed I may be confusing |
Yeah, |
Add a new
DefinitionLink
type. This type allows definition providers to return additional metadata about a definition, such as the defining span.Hook up this new provider for typescript
This PR replaces #48001
Fixes #10037