public InvocationExpression invoke(final Expression... arguments) { return new InvocationExpression(this.getOffset(), this, arguments); }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof InvocationExpression) { final InvocationExpression otherExpression = (InvocationExpression) other; return getTarget().matches(otherExpression.getTarget(), match) && getArguments().matches(otherExpression.getArguments(), match); } return false; } }
@Override public ResolveResult visitInvocationExpression(final InvocationExpression node, final Void p) { final ResolveResult result = resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE)); if (result != null) { return result; } return node.getTarget().acceptVisitor(this, p); }
private boolean isUnboxingExpression(final AstNode node) { if (!(node instanceof InvocationExpression)) { return false; } final InvocationExpression e = (InvocationExpression) node; if (e.isNull()) { return false; } final Expression target = e.getTarget(); if (!(target instanceof MemberReferenceExpression)) { return false; } final MemberReference reference = e.getUserData(Keys.MEMBER_REFERENCE); if (!(reference instanceof MethodReference)) { return false; } final String key = reference.getFullName() + ":" + reference.getSignature(); return UNBOX_METHODS.contains(key); }
super.visitInvocationExpression(node, data); final Expression target = node.getTarget(); final AstNodeCollection<Expression> arguments = node.getArguments(); reference = node.getUserData(Keys.MEMBER_REFERENCE);
private void removeBoxing(final InvocationExpression node) { if (!isValidPrimitiveParent(node, node.getParent())) { return; final MemberReference reference = node.getUserData(Keys.MEMBER_REFERENCE); final AstNodeCollection<Expression> arguments = node.getArguments(); final Expression underlyingValue = arguments.firstOrNullObject(); final ResolveResult valueResult = _resolver.apply(underlyingValue); case IMPLICIT: { underlyingValue.remove(); node.replaceWith(underlyingValue); break; node.replaceWith(new CastExpression(astBuilder.convertType(castType), underlyingValue));
super.visitInvocationExpression(node, data); final Expression target = node.getTarget(); final AstNodeCollection<Expression> arguments = node.getArguments(); reference = node.getUserData(Keys.MEMBER_REFERENCE); node.replaceWith(inlinedBody); node.replaceWith(expression); assignment.setRight(initializer); expression.remove(); node.replaceWith(expression);
private void removeUnboxingForArgument(final InvocationExpression e) { final AstNode parent = e.getParent(); final MemberReference unboxMethod = e.getUserData(Keys.MEMBER_REFERENCE); final MemberReference outerBoxMethod = parent.getUserData(Keys.MEMBER_REFERENCE); final Expression boxedValue = ((MemberReferenceExpression) e.getTarget()).getTarget(); e.replaceWith(boxedValue); return;
@Override public Void visitInvocationExpression(final InvocationExpression node, final Void data) { parenthesizeIfRequired(node.getTarget(), PRIMARY); return super.visitInvocationExpression(node, data); }
private void performUnboxingRemoval(final InvocationExpression e, final MemberReferenceExpression target) { final Expression boxedValue = target.getTarget(); final MethodReference unboxMethod = (MethodReference) e.getUserData(Keys.MEMBER_REFERENCE); final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER); boxedValue.remove(); e.replaceWith( new CastExpression( astBuilder.convertType(unboxMethod.getReturnType()), boxedValue ) ); }
public final Expression getTarget() { return getChildByRole(Roles.TARGET_EXPRESSION); }
invocation = new InvocationExpression( byteCode.getOffset(), target, invocation.putUserData(Keys.MEMBER_REFERENCE, methodReference);
invocation = new InvocationExpression( byteCode.getOffset(), target, invocation.setOffset(byteCode.getOffset()); invocation.putUserData(Keys.MEMBER_REFERENCE, methodReference);
replacement.putUserData(Keys.MEMBER_REFERENCE, boxMethod); replacement.getTarget().putUserData(Keys.MEMBER_REFERENCE, boxMethod);
final AstNodeCollection<Expression> arguments = ((InvocationExpression) parent).getArguments(); !(parent.getParent() instanceof ExpressionStatement) && StringUtilities.equals(((MemberReferenceExpression) current).getMemberName(), "toString") && ((InvocationExpression) parent).getArguments().isEmpty()) {
final MethodReference switchMapMethod = (MethodReference) switchMapMethodCall.getUserData(Keys.MEMBER_REFERENCE);
@Override public Void visitConditionalExpression(final ConditionalExpression node, final Void data) { super.visitConditionalExpression(node, data); final Match m = PATTERN.match(node); if (m.success()) { final InvocationExpression call = firstOrDefault(m.<InvocationExpression>get("methodCall")); final MemberReference method = call != null ? call.getUserData(Keys.MEMBER_REFERENCE) : null; if (method == null || !method.isEquivalentTo(_method)) { return null; } final PrimitiveExpression className = firstOrDefault(m.<PrimitiveExpression>get("class")); if (className != null && className.getValue() instanceof String) { final AstBuilder builder = context.getUserData(Keys.AST_BUILDER); final String dottedName = (String) className.getValue(); final TypeReference classType = _parser.parseTypeDescriptor(dottedName.replace('.', '/')); final ClassOfExpression replacement = new ClassOfExpression( call.getOffset(), builder.convertType(classType) ); node.replaceWith(replacement); } } return null; }
public final AstNodeCollection<Expression> getArguments() { return getChildrenByRole(Roles.ARGUMENT); }