Package org.plumelib.javacparse
Class JavacParse
java.lang.Object
org.plumelib.javacparse.JavacParse
This class contains static methods
parseJavaFile(java.lang.String)
and parseJavaCode(java.lang.String)
that parse
Java code into a JCCompilationUnit.
Internally, this class calls the javac parser from the JDK.
-
Method Summary
Modifier and TypeMethodDescriptionstatic JavacParseResult
parseJavaCode
(String javaCode) Parse a Java file's contents.static JavacParseResult
parseJavaFile
(String filename) Parse a Java file.static JavacParseResult
parseJavaFileObject
(JavaFileObject source) Parse a the contents of a JavaFileObject.
-
Method Details
-
parseJavaFile
Parse a Java file.- Parameters:
filename
- the file to parse- Returns:
- a (parsed) compilation unit, or null if there is a parse error
- Throws:
IOException
- if there is trouble reading the file
-
parseJavaCode
Parse a Java file's contents.- Parameters:
javaCode
- the contents of a Java file- Returns:
- a (parsed) compilation unit, or null if there is a parse error
-
parseJavaFileObject
Parse a the contents of a JavaFileObject. Returns null if there was a parse error (even if the javac parser could create a CompilationUnit, some of whose subcomponents are erroneous).- Parameters:
source
- a JavaFileObject- Returns:
- a compilation unit and the parse errors encountered in it
- Throws:
IOException
- if there is trouble reading the file
-