Skip to content

Commit

Permalink
* Compatibility: upgrade to 2023.3 / 233.2 version (#166)
Browse files Browse the repository at this point in the history
* Grammar: multidimensional array rule heads considered valid
* Grammar: else expressions no longer consider ':=' invalid
* tests: bump OPA version to v0.61.0

Signed-off-by: Shane Poage <[email protected]>
  • Loading branch information
spoage committed Feb 2, 2024
1 parent 2db8a03 commit 63ddf24
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:

- name: Download OPA
run: |
OPA_VERSION=v0.59.0
OPA_VERSION=v0.61.0
mkdir -p /tmp/opa_bin
curl -L -o /tmp/opa_bin/opa https://github.com/open-policy-agent/opa/releases/download/$OPA_VERSION/opa_linux_amd64
chmod +x /tmp/opa_bin/opa
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ idea {
plugins {
idea
kotlin("jvm") version "1.9.21"
id("org.jetbrains.intellij") version "1.16.1"
id("org.jetbrains.grammarkit") version "2022.3.1"
id("org.jetbrains.intellij") version "1.17.0"
id("org.jetbrains.grammarkit") version "2022.3.2"
}

allprojects {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ kotlin.code.style=official
baseIDE=idea

# if you change the version of ide, also change psiViewerPluginVersion accordingly (cf https://plugins.jetbrains.com/plugin/227-psiviewer/versions)
ideaVersion=IC-2023.2
pycharmCommunityVersion=PC-2023.2
psiViewerPluginVersion=232.2
ideaVersion=IC-2023.3
pycharmCommunityVersion=PC-2023.3
psiViewerPluginVersion=233.2

# see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for more information
sinceBuild=232
untilBuild=233.*
sinceBuild=233
untilBuild=241.*

# these two variables will be overwritten by the release process (i.e. the GitHub action) thanks to the env variables:
# - ORG_GRADLE_PROJECT_publishToken
Expand Down
4 changes: 2 additions & 2 deletions src/main/grammar/Rego.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ module ::= package (import| rule)*
package ::= "package" ref
import ::= "import" ref ( "as" var )?
rule ::= "default"? rule-head rule-body*
rule-head ::= var ( "(" rule-args? ")" )? ("[" term "]" )? ( ( ":=" | "=" ) expr )?
rule-head ::= var ( "(" rule-args? ")" )? ("[" term "]" )* ( ( ":=" | "=" ) expr )?
rule-args ::= term ( "," term )*
rule-body ::= else-expr | query-block
else-expr ::= else "=" expr query-block? | else "="? query-block
else-expr ::= else (':=' | '=') expr query-block? | else (':=' | '=')? query-block
query-block ::= "{" query "}"
query ::= ( literal |';' )+
literal ::= ( some-decl | literal-expr | "not" literal-expr ) with-modifier*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RegoHighlighter : SyntaxHighlighterBase() {

override fun getTokenHighlights(tokenType: IElementType): Array<TextAttributesKey> = pack(tokenToColorMap[tokenType])

val tokenToColorMap: Map<IElementType, TextAttributesKey> = HashMap()
val tokenToColorMap: MutableMap<IElementType, TextAttributesKey> = HashMap()

init {
fillMap(tokenToColorMap, LINE_COMMENT.textAttributesKey, RegoTypes.COMMENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ check_only_equal_querry_for_else = true {
true
}

check_else_with_colon_assignment_op {
input.x < input.y
} else := true {
input.y < input.x
} else := false

# issue 84
check_empty_query_else = true {
input.x < input.y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ b := a1 | a2 | a3
c := a1 & a2 | a3 - b

d := 1+2 - array.concat(array1, array2)[2]
e := array.concat(array1, array2)[0] + array.concat(array1, array2)[1]
e := array.concat(array1, array2)[0] + array.concat(array1, array2)[1]

# multidimensional array
f["first"]["second"] := "some value"

0 comments on commit 63ddf24

Please sign in to comment.