Skip to content
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

Adds GroovyParser (#662) #663

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-yaml</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-groovy</artifactId>
</dependency>
<dependency>
<groupId>org.openrewrite</groupId>
<artifactId>rewrite-python</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/openrewrite/maven/ResourceParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.openrewrite.ExecutionContext;
import org.openrewrite.InMemoryExecutionContext;
import org.openrewrite.SourceFile;
import org.openrewrite.groovy.GroovyParser;
import org.openrewrite.hcl.HclParser;
import org.openrewrite.java.JavaParser;
import org.openrewrite.json.JsonParser;
Expand Down Expand Up @@ -156,6 +157,9 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
KotlinParser kotlinParser = KotlinParser.builder().build();
List<Path> kotlinPaths = new ArrayList<>();

GroovyParser groovyParser = GroovyParser.builder().build();
List<Path> groovyPaths = new ArrayList<>();

HclParser hclParser = HclParser.builder().build();
List<Path> hclPaths = new ArrayList<>();

Expand All @@ -182,6 +186,8 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
pythonPaths.add(path);
} else if (kotlinParser.accept(path)) {
kotlinPaths.add(path);
} else if (groovyParser.accept(path)) {
groovyPaths.add(path);
} else if (hclParser.accept(path)) {
hclPaths.add(path);
} else if (quarkParser.accept(path)) {
Expand Down Expand Up @@ -229,6 +235,11 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
alreadyParsed.addAll(kotlinPaths);
}

if (!groovyPaths.isEmpty()) {
sourceFiles = Stream.concat(sourceFiles, (Stream<S>) groovyParser.parse(groovyPaths, baseDir, ctx));
alreadyParsed.addAll(groovyPaths);
}

if (!hclPaths.isEmpty()) {
sourceFiles = Stream.concat(sourceFiles, (Stream<S>) hclParser.parse(hclPaths, baseDir, ctx));
alreadyParsed.addAll(hclPaths);
Expand Down