@Override public boolean matches(final INode other, final Match match) { if (other instanceof Annotation) { final Annotation otherAnnotation = (Annotation) other; return !otherAnnotation.isNull() && getType().matches(otherAnnotation.getType(), match) && getArguments().matches(otherAnnotation.getArguments(), match); } return false; }
public final AstType getType() { return getChildByRole(Roles.TYPE); }
public final AstNodeCollection<Expression> getArguments() { return getChildrenByRole(Roles.ARGUMENT); }
public Annotation createAnnotation(final CustomAnnotation annotation) { final Annotation a = new Annotation(); final AstNodeCollection<Expression> arguments = a.getArguments(); a.setType(convertType(annotation.getAnnotationType())); final List<AnnotationParameter> parameters = annotation.getParameters(); for (final AnnotationParameter p : parameters) { final String member = p.getMember(); final Expression value = createAnnotationElement(p.getValue()); if (StringUtilities.isNullOrEmpty(member) || parameters.size() == 1 && "value".equals(member)) { arguments.add(value); } else { arguments.add(new AssignmentExpression(new IdentifierExpression(value.getOffset(), member), value)); } } return a; }
final TypeReference annotationType = annotation.getType().getUserData(Keys.TYPE_REFERENCE); final Annotation annotation = new Annotation(); annotation.setType(_astBuilder.convertType(annotationType)); annotation.setType(new SimpleType(annotationType.getSimpleName()));
@Override public Void visitAnnotation(final Annotation node, final Void ignored) { startNode(node); startNode(node.getType()); formatter.writeIdentifier("@"); endNode(node.getType()); node.getType().acceptVisitor(this, ignored); final AstNodeCollection<Expression> arguments = node.getArguments(); if (!arguments.isEmpty()) { writeCommaSeparatedListInParenthesis(arguments, false); } endNode(node); return null; }
private void addAnnotation( final EntityDeclaration node, final IMetadataResolver resolver, final String annotationName) { if (resolver == null) { return; } final Annotation annotation = new Annotation(); final TypeReference annotationType = new MetadataParser(resolver).parseTypeDescriptor(annotationName); if (_astBuilder != null) { annotation.setType(_astBuilder.convertType(annotationType)); } else { annotation.setType(new SimpleType(annotationType.getSimpleName())); } node.getAnnotations().add(annotation); } }
void writeAnnotations(final Iterable<Annotation> annotations, final boolean newLineAfter) { for (final Annotation annotation : annotations) { annotation.acceptVisitor(this, null); if (newLineAfter) { newLine(); } else { space(); } } }
public final void setType(final AstType type) { setChildByRole(Roles.TYPE, type); }
@Deprecated public boolean test(final Annotation a) { final TypeReference t = a.getType().getUserData(Keys.TYPE_REFERENCE); return t != null && StringUtilities.equals(t.getInternalName(), DEPRECATED_ANNOTATION_NAME); } };
public Annotation createAnnotation(final CustomAnnotation annotation) { final Annotation a = new Annotation(); final AstNodeCollection<Expression> arguments = a.getArguments(); a.setType(convertType(annotation.getAnnotationType())); final List<AnnotationParameter> parameters = annotation.getParameters(); for (final AnnotationParameter p : parameters) { final String member = p.getMember(); final Expression value = createAnnotationElement(p.getValue()); if (StringUtilities.isNullOrEmpty(member) || parameters.size() == 1 && "value".equals(member)) { arguments.add(value); } else { arguments.add(new AssignmentExpression(new IdentifierExpression(value.getOffset(), member), value)); } } return a; }
final TypeReference annotationType = annotation.getType().getUserData(Keys.TYPE_REFERENCE); final Annotation annotation = new Annotation(); annotation.setType(_astBuilder.convertType(annotationType)); annotation.setType(new SimpleType(annotationType.getSimpleName()));
@Override public Void visitAnnotation(final Annotation node, final Void ignored) { startNode(node); startNode(node.getType()); formatter.writeIdentifier("@"); endNode(node.getType()); node.getType().acceptVisitor(this, ignored); final AstNodeCollection<Expression> arguments = node.getArguments(); if (!arguments.isEmpty()) { writeCommaSeparatedListInParenthesis(arguments, false); } endNode(node); return null; }
final Annotation annotation = new Annotation(); annotation.setType(_astBuilder.convertType(annotationType)); annotation.setType(new SimpleType(annotationType.getSimpleName()));
void writeAnnotations(final Iterable<Annotation> annotations, final boolean newLineAfter) { for (final Annotation annotation : annotations) { annotation.acceptVisitor(this, null); if (newLineAfter) { newLine(); } else { space(); } } }
public final void setType(final AstType type) { setChildByRole(Roles.TYPE, type); }
@Override public boolean test(final Annotation a) { final TypeReference t = a.getType().getUserData(Keys.TYPE_REFERENCE); return t != null && StringUtilities.equals(t.getInternalName(), OVERRIDE_ANNOTATION_NAME); } };
@Override public boolean matches(final INode other, final Match match) { if (other instanceof Annotation) { final Annotation otherAnnotation = (Annotation) other; return !otherAnnotation.isNull() && getType().matches(otherAnnotation.getType(), match) && getArguments().matches(otherAnnotation.getArguments(), match); } return false; }