Package org.eclipse.jdt.core.dom

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


     * @param cname class name
     * @param isenum Java 5 enum class flag
     * @return type declaration
     */
    private AbstractTypeDeclaration createClass(String cname, boolean isenum) {
        AbstractTypeDeclaration abstype;
        if (isenum) {
            abstype = m_ast.newEnumDeclaration();
        } else {
            TypeDeclaration type = m_ast.newTypeDeclaration();
            type.setInterface(false);
            abstype = type;
        }
        abstype.modifiers().add(m_ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
        abstype.setName(m_ast.newSimpleName(cname));
        return abstype;
    }
View Full Code Here


     * @param cname class name
     * @param isenum Java 5 enum class flag
     * @return builder
     */
    public ClassBuilder newMainClass(String cname, boolean isenum) {
        AbstractTypeDeclaration decl = createClass(cname, isenum);
        m_compilationUnit.types().add(decl);
        ClassBuilder builder = new ClassBuilder(decl, this);
        m_classes.add(builder);
        return builder;
    }
View Full Code Here

     * @param outer containing class builder
     * @param isenum Java 5 enum class flag
     * @return builder
     */
    public ClassBuilder newInnerClass(String cname, ClassBuilder outer, boolean isenum) {
        AbstractTypeDeclaration decl = createClass(cname, isenum);
        decl.modifiers().add(m_ast.newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));
//        type.superInterfaceTypes().add(createType("java.io.Serializable"));
        return new ClassBuilder(decl, outer);
    }
View Full Code Here

                String typeContent = constructTypeStub(parentCU, imports, lineDelimiter);

                int index = cuContent.lastIndexOf(simpleTypeStub);
                if (index == -1) {
                    AbstractTypeDeclaration typeNode = (AbstractTypeDeclaration) astRoot.types().get(0);
                    int start = ((ASTNode) typeNode.modifiers().get(0)).getStartPosition();
                    int end = typeNode.getStartPosition() + typeNode.getLength();
                    buffer.replace(start, end - start, typeContent);
                } else {
                    buffer.replace(index, simpleTypeStub.length(), typeContent);
                }
View Full Code Here

                String typeContent = constructTypeStub(parentCU, imports, lineDelimiter);

                int index = cuContent.lastIndexOf(simpleTypeStub);
                if (index == -1) {
                    AbstractTypeDeclaration typeNode = (AbstractTypeDeclaration) astRoot.types().get(0);
                    int start = ((ASTNode) typeNode.modifiers().get(0)).getStartPosition();
                    int end = typeNode.getStartPosition() + typeNode.getLength();
                    buffer.replace(start, end - start, typeContent);
                } else {
                    buffer.replace(index, simpleTypeStub.length(), typeContent);
                }
View Full Code Here

      imports.add(visitChild(d));
    }
 
    IValueList typeDeclarations = new IValueList(values);
    for (Iterator it = node.types().iterator(); it.hasNext();) {
      AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
      typeDeclarations.add(visitChild(d));
    }
   
    ownValue = constructDeclarationNode("compilationUnit", packageOfUnit, imports.asList(), typeDeclarations.asList());   
    return false;
View Full Code Here

    for (Iterator it = node.imports().iterator(); it.hasNext(); ) {
      ImportDeclaration d = (ImportDeclaration) it.next();
      d.accept(this);
    }
    for (Iterator it = node.types().iterator(); it.hasNext(); ) {
      AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
      d.accept(this);
    }
    return false;
  }
View Full Code Here

        // update main type name
        IType[] types = cu.getTypes();
        for (int i = 0, max = types.length; i < max; i++) {
          IType currentType = types[i];
          if (currentType.getElementName().equals(oldTypeName)) {
            AbstractTypeDeclaration typeNode = (AbstractTypeDeclaration) ((JavaElement) currentType).findNode(astCU);
            if (typeNode != null) {
              // rename type
              rewriter.replace(typeNode.getName(), ast.newSimpleName(newTypeName), null);
              // rename constructors
              Iterator bodyDeclarations = typeNode.bodyDeclarations().iterator();
              while (bodyDeclarations.hasNext()) {
                Object bodyDeclaration = bodyDeclarations.next();
                if (bodyDeclaration instanceof MethodDeclaration) {
                  MethodDeclaration methodDeclaration = (MethodDeclaration) bodyDeclaration;
                  if (methodDeclaration.isConstructor()) {
View Full Code Here

  protected void initChildren(IProgressMonitor monitor) {
    CompilationUnit astNode = getASTNode();
 
    List<?> types = astNode.types();
    for (int i = 0; i < types.size(); i++) {
      AbstractTypeDeclaration declaration = (AbstractTypeDeclaration) types
          .get(i);
      if (declaration instanceof TypeDeclaration) {
        TypeDeclaration typeDeclaration = (TypeDeclaration) declaration;
        IType type = ((ICompilationUnit) getJavaElement())
            .getType(typeDeclaration.getName().getIdentifier());
        AbstractMetricElement next = new TypeMetric(type
            .getHandleIdentifier(), typeDeclaration, analyzer);
        if (next != null)
          addChild(next);
        else
          logger.warning("Get null TypeMetric when initializing.");

        addInnerClasses(typeDeclaration, type);
      } else if (declaration instanceof EnumDeclaration) {
        EnumDeclaration enumDeclaration = (EnumDeclaration) declaration;
        IType type = ((ICompilationUnit) getJavaElement())
            .getType(enumDeclaration.getName().getIdentifier());
        AbstractMetricElement next = new EnumMetric(type
            .getHandleIdentifier(), enumDeclaration, analyzer);
        if (next != null)
          addChild(next);
        else
          logger.warning("Get null EnumMetric when initializing.");
      } else if (declaration instanceof AnnotationTypeDeclaration) {
        AnnotationTypeDeclaration annotationDeclaration = (AnnotationTypeDeclaration) declaration;
        IType type = ((ICompilationUnit) getJavaElement())
            .getType(annotationDeclaration.getName()
                .getIdentifier());
        AbstractMetricElement next = new AnnotationTypeMetric(type
            .getHandleIdentifier(), annotationDeclaration, analyzer);
        if (next != null)
          addChild(next);
        else
          logger
              .warning("Get null AnnotationTypeMetric when initializing.");
      } else
        logger.warning("Unknown type : "
            + declaration.getClass().getName());
    }
  }
View Full Code Here

        }

        _output("\n");

        for (Iterator it = node.types().iterator(); it.hasNext();) {
            AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next();
            d.accept(this);
        }

        return false;
    }
View Full Code Here

TOP

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

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.