Examples of AbstractTypeDeclaration


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

        // 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

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

  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

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

        }

        _output("\n");

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

        return false;
    }
View Full Code Here

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

                            bodyDeclaration2);

                case ASTNode.TYPE_DECLARATION:
                case ASTNode.ENUM_DECLARATION:
                case ASTNode.ANNOTATION_TYPE_DECLARATION:
                    AbstractTypeDeclaration type1 = (AbstractTypeDeclaration) bodyDeclaration1;
                    AbstractTypeDeclaration type2 = (AbstractTypeDeclaration) bodyDeclaration2;

                    String typeName1 = type1.getName().getIdentifier();
                    String typeName2 = type2.getName().getIdentifier();

                    return compareNames(bodyDeclaration1, bodyDeclaration2,
                            typeName1, typeName2);

                case ASTNode.ENUM_CONSTANT_DECLARATION:
View Full Code Here

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

      unit.accept(visitor);

      List<AbstractTypeDeclaration> declarations = visitor.getTypeDeclarations();
      if (!declarations.isEmpty())
      {
         AbstractTypeDeclaration declaration = declarations.get(0);
         return getJavaSource(null, document, unit, declaration);
      }
      else if (visitor.getPackageDeclaration() != null)
      {
         return getJavaSource(null, document, unit, visitor.getPackageDeclaration());
View Full Code Here

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

   protected AbstractTypeDeclaration getBodyDeclaration()
   {
      TypeDeclarationFinderVisitor typeDeclarationFinder = new TypeDeclarationFinderVisitor();
      unit.accept(typeDeclarationFinder);
      AbstractTypeDeclaration declaration = typeDeclarationFinder.getTypeDeclaration();
      if (declaration == null)
      {
         throw new RuntimeException(
                  "A type-declaration is required in order to complete the current operation, but no type-declaration exists in compilation unit: "
                           + unit.toString());
View Full Code Here

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

   }

   @Override
   public boolean isClass()
   {
      AbstractTypeDeclaration declaration = getBodyDeclaration();
      return (declaration instanceof TypeDeclaration)
               && !((TypeDeclaration) declaration).isInterface();

   }
View Full Code Here

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

   }

   @Override
   public boolean isEnum()
   {
      AbstractTypeDeclaration declaration = getBodyDeclaration();
      return declaration instanceof EnumDeclaration;
   }
View Full Code Here

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

   }

   @Override
   public boolean isInterface()
   {
      AbstractTypeDeclaration declaration = getBodyDeclaration();
      return (declaration instanceof TypeDeclaration)
               && ((TypeDeclaration) declaration).isInterface();
   }
View Full Code Here

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

   }

   @Override
   public boolean isAnnotation()
   {
      AbstractTypeDeclaration declaration = getBodyDeclaration();
      return declaration instanceof AnnotationTypeDeclaration;
   }
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.