Created
October 13, 2011 19:37
-
-
Save rylan/1285281 to your computer and use it in GitHub Desktop.
Get an ASTNode from an ICompilationUnit (Eclipse JDT)
This file contains hidden or 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
import org.eclipse.jdt.core.dom.ASTNode; | |
import org.eclipse.jdt.core.dom.ASTParser; | |
import org.eclipse.jdt.core.dom.AST; | |
public ASTUtil { | |
public static ASTNode getASTNode(ICompilationUnit unit) { | |
ASTParser parser = ASTParser.newParser(AST.JLS3); | |
parser.setKind(ASTParser.K_COMPILATION_UNIT); | |
parser.setSource(unit); | |
parser.setResolveBindings(true); | |
return parser.createAST(null); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment