public class JavaParserUtil extends Object
Constructor and Description |
---|
JavaParserUtil() |
Modifier and Type | Method and Description |
---|---|
static com.github.javaparser.ast.CompilationUnit |
parseCompilationUnit(File file)
Parses the Java code contained in the
File and returns a CompilationUnit that
represents it. |
static com.github.javaparser.ast.CompilationUnit |
parseCompilationUnit(InputStream inputStream)
Parses the Java code contained in the
InputStream and returns a CompilationUnit
that represents it. |
static com.github.javaparser.ast.CompilationUnit |
parseCompilationUnit(String javaSource)
Parses the Java code contained in the
String and returns a CompilationUnit that
represents it. |
static com.github.javaparser.ast.StubUnit |
parseStubUnit(InputStream inputStream)
Parses the stub file contained in the
InputStream and returns a StubUnit that
represents it. |
public static com.github.javaparser.ast.CompilationUnit parseCompilationUnit(InputStream inputStream)
InputStream
and returns a CompilationUnit
that represents it.
This is like StaticJavaParser.parse
, but it does not lead to memory leaks because it
creates a new instance of JavaParser each time it is invoked. Re-using StaticJavaParser
causes memory problems because it retains too much memory.
inputStream
- the Java source codecom.github.javaparser.ParseProblemException
- if the source code has parser errorspublic static com.github.javaparser.ast.CompilationUnit parseCompilationUnit(File file) throws FileNotFoundException
File
and returns a CompilationUnit
that
represents it.
This is like StaticJavaParser.parse
, but it does not lead to memory leaks because it
creates a new instance of JavaParser each time it is invoked. Re-using StaticJavaParser
causes memory problems because it retains too much memory.
file
- the Java source codecom.github.javaparser.ParseProblemException
- if the source code has parser errorsFileNotFoundException
- if the file was not foundpublic static com.github.javaparser.ast.CompilationUnit parseCompilationUnit(String javaSource)
String
and returns a CompilationUnit
that
represents it.
This is like StaticJavaParser.parse
, but it does not lead to memory leaks because it
creates a new instance of JavaParser each time it is invoked. Re-using StaticJavaParser
causes memory problems because it retains too much memory.
javaSource
- the Java source codecom.github.javaparser.ParseProblemException
- if the source code has parser errorspublic static com.github.javaparser.ast.StubUnit parseStubUnit(InputStream inputStream)
InputStream
and returns a StubUnit
that
represents it.
This is like StaticJavaParser.parse
, but it does not lead to memory leaks because it
creates a new instance of JavaParser each time it is invoked. Re-using StaticJavaParser
causes memory problems because it retains too much memory.
inputStream
- the stub filecom.github.javaparser.ParseProblemException
- if the source code has parser errors