Add support for running ast-grep rules#14808
Conversation
|
This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR. |
|
I'll allow myself to merge this in without a review. I don't think anybody will object (but if anybody does, shout out). |
|
Thank you @dweiss, I was just slow, was testing it out. I set the property locally, and added rule and test: ---
# yaml-language-server: $schema=https://raw.githubusercontent.com/ast-grep/ast-grep/refs/heads/main/schemas/rule.json
id: java-syntax
language: java
rule:
kind: ERROR
message: Syntax Error
severity: error---
# test the parser is working
id: java-syntax
valid:
- x = 1;I introduced bogus syntax to a file and the build then failed quickly on the problem (it is just an example and we probably should not do this): |
|
Sorry for not waiting, I wanted to proceed. Please open a new issue with those rules. This one looks very neat indeed - we can even force it to run prior to javac. It's a C based parser for java... remember jikes? :) |
This is a spinoff from #14804. We should allow running
ast-grep(https://ast-grep.github.io/) rules as validation checks. This is a powerful tool (and fast).For now, running ast-grep is optional. You need to install ast-grep manually and then set this build option to the location (or name) of of the ast-grep tool:
I recommend doing this in
build-options.local.properties. If this build option is not set, the entire task (ruleset) is ignored and a warning is printed.I've set up CI jobs on github to install and run ast-grep as part of pull requests and on-commit checks for now.