-
Notifications
You must be signed in to change notification settings - Fork 37
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
Conversation
8271547
to
9edd7ba
Compare
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.
Looks good to me! Left some comments but nothing major. Some linter failures to deal with though.
bundle/regal/ast/rule_heads.rego
Outdated
# 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 { |
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'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 { |
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.
oh, the test is even named as such :)
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.
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")}}}, |
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.
Interesting. I would have thought regal.parse_module
included this
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.
This isn't actually needed for this test, so I have just dropped it and used the parse.
0b51831
to
2420d42
Compare
This allows for more reliable highlighting in the UI.
Correct rule_heads name, tidy rego test Signed-off-by: Charlie Egan <charlie@styra.com>
2420d42
to
38ed19c
Compare
Signed-off-by: Charlie Egan <charlie@styra.com>
* 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>
This allows for more reliable highlighting in the UI.
Needs: open-policy-agent/vscode-opa#241