@Override public Object getDefaultValue() { if (_defaultValue == null) { final Tree defaultValue = _method.getDefaultValue(); if (defaultValue != null) { if(defaultValue instanceof NewArrayTree) { _defaultValue = new JavaSourceDefaultValue(this, "new " + getReturnClassInfo().getName() + defaultValue.toString()); } else { _defaultValue = new JavaSourceDefaultValue(this, defaultValue.toString()); } } else { _defaultValue = JavaSourceDefaultValue.NULL; } } return _defaultValue == JavaSourceDefaultValue.NULL ? null : _defaultValue; } }
out.append(body.accept(this, v)); Tree defaultValue = node.getDefaultValue(); if (defaultValue != null) { out.append(" = ");
@Override public Void visitMethod(MethodTree expected, Tree actual) { Optional<MethodTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } checkForDiff(expected.getName().contentEquals(other.get().getName()), "Expected method name to be <%s> but was <%s>.", expected.getName(), other.get().getName()); scan(expected.getModifiers(), other.get().getModifiers()); scan(expected.getReturnType(), other.get().getReturnType()); parallelScan(expected.getTypeParameters(), other.get().getTypeParameters()); parallelScan(expected.getParameters(), other.get().getParameters()); parallelScan(expected.getThrows(), other.get().getThrows()); scan(expected.getBody(), other.get().getBody()); scan(expected.getDefaultValue(), other.get().getDefaultValue()); return null; }
@Override public Void visitMethod(MethodTree expected, Tree actual) { Optional<MethodTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } checkForDiff(expected.getName().contentEquals(other.get().getName()), "Expected method name to be <%s> but was <%s>.", expected.getName(), other.get().getName()); scan(expected.getModifiers(), other.get().getModifiers()); scan(expected.getReturnType(), other.get().getReturnType()); parallelScan(expected.getTypeParameters(), other.get().getTypeParameters()); parallelScan(expected.getParameters(), other.get().getParameters()); parallelScan(expected.getThrows(), other.get().getThrows()); scan(expected.getBody(), other.get().getBody()); scan(expected.getDefaultValue(), other.get().getDefaultValue()); return null; }
@Override public Void visitMethod(MethodTree expected, Tree actual) { Optional<MethodTree> other = checkTypeAndCast(expected, actual); if (!other.isPresent()) { addTypeMismatch(expected, actual); return null; } checkForDiff(expected.getName().contentEquals(other.get().getName()), "Expected method name to be <%s> but was <%s>.", expected.getName(), other.get().getName()); scan(expected.getModifiers(), other.get().getModifiers()); scan(expected.getReturnType(), other.get().getReturnType()); parallelScan(expected.getTypeParameters(), other.get().getTypeParameters()); parallelScan(expected.getParameters(), other.get().getParameters()); parallelScan(expected.getThrows(), other.get().getThrows()); scan(expected.getBody(), other.get().getBody()); scan(expected.getDefaultValue(), other.get().getDefaultValue()); return null; }
@Override public Tree visitMethod(MethodTree tree, Void p) { MethodTree n = make.Method((ModifiersTree) tree.getModifiers(), tree.getName().toString(), (ExpressionTree) tree.getReturnType(), tree.getTypeParameters(), tree.getParameters(), tree.getThrows(), tree.getBody(), (ExpressionTree) tree.getDefaultValue()); comments.copyComments(tree, n); model.setPos(n, model.getPos(tree)); return n; }
return false; return scan(node.getDefaultValue(), t.getDefaultValue(), p);
private MethodTree modifyMethodThrows(MethodTree method, int index, ExpressionTree throwz, Operation op) { MethodTree copy = Method( method.getModifiers(), method.getName(), method.getReturnType(), method.getTypeParameters(), method.getParameters(), c(method.getThrows(), index, throwz, op), method.getBody(), (ExpressionTree) method.getDefaultValue() ); return copy; }
protected final MethodTree rewriteChildren(MethodTree tree) { ModifiersTree mods = (ModifiersTree)translate(tree.getModifiers()); ExpressionTree restype = (ExpressionTree)translateClassRef(tree.getReturnType()); List<? extends TypeParameterTree> typarams = translateStable(tree.getTypeParameters()); List<? extends VariableTree> params = translateStable(tree.getParameters()); List<? extends ExpressionTree> thrown = translate(tree.getThrows()); ExpressionTree defaultValue = (ExpressionTree)translate(tree.getDefaultValue()); BlockTree body = (BlockTree)translate(tree.getBody()); if (restype!=tree.getReturnType() || !typarams.equals(tree.getTypeParameters()) || !params.equals(tree.getParameters()) || !thrown.equals(tree.getThrows()) || mods!=tree.getModifiers() || defaultValue!=tree.getDefaultValue() || body!=tree.getBody()) { if ((((JCModifiers) mods).flags & Flags.GENERATEDCONSTR) != 0) { mods = make.Modifiers(((JCModifiers) mods).flags & ~Flags.GENERATEDCONSTR, mods.getAnnotations()); } MethodTree n = make.Method(mods, tree.getName().toString(), restype, typarams, params, thrown, body, defaultValue); copyCommentTo(tree,n); copyPosTo(tree,n); tree = n; } return tree; }
private MethodTree modifyMethodParameter(MethodTree method, int index, VariableTree parameter, Operation op) { MethodTree copy = Method( method.getModifiers(), method.getName(), method.getReturnType(), method.getTypeParameters(), c(method.getParameters(), index, parameter, op), method.getThrows(), method.getBody(), (ExpressionTree) method.getDefaultValue() ); return copy; }
private MethodTree modifyMethodTypeParameter(MethodTree method, int index, TypeParameterTree typeParameter, Operation op) { MethodTree copy = Method( method.getModifiers(), method.getName(), method.getReturnType(), c(method.getTypeParameters(), index, typeParameter, op), method.getParameters(), method.getThrows(), method.getBody(), (ExpressionTree) method.getDefaultValue() ); return copy; }
scan(tree.getDefaultValue(), null);
public Object run(WorkingCopy wc) { TreeMaker make = wc.getTreeMaker(); ExecutableElement execElement = execElementHandle.resolve(wc); MethodTree methodTree = wc.getTrees().getTree(execElement); MethodTree newMethodTree = wc.getTreeMaker().Method(methodTree.getModifiers(), methodTree.getName(), methodTree.getReturnType(), methodTree.getTypeParameters(), methodTree.getParameters(), methodTree.getThrows(), "{" + bodyText + "}", (ExpressionTree)methodTree.getDefaultValue()); wc.rewrite(methodTree, newMethodTree); return null; } }, javaClass.getFileObject());
public R visitMethod(MethodTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getReturnType(), p, r); r = scanAndReduce(node.getTypeParameters(), p, r); r = scanAndReduce(node.getParameters(), p, r); r = scanAndReduce(node.getReceiverParameter(), p, r); r = scanAndReduce(node.getThrows(), p, r); r = scanAndReduce(node.getBody(), p, r); r = scanAndReduce(node.getDefaultValue(), p, r); return r; }
public R visitMethod(MethodTree node, P p) { R r = scan(node.getModifiers(), p); r = scanAndReduce(node.getReturnType(), p, r); r = scanAndReduce(node.getTypeParameters(), p, r); r = scanAndReduce(node.getParameters(), p, r); r = scanAndReduce(node.getReceiverParameter(), p, r); r = scanAndReduce(node.getThrows(), p, r); r = scanAndReduce(node.getBody(), p, r); r = scanAndReduce(node.getDefaultValue(), p, r); return r; }
/** * Adds an annotation to a method. This is equivalent to {@link TreeMaker#addModifiersAnnotation}, * but it creates and returns a new <code>MethodTree, not a new <code>ModifiersTree</code>. * * @param methodTree the method to add the annotation to; cannot be null. * @param annotationTree the annotation to add; cannot be null. * @return a new method annotated with the new annotation; never null. */ public MethodTree addAnnotation(MethodTree methodTree, AnnotationTree annotationTree) { Parameters.notNull("methodTree", methodTree); // NOI18N Parameters.notNull("annotationTree", annotationTree); // NOI18N TreeMaker make = getTreeMaker(); return make.Method( make.addModifiersAnnotation(methodTree.getModifiers(), annotationTree), methodTree.getName(), methodTree.getReturnType(), methodTree.getTypeParameters(), methodTree.getParameters(), methodTree.getThrows(), methodTree.getBody(), (ExpressionTree)methodTree.getDefaultValue()); }
startPos = findSubtreeEnd(cu, positions, mt.getDefaultValue(), mt.getThrows(), mt.getParameters(), mt.getModifiers()); break;
@Override public Void visitMethod(MethodTree node, Void p) { if (active || inMethod) { scan(node.getModifiers(), p); scan(node.getReturnType(), p); scan(node.getTypeParameters(), p); scan(node.getParameters(), p); scan(node.getThrows(), p); } if (node == changedMethod) { inMethod = true; } if (active || inMethod) { scan(node.getBody(), p); } if (inMethod) { active = inMethod; inMethod = false; } if (active || inMethod) { scan(node.getDefaultValue(), p); } return null; }
wrapList(cs.wrapThrowsList(), cs.alignMultilineThrows(), true, COMMA, threxs); Tree init = node.getDefaultValue(); if (init != null) { spaces(1, true);
t.getThrows(), t.getBody(), (ExpressionTree) t.getDefaultValue() ); return clone;