-
Notifications
You must be signed in to change notification settings - Fork 366
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
adding gradle and groovy auto detection #4561
Conversation
Adding autodetect for groovy and gradle, adding 2 seperact auto detection classes to allow for repositories to have different styles for gradle build files and groovy tests. These auto detection classes utilize the java auto detection
rewrite-gradle/src/test/java/org/openrewrite/gradle/style/AutodetectTest.java
Show resolved
Hide resolved
rewrite-gradle/src/test/java/org/openrewrite/gradle/style/AutodetectTest.java
Outdated
Show resolved
Hide resolved
rewrite-groovy/src/test/java/org/openrewrite/groovy/style/AutodetectTest.java
Show resolved
Hide resolved
rewrite-groovy/src/test/java/org/openrewrite/groovy/style/AutodetectTest.java
Outdated
Show resolved
Hide resolved
…detectTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…detectTest.java Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
); | ||
var detector = Autodetect.detector(); | ||
parse.forEach(detector::sample); | ||
var styles = detector.build(); |
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.
Is the type of styles
org.openrewrite.java.style.Autodetect
or org.openrewrite.gradle.style.Autodetect
? 🙂
Might influence whether your other PRs work as intended or not.
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.
you are 100% correct, I have pushed an update which will fix this issue
@@ -65,8 +65,7 @@ public static class Detector { | |||
private final FindLineFormatJavaVisitor findLineFormat = new FindLineFormatJavaVisitor(); | |||
|
|||
public void sample(SourceFile cu) { | |||
// only sample Java sources (extending languages need their own auto-detection) | |||
if (cu instanceof J.CompilationUnit) { | |||
if (cu instanceof JavaSourceFile) { |
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.
@sambsnyd It seems to me that we shouldn't have to change this now. What am I missing?
Updating the autodetect class to pick up styles from the gradle files
Previously no style would be detected for groovy files, this is because we weren't parsing the block element within lambdas in method declarations