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

Add source action to explore compiler stages #1096

Merged
merged 1 commit into from
Sep 11, 2024
Merged

Conversation

anderseknert
Copy link
Member

@anderseknert anderseknert commented Sep 10, 2024

This PR integrates @srenatus excellent opa-explorer with Regal, where we now start a web server along with the language server to host the explorer.

Users will now see a "Source Action" in the context menu of any given Rego file, and when clicked will bring them to the explorer view for that file.

Since a command for opening web pages client side is AFAIK only available in VS Code, this feature is sadly limited to that editor currently. Perhaps we can figure out some way to have the link show in Zed, similar to what we did for linter docs?

For now, we're only loading a single file into the explorer for compilation. We could perhaps consider loading all modules in the workspace too, as otherwise compilation will always fail on e.g. unknown functions from outside the policy.

@anderseknert anderseknert changed the title Add source action for to explore compiler stages Add source action to explore compiler stages Sep 10, 2024
Copy link
Member

@charlieegan3 charlieegan3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really fun feature!

Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, this is a perfect new home for that code <3

README.md Show resolved Hide resolved
internal/web/server.go Outdated Show resolved Hide resolved
Copy link
Member

@srenatus srenatus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments

internal/web/server.go Show resolved Hide resolved
cache *cache.Cache
workspaceURI string
client clients.Identifier
baseURL string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this could be racy: we're setting the baseURL from a goroutine, but we retrieve it from GetBaseURL. It's probably unlikely to be a problem in real world usage, since it involves user interactions, though. OTOH adding a mutex should be simple enough.

internal/web/assets/screenshot.png Outdated Show resolved Hide resolved
This PR integrates @srenatus excellent
[opa-explorer](https://github.com/srenatus/opa-explorer/)
with Regal, where we now start a web server along with the
language server to host the explorer.

Users will now see a "Source Action" in the context menu
of any given Rego file, and when clicked will bring them
to the explorer view for that file.

Since a command for opening web pages client side is AFAIK
only available in VS Code, this feature is sadly limited
to that editor currently. Perhaps we can figure out some
way to have the link show in Zed, similar to what we did
for linter docs?

For now, we're only loading a single file into the explorer
for compilation. We could perhaps consider loading all
modules in the workspace too, as otherwise compilation will
always fail on e.g. unknown functions from outside the policy.

Signed-off-by: Anders Eknert <anders@styra.com>
@anderseknert anderseknert merged commit da50d28 into main Sep 11, 2024
4 checks passed
@anderseknert anderseknert deleted the opa-explorer branch September 11, 2024 08:51
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
This PR integrates @srenatus excellent
[opa-explorer](https://github.com/srenatus/opa-explorer/)
with Regal, where we now start a web server along with the
language server to host the explorer.

Users will now see a "Source Action" in the context menu
of any given Rego file, and when clicked will bring them
to the explorer view for that file.

Since a command for opening web pages client side is AFAIK
only available in VS Code, this feature is sadly limited
to that editor currently. Perhaps we can figure out some
way to have the link show in Zed, similar to what we did
for linter docs?

For now, we're only loading a single file into the explorer
for compilation. We could perhaps consider loading all
modules in the workspace too, as otherwise compilation will
always fail on e.g. unknown functions from outside the policy.

Signed-off-by: Anders Eknert <anders@styra.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants