Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.AST.newCompilationUnit()


          }

          // Create new CompilationUnit
          try {
            AST ast = AST.newAST(AST.JLS3);
            CompilationUnit unit = ast.newCompilationUnit();
            PackageDeclaration packageDeclaration = ast
                .newPackageDeclaration();
            packageDeclaration.setName(ast.newSimpleName(pkg
                .getElementName()));
            unit.setPackage(packageDeclaration);
View Full Code Here


public class ASTTest {

  @SuppressWarnings("unchecked")
  public void stackoverflow_answer() {
    AST ast = AST.newAST(AST.JLS4);
    CompilationUnit cu = ast.newCompilationUnit();

    PackageDeclaration p1 = ast.newPackageDeclaration();
    p1.setName(ast.newSimpleName("foo"));
    cu.setPackage(p1);
View Full Code Here

   *            UML class
   * @return JDT compilation unit
   */
  private CompilationUnit generateException(Classifier clazz) {
    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    generatePackage(clazz, ast, cu);
    TypeDeclaration td = generateClass(clazz, ast, cu);
    generateSerialVersionUID(clazz, ast, td);
    generateMethods(clazz, ast, td);
View Full Code Here

    this.sourceDirectoryPackageName = sourceDirectoryPackageName;
    logger.log(Level.FINE, "Start generateInterface: " + clazz.getName()
        + " -----------------------------");

    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    generatePackage(clazz, ast, cu);
    TypeDeclaration td = generateClass(clazz, ast, cu);
    generateMethods(clazz, ast, td);
    generateGettersSetters(clazz, ast, td);
View Full Code Here

  public CompilationUnit generateEnum(Classifier clazz,
      String sourceDirectoryPackageName) {
    this.sourceDirectoryPackageName = sourceDirectoryPackageName;

    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    generatePackage(clazz, ast, cu);
    EnumDeclaration ed = generateEnum(clazz, ast, cu);
    generateAttributes(clazz, ast, ed);
    generateConstructor(clazz, ast, ed);
View Full Code Here

  }

  @Test
  public void testGenerateClassCheckedExceptionWithNoInheritance() {
    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    TypeDeclaration typeDeclaration = exceptionGenerator.generateClass(
        clazz, ast, cu);

    assertEquals(typeDeclaration.toString(),
View Full Code Here

    when(clazzGeneralization.getQualifiedName()).thenReturn(
        "de::test::SuperCompanyException");
    when(clazz.getGeneralizations()).thenReturn(generalizations);

    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    TypeDeclaration typeDeclaration = exceptionGenerator.generateClass(
        clazz, ast, cu);

    assertEquals(typeDeclaration.toString(),
View Full Code Here

        Answers.RETURNS_DEEP_STUBS.get());
    when(clazz.getOwnedTemplateSignature()).thenReturn(templateSignature);
    when(templateSignature.getParameters()).thenReturn(templateParameters);

    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    TypeDeclaration typeDeclaration = exceptionGenerator.generateClass(
        clazz, ast, cu);

    assertEquals(typeDeclaration.toString(),
View Full Code Here

  }

  @Test
  public void testGenerateClassUncheckedExceptionWithNoInheritance() {
    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    exceptionGenerator.setCheckedException(false);
    TypeDeclaration typeDeclaration = exceptionGenerator.generateClass(
        clazz, ast, cu);
View Full Code Here

    when(clazzGeneralization2.getQualifiedName()).thenReturn(
        "de::test::SuperDuperCompanyException");
    when(clazz.getGeneralizations()).thenReturn(generalizations);

    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    exceptionGenerator.setCheckedException(false);
    try {
      exceptionGenerator.generateClass(clazz, ast, cu);
      assertTrue(false);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.