-
Notifications
You must be signed in to change notification settings - Fork 339
Rules scripting #4887
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
Rules scripting #4887
Conversation
6ac13fc
to
3c043c2
Compare
@oss-review-toolkit/kotlin-devs, while this is still a draft, could some of you maybe confirm that this offers proper syntax hightlighting and auto-completion in IntelliJ for |
3c043c2
to
707c432
Compare
README.md
Outdated
| Kotlin script (DSL) | Evaluator | `$ORT_CONFIG_DIR/rules.kts` | Empty (n/a) | | ||
| Format | Scope | Default location | Default value | | ||
| ------ | ----- |---------------------------------| ------------- | | ||
| Kotlin script (DSL) | Evaluator | `$ORT_CONFIG_DIR/ort.rules.kts` | Empty (n/a) | |
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 have a tendency towards evaluator.rules.kts
as the default name.
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.
Fine with me, as "ort" is already part of the parent directory, and it opens the possibility to have more (non-evaluator) rules in the future.
Does not work for me. After Gradle sync I get this when opening If I apply the suggested fix it adds |
Could you additionally try to build from the command line once (I usually do this via
That's an odd suggestion... none of the examples at https://github.com/Kotlin/kotlin-script-examples has that dependency. |
9134381
to
e83f82c
Compare
Works very well for me after building it from command line. |
Same here, very nice. |
e83f82c
to
9b2506f
Compare
I'd like to move |
72f8962
to
dbe19c6
Compare
Does this solution only work within this Gradle project, or is it possible to create a minimal Gradle project that depends on the evaluator to have working completion? If it is possible I would prefer such a project and put it in the examples folder. |
It should indeed be possible to create a "rules-only" project by depending on the |
Having a dedicated extension allows to associate script configurations to that extension. Signed-off-by: Sebastian Schuberth <[email protected]>
dbe19c6
to
8e15b0f
Compare
This is to align with other default filenames that already have constants. Signed-off-by: Sebastian Schuberth <[email protected]>
Modules that want to have support in IntelliJ IDEA for ORT Kotlin scripts need to depend on this module so that the script configurations are available in the compiler's classpath. For references that helped during the implementation see [1][2][3]. [1]: https://discuss.kotlinlang.org/t/make-auto-completion-work-in-kotlin-scripts-with-context [2]: https://github.com/Kotlin/kotlin-script-examples/tree/master/jvm/basic/jvm-maven-deps [3]: https://github.com/Kotlin/KEEP/blob/master/proposals/scripting-support.md Signed-off-by: Sebastian Schuberth <[email protected]>
This adds proper syntax highlighting and auto-completion support for Rules Scripts inside IntelliJ IDEA, like for example for the evaluator/src/main/resources/rules/no_gpl.rules.kts resource. Resolves #2950. Signed-off-by: Sebastian Schuberth <[email protected]>
Even for small scripts, this can reduce compile time to about an eighth. The code has been partly taken from [1]. [1]: https://github.com/Kotlin/kotlin-script-examples/blob/852c835/jvm/simple-main-kts/simple-main-kts/src/main/kotlin/org/jetbrains/kotlin/script/examples/simpleMainKts/scriptDef.kt#L151-L161 Signed-off-by: Sebastian Schuberth <[email protected]>
8e15b0f
to
e0f282d
Compare
Please have a look at the individual commit messages for the details.