public class JavaParser extends Object implements Closeable
Constructor and Description |
---|
JavaParser()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
Iterable<? extends JavaFileObject> |
generate(JavaFileObject... sources)
Parses
sources into com.sun.source.tree.CompilationUnitTree units. |
Iterable<? extends JavaFileObject> |
generate(String className,
String code)
Parses
sources into com.sun.source.tree.CompilationUnitTree units. |
protected AggregatingTypeElementVisitorProcessor |
getAggregatingTypeElementVisitorProcessor()
The type element visitor processor to use.
|
protected List<Processor> |
getAnnotationProcessors()
The list of processors to use.
|
protected BeanDefinitionInjectProcessor |
getBeanDefinitionInjectProcessor()
The
BeanDefinitionInjectProcessor to use. |
JavaCompiler |
getCompiler() |
JavaFileManager |
getFileManager() |
Filer |
getFiler() |
JavacTask |
getJavacTask(JavaFileObject... sources)
gets the javac task.
|
Optional<JavacTask> |
getLastTask() |
ProcessingEnvironment |
getProcessingEnv() |
protected TypeElementVisitorProcessor |
getTypeElementVisitorProcessor()
The type element visitor processor to use.
|
Iterable<? extends Element> |
parse(JavaFileObject... sources)
Parses
sources into com.sun.source.tree.CompilationUnitTree units. |
Iterable<? extends Element> |
parseLines(String className,
String... lines)
Parses
sources into compilation units. |
Reader |
readGenerated(String filePath,
String className,
String code)
Reads the contents of a generated file as a reader.
|
public JavaCompiler getCompiler()
public JavaFileManager getFileManager()
public Filer getFiler()
public ProcessingEnvironment getProcessingEnv()
public Iterable<? extends Element> parseLines(String className, String... lines)
sources
into compilation units. This method
does not compile the sources.className
- The class namelines
- The lines to parsepublic Iterable<? extends Element> parse(JavaFileObject... sources)
sources
into com.sun.source.tree.CompilationUnitTree
units. This method
does not compile the sources.sources
- The sourcespublic Optional<JavacTask> getLastTask()
public JavacTask getJavacTask(JavaFileObject... sources)
sources
- The sourcespublic Iterable<? extends JavaFileObject> generate(String className, String code)
sources
into com.sun.source.tree.CompilationUnitTree
units. This method
does not compile the sources.className
- The class namecode
- the raw code@Nullable public Reader readGenerated(@NonNull String filePath, String className, String code) throws IOException
filePath
- The file pathclassName
- The class name that produces the filecode
- The code of the classIOException
- when an error occurs reading the filepublic Iterable<? extends JavaFileObject> generate(JavaFileObject... sources)
sources
into com.sun.source.tree.CompilationUnitTree
units. This method
does not compile the sources.sources
- The sources@NonNull protected List<Processor> getAnnotationProcessors()
@NonNull protected BeanDefinitionInjectProcessor getBeanDefinitionInjectProcessor()
BeanDefinitionInjectProcessor
to use.BeanDefinitionInjectProcessor
@NonNull protected TypeElementVisitorProcessor getTypeElementVisitorProcessor()
@NonNull protected AggregatingTypeElementVisitorProcessor getAggregatingTypeElementVisitorProcessor()
public void close()
close
in interface Closeable
close
in interface AutoCloseable