@Override ASTNode clone0(AST target) { ExpressionMethodReference result = new ExpressionMethodReference(target); result.setSourceRange(getStartPosition(), getLength()); result.setExpression( (Expression) ASTNode.copySubtree(target, getExpression())); result.typeArguments().addAll(ASTNode.copySubtrees(target, typeArguments())); result.setName((SimpleName) getName().clone(target)); return result; }
@Override void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getExpression()); acceptChildren(visitor, this.typeArguments); acceptChild(visitor, getName()); } visitor.endVisit(this); }
@Override final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == NAME_PROPERTY) { if (get) { return getName(); } else { setName((SimpleName) child); return null; } } if (property == EXPRESSION_PROPERTY) { if (get) { return getExpression(); } else { setExpression((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
@Override public boolean visit(ExpressionMethodReference node) { evalQualifyingExpression(node.getExpression(), node.getName()); doVisitChildren(node.typeArguments()); return false; }
result = superMethodReference; } else { ExpressionMethodReference expressionMethodReference = new ExpressionMethodReference(this.ast); expressionMethodReference.setExpression(convert(lhs)); typeArguments = expressionMethodReference.typeArguments(); expressionMethodReference.setName(name); result = expressionMethodReference;
int treeSize() { return memSize() + (this.expression == null ? 0 : getExpression().treeSize()) + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) + (this.methodName == null ? 0 : getName().treeSize()); } }
replacement= exprMethodReference; exprMethodReference.setName((SimpleName) rewrite.createCopyTarget(methodInvocation.getName())); if (invocationQualifier != null) { exprMethodReference.setExpression((Expression) rewrite.createCopyTarget(invocationQualifier)); } else { exprMethodReference.setExpression(ast.newThisExpression()); exprMethodReference.typeArguments().addAll(getCopiedTypeArguments(rewrite, methodInvocation.typeArguments()));
@Override final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == TYPE_ARGUMENTS_PROPERTY) { return typeArguments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
@Override protected SimpleName getMethodNameNode() { return fMethodRef.getName(); }
private static boolean isTypeReferenceToInstanceMethod(MethodReference methodReference) { if (methodReference instanceof TypeMethodReference) { return true; } if (methodReference instanceof ExpressionMethodReference) { Expression expression = ((ExpressionMethodReference) methodReference).getExpression(); if (expression instanceof Name) { IBinding nameBinding = ((Name) expression).resolveBinding(); if (nameBinding != null && nameBinding instanceof ITypeBinding) { return true; } } } return false; }
private void replaceByMethodReference(final LambdaExpression node, final MethodInvocation mi) { final ASTBuilder b = ctx.getASTBuilder(); final ExpressionMethodReference typeMethodRef = b.exprMethodRef(); if (mi.getExpression() != null) { typeMethodRef.setExpression(b.copy(mi.getExpression())); } else { typeMethodRef.setExpression(b.this0()); } typeMethodRef.setName(b.copy(mi.getName())); ctx.getRefactorings().replace(node, typeMethodRef); } }
/** * Creates an unparented expression method reference node owned by this AST. * By default, the expression and method name are unspecified (but legal), * and there are no type arguments. * * @return a new unparented expression method reference expression node * @exception UnsupportedOperationException if this operation is used in a JLS2, JLS3 or JLS4 AST * @since 3.10 */ public ExpressionMethodReference newExpressionMethodReference() { ExpressionMethodReference result = new ExpressionMethodReference(this); return result; }
@Override public boolean visit(ExpressionMethodReference node) { evalQualifyingExpression(node.getExpression(), node.getName()); doVisitChildren(node.typeArguments()); return false; }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == NAME_PROPERTY) { if (get) { return getName(); } else { setName((SimpleName) child); return null; } } if (property == EXPRESSION_PROPERTY) { if (get) { return getExpression(); } else { setExpression((Expression) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
result = superMethodReference; } else { ExpressionMethodReference expressionMethodReference = new ExpressionMethodReference(this.ast); expressionMethodReference.setExpression(convert(lhs)); typeArguments = expressionMethodReference.typeArguments(); expressionMethodReference.setName(name); result = expressionMethodReference;
@Override int treeSize() { return memSize() + (this.expression == null ? 0 : getExpression().treeSize()) + (this.typeArguments == null ? 0 : this.typeArguments.listSize()) + (this.methodName == null ? 0 : getName().treeSize()); } }
replacement= exprMethodReference; exprMethodReference.setName((SimpleName) rewrite.createCopyTarget(methodInvocation.getName())); if (invocationQualifier != null) { exprMethodReference.setExpression((Expression) rewrite.createCopyTarget(invocationQualifier)); } else { exprMethodReference.setExpression(ast.newThisExpression()); exprMethodReference.typeArguments().addAll(getCopiedTypeArguments(rewrite, methodInvocation.typeArguments()));
final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == TYPE_ARGUMENTS_PROPERTY) { return typeArguments(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
@Override protected SimpleName getMethodNameNode() { return fMethodRef.getName(); }
private static boolean isTypeReferenceToInstanceMethod(MethodReference methodReference) { if (methodReference instanceof TypeMethodReference) return true; if (methodReference instanceof ExpressionMethodReference) { Expression expression= ((ExpressionMethodReference) methodReference).getExpression(); if (expression instanceof Name) { IBinding nameBinding= ((Name) expression).resolveBinding(); if (nameBinding != null && nameBinding instanceof ITypeBinding) { return true; } } } return false; }