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

项目:eclipse.jdt.ls    文件:ModifierCorrectionSubProcessor.java   
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface, String groupId) {
    ASTNode modifier = findVisibilityModifier(modifiers);
    if (modifier != null) {
        int selected = ((Modifier) modifier).getKeyword().toFlagValue();

        LinkedProposalPositionGroup positionGroup = linkedProposalModel.getPositionGroup(groupId, true);
        positionGroup.addPosition(rewrite.track(modifier), false);
        positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));

        // add all others
        int[] flagValues = inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
        for (int i = 0; i < flagValues.length; i++) {
            if (flagValues[i] != selected) {
                positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
            }
        }
    }
}
项目:code    文件:RemoveAnnotations.java   
private ASTNode getAnnotation(List paramModifiers, String annotation) {
    ASTNode found = null;
    for (Iterator itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        IExtendedModifier o = (IExtendedModifier) itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;

            String name = annot.getTypeName().toString();
            if (name.compareTo(annotation) == 0) {
                found = annot;
                break;
            }
        }
    }
    return found;
}
项目:code    文件:RemoveAnnotations.java   
private ASTNode getAnnotation(List paramModifiers, String annotation) {
    ASTNode found = null;
    for (Iterator itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        IExtendedModifier o = (IExtendedModifier) itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;

            String name = annot.getTypeName().toString();
            if (name.compareTo(annotation) == 0) {
                found = annot;
                break;
            }
        }
    }
    return found;
}
项目:che    文件:NullAnnotationsRewriteOperations.java   
boolean checkExisting(
    List<IExtendedModifier> existingModifiers,
    ListRewrite listRewrite,
    TextEditGroup editGroup) {
  for (Object mod : existingModifiers) {
    if (mod instanceof MarkerAnnotation) {
      MarkerAnnotation annotation = (MarkerAnnotation) mod;
      String existingName = annotation.getTypeName().getFullyQualifiedName();
      int lastDot = fAnnotationToRemove.lastIndexOf('.');
      if (existingName.equals(fAnnotationToRemove)
          || (lastDot != -1
              && fAnnotationToRemove.substring(lastDot + 1).equals(existingName))) {
        if (!fAllowRemove) return false; // veto this change
        listRewrite.remove(annotation, editGroup);
        return true;
      }
      // paranoia: check if by accident the annotation is already present (shouldn't happen):
      lastDot = fAnnotationToAdd.lastIndexOf('.');
      if (existingName.equals(fAnnotationToAdd)
          || (lastDot != -1 && fAnnotationToAdd.substring(lastDot + 1).equals(existingName))) {
        return false; // already present
      }
    }
  }
  return true;
}
项目:che    文件:NullAnnotationsRewriteOperations.java   
private static boolean hasNullAnnotation(MethodDeclaration decl) {
  List<IExtendedModifier> modifiers = decl.modifiers();
  String nonnull =
      NullAnnotationsFix.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
  String nullable =
      NullAnnotationsFix.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
  for (Object mod : modifiers) {
    if (mod instanceof Annotation) {
      Name annotationName = ((Annotation) mod).getTypeName();
      String fullyQualifiedName = annotationName.getFullyQualifiedName();
      if (annotationName.isSimpleName()
          ? nonnull.endsWith(fullyQualifiedName)
          : fullyQualifiedName.equals(nonnull)) return true;
      if (annotationName.isSimpleName()
          ? nullable.endsWith(fullyQualifiedName)
          : fullyQualifiedName.equals(nullable)) return true;
    }
  }
  return false;
}
项目:che    文件:ModifierCorrectionSubProcessor.java   
public static void installLinkedVisibilityProposals(
    LinkedProposalModel linkedProposalModel,
    ASTRewrite rewrite,
    List<IExtendedModifier> modifiers,
    boolean inInterface) {
  ASTNode modifier = findVisibilityModifier(modifiers);
  if (modifier != null) {
    int selected = ((Modifier) modifier).getKeyword().toFlagValue();

    LinkedProposalPositionGroup positionGroup =
        linkedProposalModel.getPositionGroup(KEY_MODIFIER, true);
    positionGroup.addPosition(rewrite.track(modifier), false);
    positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));

    // add all others
    int[] flagValues =
        inInterface
            ? new int[] {Modifier.PUBLIC, 0}
            : new int[] {Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE};
    for (int i = 0; i < flagValues.length; i++) {
      if (flagValues[i] != selected) {
        positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
      }
    }
  }
}
项目:Eclipse-Postfix-Code-Completion    文件:NullAnnotationsRewriteOperations.java   
boolean checkExisting(List<IExtendedModifier> existingModifiers, ListRewrite listRewrite, TextEditGroup editGroup) {
    for (Object mod : existingModifiers) {
        if (mod instanceof MarkerAnnotation) {
            MarkerAnnotation annotation= (MarkerAnnotation) mod;
            String existingName= annotation.getTypeName().getFullyQualifiedName();
            int lastDot= fAnnotationToRemove.lastIndexOf('.');
            if (existingName.equals(fAnnotationToRemove) || (lastDot != -1 && fAnnotationToRemove.substring(lastDot + 1).equals(existingName))) {
                if (!fAllowRemove)
                    return false; // veto this change
                listRewrite.remove(annotation, editGroup);
                return true;
            }
            // paranoia: check if by accident the annotation is already present (shouldn't happen):
            lastDot= fAnnotationToAdd.lastIndexOf('.');
            if (existingName.equals(fAnnotationToAdd) || (lastDot != -1 && fAnnotationToAdd.substring(lastDot + 1).equals(existingName))) {
                return false; // already present
            }
        }
    }
    return true;
}
项目:Eclipse-Postfix-Code-Completion    文件:NullAnnotationsRewriteOperations.java   
private static boolean hasNullAnnotation(MethodDeclaration decl) {
    List<IExtendedModifier> modifiers= decl.modifiers();
    String nonnull= NullAnnotationsFix.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
    String nullable= NullAnnotationsFix.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
    for (Object mod : modifiers) {
        if (mod instanceof Annotation) {
            Name annotationName= ((Annotation) mod).getTypeName();
            String fullyQualifiedName= annotationName.getFullyQualifiedName();
            if (annotationName.isSimpleName() ? nonnull.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nonnull))
                return true;
            if (annotationName.isSimpleName() ? nullable.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nullable))
                return true;
        }
    }
    return false;
}
项目:Eclipse-Postfix-Code-Completion    文件:SurroundWith.java   
/**
 * Split the fragments in <code>statement</code> to multiple VariableDeclarationStatements whenever
 * <code>splitOperator.needsSplit</code> returns <code>true</code>.
 * i.e.:
 * int i, j; ---> int i; int j; (if splitOperator.needsSplit(i, j) == true)
 *
 * @param statement The VariableDeclarationStatement to split
 * @param splitOperator The operator to use to split
 * @param rewrite The rewriter to use to generate new VariableDeclarationStatements.
 */
private void splitVariableDeclarationStatement(VariableDeclarationStatement statement, ISplitOperation splitOperator, ASTRewrite rewrite) {

    List<VariableDeclarationFragment> fragments= statement.fragments();
    Iterator<VariableDeclarationFragment> iter= fragments.iterator();
    VariableDeclarationFragment lastFragment= iter.next();
    VariableDeclarationStatement lastStatement= statement;

    splitOperator.initializeStatement(lastStatement, lastFragment);

    ListRewrite fragmentsRewrite= null;
    while (iter.hasNext()) {
        VariableDeclarationFragment currentFragment= iter.next();

        if (splitOperator.needsSplit(lastFragment, currentFragment)) {

            VariableDeclarationStatement newStatement= getAst().newVariableDeclarationStatement((VariableDeclarationFragment)rewrite.createMoveTarget(currentFragment));

            ListRewrite modifierRewrite= rewrite.getListRewrite(newStatement, VariableDeclarationStatement.MODIFIERS2_PROPERTY);
            for (Iterator<IExtendedModifier> iterator= statement.modifiers().iterator(); iterator.hasNext();) {
                modifierRewrite.insertLast(rewrite.createCopyTarget((ASTNode)iterator.next()), null);
            }

            newStatement.setType((Type)rewrite.createCopyTarget(statement.getType()));

            splitOperator.initializeStatement(newStatement, currentFragment);

            fragmentsRewrite= rewrite.getListRewrite(newStatement, VariableDeclarationStatement.FRAGMENTS_PROPERTY);

            lastStatement= newStatement;
        } else if (fragmentsRewrite != null) {
            ASTNode fragment0= rewrite.createMoveTarget(currentFragment);
            fragmentsRewrite.insertLast(fragment0, null);
        }
        lastFragment= currentFragment;
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:ModifierCorrectionSubProcessor.java   
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface) {
    ASTNode modifier= findVisibilityModifier(modifiers);
    if (modifier != null) {
        int selected= ((Modifier) modifier).getKeyword().toFlagValue();

        LinkedProposalPositionGroup positionGroup= linkedProposalModel.getPositionGroup(KEY_MODIFIER, true);
        positionGroup.addPosition(rewrite.track(modifier), false);
        positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));

        // add all others
        int[] flagValues= inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
        for (int i= 0; i < flagValues.length; i++) {
            if (flagValues[i] != selected) {
                positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
            }
        }
    }
}
项目:EASyProducer    文件:JavaAttribute.java   
/**
 * Makes an attribute constant.
 */
@SuppressWarnings("unchecked")
public void makeConstant() {
    List<IExtendedModifier> modifierList = fieldDeclaration.modifiers();
    logger.debug("Trying to make attribute '" + attributeName + "' constant...");
    /*
     * Test if modifier already exists. If they don't exist than add them to the modifier list.
     */
    if (testIfModifierExists(ModifierKeyword.STATIC_KEYWORD, modifierList)) {
        logger.debug("modifier 'static' already exists");
    } else {
        modifierList.add(fieldDeclaration.getAST().newModifier(Modifier.ModifierKeyword.STATIC_KEYWORD));
        logger.debug("Added 'static' modifier to '" + attributeName + "'");
    }
    if (testIfModifierExists(ModifierKeyword.FINAL_KEYWORD, modifierList)) {
        logger.debug("modifier 'final' already exists...");
    } else {
        modifierList.add(fieldDeclaration.getAST().newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
        logger.debug("Added 'final' modifier to '" + attributeName + "'");
    }
    notifyChanged();
}
项目:EASyProducer    文件:JavaAttribute.java   
/**
 * Makes a constant attribute variable.
 */
@SuppressWarnings("unchecked")
public void makeVariable() {
    List<IExtendedModifier> modifierList = fieldDeclaration.modifiers();
    List<IExtendedModifier> removeList = new ArrayList<IExtendedModifier>();
    logger.debug("Trying to make attribute '" + attributeName + "' variable...");
    for (Object modifier : modifierList) {
        /*
         * Mark modifier for deletion if it exists. To avoid NoSuchElementException this modifier will be put in a
         * separate list and will be removed later.
         */
        if (modifier.toString().equals(Modifier.ModifierKeyword.FINAL_KEYWORD.toString())
                || modifier.toString().equals(Modifier.ModifierKeyword.STATIC_KEYWORD.toString())) {
            logger.debug("'" + modifier + "' flagged for deletion...");
            removeList.add((IExtendedModifier) modifier);
        }
    }
    logger.debug("Remove modifiers...");
    modifierList.removeAll(removeList);
    notifyChanged();
}
项目:EASyProducer    文件:JavaParentFragmentArtifact.java   
/**
 * Returns the annotations for a given <code>modifierList</code>.
 * 
 * @param modifierList the modifier list to be processed
 * @return An ArraySet with all annotations
 */
@OperationMeta(returnGenerics = JavaAnnotation.class)
public Set<JavaAnnotation> annotations(List<IExtendedModifier> modifierList) {
    List<JavaAnnotation> list = new ArrayList<JavaAnnotation>();
    for (Object modifier : modifierList) {
        if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) {
            org.eclipse.jdt.core.dom.Annotation annot = (org.eclipse.jdt.core.dom.Annotation) modifier;
            // Get annotation name and value
            Map<String, String> fields = new HashMap<String, String>();
            // possibly the unqualified name as not resolved unless not given as qualified name!
            String name = annot.getTypeName().getFullyQualifiedName(); 
            if (annot instanceof SingleMemberAnnotation) {
                fields.put(JavaAnnotation.DEFAULT_FIELD, 
                    toString(((SingleMemberAnnotation) modifier).getValue()));
            } else if (annot instanceof NormalAnnotation) {
                @SuppressWarnings("unchecked")
                List<MemberValuePair> values = ((NormalAnnotation) annot).values();
                for (MemberValuePair pair : values) {
                    fields.put(pair.getName().getIdentifier(), toString(pair.getValue()));
                }
            }
            list.add(new JavaAnnotation(name, fields, this));
        }
    }
    return new ArraySet<JavaAnnotation>(list.toArray(new JavaAnnotation[list.size()]), JavaAnnotation.class);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:SurroundWith.java   
/**
 * Split the fragments in <code>statement</code> to multiple VariableDeclarationStatements whenever
 * <code>splitOperator.needsSplit</code> returns <code>true</code>.
 * i.e.:
 * int i, j; ---> int i; int j; (if splitOperator.needsSplit(i, j) == true)
 *
 * @param statement The VariableDeclarationStatement to split
 * @param splitOperator The operator to use to split
 * @param rewrite The rewriter to use to generate new VariableDeclarationStatements.
 */
private void splitVariableDeclarationStatement(VariableDeclarationStatement statement, ISplitOperation splitOperator, ASTRewrite rewrite) {

    List<VariableDeclarationFragment> fragments= statement.fragments();
    Iterator<VariableDeclarationFragment> iter= fragments.iterator();
    VariableDeclarationFragment lastFragment= iter.next();
    VariableDeclarationStatement lastStatement= statement;

    splitOperator.initializeStatement(lastStatement, lastFragment);

    ListRewrite fragmentsRewrite= null;
    while (iter.hasNext()) {
        VariableDeclarationFragment currentFragment= iter.next();

        if (splitOperator.needsSplit(lastFragment, currentFragment)) {

            VariableDeclarationStatement newStatement= getAst().newVariableDeclarationStatement((VariableDeclarationFragment)rewrite.createMoveTarget(currentFragment));

            ListRewrite modifierRewrite= rewrite.getListRewrite(newStatement, VariableDeclarationStatement.MODIFIERS2_PROPERTY);
            for (Iterator<IExtendedModifier> iterator= statement.modifiers().iterator(); iterator.hasNext();) {
                modifierRewrite.insertLast(rewrite.createCopyTarget((ASTNode)iterator.next()), null);
            }

            newStatement.setType((Type)rewrite.createCopyTarget(statement.getType()));

            splitOperator.initializeStatement(newStatement, currentFragment);

            fragmentsRewrite= rewrite.getListRewrite(newStatement, VariableDeclarationStatement.FRAGMENTS_PROPERTY);

            lastStatement= newStatement;
        } else if (fragmentsRewrite != null) {
            ASTNode fragment0= rewrite.createMoveTarget(currentFragment);
            fragmentsRewrite.insertLast(fragment0, null);
        }
        lastFragment= currentFragment;
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:ModifierCorrectionSubProcessor.java   
public static void installLinkedVisibilityProposals(LinkedProposalModel linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface) {
    ASTNode modifier= findVisibilityModifier(modifiers);
    if (modifier != null) {
        int selected= ((Modifier) modifier).getKeyword().toFlagValue();

        LinkedProposalPositionGroup positionGroup= linkedProposalModel.getPositionGroup(KEY_MODIFIER, true);
        positionGroup.addPosition(rewrite.track(modifier), false);
        positionGroup.addProposal(new ModifierLinkedModeProposal(selected, 10));

        // add all others
        int[] flagValues= inInterface ? new int[] { Modifier.PUBLIC, 0 } : new int[] { Modifier.PUBLIC, 0, Modifier.PROTECTED, Modifier.PRIVATE };
        for (int i= 0; i < flagValues.length; i++) {
            if (flagValues[i] != selected) {
                positionGroup.addProposal(new ModifierLinkedModeProposal(flagValues[i], 9 - i));
            }
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NullRewriteOperations.java   
boolean checkExisting(List<IExtendedModifier> existingModifiers, ListRewrite listRewrite, TextEditGroup editGroup) {
    for (Object mod : existingModifiers) {
        if (mod instanceof MarkerAnnotation) {
            MarkerAnnotation annotation= (MarkerAnnotation) mod;
            String existingName= annotation.getTypeName().getFullyQualifiedName();
            int lastDot= fAnnotationToRemove.lastIndexOf('.');
            if (existingName.equals(fAnnotationToRemove) || (lastDot != -1 && fAnnotationToRemove.substring(lastDot + 1).equals(existingName))) {
                if (!fAllowRemove)
                    return false; // veto this change
                listRewrite.remove(annotation, editGroup);
                return true;
            }
            // paranoia: check if by accident the annotation is already present (shouldn't happen):
            lastDot= fAnnotationToAdd.lastIndexOf('.');
            if (existingName.equals(fAnnotationToAdd) || (lastDot != -1 && fAnnotationToAdd.substring(lastDot + 1).equals(existingName))) {
                return false; // already present
            }
        }
    }
    return true;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:NullRewriteOperations.java   
private static boolean hasNullAnnotation(MethodDeclaration decl) {
    List<IExtendedModifier> modifiers= decl.modifiers();
    String nonnull= NullQuickFixes.getNonNullAnnotationName(decl.resolveBinding().getJavaElement(), false);
    String nullable= NullQuickFixes.getNullableAnnotationName(decl.resolveBinding().getJavaElement(), false);
    for (Object mod : modifiers) {
        if (mod instanceof Annotation) {
            Name annotationName= ((Annotation) mod).getTypeName();
            String fullyQualifiedName= annotationName.getFullyQualifiedName();
            if (annotationName.isSimpleName() ? nonnull.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nonnull))
                return true;
            if (annotationName.isSimpleName() ? nullable.endsWith(fullyQualifiedName) : fullyQualifiedName.equals(nullable))
                return true;
        }
    }
    return false;
}
项目:jenkins.py    文件:MethodMaker.java   
/**
 * Sets the public modifier and deletes the protected one.
 */
private void setPublic(MethodDeclaration md) {
    // if already public, do nothing
    if (isPublic(md)) {
        return;
    }
    // set public
    Modifier modifier = ast.newModifier(ModifierKeyword.fromFlagValue(Modifier.PUBLIC));
    md.modifiers().add(0, modifier);
    // delete protected
    for (int i = 0; i < md.modifiers().size(); i++) {
        if (((IExtendedModifier)md.modifiers().get(i)).isModifier()) {
            Modifier m = (Modifier)md.modifiers().get(i);
            if (m.isProtected()) {
                m.delete();
                break;
            }
        }
    }
}
项目:eclipse-optimus    文件:ASTHelper.java   
/**
 * Return an Annotation instance used on this body declaration
 */
public static Annotation getAnnotation(String annotationName,
        BodyDeclaration bodyDeclaration) {
    List<?> modifiers = bodyDeclaration.modifiers();

    // Test if this MethodDeclaration contains modifiers
    if (modifiers != null) {
        Iterator<?> modifiersIterator = modifiers.iterator();

        while (modifiersIterator.hasNext()) {
            IExtendedModifier modifier = (IExtendedModifier) modifiersIterator
                    .next();

            if (modifier.isAnnotation()) {
                Annotation a = (Annotation) modifier;
                String annotationType = a.getTypeName().toString();

                if (annotationType.endsWith(annotationName)) {
                    return a;
                }
            }
        }
    }

    return null;
}
项目:SparkBuilderGenerator    文件:ClassFieldCollector.java   
private boolean isStatic(FieldDeclaration field) {
    List<IExtendedModifier> fieldModifiers = field.modifiers();
    return fieldModifiers.stream()
            .filter(modifier -> modifier instanceof Modifier)
            .filter(modifer -> ((Modifier) modifer).getKeyword().equals(ModifierKeyword.STATIC_KEYWORD))
            .findFirst()
            .isPresent();
}
项目:SparkBuilderGenerator    文件:BodyDeclarationVisibleFromPredicate.java   
private JavaVisibilityScopeModifier getFieldModifier(BodyDeclaration fieldDeclaration) {
    return ((List<IExtendedModifier>) fieldDeclaration.modifiers())
            .stream()
            .filter(modifier -> modifier instanceof Modifier)
            .map(modifier -> ((Modifier) modifier).getKeyword().toString())
            .filter(modifierKeyword -> JavaVisibilityScopeModifier.isValid(modifierKeyword))
            .map(modifierKeyword -> JavaVisibilityScopeModifier.convert(modifierKeyword))
            .filter(Optional::isPresent)
            .map(Optional::get)
            .findFirst()
            .orElse(JavaVisibilityScopeModifier.DEFAULT_MODIFIER);
}
项目:SparkBuilderGenerator    文件:StaticBuilderMethodRemover.java   
private boolean isPublic(MethodDeclaration method) {
    return ((List<IExtendedModifier>) method.modifiers())
            .stream()
            .filter(modifier -> modifier instanceof Modifier)
            .filter(modifier -> ((Modifier) modifier).equals(Modifier.PUBLIC))
            .findFirst()
            .isPresent();
}
项目:SparkBuilderGenerator    文件:GenericModifierPredicate.java   
public boolean test(BodyDeclaration method, Predicate<IExtendedModifier> modifiedPredicate) {
    return ((List<IExtendedModifier>) method.modifiers())
            .stream()
            .filter(modifier -> modifier instanceof Modifier)
            .filter(modifiedPredicate)
            .findFirst()
            .isPresent();
}
项目:SparkBuilderGenerator    文件:GeneratedAnnotationPredicate.java   
@Override
public boolean test(BodyDeclaration bodyDeclaration) {
    return ((List<IExtendedModifier>) bodyDeclaration.modifiers())
            .stream()
            .filter(modifier -> modifier instanceof SingleMemberAnnotation)
            .map(modifier -> (SingleMemberAnnotation) modifier)
            .filter(modifier -> isGeneratedAnnotation(modifier))
            .filter(modifier -> modifier.getValue() instanceof StringLiteral)
            .filter(annotation -> ((StringLiteral) annotation.getValue()).getLiteralValue().equals(PLUGIN_GENERATED_ANNOTATION_NAME))
            .findFirst()
            .isPresent();
}
项目:eclipse.jdt.ls    文件:ModifierCorrectionSubProcessor.java   
private static Modifier findVisibilityModifier(List<IExtendedModifier> modifiers) {
    for (int i = 0; i < modifiers.size(); i++) {
        IExtendedModifier curr = modifiers.get(i);
        if (curr instanceof Modifier) {
            Modifier modifier = (Modifier) curr;
            ModifierKeyword keyword = modifier.getKeyword();
            if (keyword == ModifierKeyword.PUBLIC_KEYWORD || keyword == ModifierKeyword.PROTECTED_KEYWORD || keyword == ModifierKeyword.PRIVATE_KEYWORD) {
                return modifier;
            }
        }
    }
    return null;
}
项目:eclipse.jdt.ls    文件:ASTNodes.java   
public static List<IExtendedModifier> getModifiers(VariableDeclaration declaration) {
    Assert.isNotNull(declaration);
    if (declaration instanceof SingleVariableDeclaration) {
        return ((SingleVariableDeclaration)declaration).modifiers();
    } else if (declaration instanceof VariableDeclarationFragment) {
        ASTNode parent= declaration.getParent();
        if (parent instanceof VariableDeclarationExpression) {
            return ((VariableDeclarationExpression)parent).modifiers();
        } else if (parent instanceof VariableDeclarationStatement) {
            return ((VariableDeclarationStatement)parent).modifiers();
        }
    }
    return new ArrayList<>(0);
}
项目:eclipse.jdt.ls    文件:ASTNodes.java   
public static Modifier findModifierNode(int flag, List<IExtendedModifier> modifiers) {
    for (int i= 0; i < modifiers.size(); i++) {
        Object curr= modifiers.get(i);
        if (curr instanceof Modifier && ((Modifier) curr).getKeyword().toFlagValue() == flag) {
            return (Modifier) curr;
        }
    }
    return null;
}
项目:eclipse.jdt.ls    文件:ASTNodeFactory.java   
/**
 * Returns a list of newly created Modifier nodes corresponding to a given list of existing modifiers.
 * @param ast The AST to create the nodes for.
 * @param modifierNodes The modifier nodes describing the modifier nodes to create. Only
 * nodes of type {@link Modifier} are looked at and cloned. To create a full copy of the list consider
 * to use {@link ASTNode#copySubtrees(AST, List)}.
 * @return Returns a list of nodes of type {@link Modifier}.
 */
public static List<Modifier> newModifiers(AST ast, List<? extends IExtendedModifier> modifierNodes) {
    List<Modifier> res= new ArrayList<>(modifierNodes.size());
    for (int i= 0; i < modifierNodes.size(); i++) {
        Object curr= modifierNodes.get(i);
        if (curr instanceof Modifier) {
            res.add(ast.newModifier(((Modifier) curr).getKeyword()));
        }
    }
    return res;
}
项目:eclipse.jdt.ls    文件:StubUtility2.java   
public static Annotation findAnnotation(String qualifiedTypeName, List<IExtendedModifier> modifiers) {
    for (int i= 0; i < modifiers.size(); i++) {
        IExtendedModifier curr= modifiers.get(i);
        if (curr instanceof Annotation) {
            Annotation annot= (Annotation) curr;
            ITypeBinding binding= annot.getTypeName().resolveTypeBinding();
            if (binding != null && qualifiedTypeName.equals(binding.getQualifiedName())) {
                return annot;
            }
        }
    }
    return null;
}
项目:code    文件:AnnotatMetrics.java   
private boolean hasAnnotation(List<IExtendedModifier> paramModifiers) {
    boolean found = false;
    for (Iterator<IExtendedModifier> itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        Object o = itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
            String name = annot.getTypeName().toString();
            if (name.compareTo("Domain") == 0) {
                found = true;
            }
        }
    }
    return found;
}
项目:code    文件:AnnotatMetrics.java   
public List<String> getAnnotationList(List<IExtendedModifier> paramModifiers, String annotation) {  
    List<String> found = new ArrayList<String>();

    for (IExtendedModifier o:paramModifiers){
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
            if (annot.getTypeName().toString().equals(annotation)) {

                Expression value = annot.getValue();
                if (value instanceof ArrayInitializer) { //@Domains( {"D", "U"})
                    ArrayInitializer annotValueArray = (ArrayInitializer)value;
                    found = new ArrayList<String>();
                    for (Object s:annotValueArray.expressions()){
                        if (s instanceof StringLiteral) {
                            StringLiteral sLiteral = (StringLiteral)s;
                            found.add(sLiteral.getLiteralValue());
                        }
                    }
                    return found;
                }
                if (value instanceof StringLiteral) { //@Domains ("D")
                    StringLiteral annotValue = (StringLiteral)value;
                    String parserInput = annotValue.getLiteralValue();
                    found = new ArrayList<String>();
                    found.add(parserInput);
                    return found;
                }
            }
        }
    }
    return found;
}
项目:code    文件:SaveAnnotations.java   
private SingleMemberAnnotation getCurrentAnnotation(List<IExtendedModifier> paramModifiers) {
    SingleMemberAnnotation currentAnnotation = null;
    if(paramModifiers != null)
    for (Iterator<IExtendedModifier> itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        Object o = itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
            if (annot.getTypeName().toString().compareTo("Domain") == 0) {
                currentAnnotation = annot;
                break;
            }
        }
    }
    return currentAnnotation;
}
项目:code    文件:SaveAnnotations.java   
private ASTNode hasTypeAnnotation(List<IExtendedModifier> paramModifiers, String annotation) {
    ASTNode found = null;
    for (Iterator<IExtendedModifier> itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        Object o = itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
            String name = annot.getTypeName().toString();
            if (name.compareTo(annotation) == 0) {
                found = annot;
                break;
            }
        }
    }
    return found;
}
项目:code    文件:SaveAnnotations.java   
private SingleMemberAnnotation getCurrentAnnotation(List<IExtendedModifier> paramModifiers) {
    SingleMemberAnnotation currentAnnotation = null;
    if(paramModifiers != null)
    for (Iterator<IExtendedModifier> itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        Object o = itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
            if (annot.getTypeName().toString().compareTo("Domain") == 0) {
                currentAnnotation = annot;
                break;
            }
        }
    }
    return currentAnnotation;
}
项目:code    文件:SaveAnnotations.java   
private ASTNode hasTypeAnnotation(List<IExtendedModifier> paramModifiers, String annotation) {
    ASTNode found = null;
    for (Iterator<IExtendedModifier> itParamModifiers = paramModifiers.iterator(); itParamModifiers.hasNext();) {
        Object o = itParamModifiers.next();
        if (o instanceof SingleMemberAnnotation) {
            SingleMemberAnnotation annot = (SingleMemberAnnotation) o;
            String name = annot.getTypeName().toString();
            if (name.compareTo(annotation) == 0) {
                found = annot;
                break;
            }
        }
    }
    return found;
}
项目:jsr305CleanUp    文件:Jsr305CleanUp.java   
private static Annotation findAnnotation(final List<IExtendedModifier> modifiers, final String className) {
    for (final IExtendedModifier modifier : modifiers) {
        if (modifier.isAnnotation()) {
            final Annotation anno = (Annotation) modifier;
            final String fqn = anno.resolveTypeBinding().getQualifiedName();
            if (className.equals(fqn)) {
                return anno;
            }
        }
    }
    return null;
}
项目:che    文件:ModifierRewrite.java   
public void copyAllAnnotations(ASTNode otherDecl, TextEditGroup editGroup) {
  ListRewrite modifierList = evaluateListRewrite(fModifierRewrite.getASTRewrite(), otherDecl);
  List<IExtendedModifier> originalList = modifierList.getOriginalList();

  for (Iterator<IExtendedModifier> iterator = originalList.iterator(); iterator.hasNext(); ) {
    IExtendedModifier modifier = iterator.next();
    if (modifier.isAnnotation()) {
      fModifierRewrite.insertLast(
          fModifierRewrite.getASTRewrite().createCopyTarget((Annotation) modifier), editGroup);
    }
  }
}
项目:che    文件:ASTNodeFactory.java   
/**
 * Returns a list of newly created Modifier nodes corresponding to a given list of existing
 * modifiers.
 *
 * @param ast The AST to create the nodes for.
 * @param modifierNodes The modifier nodes describing the modifier nodes to create. Only nodes of
 *     type {@link Modifier} are looked at and cloned. To create a full copy of the list consider
 *     to use {@link ASTNode#copySubtrees(AST, List)}.
 * @return Returns a list of nodes of type {@link Modifier}.
 */
public static List<Modifier> newModifiers(
    AST ast, List<? extends IExtendedModifier> modifierNodes) {
  List<Modifier> res = new ArrayList<Modifier>(modifierNodes.size());
  for (int i = 0; i < modifierNodes.size(); i++) {
    Object curr = modifierNodes.get(i);
    if (curr instanceof Modifier) {
      res.add(ast.newModifier(((Modifier) curr).getKeyword()));
    }
  }
  return res;
}
项目:che    文件:ExtractConstantRefactoring.java   
private Iterator<ASTNode> getReplacementScope() throws JavaModelException {
  boolean declPredecessorReached = false;

  Collection<ASTNode> scope = new ArrayList<ASTNode>();

  AbstractTypeDeclaration containingType = getContainingTypeDeclarationNode();
  if (containingType instanceof EnumDeclaration) {
    // replace in all enum constants bodies
    EnumDeclaration enumDeclaration = (EnumDeclaration) containingType;
    scope.addAll(enumDeclaration.enumConstants());
  }

  for (Iterator<IExtendedModifier> iter = containingType.modifiers().iterator();
      iter.hasNext(); ) {
    IExtendedModifier modifier = iter.next();
    if (modifier instanceof Annotation) {
      scope.add((ASTNode) modifier);
    }
  }

  for (Iterator<BodyDeclaration> bodyDeclarations = containingType.bodyDeclarations().iterator();
      bodyDeclarations.hasNext(); ) {
    BodyDeclaration bodyDeclaration = bodyDeclarations.next();

    if (bodyDeclaration == getNodeToInsertConstantDeclarationAfter())
      declPredecessorReached = true;

    if (insertFirst()
        || declPredecessorReached
        || !isStaticFieldOrStaticInitializer(bodyDeclaration)) scope.add(bodyDeclaration);
  }
  return scope.iterator();
}
项目:che    文件:TypeContextChecker.java   
private static void appendModifiers(StringBuffer buf, List<IExtendedModifier> modifiers) {
  for (Iterator<IExtendedModifier> iterator = modifiers.iterator(); iterator.hasNext(); ) {
    IExtendedModifier extendedModifier = iterator.next();
    if (extendedModifier.isModifier()) {
      Modifier modifier = (Modifier) extendedModifier;
      buf.append(modifier.getKeyword().toString()).append(' ');
    }
  }
}