org.eclipse.jdt.core.dom.IExtendedModifier Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.IExtendedModifier.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 6 votes |
public boolean visit(VariableDeclarationStatement stmnt) { /* { ExtendedModifier } Type VariableDeclarationFragment { , VariableDeclarationFragment } ; */ // Append modifiers if applicable for (int i = 0; i < stmnt.modifiers().size(); i++) { handleModifier((IExtendedModifier) stmnt.modifiers().get(i)); appendSpace(); } // Append Type handleType(stmnt.getType()); appendSpace(); // Visit Fragments for (int i = 0; i < stmnt.fragments().size(); i++) { visit((VariableDeclarationFragment) stmnt.fragments().get(i)); if(i < stmnt.fragments().size() - 1) { appendComma(); } } appendSemicolon(); return false; }
Example #2
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 6 votes |
public boolean visit(VariableDeclarationExpression expr) { /* VariableDeclarationExpression: { ExtendedModifier } Type VariableDeclarationFragment { , VariableDeclarationFragment } */ activateDiffStyle(expr); // Append modifiers for (int i = 0; i < expr.modifiers().size(); i++) { handleModifier((IExtendedModifier) expr.modifiers().get(i)); appendSpace(); } // Append Type handleType(expr.getType()); appendSpace(); // Visit Fragments for (int i = 0; i < expr.fragments().size(); i++) { visit((VariableDeclarationFragment) expr.fragments().get(i)); if(i < expr.fragments().size() - 1) { appendComma(); } } // No semicolon needed as this is an expression deactivateDiffStyle(expr); return false; }
Example #3
Source File: ModifierCorrectionSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 6 votes |
public static void installLinkedVisibilityProposals(LinkedProposalModelCore linkedProposalModel, ASTRewrite rewrite, List<IExtendedModifier> modifiers, boolean inInterface, String groupId) { ASTNode modifier = findVisibilityModifier(modifiers); if (modifier != null) { int selected = ((Modifier) modifier).getKeyword().toFlagValue(); LinkedProposalPositionGroupCore 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)); } } } }
Example #4
Source File: VariableDeclaration.java From RefactoringMiner with MIT License | 6 votes |
public VariableDeclaration(CompilationUnit cu, String filePath, SingleVariableDeclaration fragment) { this.annotations = new ArrayList<UMLAnnotation>(); List<IExtendedModifier> extendedModifiers = fragment.modifiers(); for(IExtendedModifier extendedModifier : extendedModifiers) { if(extendedModifier.isAnnotation()) { Annotation annotation = (Annotation)extendedModifier; this.annotations.add(new UMLAnnotation(cu, filePath, annotation)); } } this.locationInfo = new LocationInfo(cu, filePath, fragment, extractVariableDeclarationType(fragment)); this.variableName = fragment.getName().getIdentifier(); this.initializer = fragment.getInitializer() != null ? new AbstractExpression(cu, filePath, fragment.getInitializer(), CodeElementType.VARIABLE_DECLARATION_INITIALIZER) : null; Type astType = extractType(fragment); this.type = UMLType.extractTypeObject(cu, filePath, astType, fragment.getExtraDimensions()); int startOffset = fragment.getStartPosition(); ASTNode scopeNode = getScopeNode(fragment); int endOffset = scopeNode.getStartPosition() + scopeNode.getLength(); this.scope = new VariableScope(cu, filePath, startOffset, endOffset); }
Example #5
Source File: UMLModelASTReader.java From RefactoringMiner with MIT License | 6 votes |
private void processModifiers(CompilationUnit cu, String sourceFile, AbstractTypeDeclaration typeDeclaration, UMLClass umlClass) { int modifiers = typeDeclaration.getModifiers(); if((modifiers & Modifier.ABSTRACT) != 0) umlClass.setAbstract(true); if((modifiers & Modifier.PUBLIC) != 0) umlClass.setVisibility("public"); else if((modifiers & Modifier.PROTECTED) != 0) umlClass.setVisibility("protected"); else if((modifiers & Modifier.PRIVATE) != 0) umlClass.setVisibility("private"); else umlClass.setVisibility("package"); List<IExtendedModifier> extendedModifiers = typeDeclaration.modifiers(); for(IExtendedModifier extendedModifier : extendedModifiers) { if(extendedModifier.isAnnotation()) { Annotation annotation = (Annotation)extendedModifier; umlClass.addAnnotation(new UMLAnnotation(cu, sourceFile, annotation)); } } }
Example #6
Source File: ModifierCorrectionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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)); } } } }
Example #7
Source File: NullAnnotationsRewriteOperations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example #8
Source File: NullAnnotationsRewriteOperations.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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; }
Example #9
Source File: ClassFieldCollector.java From SparkBuilderGenerator with MIT License | 5 votes |
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(); }
Example #10
Source File: MethodUtils.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static boolean hasOverrideAnnotation(final MethodDeclaration node) { final List modifiers = node.modifiers(); for (final Object mod : modifiers) { final IExtendedModifier modifier = (IExtendedModifier) mod; if (modifier.isAnnotation()) { final Annotation annotation = (Annotation) modifier; if (annotation.getTypeName().toString().equals("Override")) { return true; } } } return false; }
Example #11
Source File: ExtractClassRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void fieldCreated(CompilationUnitRewrite cuRewrite, FieldDeclaration field, ParameterInfo pi) { FieldInfo fieldInfo= getFieldInfo(pi.getOldName()); FieldDeclaration parent= (FieldDeclaration) fieldInfo.declaration.getParent(); List<IExtendedModifier> modifiers= parent.modifiers(); ListRewrite listRewrite= cuRewrite.getASTRewrite().getListRewrite(field, FieldDeclaration.MODIFIERS2_PROPERTY); for (Iterator<IExtendedModifier> iterator= modifiers.iterator(); iterator.hasNext();) { IExtendedModifier mod= iterator.next(); //Temporarily disabled until initialization of final fields is handled correctly // if (mod.isModifier()) { // Modifier modifier= (Modifier) mod; // if (modifier.isFinal()) // listRewrite.insertLast(moveNode(cuRewrite, modifier), null); // } if (mod.isAnnotation()) { listRewrite.insertFirst(moveNode(cuRewrite, (ASTNode) mod), null); } } if (fieldInfo.initializer != null && fieldInfo.hasFieldReference()) { List<VariableDeclarationFragment> fragments= field.fragments(); for (Iterator<VariableDeclarationFragment> iterator= fragments.iterator(); iterator.hasNext();) { VariableDeclarationFragment vdf= iterator.next(); vdf.setInitializer((Expression) moveNode(cuRewrite, fieldInfo.initializer)); } } if (parent.getJavadoc() != null) { field.setJavadoc((Javadoc) moveNode(cuRewrite, parent.getJavadoc())); } }
Example #12
Source File: ExtractConstantRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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(); }
Example #13
Source File: TypeContextChecker.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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(' '); } } }
Example #14
Source File: ASTNodes.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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<IExtendedModifier>(0); }
Example #15
Source File: ASTNodes.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; }
Example #16
Source File: ModifierRewrite.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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); } } }
Example #17
Source File: ASTNodeFactory.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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; }
Example #18
Source File: SurroundWith.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * 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; } }
Example #19
Source File: ModifierCorrectionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
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; }
Example #20
Source File: ModifierCorrectionSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private 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; }
Example #21
Source File: MoveMethodRefactoring.java From JDeodorant with MIT License | 5 votes |
private void setPublicModifierToSourceMethod(IMethodBinding methodBinding, TypeDeclaration sourceTypeDeclaration) { MethodDeclaration[] methodDeclarations = sourceTypeDeclaration.getMethods(); for(MethodDeclaration methodDeclaration : methodDeclarations) { if(methodDeclaration.resolveBinding().isEqualTo(methodBinding)) { CompilationUnit sourceCompilationUnit = RefactoringUtility.findCompilationUnit(methodDeclaration); ASTRewrite sourceRewriter = ASTRewrite.create(sourceCompilationUnit.getAST()); ListRewrite modifierRewrite = sourceRewriter.getListRewrite(methodDeclaration, MethodDeclaration.MODIFIERS2_PROPERTY); Modifier publicModifier = methodDeclaration.getAST().newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); boolean modifierFound = false; List<IExtendedModifier> modifiers = methodDeclaration.modifiers(); for(IExtendedModifier extendedModifier : modifiers) { if(extendedModifier.isModifier()) { Modifier modifier = (Modifier)extendedModifier; if(modifier.getKeyword().equals(Modifier.ModifierKeyword.PUBLIC_KEYWORD)) { modifierFound = true; } else if(modifier.getKeyword().equals(Modifier.ModifierKeyword.PRIVATE_KEYWORD)) { modifierFound = true; modifierRewrite.replace(modifier, publicModifier, null); updateAccessModifier(sourceRewriter, sourceCompilationUnit); } else if(modifier.getKeyword().equals(Modifier.ModifierKeyword.PROTECTED_KEYWORD)) { modifierFound = true; IPackageBinding targetTypeDeclarationPackageBinding = this.targetTypeDeclaration.resolveBinding().getPackage(); IPackageBinding typeDeclarationPackageBinding = sourceTypeDeclaration.resolveBinding().getPackage(); if(targetTypeDeclarationPackageBinding != null && typeDeclarationPackageBinding != null && !targetTypeDeclarationPackageBinding.isEqualTo(typeDeclarationPackageBinding)) { modifierRewrite.replace(modifier, publicModifier, null); updateAccessModifier(sourceRewriter, sourceCompilationUnit); } } } } if(!modifierFound) { modifierRewrite.insertFirst(publicModifier, null); updateAccessModifier(sourceRewriter, sourceCompilationUnit); } } } }
Example #22
Source File: StyledStringVisitor.java From JDeodorant with MIT License | 5 votes |
private void handleModifier(IExtendedModifier extendedModifier) { if(extendedModifier instanceof Modifier) { visit((Modifier) extendedModifier); } else if(extendedModifier instanceof MarkerAnnotation) { visit((MarkerAnnotation) extendedModifier); } else if(extendedModifier instanceof NormalAnnotation) { visit((NormalAnnotation) extendedModifier); } else if(extendedModifier instanceof SingleMemberAnnotation) { visit((SingleMemberAnnotation) extendedModifier); } }
Example #23
Source File: MethodUtils.java From codemining-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
public static boolean hasOverrideAnnotation(final MethodDeclaration node) { final List modifiers = node.modifiers(); for (final Object mod : modifiers) { final IExtendedModifier modifier = (IExtendedModifier) mod; if (modifier.isAnnotation()) { final Annotation annotation = (Annotation) modifier; if (annotation.getTypeName().toString().equals("Override")) { return true; } } } return false; }
Example #24
Source File: SharedUtils.java From txtUML with Eclipse Public License 1.0 | 5 votes |
public static IAnnotationBinding obtainAnnotationBinding(BodyDeclaration declaration, Class<?> annotationClass) { for (Object mod : declaration.modifiers()) { IExtendedModifier modifier = (IExtendedModifier) mod; if (modifier.isAnnotation()) { Annotation annotation = (Annotation) modifier; if (identicalAnnotations(annotation, annotationClass)) { return annotation.resolveAnnotationBinding(); } } } return null; }
Example #25
Source File: BodyDeclarationVisibleFromPredicate.java From SparkBuilderGenerator with MIT License | 5 votes |
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); }
Example #26
Source File: GenericModifierPredicate.java From SparkBuilderGenerator with MIT License | 5 votes |
public boolean test(BodyDeclaration method, Predicate<IExtendedModifier> modifiedPredicate) { return ((List<IExtendedModifier>) method.modifiers()) .stream() .filter(modifier -> modifier instanceof Modifier) .filter(modifiedPredicate) .findFirst() .isPresent(); }
Example #27
Source File: GeneratedAnnotationPredicate.java From SparkBuilderGenerator with MIT License | 5 votes |
@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(); }
Example #28
Source File: JsonDeserializeRemover.java From SparkBuilderGenerator with MIT License | 5 votes |
@Override public void remove(ASTRewrite rewriter, TypeDeclaration mainType) { if (preferencesManager.getPreferenceValue(ADD_JACKSON_DESERIALIZE_ANNOTATION)) { ((List<IExtendedModifier>) mainType.modifiers()) .stream() .filter(modifier -> modifier instanceof NormalAnnotation) .map(modifier -> (NormalAnnotation) modifier) .filter(annotation -> annotation.getTypeName().toString().equals(JSON_DESERIALIZE_CLASS_NAME)) .filter(annotation -> isBuilderDeserializer(annotation)) .findFirst() .ifPresent(annotation -> removeAnnotation(annotation, rewriter, mainType)); } }
Example #29
Source File: ModifierCorrectionSubProcessor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
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; }
Example #30
Source File: ModifierRewrite.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
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); } } }