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