Created
February 7, 2012 21:09
-
-
Save jbranchaud/1761964 to your computer and use it in GitHub Desktop.
Create an ASTParser (CompilationUnit) for the JDT using a char[]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public CompilationUnit createParser(char[] contents) { | |
// Create the ASTParser which will be a CompilationUnit | |
ASTParser parser = ASTParser.newParser(AST.JLS4); | |
parser.setKind(ASTParser.K_COMPILATION_UNIT); | |
parser.setSource(contents); | |
parser.setResolveBindings(true); | |
CompilationUnit parse = (CompilationUnit) parser.createAST(null); | |
return parse; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment