CompilationUnit buildCompilationUnit(BuildContext file) { IJavaProject javaProject = JavaCore.create(file.getFile().getProject()); ASTParser p = ASTParser.newParser(JavaConstants.AST_LEVEL); p.setProject(javaProject); p.setSource(file.getContents()); p.setResolveBindings(true); p.setKind(ASTParser.K_COMPILATION_UNIT); p.setUnitName(file.getFile().getName()); return (CompilationUnit) p.createAST(null); }