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

lsp: Workspace eval, return rule head locations #985

Merged
merged 3 commits into from
Aug 13, 2024

Conversation

charlieegan3
Copy link
Member

@charlieegan3 charlieegan3 commented Aug 13, 2024

This allows for more reliable highlighting in the UI.

Needs: open-policy-agent/vscode-opa#241

Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

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

Looks good to me! Left some comments but nothing major. Some linter failures to deal with though.

# description: |
# For a given rule head name, this rule contains a list of locations where
# there is a rule head with that name.
rule_heads[name] contains info if {
Copy link
Member

Choose a reason for hiding this comment

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

I'd probably call this rule_head_locations or something as the full rule head isn't in the set


import data.regal.ast

test_rule_head_locations if {
Copy link
Member

Choose a reason for hiding this comment

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

oh, the test is even named as such :)

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha, it was that, then is was rule_heads, and now it's back again!


result := ast.rule_heads with input as object.union(
regal.parse_module("p.rego", policy),
{"regal": {"file": {"lines": split(policy, "\n")}}},
Copy link
Member

Choose a reason for hiding this comment

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

Interesting. I would have thought regal.parse_module included this

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't actually needed for this test, so I have just dropped it and used the parse.

@charlieegan3 charlieegan3 force-pushed the rule-head-wip branch 2 times, most recently from 0b51831 to 2420d42 Compare August 13, 2024 13:05
This allows for more reliable highlighting in the UI.
Correct rule_heads name, tidy rego test

Signed-off-by: Charlie Egan <charlie@styra.com>
Signed-off-by: Charlie Egan <charlie@styra.com>
@charlieegan3 charlieegan3 merged commit c5aa188 into StyraInc:main Aug 13, 2024
3 checks passed
srenatus pushed a commit to srenatus/regal that referenced this pull request Oct 1, 2024
* lsp: Workspace eval, return rule head locations

This allows for more reliable highlighting in the UI.

* Address PR comments

Correct rule_heads name, tidy rego test

Signed-off-by: Charlie Egan <charlie@styra.com>

* lsp: Fix linter

Signed-off-by: Charlie Egan <charlie@styra.com>

---------

Signed-off-by: Charlie Egan <charlie@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.

2 participants