Skip to content
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

Implement "go to definition" #645

Closed
anderseknert opened this issue Apr 11, 2024 · 0 comments · Fixed by #664
Closed

Implement "go to definition" #645

anderseknert opened this issue Apr 11, 2024 · 0 comments · Fixed by #664

Comments

@anderseknert
Copy link
Member

As described in the spec https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_definition

OPA already provides some means to do this, and the VS Code extension currently calls the "opa oracle" command. A first implementation would likely use the same API from Regal.

As this too is covered by the VS Code client already, we'll want to guard this similarly to how @charlieegan3 implemented it for formatting open-policy-agent/vscode-opa#148

@anderseknert anderseknert self-assigned this Apr 19, 2024
anderseknert added a commit that referenced this issue Apr 20, 2024
This was rather simple, as this was already handled by the
`opa oracle find-definition` command. The API for that was however
internal, so I've copied the single file handling that from OPA.

PR marked WIP as two things warrants some discussion:
* Similarly to formatting, this LSP feature seems to conflict with
  client side implementations, and you'll see duplicate "definitions"
  in VS Code when this is enabled both in the client and from the LSP
  server. We should probably make this conditional on Regal in VS Code.
* The `GetAllModules` function that exists on the cache does not seem
  to take into account files that have been marked as ignored via
  `.regal/config.yaml`. This lead to an annoying situation when this
  was used in the Regal repo, as some files we've ignored did not
  compile, and that caused go to definition to fail.

Fixes #645
anderseknert added a commit that referenced this issue Apr 20, 2024
This was rather simple, as this was already handled by the
`opa oracle find-definition` command. The API for that was however
internal, so I've copied the single file handling that from OPA.

PR marked WIP as two things warrants some discussion:
* Similarly to formatting, this LSP feature seems to conflict with
  client side implementations, and you'll see duplicate "definitions"
  in VS Code when this is enabled both in the client and from the LSP
  server. We should probably make this conditional on Regal in VS Code.
* The `GetAllModules` function that exists on the cache does not seem
  to take into account files that have been marked as ignored via
  `.regal/config.yaml`. This lead to an annoying situation when this
  was used in the Regal repo, as some files we've ignored did not
  compile, and that caused go to definition to fail.

Fixes #645
anderseknert added a commit that referenced this issue Apr 22, 2024
This was rather simple, as this was already handled by the
`opa oracle find-definition` command. The API for that was however
internal, so I've copied the single file handling that from OPA.

PR marked WIP as two things warrants some discussion:
* Similarly to formatting, this LSP feature seems to conflict with
  client side implementations, and you'll see duplicate "definitions"
  in VS Code when this is enabled both in the client and from the LSP
  server. We should probably make this conditional on Regal in VS Code.
* The `GetAllModules` function that exists on the cache does not seem
  to take into account files that have been marked as ignored via
  `.regal/config.yaml`. This lead to an annoying situation when this
  was used in the Regal repo, as some files we've ignored did not
  compile, and that caused go to definition to fail.

Fixes #645
anderseknert added a commit that referenced this issue Apr 22, 2024
This was rather simple, as this was already handled by the
`opa oracle find-definition` command. The API for that was however
internal, so I've copied the single file handling that from OPA.

PR marked WIP as two things warrants some discussion:
* Similarly to formatting, this LSP feature seems to conflict with
  client side implementations, and you'll see duplicate "definitions"
  in VS Code when this is enabled both in the client and from the LSP
  server. We should probably make this conditional on Regal in VS Code.
* The `GetAllModules` function that exists on the cache does not seem
  to take into account files that have been marked as ignored via
  `.regal/config.yaml`. This lead to an annoying situation when this
  was used in the Regal repo, as some files we've ignored did not
  compile, and that caused go to definition to fail.

Fixes #645
anderseknert added a commit that referenced this issue Apr 22, 2024
This was rather simple, as this was already handled by the
`opa oracle find-definition` command. The API for that was however
internal, so I've copied the single file handling that from OPA.

PR marked WIP as two things warrants some discussion:
* Similarly to formatting, this LSP feature seems to conflict with
  client side implementations, and you'll see duplicate "definitions"
  in VS Code when this is enabled both in the client and from the LSP
  server. We should probably make this conditional on Regal in VS Code.
* The `GetAllModules` function that exists on the cache does not seem
  to take into account files that have been marked as ignored via
  `.regal/config.yaml`. This lead to an annoying situation when this
  was used in the Regal repo, as some files we've ignored did not
  compile, and that caused go to definition to fail.

Fixes #645
anderseknert added a commit that referenced this issue Apr 22, 2024
This was rather simple, as this was already handled by the
`opa oracle find-definition` command. The API for that was however
internal, so I've copied the single file handling that from OPA.

PR marked WIP as two things warrants some discussion:
* Similarly to formatting, this LSP feature seems to conflict with
  client side implementations, and you'll see duplicate "definitions"
  in VS Code when this is enabled both in the client and from the LSP
  server. We should probably make this conditional on Regal in VS Code.
* The `GetAllModules` function that exists on the cache does not seem
  to take into account files that have been marked as ignored via
  `.regal/config.yaml`. This lead to an annoying situation when this
  was used in the Regal repo, as some files we've ignored did not
  compile, and that caused go to definition to fail.

Fixes #645
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant