/** * Creates a new expression statement for the method invocation. * * @param invocation the method invocation * @return the corresponding statement */ private ExpressionStatement createExpressionStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); return invocation.getAST().newExpressionStatement(invocation); }
/** * Creates a new expression statement for the method invocation. * * @param invocation the method invocation * @return the corresponding statement */ private ExpressionStatement createExpressionStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); return invocation.getAST().newExpressionStatement(invocation); }
/** * Creates a new expression statement for the method invocation. * * @param invocation the method invocation * @return the corresponding statement */ private ExpressionStatement createExpressionStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); return invocation.getAST().newExpressionStatement(invocation); }
/** * Creates a new expression statement for the method invocation. * * @param invocation the method invocation * @return the corresponding statement */ private ExpressionStatement createExpressionStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); return invocation.getAST().newExpressionStatement(invocation); }
/** * Creates a new return statement for the method invocation. * * @param invocation the method invocation to create a return statement for * @return the corresponding statement */ private ReturnStatement createReturnStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); final ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
/** * Creates a new return statement for the method invocation. * * @param invocation the method invocation to create a return statement for * @return the corresponding statement */ private ReturnStatement createReturnStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); final ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
/** * Creates a new return statement for the method invocation. * * @param invocation the method invocation to create a return statement for * @return the corresponding statement */ private ReturnStatement createReturnStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); final ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
/** * Creates a new return statement for the method invocation. * * @param invocation the method invocation to create a return statement for * @return the corresponding statement */ private ReturnStatement createReturnStatement(final MethodInvocation invocation) { Assert.isNotNull(invocation); final ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
private Statement encapsulateInvocation(MethodDeclaration declaration, MethodInvocation invocation) { final Type type= declaration.getReturnType2(); if (type == null || (type instanceof PrimitiveType && PrimitiveType.VOID.equals( ((PrimitiveType) type).getPrimitiveTypeCode()))) return invocation.getAST().newExpressionStatement(invocation); ReturnStatement statement= invocation.getAST().newReturnStatement(); statement.setExpression(invocation); return statement; }
private void correctMI(MethodInvocation mi) { StringLiteral sl = mi.getAST().newStringLiteral(); sl.setLiteralValue("Error occurred: "); mi.arguments().add(0, sl); }
public boolean visit(MethodInvocation node) { ASTNode expression= getChildNode(node, MethodInvocation.EXPRESSION_PROPERTY); if (expression != null) { expression.accept(this); this.result.append('.'); } if (node.getAST().apiLevel() >= JLS3_INTERNAL) { visitList(node, MethodInvocation.TYPE_ARGUMENTS_PROPERTY, String.valueOf(','), String.valueOf('<'), String.valueOf('>')); } getChildNode(node, MethodInvocation.NAME_PROPERTY).accept(this); this.result.append('('); visitList(node, MethodInvocation.ARGUMENTS_PROPERTY, String.valueOf(',')); this.result.append(')'); return false; }
@Override public boolean visit(MethodInvocation node) { ASTNode expression= getChildNode(node, MethodInvocation.EXPRESSION_PROPERTY); if (expression != null) { expression.accept(this); this.result.append('.'); } if (node.getAST().apiLevel() >= JLS3_INTERNAL) { visitList(node, MethodInvocation.TYPE_ARGUMENTS_PROPERTY, String.valueOf(','), String.valueOf('<'), String.valueOf('>')); } getChildNode(node, MethodInvocation.NAME_PROPERTY).accept(this); this.result.append('('); visitList(node, MethodInvocation.ARGUMENTS_PROPERTY, String.valueOf(',')); this.result.append(')'); return false; }
public boolean visit(MethodInvocation node) { ASTNode expression= getChildNode(node, MethodInvocation.EXPRESSION_PROPERTY); if (expression != null) { expression.accept(this); this.result.append('.'); } if (node.getAST().apiLevel() >= JLS3_INTERNAL) { visitList(node, MethodInvocation.TYPE_ARGUMENTS_PROPERTY, String.valueOf(','), String.valueOf('<'), String.valueOf('>')); } getChildNode(node, MethodInvocation.NAME_PROPERTY).accept(this); this.result.append('('); visitList(node, MethodInvocation.ARGUMENTS_PROPERTY, String.valueOf(',')); this.result.append(')'); return false; }
public boolean visit(MethodInvocation node) { ASTNode expression= getChildNode(node, MethodInvocation.EXPRESSION_PROPERTY); if (expression != null) { expression.accept(this); this.result.append('.'); } if (node.getAST().apiLevel() >= AST.JLS3) { visitList(node, MethodInvocation.TYPE_ARGUMENTS_PROPERTY, String.valueOf(','), String.valueOf('<'), String.valueOf('>')); } getChildNode(node, MethodInvocation.NAME_PROPERTY).accept(this); this.result.append('('); visitList(node, MethodInvocation.ARGUMENTS_PROPERTY, String.valueOf(',')); this.result.append(')'); return false; }
public boolean visit(MethodInvocation node) { ASTNode expression= getChildNode(node, MethodInvocation.EXPRESSION_PROPERTY); if (expression != null) { expression.accept(this); this.result.append('.'); } if (node.getAST().apiLevel() >= JLS3_INTERNAL) { visitList(node, MethodInvocation.TYPE_ARGUMENTS_PROPERTY, String.valueOf(','), String.valueOf('<'), String.valueOf('>')); } getChildNode(node, MethodInvocation.NAME_PROPERTY).accept(this); this.result.append('('); visitList(node, MethodInvocation.ARGUMENTS_PROPERTY, String.valueOf(',')); this.result.append(')'); return false; }
public boolean visit(MethodInvocation node) { if (!isSelected(node)) return false; return handleExceptions(node.resolveMethodBinding(), node.getAST()); }
private Pair<ITypeBinding, Expression> getTypeAndValue(final MethodInvocation mi) { final ITypeBinding expectedType = mi.resolveMethodBinding().getParameterTypes()[0]; if (hasType(arg0(mi), expectedType.getQualifiedName(), getBoxedTypeBinding(expectedType, mi.getAST()).getQualifiedName())) { return Pair.<ITypeBinding, Expression>of(null, arg0(mi)); } else { return Pair.<ITypeBinding, Expression>of(expectedType, arg0(mi)); } }
private void replaceStringValueOfByArg0(final Expression toReplace, final MethodInvocation mi) { final ASTBuilder b = this.ctx.getASTBuilder(); final ITypeBinding expectedType = mi.resolveMethodBinding().getParameterTypes()[0]; final ITypeBinding actualType = arg0(mi).resolveTypeBinding(); if (!expectedType.equals(actualType) && !getBoxedTypeBinding(expectedType, mi.getAST()).equals(actualType)) { ctx.getRefactorings().replace(toReplace, b.cast(b.type(expectedType.getQualifiedName()), b.move(arg0(mi)))); } else { ctx.getRefactorings().replace(toReplace, b.parenthesizeIfNeeded(b.move(arg0(mi)))); } }