diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-02-28 11:36:25 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-02-28 11:36:25 +0000 |
| commit | 4e4f98062c07afdeef14d4031ca69668649e5873 (patch) | |
| tree | 6415aea98dc33ab50c490fbb3f812412f6dad8f0 /src/main/java/org/zwobble/couscous/frontends | |
| parent | c588167505864bece6cbb2dc68814f7d967d9a6a (diff) | |
Introduce InterfaceNode
Diffstat (limited to 'src/main/java/org/zwobble/couscous/frontends')
| -rw-r--r-- | src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java | 11 | ||||
| -rw-r--r-- | src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java | 4 |
2 files changed, 6 insertions, 9 deletions
diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java index 5ab2678..51df264 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaFrontend.java @@ -1,10 +1,7 @@ package org.zwobble.couscous.frontends.java; import com.google.common.collect.Multimaps; -import org.zwobble.couscous.ast.ClassNode; -import org.zwobble.couscous.ast.Node; -import org.zwobble.couscous.ast.VariableDeclaration; -import org.zwobble.couscous.ast.VariableNode; +import org.zwobble.couscous.ast.*; import java.io.IOException; import java.nio.file.Files; @@ -20,8 +17,8 @@ import static org.zwobble.couscous.util.ExtraLists.flatMap; import static org.zwobble.couscous.util.ExtraStreams.toStream; public class JavaFrontend { - public List<ClassNode> readSourceDirectory(List<Path> sourcePaths, Path directoryPath) throws IOException { - List<ClassNode> classNodes = flatMap( + public List<TypeNode> readSourceDirectory(List<Path> sourcePaths, Path directoryPath) throws IOException { + List<TypeNode> classNodes = flatMap( findJavaFiles(directoryPath), javaFile -> JavaReader.readClassFromFile(sourcePaths, javaFile)); ensureDeclarationsAreUnique(classNodes); @@ -33,7 +30,7 @@ public class JavaFrontend { .filter(path -> path.toFile().isFile() && path.toString().endsWith(".java")); } - private void ensureDeclarationsAreUnique(List<ClassNode> classNodes) { + private void ensureDeclarationsAreUnique(List<TypeNode> classNodes) { List<VariableDeclaration> declarations = eagerFlatMap(classNodes, this::findDeclarations); Multimaps.index(declarations, VariableDeclaration::getId) .asMap() diff --git a/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java b/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java index c85b4fb..6e7f3fc 100644 --- a/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java +++ b/src/main/java/org/zwobble/couscous/frontends/java/JavaReader.java @@ -37,7 +37,7 @@ import static org.zwobble.couscous.frontends.java.JavaTypes.*; import static org.zwobble.couscous.util.ExtraLists.*; public class JavaReader { - public static List<ClassNode> readClassFromFile(List<Path> sourcePaths, Path sourcePath) throws IOException { + public static List<TypeNode> readClassFromFile(List<Path> sourcePaths, Path sourcePath) throws IOException { CompilationUnit ast = new JavaParser().parseCompilationUnit(sourcePaths, sourcePath); ImmutableList<IProblem> errors = ImmutableList.copyOf(filter(asList(ast.getProblems()), problem -> problem.isError())); @@ -58,7 +58,7 @@ public class JavaReader { error.getMessage(); } - private final ImmutableList.Builder<ClassNode> classes; + private final ImmutableList.Builder<TypeNode> classes; private int anonymousClassCount = 0; private JavaReader() { |
