org.eclipse.jdt.core.dom.NormalAnnotation Java Examples
The following examples show how to use
org.eclipse.jdt.core.dom.NormalAnnotation.
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(NormalAnnotation annotation) { /* * NormalAnnotation: @ TypeName ( [ MemberValuePair { , MemberValuePair } ] ) */ activateDiffStyle(annotation); appendAtSign(); handleExpression(annotation.getTypeName()); appendOpenParenthesis(); for(int i=0; i<annotation.values().size(); i++) { visit((MemberValuePair) annotation.values().get(i)); if(i < annotation.values().size() - 1) { appendComma(); } } appendClosedParenthesis(); deactivateDiffStyle(annotation); return false; }
Example #2
Source File: MissingAnnotationAttributesProposal.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected ASTRewrite getRewrite() throws CoreException { AST ast= fAnnotation.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); createImportRewrite((CompilationUnit) fAnnotation.getRoot()); ListRewrite listRewrite; if (fAnnotation instanceof NormalAnnotation) { listRewrite= rewrite.getListRewrite(fAnnotation, NormalAnnotation.VALUES_PROPERTY); } else { NormalAnnotation newAnnotation= ast.newNormalAnnotation(); newAnnotation.setTypeName((Name) rewrite.createMoveTarget(fAnnotation.getTypeName())); rewrite.replace(fAnnotation, newAnnotation, null); listRewrite= rewrite.getListRewrite(newAnnotation, NormalAnnotation.VALUES_PROPERTY); } addMissingAtributes(fAnnotation.resolveTypeBinding(), listRewrite); return rewrite; }
Example #3
Source File: SuppressWarningsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static Annotation findExistingAnnotation(List<? extends ASTNode> modifiers) { for (int i= 0, len= modifiers.size(); i < len; i++) { Object curr= modifiers.get(i); if (curr instanceof NormalAnnotation || curr instanceof SingleMemberAnnotation) { Annotation annotation= (Annotation) curr; ITypeBinding typeBinding= annotation.resolveTypeBinding(); if (typeBinding != null) { if ("java.lang.SuppressWarnings".equals(typeBinding.getQualifiedName())) { //$NON-NLS-1$ return annotation; } } else { String fullyQualifiedName= annotation.getTypeName().getFullyQualifiedName(); if ("SuppressWarnings".equals(fullyQualifiedName) || "java.lang.SuppressWarnings".equals(fullyQualifiedName)) { //$NON-NLS-1$ //$NON-NLS-2$ return annotation; } } } } return null; }
Example #4
Source File: UMLAnnotation.java From RefactoringMiner with MIT License | 6 votes |
public UMLAnnotation(CompilationUnit cu, String filePath, Annotation annotation) { this.typeName = annotation.getTypeName().getFullyQualifiedName(); this.locationInfo = new LocationInfo(cu, filePath, annotation, CodeElementType.ANNOTATION); if(annotation instanceof SingleMemberAnnotation) { SingleMemberAnnotation singleMemberAnnotation = (SingleMemberAnnotation)annotation; this.value = new AbstractExpression(cu, filePath, singleMemberAnnotation.getValue(), CodeElementType.SINGLE_MEMBER_ANNOTATION_VALUE); } else if(annotation instanceof NormalAnnotation) { NormalAnnotation normalAnnotation = (NormalAnnotation)annotation; List<MemberValuePair> pairs = normalAnnotation.values(); for(MemberValuePair pair : pairs) { AbstractExpression value = new AbstractExpression(cu, filePath, pair.getValue(), CodeElementType.NORMAL_ANNOTATION_MEMBER_VALUE_PAIR); memberValuePairs.put(pair.getName().getIdentifier(), value); } } }
Example #5
Source File: JsonDeserializeAdder.java From SparkBuilderGenerator with MIT License | 5 votes |
public void addJsonDeserializeAnnotation(CompilationUnitModificationDomain compilationUnitModificationDomain, TypeDeclaration builderType) { AST ast = compilationUnitModificationDomain.getAst(); ASTRewrite rewriter = compilationUnitModificationDomain.getAstRewriter(); ListRewrite modifierRewrite = rewriter.getListRewrite(compilationUnitModificationDomain.getOriginalType(), TypeDeclaration.MODIFIERS2_PROPERTY); NormalAnnotation annotation = createAnnotation(ast, compilationUnitModificationDomain, builderType); modifierRewrite.insertFirst(annotation, null); importRepository.addImport(StaticPreferences.JSON_DESERIALIZE_FULLY_QUALIFIED_NAME); }
Example #6
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 #7
Source File: SuppressWarningsSubProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public static void addRemoveUnusedSuppressWarningProposals(IInvocationContext context, IProblemLocation problem, Collection<ICommandAccess> proposals) { ASTNode coveringNode= problem.getCoveringNode(context.getASTRoot()); if (!(coveringNode instanceof StringLiteral)) return; StringLiteral literal= (StringLiteral) coveringNode; if (coveringNode.getParent() instanceof MemberValuePair) { coveringNode= coveringNode.getParent(); } ASTNode parent= coveringNode.getParent(); ASTRewrite rewrite= ASTRewrite.create(coveringNode.getAST()); if (parent instanceof SingleMemberAnnotation) { rewrite.remove(parent, null); } else if (parent instanceof NormalAnnotation) { NormalAnnotation annot= (NormalAnnotation) parent; if (annot.values().size() == 1) { rewrite.remove(annot, null); } else { rewrite.remove(coveringNode, null); } } else if (parent instanceof ArrayInitializer) { rewrite.remove(coveringNode, null); } else { return; } String label= Messages.format(CorrectionMessages.SuppressWarningsSubProcessor_remove_annotation_label, literal.getLiteralValue()); Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, IProposalRelevance.REMOVE_ANNOTATION, image); proposals.add(proposal); }
Example #8
Source File: FlowAnalyzer.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
@Override public void endVisit(NormalAnnotation node) { if (skipNode(node)) return; GenericSequentialFlowInfo info= processSequential(node, node.getTypeName()); process(info, node.values()); }
Example #9
Source File: ValidationSuppressionVisitor.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public boolean visit(NormalAnnotation node) { IAnnotationBinding resolvedAnnotationBinding = node.resolveAnnotationBinding(); processAnnotationBinding(resolvedAnnotationBinding); // Don't visit this node's children; they don't impact the result return false; }
Example #10
Source File: JavaASTUtils.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
/** * Returns an annotation's value. If the annotation not a single-member * annotation, this is the value corresponding to the key named "value". */ @SuppressWarnings("unchecked") public static Expression getAnnotationValue(Annotation annotation) { if (annotation instanceof SingleMemberAnnotation) { return ((SingleMemberAnnotation) annotation).getValue(); } else if (annotation instanceof NormalAnnotation) { NormalAnnotation normalAnnotation = (NormalAnnotation) annotation; for (MemberValuePair pair : (List<MemberValuePair>) normalAnnotation.values()) { if (pair.getName().getIdentifier().equals("value")) { return pair.getValue(); } } } return null; }
Example #11
Source File: JavaASTFlattener.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
@Override public boolean visit(final NormalAnnotation node) { this.appendToBuffer("@"); node.getTypeName().accept(this); this.appendToBuffer("("); this.visitAllSeparatedByComma(node.values()); this.appendToBuffer(")"); return false; }
Example #12
Source File: FlowAnalyzer.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override public void endVisit(NormalAnnotation node) { if (skipNode(node)) { return; } GenericSequentialFlowInfo info = processSequential(node, node.getTypeName()); process(info, node.values()); }
Example #13
Source File: JsonDeserializeRemover.java From SparkBuilderGenerator with MIT License | 5 votes |
private boolean isBuilderDeserializer(NormalAnnotation annotation) { List<MemberValuePair> values = annotation.values(); if (values.size() != 1) { return false; } return values.get(0) .getName() .toString() .equals("builder"); }
Example #14
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 #15
Source File: JsonPOJOBuilderAdderFragment.java From SparkBuilderGenerator with MIT License | 5 votes |
private NormalAnnotation createJsonPojoBuilderAnnotationWithAttributes(AST ast, String buildMethodName, String withMethodPrefix) { NormalAnnotation annotation = ast.newNormalAnnotation(); annotation.values().add(createAnnotationAttribute(ast, "buildMethodName", buildMethodName)); annotation.values().add(createAnnotationAttribute(ast, "withPrefix", withMethodPrefix)); return annotation; }
Example #16
Source File: JsonDeserializeAdder.java From SparkBuilderGenerator with MIT License | 5 votes |
private NormalAnnotation createAnnotation(AST ast, CompilationUnitModificationDomain compilationUnitModificationDomain, TypeDeclaration builderType) { TypeLiteral typeLiteral = createBuilderClassReferenceLiteral(ast, compilationUnitModificationDomain, builderType); NormalAnnotation jsonDeserializeAnnotation = ast.newNormalAnnotation(); jsonDeserializeAnnotation.setTypeName(ast.newSimpleName(JSON_DESERIALIZE_CLASS_NAME)); MemberValuePair builderAttribute = ast.newMemberValuePair(); builderAttribute.setName(ast.newSimpleName("builder")); builderAttribute.setValue(typeLiteral); jsonDeserializeAnnotation.values().add(builderAttribute); return jsonDeserializeAnnotation; }
Example #17
Source File: AstVisitor.java From jdt2famix with Eclipse Public License 1.0 | 4 votes |
/** * handles: @ TypeName ( [ MemberValuePair { , MemberValuePair } ] ) see comment * from {@link #visit(MarkerAnnotation)} */ @Override public boolean visit(NormalAnnotation node) { addTypeAnnotationSourceAnchor(node); return true; }
Example #18
Source File: JsonDeserializeRemover.java From SparkBuilderGenerator with MIT License | 4 votes |
private void removeAnnotation(NormalAnnotation annotation, ASTRewrite rewriter, TypeDeclaration mainType) { ListRewrite modifierRewrite = rewriter.getListRewrite(mainType, TypeDeclaration.MODIFIERS2_PROPERTY); modifierRewrite.remove(annotation, null); }
Example #19
Source File: AstMatchingNodeFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(NormalAnnotation node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
Example #20
Source File: ConstraintCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(NormalAnnotation node) { return false; }
Example #21
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public void endVisit(NormalAnnotation node) { endVisitNode(node); }
Example #22
Source File: GenericVisitor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(NormalAnnotation node) { return visitNode(node); }
Example #23
Source File: ImportReferencesCollector.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
@Override public boolean visit(NormalAnnotation node) { typeRefFound(node.getTypeName()); doVisitChildren(node.values()); return false; }
Example #24
Source File: DOMFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
public boolean visit(NormalAnnotation node) { if (found(node, node) && this.resolveBinding) this.foundBinding = node.resolveAnnotationBinding(); return true; }
Example #25
Source File: ReferencedClassesParser.java From BUILD_file_generator with Apache License 2.0 | 4 votes |
@Override public boolean visit(NormalAnnotation node) { return visitAnnotation(node); }