Class JavaParser
java.lang.Object
manifold.internal.javac.JavaParser
- All Implemented Interfaces:
IJavaParser
A tool for parsing and compiling Java source.
A notable feature of this tool is its ability to compile Java sources that reference and invoke Manifold types. This feature enables bi-directional Java interop with Manifold.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()compile(String fqn, Iterable<String> options, DiagnosticCollector<JavaFileObject> errorHandler) Compiles specified Java class name.compile(Collection<JavaFileObject> files, Iterable<String> options, DiagnosticCollector<JavaFileObject> errorHandler) Compiles a collection of java source files, intended for use a command line compiler.compile(JavaFileObject jfo, String fqn, Iterable<String> options, DiagnosticCollector<JavaFileObject> errorHandler) Compiles fresh, no caching.manifold.rt.api.util.Pair<JavaFileObject, String> findJavaSource(String fqn, DiagnosticListener<JavaFileObject> errorHandler) getHost()com.sun.tools.javac.api.BasicJavacTaskcom.sun.tools.javac.tree.JCTree.JCExpressionparseExpr(String expr, DiagnosticCollector<JavaFileObject> errorHandler) booleanparseText(String src, List<com.sun.source.tree.CompilationUnitTree> trees, Consumer<com.sun.source.util.SourcePositions> sourcePositions, Consumer<com.sun.source.util.DocTrees> docTrees, DiagnosticCollector<JavaFileObject> errorHandler) booleanparseType(String fqn, List<com.sun.source.tree.CompilationUnitTree> trees, DiagnosticCollector<JavaFileObject> errorHandler)
-
Constructor Details
-
JavaParser
For internal use only. UseaIManifoldHost.getJavaParser()
-
-
Method Details
-
getHost
-
parseType
public boolean parseType(String fqn, List<com.sun.source.tree.CompilationUnitTree> trees, DiagnosticCollector<JavaFileObject> errorHandler) - Specified by:
parseTypein interfaceIJavaParser
-
parseText
public boolean parseText(String src, List<com.sun.source.tree.CompilationUnitTree> trees, Consumer<com.sun.source.util.SourcePositions> sourcePositions, Consumer<com.sun.source.util.DocTrees> docTrees, DiagnosticCollector<JavaFileObject> errorHandler) - Specified by:
parseTextin interfaceIJavaParser
-
parseExpr
public com.sun.tools.javac.tree.JCTree.JCExpression parseExpr(String expr, DiagnosticCollector<JavaFileObject> errorHandler) -
compile
public InMemoryClassJavaFileObject compile(String fqn, Iterable<String> options, DiagnosticCollector<JavaFileObject> errorHandler) Compiles specified Java class name. Maintains cache between calls to this method, therefore subsequent calls to this method will consult the cache and return the previously compiled class if cached.- Specified by:
compilein interfaceIJavaParser
-
compile
public InMemoryClassJavaFileObject compile(JavaFileObject jfo, String fqn, Iterable<String> options, DiagnosticCollector<JavaFileObject> errorHandler) Compiles fresh, no caching. Intended for use with parser feedback tooling e.g., a Java editor.- Specified by:
compilein interfaceIJavaParser
-
compile
public Collection<InMemoryClassJavaFileObject> compile(Collection<JavaFileObject> files, Iterable<String> options, DiagnosticCollector<JavaFileObject> errorHandler) Compiles a collection of java source files, intended for use a command line compiler.- Specified by:
compilein interfaceIJavaParser
-
findJavaSource
public manifold.rt.api.util.Pair<JavaFileObject, String> findJavaSource(String fqn, DiagnosticListener<JavaFileObject> errorHandler) - Specified by:
findJavaSourcein interfaceIJavaParser
-
getJavacTask
public com.sun.tools.javac.api.BasicJavacTask getJavacTask() -
clear
public void clear()- Specified by:
clearin interfaceIJavaParser
-