public class ASTBuilder
extends java.lang.Object
Currently only Java 1.4 source files are accepted.
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_LANGUAGE_SPECIFICATION
The ID of the Java language specification being used by the parser.
|
Constructor and Description |
---|
ASTBuilder() |
Modifier and Type | Method and Description |
---|---|
static int |
getLanguageSpecification()
Return the ID of the Java language specification being used by the
parser.
|
static org.eclipse.jdt.core.dom.CompilationUnit |
parse(char[] source)
Parse the Java source code given in the source buffer, and
return the root of the AST.
|
static org.eclipse.jdt.core.dom.CompilationUnit |
parse(java.lang.String fileName)
Parse a Java source file given by its name, and return the
root of the AST.
|
static void |
setLanguageSpecification(int level)
Set the ID of the Java language specification being used by the
parser.
|
public static int DEFAULT_LANGUAGE_SPECIFICATION
public static int getLanguageSpecification()
setLanguageSpecification(int)
public static org.eclipse.jdt.core.dom.CompilationUnit parse(java.lang.String fileName) throws java.io.IOException, ASTMalformedException
fileName
- The Java source file name.java.io.IOException
- If IO exception occurs.ASTMalformedException
- If the Java source file
does not conform to the supported Java grammar.parse(char[])
public static org.eclipse.jdt.core.dom.CompilationUnit parse(char[] source) throws ASTMalformedException
source
- The char array that contains the
source code in a single Java source file.ASTMalformedException
- If the Java source file
does not conform to the supported Java grammar.public static void setLanguageSpecification(int level)
Users may change the language specification before Java source is parsed. The language specification is set statically. It is users' responsibility to synchronize its usage if multiple threads parse Java sources at the same time with different language specifications.
level
- The ID of the Java language specification.getLanguageSpecification()