Java 类org.eclipse.jdt.core.dom.EnumConstantDeclaration 实例源码

项目:che    文件:Invocations.java   
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      return MethodInvocation.ARGUMENTS_PROPERTY;
    case ASTNode.SUPER_METHOD_INVOCATION:
      return SuperMethodInvocation.ARGUMENTS_PROPERTY;

    case ASTNode.CONSTRUCTOR_INVOCATION:
      return ConstructorInvocation.ARGUMENTS_PROPERTY;
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return SuperConstructorInvocation.ARGUMENTS_PROPERTY;

    case ASTNode.CLASS_INSTANCE_CREATION:
      return ClassInstanceCreation.ARGUMENTS_PROPERTY;
    case ASTNode.ENUM_CONSTANT_DECLARATION:
      return EnumConstantDeclaration.ARGUMENTS_PROPERTY;

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:eclipse.jdt.ls    文件:UnimplementedCodeFix.java   
private static boolean isTypeBindingNull(ASTNode typeNode) {
    if (typeNode instanceof AbstractTypeDeclaration) {
        AbstractTypeDeclaration abstractTypeDeclaration= (AbstractTypeDeclaration) typeNode;
        if (abstractTypeDeclaration.resolveBinding() == null) {
            return true;
        }

        return false;
    } else if (typeNode instanceof AnonymousClassDeclaration) {
        AnonymousClassDeclaration anonymousClassDeclaration= (AnonymousClassDeclaration) typeNode;
        if (anonymousClassDeclaration.resolveBinding() == null) {
            return true;
        }

        return false;
    } else if (typeNode instanceof EnumConstantDeclaration) {
        return false;
    } else {
        return true;
    }
}
项目:eclipse.jdt.ls    文件:NewVariableCorrectionProposal.java   
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) {
    SimpleName node= fOriginalNode;

    ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);
    if (newTypeDecl == null) {
        astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);
        newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
    }

    if (newTypeDecl != null) {
        AST ast= newTypeDecl.getAST();

        ASTRewrite rewrite= ASTRewrite.create(ast);

        EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
        constDecl.setName(ast.newSimpleName(node.getIdentifier()));

        ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
        listRewriter.insertLast(constDecl, null);

        return rewrite;
    }
    return null;
}
项目:che    文件:UnimplementedCodeFix.java   
public static ASTNode getSelectedTypeNode(CompilationUnit root, IProblemLocation problem) {
  ASTNode selectedNode = problem.getCoveringNode(root);
  if (selectedNode == null) return null;

  if (selectedNode.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION) { // bug 200016
    selectedNode = selectedNode.getParent();
  }

  if (selectedNode.getLocationInParent() == EnumConstantDeclaration.NAME_PROPERTY) {
    selectedNode = selectedNode.getParent();
  }
  if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME
      && selectedNode.getParent() instanceof AbstractTypeDeclaration) {
    return selectedNode.getParent();
  } else if (selectedNode.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
    return ((ClassInstanceCreation) selectedNode).getAnonymousClassDeclaration();
  } else if (selectedNode.getNodeType() == ASTNode.ENUM_CONSTANT_DECLARATION) {
    EnumConstantDeclaration enumConst = (EnumConstantDeclaration) selectedNode;
    if (enumConst.getAnonymousClassDeclaration() != null)
      return enumConst.getAnonymousClassDeclaration();
    return enumConst;
  } else {
    return null;
  }
}
项目:che    文件:UnimplementedCodeFix.java   
private static boolean isTypeBindingNull(ASTNode typeNode) {
  if (typeNode instanceof AbstractTypeDeclaration) {
    AbstractTypeDeclaration abstractTypeDeclaration = (AbstractTypeDeclaration) typeNode;
    if (abstractTypeDeclaration.resolveBinding() == null) return true;

    return false;
  } else if (typeNode instanceof AnonymousClassDeclaration) {
    AnonymousClassDeclaration anonymousClassDeclaration = (AnonymousClassDeclaration) typeNode;
    if (anonymousClassDeclaration.resolveBinding() == null) return true;

    return false;
  } else if (typeNode instanceof EnumConstantDeclaration) {
    return false;
  } else {
    return true;
  }
}
项目:che    文件:ChangeSignatureProcessor.java   
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(
    ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) {
  if (BUG_89686
      && node instanceof SimpleName
      && node.getParent() instanceof EnumConstantDeclaration) node = node.getParent();

  if (Invocations.isInvocationWithArguments(node))
    return new ReferenceUpdate(node, cuRewrite, result);
  else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration)
    return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result);
  else if (node instanceof MemberRef || node instanceof MethodRef)
    return new DocReferenceUpdate(node, cuRewrite, result);
  else if (ASTNodes.getParent(node, ImportDeclaration.class) != null)
    return new StaticImportUpdate(
        (ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result);
  else if (node instanceof LambdaExpression)
    return new LambdaExpressionUpdate((LambdaExpression) node, cuRewrite, result);
  else if (node.getLocationInParent() == ExpressionMethodReference.NAME_PROPERTY)
    return new ExpressionMethodRefUpdate(
        (ExpressionMethodReference) node.getParent(), cuRewrite, result);
  else return new NullOccurrenceUpdate(node, cuRewrite, result);
}
项目:che    文件:ChangeSignatureProcessor.java   
protected String getFullTypeName() {
  ASTNode node = getNode();
  while (true) {
    node = node.getParent();
    if (node instanceof AbstractTypeDeclaration) {
      String typeName = ((AbstractTypeDeclaration) node).getName().getIdentifier();
      if (getNode() instanceof LambdaExpression) {
        return Messages.format(
            RefactoringCoreMessages.ChangeSignatureRefactoring_lambda_expression, typeName);
      }
      return typeName;
    } else if (node instanceof ClassInstanceCreation) {
      ClassInstanceCreation cic = (ClassInstanceCreation) node;
      return Messages.format(
          RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass,
          BasicElementLabels.getJavaElementName(ASTNodes.asString(cic.getType())));
    } else if (node instanceof EnumConstantDeclaration) {
      EnumDeclaration ed = (EnumDeclaration) node.getParent();
      return Messages.format(
          RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass,
          BasicElementLabels.getJavaElementName(ASTNodes.asString(ed.getName())));
    }
  }
}
项目:che    文件:Invocations.java   
public static List<Expression> getArguments(ASTNode invocation) {
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      return ((MethodInvocation) invocation).arguments();
    case ASTNode.SUPER_METHOD_INVOCATION:
      return ((SuperMethodInvocation) invocation).arguments();

    case ASTNode.CONSTRUCTOR_INVOCATION:
      return ((ConstructorInvocation) invocation).arguments();
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return ((SuperConstructorInvocation) invocation).arguments();

    case ASTNode.CLASS_INSTANCE_CREATION:
      return ((ClassInstanceCreation) invocation).arguments();
    case ASTNode.ENUM_CONSTANT_DECLARATION:
      return ((EnumConstantDeclaration) invocation).arguments();

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:che    文件:Invocations.java   
public static IMethodBinding resolveBinding(ASTNode invocation) {
  switch (invocation.getNodeType()) {
    case ASTNode.METHOD_INVOCATION:
      return ((MethodInvocation) invocation).resolveMethodBinding();
    case ASTNode.SUPER_METHOD_INVOCATION:
      return ((SuperMethodInvocation) invocation).resolveMethodBinding();

    case ASTNode.CONSTRUCTOR_INVOCATION:
      return ((ConstructorInvocation) invocation).resolveConstructorBinding();
    case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
      return ((SuperConstructorInvocation) invocation).resolveConstructorBinding();

    case ASTNode.CLASS_INSTANCE_CREATION:
      return ((ClassInstanceCreation) invocation).resolveConstructorBinding();
    case ASTNode.ENUM_CONSTANT_DECLARATION:
      return ((EnumConstantDeclaration) invocation).resolveConstructorBinding();

    default:
      throw new IllegalArgumentException(invocation.toString());
  }
}
项目:compiler    文件:UglyMathCommentsExtractor.java   
private static int getNodeStartPosition(final ASTNode node) {
    if (node instanceof MethodDeclaration) {
        MethodDeclaration decl = (MethodDeclaration) node;
        return decl.isConstructor() ? decl.getName().getStartPosition() : decl.getReturnType2().getStartPosition();
    } else if (node instanceof FieldDeclaration) {
        return ((FieldDeclaration) node).getType().getStartPosition();
    } else if (node instanceof AbstractTypeDeclaration) {
        return ((AbstractTypeDeclaration) node).getName().getStartPosition();
    } else if (node instanceof AnnotationTypeMemberDeclaration) {
        return ((AnnotationTypeMemberDeclaration) node).getName().getStartPosition();
    } else if (node instanceof EnumConstantDeclaration) {
        return ((EnumConstantDeclaration) node).getName().getStartPosition();
    } else if (node instanceof PackageDeclaration) {
        return ((PackageDeclaration) node).getName().getStartPosition();
    }
    /* TODO: Initializer */

    return node.getStartPosition();
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) {
    if (BUG_89686 && node instanceof SimpleName && node.getParent() instanceof EnumConstantDeclaration)
        node= node.getParent();

    if (Invocations.isInvocationWithArguments(node))
        return new ReferenceUpdate(node, cuRewrite, result);

    else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration)
        return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result);

    else if (node instanceof MemberRef || node instanceof MethodRef)
        return new DocReferenceUpdate(node, cuRewrite, result);

    else if (ASTNodes.getParent(node, ImportDeclaration.class) != null)
        return new StaticImportUpdate((ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result);

    else if (node instanceof LambdaExpression)
        return new LambdaExpressionUpdate((LambdaExpression) node, cuRewrite, result);

    else if (node.getLocationInParent() == ExpressionMethodReference.NAME_PROPERTY)
        return new ExpressionMethodRefUpdate((ExpressionMethodReference) node.getParent(), cuRewrite, result);

    else
        return new NullOccurrenceUpdate(node, cuRewrite, result);
}
项目:Eclipse-Postfix-Code-Completion    文件:ChangeSignatureProcessor.java   
protected String getFullTypeName() {
    ASTNode node= getNode();
    while (true) {
        node= node.getParent();
        if (node instanceof AbstractTypeDeclaration) {
            String typeName= ((AbstractTypeDeclaration) node).getName().getIdentifier();
            if (getNode() instanceof LambdaExpression) {
                return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_lambda_expression, typeName);
            }
            return typeName;
        } else if (node instanceof ClassInstanceCreation) {
            ClassInstanceCreation cic= (ClassInstanceCreation) node;
            return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(cic.getType())));
        } else if (node instanceof EnumConstantDeclaration) {
            EnumDeclaration ed= (EnumDeclaration) node.getParent();
            return Messages.format(RefactoringCoreMessages.ChangeSignatureRefactoring_anonymous_subclass, BasicElementLabels.getJavaElementName(ASTNodes.asString(ed.getName())));
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static List<Expression> getArguments(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).arguments();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).arguments();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).arguments();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).arguments();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).arguments();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).arguments();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return MethodInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_METHOD_INVOCATION:
            return SuperMethodInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ConstructorInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return SuperConstructorInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ClassInstanceCreation.ARGUMENTS_PROPERTY;
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return EnumConstantDeclaration.ARGUMENTS_PROPERTY;

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:Invocations.java   
public static IMethodBinding resolveBinding(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).resolveMethodBinding();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).resolveMethodBinding();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).resolveConstructorBinding();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).resolveConstructorBinding();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).resolveConstructorBinding();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).resolveConstructorBinding();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ExtractMethodInputPage.java   
private String getLabel(ASTNode node) {
    if (node instanceof AbstractTypeDeclaration) {
        return ((AbstractTypeDeclaration)node).getName().getIdentifier();
    } else if (node instanceof AnonymousClassDeclaration) {
        if (node.getLocationInParent() == ClassInstanceCreation.ANONYMOUS_CLASS_DECLARATION_PROPERTY) {
            ClassInstanceCreation creation= (ClassInstanceCreation)node.getParent();
            return Messages.format(
                RefactoringMessages.ExtractMethodInputPage_anonymous_type_label,
                BasicElementLabels.getJavaElementName(ASTNodes.asString(creation.getType())));
        } else if (node.getLocationInParent() == EnumConstantDeclaration.ANONYMOUS_CLASS_DECLARATION_PROPERTY) {
            EnumConstantDeclaration decl= (EnumConstantDeclaration)node.getParent();
            return decl.getName().getIdentifier();
        }
    }
    return "UNKNOWN"; //$NON-NLS-1$
}
项目:Eclipse-Postfix-Code-Completion    文件:ModifierRewrite.java   
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) {
    switch (declNode.getNodeType()) {
        case ASTNode.METHOD_DECLARATION:
            return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.FIELD_DECLARATION:
            return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
            return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY);
        case ASTNode.VARIABLE_DECLARATION_STATEMENT:
            return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY);
        case ASTNode.SINGLE_VARIABLE_DECLARATION:
            return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.TYPE_DECLARATION:
            return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ENUM_DECLARATION:
            return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ANNOTATION_TYPE_DECLARATION:
            return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
            return rewrite.getListRewrite(declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY);
        default:
            throw new IllegalArgumentException("node has no modifiers: " + declNode.getClass().getName()); //$NON-NLS-1$
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:UnimplementedCodeFix.java   
public static ASTNode getSelectedTypeNode(CompilationUnit root, IProblemLocation problem) {
    ASTNode selectedNode= problem.getCoveringNode(root);
    if (selectedNode == null)
        return null;

    if (selectedNode.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION) { // bug 200016
        selectedNode= selectedNode.getParent();
    }

    if (selectedNode.getLocationInParent() == EnumConstantDeclaration.NAME_PROPERTY) {
        selectedNode= selectedNode.getParent();
    }
    if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME && selectedNode.getParent() instanceof AbstractTypeDeclaration) {
        return selectedNode.getParent();
    } else if (selectedNode.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
        return ((ClassInstanceCreation) selectedNode).getAnonymousClassDeclaration();
    } else if (selectedNode.getNodeType() == ASTNode.ENUM_CONSTANT_DECLARATION) {
        EnumConstantDeclaration enumConst= (EnumConstantDeclaration) selectedNode;
        if (enumConst.getAnonymousClassDeclaration() != null)
            return enumConst.getAnonymousClassDeclaration();
        return enumConst;
    } else {
        return null;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:UnimplementedCodeFix.java   
private static boolean isTypeBindingNull(ASTNode typeNode) {
    if (typeNode instanceof AbstractTypeDeclaration) {
        AbstractTypeDeclaration abstractTypeDeclaration= (AbstractTypeDeclaration) typeNode;
        if (abstractTypeDeclaration.resolveBinding() == null)
            return true;

        return false;
    } else if (typeNode instanceof AnonymousClassDeclaration) {
        AnonymousClassDeclaration anonymousClassDeclaration= (AnonymousClassDeclaration) typeNode;
        if (anonymousClassDeclaration.resolveBinding() == null)
            return true;

        return false;
    } else if (typeNode instanceof EnumConstantDeclaration) {
        return false;
    } else {
        return true;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:NewVariableCorrectionProposal.java   
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) {
    SimpleName node= fOriginalNode;

    ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);
    if (newTypeDecl == null) {
        astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);
        newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
    }

    if (newTypeDecl != null) {
        AST ast= newTypeDecl.getAST();

        ASTRewrite rewrite= ASTRewrite.create(ast);

        EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
        constDecl.setName(ast.newSimpleName(node.getIdentifier()));

        ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
        listRewriter.insertLast(constDecl, null);

        addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME);

        return rewrite;
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion    文件:DOMFinder.java   
public boolean visit(AnonymousClassDeclaration node) {
    ASTNode name;
    ASTNode parent = node.getParent();
    switch (parent.getNodeType()) {
        case ASTNode.CLASS_INSTANCE_CREATION:
            name = ((ClassInstanceCreation) parent).getType();
            if (name.getNodeType() == ASTNode.PARAMETERIZED_TYPE) {
                name = ((ParameterizedType) name).getType();
            }
            break;
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            name = ((EnumConstantDeclaration) parent).getName();
            break;
        default:
            return true;
    }
    if (found(node, name) && this.resolveBinding)
        this.foundBinding = node.resolveBinding();
    return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ChangeSignatureProcessor.java   
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) {
    if (BUG_89686 && node instanceof SimpleName && node.getParent() instanceof EnumConstantDeclaration)
        node= node.getParent();

    if (Invocations.isInvocationWithArguments(node))
        return new ReferenceUpdate(node, cuRewrite, result);

    else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration)
        return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result);

    else if (node instanceof MemberRef || node instanceof MethodRef)
        return new DocReferenceUpdate(node, cuRewrite, result);

    else if (ASTNodes.getParent(node, ImportDeclaration.class) != null)
        return new StaticImportUpdate((ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result);

    else
        return new NullOccurrenceUpdate(node, cuRewrite, result);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static List<Expression> getArguments(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).arguments();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).arguments();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).arguments();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).arguments();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).arguments();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).arguments();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static ChildListPropertyDescriptor getArgumentsProperty(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return MethodInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_METHOD_INVOCATION:
            return SuperMethodInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ConstructorInvocation.ARGUMENTS_PROPERTY;
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return SuperConstructorInvocation.ARGUMENTS_PROPERTY;

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ClassInstanceCreation.ARGUMENTS_PROPERTY;
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return EnumConstantDeclaration.ARGUMENTS_PROPERTY;

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:Invocations.java   
public static IMethodBinding resolveBinding(ASTNode invocation) {
    switch (invocation.getNodeType()) {
        case ASTNode.METHOD_INVOCATION:
            return ((MethodInvocation)invocation).resolveMethodBinding();
        case ASTNode.SUPER_METHOD_INVOCATION:
            return ((SuperMethodInvocation)invocation).resolveMethodBinding();

        case ASTNode.CONSTRUCTOR_INVOCATION:
            return ((ConstructorInvocation)invocation).resolveConstructorBinding();
        case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
            return ((SuperConstructorInvocation)invocation).resolveConstructorBinding();

        case ASTNode.CLASS_INSTANCE_CREATION:
            return ((ClassInstanceCreation)invocation).resolveConstructorBinding();
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return ((EnumConstantDeclaration)invocation).resolveConstructorBinding();

        default:
            throw new IllegalArgumentException(invocation.toString());
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:InlineConstantRefactoring.java   
private Name findConstantNameNode() {
    ASTNode node= NodeFinder.perform(fSelectionCuRewrite.getRoot(), fSelectionStart, fSelectionLength);
    if (node == null)
        return null;
    if (node instanceof FieldAccess)
        node= ((FieldAccess) node).getName();
    if (node.getParent() instanceof EnumConstantDeclaration)
        return null;
    if (!(node instanceof Name))
        return null;
    Name name= (Name) node;
    IBinding binding= name.resolveBinding();
    if (!(binding instanceof IVariableBinding))
        return null;
    IVariableBinding variableBinding= (IVariableBinding) binding;
    if (!variableBinding.isField() || variableBinding.isEnumConstant())
        return null;
    int modifiers= binding.getModifiers();
    if (! (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)))
        return null;

    return name;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ExtractMethodInputPage.java   
private String getLabel(ASTNode node) {
    if (node instanceof AbstractTypeDeclaration) {
        return ((AbstractTypeDeclaration)node).getName().getIdentifier();
    } else if (node instanceof AnonymousClassDeclaration) {
        if (node.getLocationInParent() == ClassInstanceCreation.ANONYMOUS_CLASS_DECLARATION_PROPERTY) {
            ClassInstanceCreation creation= (ClassInstanceCreation)node.getParent();
            return Messages.format(
                RefactoringMessages.ExtractMethodInputPage_anonymous_type_label,
                BasicElementLabels.getJavaElementName(ASTNodes.asString(creation.getType())));
        } else if (node.getLocationInParent() == EnumConstantDeclaration.ANONYMOUS_CLASS_DECLARATION_PROPERTY) {
            EnumConstantDeclaration decl= (EnumConstantDeclaration)node.getParent();
            return decl.getName().getIdentifier();
        }
    }
    return "UNKNOWN"; //$NON-NLS-1$
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ASTFlattener.java   
@Override
public boolean visit(EnumConstantDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }
    printModifiers(node.modifiers());
    node.getName().accept(this);
    if (!node.arguments().isEmpty()) {
        this.fBuffer.append("(");//$NON-NLS-1$
        for (Iterator<Expression> it= node.arguments().iterator(); it.hasNext();) {
            Expression e= it.next();
            e.accept(this);
            if (it.hasNext()) {
                this.fBuffer.append(",");//$NON-NLS-1$
            }
        }
        this.fBuffer.append(")");//$NON-NLS-1$
    }
    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ModifierRewrite.java   
private ListRewrite evaluateListRewrite(ASTRewrite rewrite, ASTNode declNode) {
    switch (declNode.getNodeType()) {
        case ASTNode.METHOD_DECLARATION:
            return rewrite.getListRewrite(declNode, MethodDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.FIELD_DECLARATION:
            return rewrite.getListRewrite(declNode, FieldDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
            return rewrite.getListRewrite(declNode, VariableDeclarationExpression.MODIFIERS2_PROPERTY);
        case ASTNode.VARIABLE_DECLARATION_STATEMENT:
            return rewrite.getListRewrite(declNode, VariableDeclarationStatement.MODIFIERS2_PROPERTY);
        case ASTNode.SINGLE_VARIABLE_DECLARATION:
            return rewrite.getListRewrite(declNode, SingleVariableDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.TYPE_DECLARATION:
            return rewrite.getListRewrite(declNode, TypeDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ENUM_DECLARATION:
            return rewrite.getListRewrite(declNode, EnumDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ANNOTATION_TYPE_DECLARATION:
            return rewrite.getListRewrite(declNode, AnnotationTypeDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            return rewrite.getListRewrite(declNode, EnumConstantDeclaration.MODIFIERS2_PROPERTY);
        case ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION:
            return rewrite.getListRewrite(declNode, AnnotationTypeMemberDeclaration.MODIFIERS2_PROPERTY);
        default:
            throw new IllegalArgumentException("node has no modifiers: " + declNode.getClass().getName()); //$NON-NLS-1$
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:UnimplementedCodeFix.java   
public static ASTNode getSelectedTypeNode(CompilationUnit root, IProblemLocation problem) {
    ASTNode selectedNode= problem.getCoveringNode(root);
    if (selectedNode == null)
        return null;

    if (selectedNode.getNodeType() == ASTNode.ANONYMOUS_CLASS_DECLARATION) { // bug 200016
        selectedNode= selectedNode.getParent();
    }

    if (selectedNode.getLocationInParent() == EnumConstantDeclaration.NAME_PROPERTY) {
        selectedNode= selectedNode.getParent();
    }
    if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME && selectedNode.getParent() instanceof AbstractTypeDeclaration) {
        return selectedNode.getParent();
    } else if (selectedNode.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
        return ((ClassInstanceCreation) selectedNode).getAnonymousClassDeclaration();
    } else if (selectedNode.getNodeType() == ASTNode.ENUM_CONSTANT_DECLARATION) {
        EnumConstantDeclaration enumConst= (EnumConstantDeclaration) selectedNode;
        if (enumConst.getAnonymousClassDeclaration() != null)
            return enumConst.getAnonymousClassDeclaration();
        return enumConst;
    } else {
        return null;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:UnimplementedCodeFix.java   
private static boolean isTypeBindingNull(ASTNode typeNode) {
    if (typeNode instanceof AbstractTypeDeclaration) {
        AbstractTypeDeclaration abstractTypeDeclaration= (AbstractTypeDeclaration) typeNode;
        if (abstractTypeDeclaration.resolveBinding() == null)
            return true;

        return false;
    } else if (typeNode instanceof AnonymousClassDeclaration) {
        AnonymousClassDeclaration anonymousClassDeclaration= (AnonymousClassDeclaration) typeNode;
        if (anonymousClassDeclaration.resolveBinding() == null)
            return true;

        return false;
    } else if (typeNode instanceof EnumConstantDeclaration) {
        return false;
    } else {
        return true;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NewVariableCorrectionProposal.java   
private ASTRewrite doAddEnumConst(CompilationUnit astRoot) {
    SimpleName node= fOriginalNode;

    ASTNode newTypeDecl= astRoot.findDeclaringNode(fSenderBinding);
    if (newTypeDecl == null) {
        astRoot= ASTResolving.createQuickFixAST(getCompilationUnit(), null);
        newTypeDecl= astRoot.findDeclaringNode(fSenderBinding.getKey());
    }

    if (newTypeDecl != null) {
        AST ast= newTypeDecl.getAST();

        ASTRewrite rewrite= ASTRewrite.create(ast);

        EnumConstantDeclaration constDecl= ast.newEnumConstantDeclaration();
        constDecl.setName(ast.newSimpleName(node.getIdentifier()));

        ListRewrite listRewriter= rewrite.getListRewrite(newTypeDecl, EnumDeclaration.ENUM_CONSTANTS_PROPERTY);
        listRewriter.insertLast(constDecl, null);

        addLinkedPosition(rewrite.track(constDecl.getName()), false, KEY_NAME);

        return rewrite;
    }
    return null;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:DOMFinder.java   
public boolean visit(AnonymousClassDeclaration node) {
    ASTNode name;
    ASTNode parent = node.getParent();
    switch (parent.getNodeType()) {
        case ASTNode.CLASS_INSTANCE_CREATION:
            name = ((ClassInstanceCreation) parent).getType();
            if (name.getNodeType() == ASTNode.PARAMETERIZED_TYPE) {
                name = ((ParameterizedType) name).getType();
            }
            break;
        case ASTNode.ENUM_CONSTANT_DECLARATION:
            name = ((EnumConstantDeclaration) parent).getName();
            break;
        default:
            return true;
    }
    if (found(node, name) && this.resolveBinding)
        this.foundBinding = node.resolveBinding();
    return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NaiveASTFlattener.java   
public boolean visit(EnumConstantDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }
    printIndent();
    printModifiers(node.modifiers());
    node.getName().accept(this);
    if (!node.arguments().isEmpty()) {
        this.buffer.append("(");//$NON-NLS-1$
        for (Iterator it = node.arguments().iterator(); it.hasNext(); ) {
            Expression e = (Expression) it.next();
            e.accept(this);
            if (it.hasNext()) {
                this.buffer.append(",");//$NON-NLS-1$
            }
        }
        this.buffer.append(")");//$NON-NLS-1$
    }
    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}
项目:jive    文件:StaticModelFactoryAdapterForAST.java   
private int lineFromNumber(final ASTNode node)
{
  int nodeStart = node.getStartPosition();
  /**
   * Skip the java documentation in body declaration nodes.
   */
  if (node instanceof AbstractTypeDeclaration)
  {
    nodeStart = ((AbstractTypeDeclaration) node).getName().getStartPosition();
  }
  else if (node instanceof EnumConstantDeclaration)
  {
    nodeStart = ((EnumConstantDeclaration) node).getName().getStartPosition();
  }
  else if (node instanceof Initializer)
  {
    nodeStart = ((Initializer) node).getBody().getStartPosition();
  }
  else if (node instanceof MethodDeclaration)
  {
    nodeStart = ((MethodDeclaration) node).getName().getStartPosition();
  }
  return ASTTools.lineNumber(node, nodeStart);
}
项目:jive    文件:StatementVisitor.java   
@Override
public boolean visit(final EnumConstantDeclaration node)
{
  // new dependence
  final IResolvedLine rd = createDependence(LK_ENUM_CONSTANT_DECLARATION, lineStart(node),
      mdg.parent());
  // new resolved variable
  final IResolvedData rv = factory.newResolvedVariable(node, ASTTools.enclosingScope(node), null,
      true, false, true);
  // map the enum constant definition
  rd.definitions().add(rv);
  // append call and data dependences
  processCall(rd, node);
  // // map the enum constant constructor binding
  // final IMethodBinding mb = node.resolveConstructorBinding();
  // final IResolvedCall rc = factory.newResolvedCall(node, mb, lineStart(node), null, false,
  // false);
  // rd.uses().add(rc);
  // do not visit children
  return false;
}
项目:jive    文件:ExpressionVisitor.java   
@Override
public boolean visit(final EnumConstantDeclaration node)
{
  // method binding for this creation (with *formal* argument types)
  final IMethodBinding method = node.resolveConstructorBinding().getMethodDeclaration();
  // create the resolved call
  final IResolvedCall rcall = createResolvedCall(node, node.getName().getStartPosition(), method);
  // process the arguments
  if (rcall != null)
  {
    // actual-ins
    processActualParameters(node, node.getName().getStartPosition(), rcall, node.arguments());
    // append the call after all its arguments
    uses.add(rcall);
  }
  // do not visit children
  return false;
}
项目:asup    文件:JDTCallableUnitWriter.java   
@SuppressWarnings("unchecked")
public void writeLabels(Collection<String> labels) {

    if (labels.isEmpty())
        return;

    EnumDeclaration enumType = getAST().newEnumDeclaration();
    enumType.setName(getAST().newSimpleName("TAG"));
    enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
    enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));

    // elements
    int num = 0;

    for (String label : labels) {

        EnumConstantDeclaration constantDeclaration = getAST().newEnumConstantDeclaration();
        constantDeclaration.setName(getAST().newSimpleName(normalizeEnumName(label)));

        enumType.enumConstants().add(num, constantDeclaration);
        num++;
    }

    getTarget().bodyDeclarations().add(enumType);
}
项目:asup    文件:JDTCallableUnitWriter.java   
@SuppressWarnings("unchecked")
public void writeMessages(Collection<String> messages) {

    EnumDeclaration enumType = getAST().newEnumDeclaration();
    enumType.setName(getAST().newSimpleName("QCPFMSG"));
    enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
    enumType.modifiers().add(getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));

    // elements
    int num = 0;

    for (String message : messages) {
        if (message.equalsIgnoreCase("CPF0000"))
            continue;
        EnumConstantDeclaration constantDeclaration = getAST().newEnumConstantDeclaration();
        constantDeclaration.setName(getAST().newSimpleName(normalizeEnumName(message)));

        enumType.enumConstants().add(num, constantDeclaration);
        num++;
    }

    getTarget().bodyDeclarations().add(enumType);
}
项目:asup    文件:JDTNamedNodeWriter.java   
@SuppressWarnings("unchecked")
public void writeEnumField(EnumConstantDeclaration enumField, QSpecialElement elem) {
    AST ast = enumField.getAST();
    NormalAnnotation normalAnnotation = ast.newNormalAnnotation();

    String name = new String("*" + enumField.getName());
    if (elem.getValue() != null && !name.equals(elem.getValue())) {
        normalAnnotation.setTypeName(ast.newSimpleName(Special.class.getSimpleName()));
        MemberValuePair memberValuePair = ast.newMemberValuePair();
        memberValuePair.setName(ast.newSimpleName("value"));
        StringLiteral stringLiteral = ast.newStringLiteral();
        stringLiteral.setLiteralValue(elem.getValue());
        memberValuePair.setValue(stringLiteral);
        normalAnnotation.values().add(memberValuePair);

        enumField.modifiers().add(normalAnnotation);
    }
}