-
Notifications
You must be signed in to change notification settings - Fork 677
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
Fix "go to definition" from metadata within the same metadata file #1772
Fix "go to definition" from metadata within the same metadata file #1772
Conversation
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.
LGTM. Just minor nits.
@@ -38,9 +41,8 @@ export default class DefinitionMetadataDocumentProvider implements TextDocumentC | |||
return this._documents.get(uri.toString()).Source; | |||
} | |||
|
|||
private createUri(metadataResponse: MetadataResponse) : Uri { | |||
private createUri(sourceName:string) : Uri { |
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.
nit: space after :
this._documents.set(uri.toString(), metadataResponse); | ||
|
||
return uri; | ||
} | ||
|
||
public getExistingMetadataResponseUri(sourceName:string) : Uri { |
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.
nit: space after :
if (gotoDefinitionResponse && gotoDefinitionResponse.FileName) { | ||
|
||
// if it is part of an already used metadata file, retrieve its uri instead of going to the physical file | ||
if (gotoDefinitionResponse.FileName.startsWith("$metadata$")) { |
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.
We should add something to the OmniSharp response to indicate that the result is in metadata, rather than checking the file name. Not a blocking a issue, but I wanted to capture it.
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.
yes I agree, good point
src/omnisharp/typeConvertion.ts
Outdated
return toLocationFromUri(fileName, location); | ||
} | ||
|
||
export function toLocationFromUri(uri:vscode.Uri, location: protocol.ResourceLocation | protocol.QuickFix): vscode.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.
nit: space after :
src/features/definitionProvider.ts
Outdated
|
||
// if it is part of an already used metadata file, retrieve its uri instead of going to the physical file | ||
if (gotoDefinitionResponse.FileName.startsWith("$metadata$")) { | ||
let uri = this._definitionMetadataDocumentProvider.getExistingMetadataResponseUri(gotoDefinitionResponse.FileName); |
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.
nit: const
rather than let
Looks good! Anything else? |
No, I think this can go as is. We will do something smarter in Omnisharp in the future and then we can tweak this code to be a bit cleaner. ✨ |
Sounds great. |
At the moment we have a nice story of going from
source -> metadata
and frommetadata -> other metadata
.However, when trying to go from metadata as source file to the same metadata as source file, we get an error.
Albeit not a huge issue, it can be a little annoying. An example is below.
Given the following metadata as source file (shortened for brevity), where we position the caret at
$$
:When I invoke "go to definition" on
$$
, I should be taken back toEncoding
definition within the same metadata file. Instead I get:This PR fixes this.