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);
 }
  /**
   * Ensures that creating a DOM AST and computing the bindings takes the owner's working copies
   * into account.
   *
   * @deprecated using deprecated code
   */
  public void testParseCompilationUnit2() throws CoreException {
    TestWorkingCopyOwner owner = new TestWorkingCopyOwner();
    this.workingCopy = getCompilationUnit("P/Y.java").getWorkingCopy(owner, null);
    this.workingCopy.getBuffer().setContents("public class Y {\n" + "}");
    this.workingCopy.makeConsistent(null);

    char[] source = ("public class Z extends Y {\n" + "}").toCharArray();
    ASTParser parser = ASTParser.newParser(AST.JLS2);
    parser.setSource(source);
    parser.setUnitName("Z.java");
    parser.setProject(getJavaProject("P"));
    parser.setWorkingCopyOwner(owner);
    parser.setResolveBindings(true);
    CompilationUnit cu = (CompilationUnit) parser.createAST(null);

    List types = cu.types();
    assertEquals("Unexpected number of types in AST", 1, types.size());
    TypeDeclaration type = (TypeDeclaration) types.get(0);
    ITypeBinding typeBinding = type.resolveBinding();
    assertNotNull("No binding", typeBinding);
    assertEquals("Unexpected super type", "Y", typeBinding.getSuperclass().getQualifiedName());
  }