@Override public boolean visit(SingleMemberAnnotation node) { if (nestLevel != 1) return false; String typeFqn = node.resolveTypeBinding().getQualifiedName(); if ("org.apache.ibatis.annotations.Select".equals(typeFqn) || "org.apache.ibatis.annotations.Update".equals(typeFqn) || "org.apache.ibatis.annotations.Insert".equals(typeFqn) || "org.apache.ibatis.annotations.Delete".equals(typeFqn)) { Expression value = node.getValue(); int valueType = value.getNodeType(); if (valueType == ASTNode.STRING_LITERAL) { mapperMethod.setStatement(((StringLiteral) value).getLiteralValue()); } else if (valueType == ASTNode.ARRAY_INITIALIZER) { StringBuilder buffer = new StringBuilder(); @SuppressWarnings("unchecked") List<Expression> expressions = (List<Expression>) ((ArrayInitializer) value).expressions(); for (Expression expression : expressions) { int expressionType = expression.getNodeType(); if (expressionType == ASTNode.STRING_LITERAL) { if (buffer.length() > 0) buffer.append(' '); buffer.append(((StringLiteral) expression).getLiteralValue()); } else if (expressionType == ASTNode.INFIX_EXPRESSION) { buffer.append(parseInfixExpression((InfixExpression) expression)); } } mapperMethod.setStatement(buffer.toString()); } else if (valueType == ASTNode.INFIX_EXPRESSION) { mapperMethod.setStatement(parseInfixExpression((InfixExpression) value)); } } return false; }
/* * @see ASTVisitor#visit(SingleMemberAnnotation) * @since 3.0 */ public boolean visit(SingleMemberAnnotation node) { this.fBuffer.append("@"); // $NON-NLS-1$ node.getTypeName().accept(this); this.fBuffer.append("("); // $NON-NLS-1$ node.getValue().accept(this); this.fBuffer.append(")"); // $NON-NLS-1$ return false; }
/** * {@inheritDoc} (non-Javadoc) * * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SingleMemberAnnotation) */ @Override public boolean visit(SingleMemberAnnotation node) { int startPosition = node.getStartPosition(); int endPosition = startPosition + node.getLength(); if (startPosition <= offset && offset <= endPosition) { binding = node.resolveAnnotationBinding(); } return super.visit(node); }
/** * Only Parameters annotation can be used to describe the parameters. * * @see org.eclipse.jdt.core.dom.ASTVisitor#visit(org.eclipse.jdt.core.dom.SingleMemberAnnotation) */ public boolean visit(SingleMemberAnnotation annotation) { if (isParameterAnnotation(annotation.getTypeName().getFullyQualifiedName())) { Expression paramValues = annotation.getValue(); if (paramValues instanceof ArrayInitializer) { record((MethodDeclaration) annotation.getParent(), (ArrayInitializer) paramValues); } } return false; }
public static Expression obtainSingleMemberAnnotationValue( BodyDeclaration declaration, Class<?> annotationClass) { for (Object mod : declaration.modifiers()) { IExtendedModifier modifier = (IExtendedModifier) mod; if (modifier.isAnnotation()) { Annotation annotation = (Annotation) modifier; if (annotation.isSingleMemberAnnotation() && identicalAnnotations(annotation, annotationClass)) { SingleMemberAnnotation singleMemberAnnot = (SingleMemberAnnotation) annotation; return singleMemberAnnot.getValue(); } } } return null; }
public boolean visit(SingleMemberAnnotation node) { if (found(node, node) && this.resolveBinding) this.foundBinding = node.resolveAnnotationBinding(); return true; }
/** * Builds a new {@link SingleMemberAnnotation} instance. * * @param typeName the annotation type name * @param value the annotation single value * @return a new single member annotation */ public SingleMemberAnnotation singleValueAnnotation(Name typeName, Expression value) { final SingleMemberAnnotation sma = ast.newSingleMemberAnnotation(); sma.setTypeName(typeName); sma.setValue(value); return sma; }
/* (non-Javadoc) * @see org.eclipse.jdt.internal.corext.dom.GenericVisitor#visit(org.eclipse.jdt.core.dom.MarkerAnnotation) */ @Override public boolean visit(SingleMemberAnnotation node) { typeRefFound(node.getTypeName()); doVisitNode(node.getValue()); return false; }