Skip to content

Commit

Permalink
Adds GroovyParser (#662) (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonzn committed Nov 21, 2023
1 parent 002b3ce commit 28bd2ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
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

0 comments on commit 28bd2ba

Please sign in to comment.