Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.AST


    parser.setSource(source.toCharArray());
    final ASTNode node = parser.createAST(null);
    ASTVisitor visitor = new ASTVisitor(){
      @SuppressWarnings("unchecked")
      public boolean visit(Javadoc doc){
        AST ast = doc.getAST();
        TagElement tag = ast.newTagElement();
        tag.setTagName(TagElement.TAG_SEE);
        doc.tags().add(tag);
        MethodRef method = ast.newMethodRef();
        tag.fragments().add(method);
        SimpleName name = ast.newSimpleName("Test");
        method.setQualifier(ast.newQualifiedName(ast.newQualifiedName(ast.newName("org"), ast.newSimpleName("junit")), name));
        name = ast.newSimpleName("test");
        method.setName(name);
        return super.visit(doc);
      }
    };
    node.accept(visitor);
View Full Code Here


         {
            final String stub = "enum StubEnum { FOO() {}; }";
            final JavaEnum temp = JavaParser.parse(JavaEnum.class, stub);
            final AnonymousClassDeclaration body = ((EnumConstantBodyImpl) temp.getEnumConstants().get(0).getBody())
                     .getBody();
            final AST ast = ((ASTNode) javaEnum.getInternal()).getAST();
            result = (AnonymousClassDeclaration) ASTNode.copySubtree(ast, body);
            enumConstantDeclaration.setAnonymousClassDeclaration(result);
         }
         return result;
      }
View Full Code Here

    JavaCore.setComplianceOptions(JavaCore.VERSION_1_6, options);
    parser.setCompilerOptions(options);
    CompilationUnit unit = (CompilationUnit) parser.createAST(null);
    unit.recordModifications();

    AST ast = unit.getAST();

    // Package statement
    // package astexplorer;

    PackageDeclaration packageDeclaration = ast.newPackageDeclaration();
    unit.setPackage(packageDeclaration);
    // unit.se
    packageDeclaration.setName(ast.newSimpleName(fileName));
    // System.out.println("Filename: " + fileName);
    // class declaration
    // public class SampleComposite extends Composite {

    TypeDeclaration classType = ast.newTypeDeclaration();
    classType.setInterface(false);
    // classType.s
    classType.setName(ast.newSimpleName(fileName));
    unit.types().add(classType);
    // classType.setSuperclass(ast.newSimpleName("Composite"));
    return new CompilationUnitImpl(unit);
  }
View Full Code Here

   }

   private static org.eclipse.jdt.core.dom.Annotation createAnnotation(final AnnotationTargetSource<?, ?> parent,
            final AnnotationType type)
   {
      AST ast = ((ASTNode) parent.getInternal()).getAST();
      switch (type)
      {
      case MARKER:
         return ast.newMarkerAnnotation();
      case SINGLE:
         return ast.newSingleMemberAnnotation();
      case NORMAL:
         return ast.newNormalAnnotation();
      default:
         throw new IllegalArgumentException("Unknown annotation type: " + type);
      }
   }
View Full Code Here

   * @param clazz
   *            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

      String sourceDirectoryPackageName) {
    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

    JavaCore.setComplianceOptions(JavaCore.VERSION_1_6, options);
    parser.setCompilerOptions(options);
    CompilationUnit unit = (CompilationUnit) parser.createAST(null);
    unit.recordModifications();

    AST ast = unit.getAST();

    // Package statement
    // package astexplorer;

    PackageDeclaration packageDeclaration = ast.newPackageDeclaration();
    unit.setPackage(packageDeclaration);
    // unit.se
    packageDeclaration.setName(ast.newSimpleName(fileName));
    // System.out.println("Filename: " + fileName);
    // class declaration
    // public class SampleComposite extends Composite {

    TypeDeclaration classType = ast.newTypeDeclaration();
    classType.setInterface(false);
    // classType.s
    classType.setName(ast.newSimpleName(fileName));
    unit.types().add(classType);
    // classType.setSuperclass(ast.newSimpleName("Composite"));
    return new CompilationUnitImpl(unit);
  }
View Full Code Here

    list.add(expression);
  }

  @SuppressWarnings("unchecked")
  public static void addLiteralMemberValuePair(NormalAnnotation annotation, String name, String value) {
    AST ast = annotation.getAST();
   
    List list = (List) annotation.getStructuralProperty(NormalAnnotation.VALUES_PROPERTY);
    MemberValuePair newValuePair = ast.newMemberValuePair();
    newValuePair.setName(ast.newSimpleName(name));
    newValuePair.setValue(ASTTools.newStringLiteral(ast, value));
    list.add(newValuePair);
  }
View Full Code Here

      ASTTools.annotation(declaration, getAnnotationUnqualifiedName());
    if (annotation != null) {
      return;
    }
   
    AST ast = declaration.getAST();
   
    annotation = AstUtils.createMarkerAnnotation(
      ast, getAnnotationFullyQualifiedName());
    annotation.setSourceRange(
        AstUtils.calculateOffset(declaration, true).offset,
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.AST

Copyright © 2018 www.massapicom. 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.