mi.setName(ast.newSimpleName("x"));
@Override protected void refactorMethod(final ASTBuilder b, final MethodInvocation originalMi, final MethodInvocation refactoredMi) { refactoredMi.setName(b.simpleName("containsValue")); }
private Statement createAddOuterHashCode() { MethodInvocation outer= fAst.newMethodInvocation(); outer.setName(fAst.newSimpleName(METHODNAME_OUTER_TYPE)); MethodInvocation hashAccess= fAst.newMethodInvocation(); hashAccess.setName(fAst.newSimpleName(METHODNAME_HASH_CODE)); hashAccess.setExpression(outer); return prepareAssignment(hashAccess); }
private Expression createMethodInvocation(Expression access, String qualifiedClassName, String methodName) { MethodInvocation invoc= fAst.newMethodInvocation(); invoc.setExpression(getQualifiedName(qualifiedClassName)); invoc.setName(fAst.newSimpleName(methodName)); invoc.arguments().add(access); return invoc; }
private Expression createMethodInvocation(Expression access, String qualifiedClassName, String methodName) { MethodInvocation invoc= fAst.newMethodInvocation(); invoc.setExpression(getQualifiedName(qualifiedClassName)); invoc.setName(fAst.newSimpleName(methodName)); invoc.arguments().add(access); return invoc; }
protected Expression createSubListInvocation(Expression memberAccess, Expression sizeAccess) { MethodInvocation subListInvocation= fAst.newMethodInvocation(); subListInvocation.setExpression(memberAccess); subListInvocation.setName(fAst.newSimpleName("subList")); //$NON-NLS-1$ subListInvocation.arguments().add(fAst.newNumberLiteral(String.valueOf(0))); MethodInvocation minInvocation= createMethodInvocation(addImport("java.lang.Math"), "min", sizeAccess); //$NON-NLS-1$ //$NON-NLS-2$ minInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName)); subListInvocation.arguments().add(minInvocation); needMaxLenVariable= true; return subListInvocation; }
protected Expression createSubListInvocation(Expression memberAccess, Expression sizeAccess) { MethodInvocation subListInvocation= fAst.newMethodInvocation(); subListInvocation.setExpression(memberAccess); subListInvocation.setName(fAst.newSimpleName("subList")); //$NON-NLS-1$ subListInvocation.arguments().add(fAst.newNumberLiteral(String.valueOf(0))); MethodInvocation minInvocation= createMethodInvocation(addImport("java.lang.Math"), "min", sizeAccess); //$NON-NLS-1$ //$NON-NLS-2$ minInvocation.arguments().add(fAst.newSimpleName(fMaxLenVariableName)); subListInvocation.arguments().add(minInvocation); needMaxLenVariable= true; return subListInvocation; }
protected void appendExpression(Expression expression) { MethodInvocation appendInvocation= fAst.newMethodInvocation(); if (temporaryExpression != null) appendInvocation.setExpression(temporaryExpression); else appendInvocation.setExpression(fAst.newSimpleName(fBuilderVariableName)); appendInvocation.setName(fAst.newSimpleName(APPEND_METHOD_NAME)); appendInvocation.arguments().add(expression); temporaryExpression= appendInvocation; }
/** * Create internal member method call builder. * * @param mname method name * @return builder */ public InvocationBuilder createMemberMethodCall(String mname) { MethodInvocation methcall = getAST().newMethodInvocation(); methcall.setName(getAST().newSimpleName(mname)); return new InvocationBuilder(this, methcall); }
private MethodInvocation createStandaloneJ7HashCall() { MethodInvocation j7Invoc= fAst.newMethodInvocation(); for (int i= 0; i < fFields.length; i++) { j7Invoc.arguments().add(fAst.newSimpleName(fFields[i].getName())); } j7Invoc.setExpression(getQualifiedName(JAVA_UTIL_OBJECTS)); j7Invoc.setName(fAst.newSimpleName(METHODNAME_HASH)); return j7Invoc; }
public Expression createFieldWriteAccess(ParameterInfo pi, String paramName, AST ast, IJavaProject project, Expression assignedValue, boolean useSuper, Expression qualifier) { Expression completeQualifier= generateQualifier(paramName, ast, useSuper, qualifier); if (fCreateSetter) { MethodInvocation mi= ast.newMethodInvocation(); mi.setName(ast.newSimpleName(getSetterName(pi, ast, project))); mi.setExpression(completeQualifier); mi.arguments().add(assignedValue); return mi; } return createFieldAccess(pi, ast, completeQualifier); }
public Expression createFieldReadAccess(ParameterInfo pi, String paramName, AST ast, IJavaProject project, boolean useSuper, Expression qualifier) { Expression completeQualifier= generateQualifier(paramName, ast, useSuper, qualifier); if (fCreateGetter) { MethodInvocation mi= ast.newMethodInvocation(); mi.setName(ast.newSimpleName(getGetterName(pi, ast, project))); mi.setExpression(completeQualifier); return mi; } return createFieldAccess(pi, ast, completeQualifier); }
public Expression createFieldReadAccess(ParameterInfo pi, String paramName, AST ast, IJavaProject project, boolean useSuper, Expression qualifier) { Expression completeQualifier= generateQualifier(paramName, ast, useSuper, qualifier); if (fCreateGetter) { MethodInvocation mi= ast.newMethodInvocation(); mi.setName(ast.newSimpleName(getGetterName(pi, ast, project))); mi.setExpression(completeQualifier); return mi; } return createFieldAccess(pi, ast, completeQualifier); }
ASTNode clone0(AST target) { MethodInvocation result = new MethodInvocation(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) getName().clone(target)); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); return result; }
ASTNode clone0(AST target) { MethodInvocation result = new MethodInvocation(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) getName().clone(target)); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); if (this.ast.apiLevel >= AST.JLS3) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); return result; }
ASTNode clone0(AST target) { MethodInvocation result = new MethodInvocation(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) getName().clone(target)); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); return result; }
ASTNode clone0(AST target) { MethodInvocation result = new MethodInvocation(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) getName().clone(target)); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); return result; }
ASTNode clone0(AST target) { MethodInvocation result = new MethodInvocation(target); result.setSourceRange(getStartPosition(), getLength()); result.setName((SimpleName) getName().clone(target)); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); if (this.ast.apiLevel >= AST.JLS3_INTERNAL) { result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); } result.arguments().addAll(ASTNode.copySubtrees(target, arguments())); return result; }
/** * Create method call builder on a local variable or field value. * * @param name local variable or field name * @param mname method name * @return builder */ public InvocationBuilder createNormalMethodCall(String name, String mname) { MethodInvocation methcall = getAST().newMethodInvocation(); methcall.setExpression(getAST().newSimpleName(name)); methcall.setName(getAST().newSimpleName(mname)); return new InvocationBuilder(this, methcall); }
protected ASTNode createBody(BodyDeclaration bd) throws JavaModelException { MethodDeclaration methodDeclaration= (MethodDeclaration) bd; final MethodInvocation invocation= getAst().newMethodInvocation(); invocation.setName(getAst().newSimpleName(getNewElementName())); invocation.setExpression(createSimpleTargetAccessExpression(methodDeclaration)); fNeededInsertion= createArgumentList(methodDeclaration, invocation.arguments(), new VisibilityAdjustingArgumentFactory(getAst(), fRewrites, fAdjustments)); final Block block= getAst().newBlock(); block.statements().add(createMethodInvocation(methodDeclaration, invocation)); if (!fSourceRewrite.getCu().equals(fTargetType.getCompilationUnit())) fSourceRewrite.getImportRemover().registerRemovedNode(methodDeclaration.getBody()); return block; }