@Override ASTNode clone0(AST target) { SingleMemberAnnotation result = new SingleMemberAnnotation(target); result.setSourceRange(getStartPosition(), getLength()); result.setTypeName((Name) ASTNode.copySubtree(target, getTypeName())); result.setValue((Expression) ASTNode.copySubtree(target, getValue())); return result; }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
@Override public boolean visit(SingleMemberAnnotation node) { this.buffer.append("@");//$NON-NLS-1$ node.getTypeName().accept(this); this.buffer.append("(");//$NON-NLS-1$ node.getValue().accept(this); this.buffer.append(")");//$NON-NLS-1$ return false; }
@Override int treeSize() { return memSize() + (this.typeName == null ? 0 : getTypeName().treeSize()) + (this.value == null ? 0 : getValue().treeSize()); } }
void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getTypeName()); acceptChild(visitor, getValue()); } visitor.endVisit(this); }
public void endVisit(SingleMemberAnnotation node) { endVisitNode(node); // is inside diet part of the ast if(this.blockDepth < 1) { Expression value = node.getValue(); int annotationEnd = node.getStartPosition() + node.getLength(); int valueEnd = value.getStartPosition() + value.getLength(); if (annotationEnd == valueEnd) { node.setFlags(node.getFlags() | ASTNode.RECOVERED); } } } }
/** * 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; }
protected void setValueSingleMemberAnnotation(Expression value, SingleMemberAnnotation annotation, ModifiedDeclaration declaration) { if (this.elementName.equals("value")) { // @Foo("yyy") => @Foo("xxx") annotation.setValue(value); } else { // @Foo("yyy") => @Foo(value="yyy", bar="xxx") Expression vv = annotation.getValue(); vv = (Expression) ASTNode.copySubtree(vv.getAST(), vv); NormalAnnotation normalAnnotation = this.annotationAdapter.newNormalAnnotation(declaration); this.addValue(vv, normalAnnotation, "value"); this.addValue(value, normalAnnotation); } }
newAnnot.setTypeName(ast.newName(importString)); newAnnot.setValue(newStringLiteral); Expression value= annotation.getValue(); if (!addSuppressArgument(rewrite, value, newStringLiteral)) { rewrite.set(existing, SingleMemberAnnotation.VALUE_PROPERTY, newStringLiteral, null);
public SingleMemberAnnotation convert(org.eclipse.jdt.internal.compiler.ast.SingleMemberAnnotation annotation) { final SingleMemberAnnotation singleMemberAnnotation = new SingleMemberAnnotation(this.ast); setTypeNameForAnnotation(annotation, singleMemberAnnotation); singleMemberAnnotation.setValue(convert(annotation.memberValue)); int start = annotation.sourceStart; int end = annotation.declarationSourceEnd; singleMemberAnnotation.setSourceRange(start, end - start + 1); if (this.resolveBindings) { recordNodes(singleMemberAnnotation, annotation); singleMemberAnnotation.resolveAnnotationBinding(); } return singleMemberAnnotation; }
@Override public boolean visit(SingleMemberAnnotation node) { if (node.getParent().getNodeType() == ASTNode.TYPE_DECLARATION && node.getTypeName().toString().equals("Path")) { //this is a REST serivce class hasPath = true; this.rootPath = node.getValue().toString(); this.restServiceClass = ((TypeDeclaration)node.getParent()).getName().toString(); return false; } if (node.getParent().getNodeType() == ASTNode.METHOD_DECLARATION && node.getTypeName().toString().equals("Path")) { //this is a REST method restMethod.add((MethodDeclaration)node.getParent()); return false; } return true; }
if (annotation.isSingleMemberAnnotation()) { org.eclipse.jdt.core.dom.SingleMemberAnnotation smAnn = (org.eclipse.jdt.core.dom.SingleMemberAnnotation) annotation; values.add(smAnn.getValue().toString()); } else if (annotation.isNormalAnnotation()) { org.eclipse.jdt.core.dom.NormalAnnotation normalAnn = (org.eclipse.jdt.core.dom.NormalAnnotation) annotation;
/** * <pre> * @Outer("lorem ipsum") => @Outer(@Inner) * </pre> */ @Override protected void modifyAnnotationValue(SingleMemberAnnotation outer, Annotation inner) { // replace(?) the current element value outer.setValue(inner); }
@Override public boolean visit(SingleMemberAnnotation node) { processName(node.getTypeName(), TypeReferenceLocation.ANNOTATION, cu.getLineNumber(node.getStartPosition()), cu.getColumnNumber(node.getStartPosition()), node.getLength()); return super.visit(node); }
@Override public boolean visit(SingleMemberAnnotation node) { processName(node.getTypeName(), "Annotation", cu.getLineNumber(node.getStartPosition())); return super.visit(node); }
protected SingleMemberAnnotation newSingleMemberAnnotation(AST ast, String name) { SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation(); annotation.setTypeName(ast.newName(name)); return annotation; }
public boolean visit(SingleMemberAnnotation node) { if (found(node, node) && this.resolveBinding) this.foundBinding = node.resolveAnnotationBinding(); return true; }
@Override final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == TYPE_NAME_PROPERTY) { if (get) { return getTypeName(); } else { setTypeName((Name) child); return null; } } if (property == VALUE_PROPERTY) { if (get) { return getValue(); } else { setValue((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
public boolean visit(SingleMemberAnnotation node) { this.buffer.append("@");//$NON-NLS-1$ node.getTypeName().accept(this); this.buffer.append("(");//$NON-NLS-1$ node.getValue().accept(this); this.buffer.append(")");//$NON-NLS-1$ return false; }
int treeSize() { return memSize() + (this.typeName == null ? 0 : getTypeName().treeSize()) + (this.value == null ? 0 : getValue().treeSize()); } }