-
Notifications
You must be signed in to change notification settings - Fork 11
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
Feat: Go to definition for uris in string content #23
Feat: Go to definition for uris in string content #23
Conversation
…re storing the symbols as they are only needed occasionally
const { workspaceFolders } = analyzer | ||
if (workspaceFolders !== undefined && workspaceFolders !== null) { | ||
for (const workspaceFolder of workspaceFolders) { | ||
const filePath = findFileInDirectory(workspaceFolder.uri.replace('file://', ''), uriAtPosition.name) |
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.
The user's workspace may contain several yocto layers and build directories which are not ignored here. Looking up the whole workspaceFolder will be inaccurate and slow. I suggest rather searching only the directory or immediate parent of the recipe file.
@@ -132,3 +156,22 @@ function createDefinitionLocationForPathInfo (path: ParsedPath): Location { | |||
|
|||
return location | |||
} | |||
|
|||
function findFileInDirectory (dir: string, fileName: string): string | null { | |||
try { |
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.
Use a library for finding files, I don't think there is added value in defining this ourselves.
Use https://code.visualstudio.com/api/references/vscode-api#workspace.findFiles
(or alternatively https://github.com/isaacs/node-glob)
}) | ||
if (foundRecipe !== undefined) { | ||
if (foundRecipe?.path !== undefined) { | ||
allSymbolsAtPosition.push({ |
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.
I'm not sure there is a need for go to definition for URIs. They are usually related only to the current file itself. Why could several recipe files be matched? Only the opened one should be suggested I think.
|
||
SRC_URI = 'file://foo.inc \ | ||
file://foo.inc' |
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.
Weird for a bitbake file to provide the same URI twice. Not sure it would be compile through bitbake.
}) | ||
if (foundRecipe !== undefined) { | ||
if (foundRecipe?.path !== undefined) { | ||
allSymbolsAtPosition.push({ |
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.
Instead of providing "Go to definition", register a https://code.visualstudio.com/api/references/vscode-api#DocumentLinkProvider
This will make ctrl+click work instead of manually selecting "go to definition".
Opened a new PR using |
Duplicate of #27 |
This PR provides
go to definition
for uris prefixed withfile://
in the string content. Example:Caveat:
Since VSCode inherently handles the URIs in the string with
ctrl + click
to provide redirection. It is difficult to triggergo to definition
with the same shortcut, thego to definition
in the normalright-click
context menu will still work.