private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate( ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) { if (BUG_89686 && node instanceof SimpleName && node.getParent() instanceof EnumConstantDeclaration) node = node.getParent(); if (Invocations.isInvocationWithArguments(node)) return new ReferenceUpdate(node, cuRewrite, result); else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration) return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result); else if (node instanceof MemberRef || node instanceof MethodRef) return new DocReferenceUpdate(node, cuRewrite, result); else if (ASTNodes.getParent(node, ImportDeclaration.class) != null) return new StaticImportUpdate( (ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result); else if (node instanceof LambdaExpression) return new LambdaExpressionUpdate((LambdaExpression) node, cuRewrite, result); else if (node.getLocationInParent() == ExpressionMethodReference.NAME_PROPERTY) return new ExpressionMethodRefUpdate( (ExpressionMethodReference) node.getParent(), cuRewrite, result); else return new NullOccurrenceUpdate(node, cuRewrite, result); }
private OccurrenceUpdate<? extends ASTNode> createOccurrenceUpdate(ASTNode node, CompilationUnitRewrite cuRewrite, RefactoringStatus result) { if (BUG_89686 && node instanceof SimpleName && node.getParent() instanceof EnumConstantDeclaration) node= node.getParent(); if (Invocations.isInvocationWithArguments(node)) return new ReferenceUpdate(node, cuRewrite, result); else if (node instanceof SimpleName && node.getParent() instanceof MethodDeclaration) return new DeclarationUpdate((MethodDeclaration) node.getParent(), cuRewrite, result); else if (node instanceof MemberRef || node instanceof MethodRef) return new DocReferenceUpdate(node, cuRewrite, result); else if (ASTNodes.getParent(node, ImportDeclaration.class) != null) return new StaticImportUpdate((ImportDeclaration) ASTNodes.getParent(node, ImportDeclaration.class), cuRewrite, result); else if (node instanceof LambdaExpression) return new LambdaExpressionUpdate((LambdaExpression) node, cuRewrite, result); else if (node.getLocationInParent() == ExpressionMethodReference.NAME_PROPERTY) return new ExpressionMethodRefUpdate((ExpressionMethodReference) node.getParent(), cuRewrite, result); else return new NullOccurrenceUpdate(node, cuRewrite, result); }
@Override public boolean visit(Name name) { StructuralPropertyDescriptor locationInParent= name.getLocationInParent(); if (locationInParent == ExpressionMethodReference.NAME_PROPERTY || locationInParent == TypeMethodReference.NAME_PROPERTY || locationInParent == SuperMethodReference.NAME_PROPERTY) { return false; } SimpleName leftmost= getLeftmost(name); IBinding leftmostBinding= leftmost.resolveBinding(); if (leftmostBinding instanceof IVariableBinding || leftmostBinding instanceof IMethodBinding || leftmostBinding instanceof ITypeBinding) { if (shouldUnqualify(leftmost)) unqualifyMemberName(leftmost); else qualifyUnqualifiedMemberNameIfNecessary(leftmost); } if (leftmostBinding instanceof ITypeBinding) { String addedImport= fNewLocationCuRewrite.getImportRewrite().addImport((ITypeBinding)leftmostBinding, fNewLocationContext); fNewLocationCuRewrite.getImportRemover().registerAddedImport(addedImport); } return false; }
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 static SimpleName getMethodInvocationName(MethodReference methodReference) { SimpleName name = null; if (methodReference instanceof ExpressionMethodReference) { name = ((ExpressionMethodReference) methodReference).getName(); } else if (methodReference instanceof TypeMethodReference) { name = ((TypeMethodReference) methodReference).getName(); } else if (methodReference instanceof SuperMethodReference) { name = ((SuperMethodReference) methodReference).getName(); } return name; }
protected ExpressionMethodRefUpdate( ExpressionMethodReference decl, CompilationUnitRewrite cuRewrite, RefactoringStatus result) { super( cuRewrite, cuRewrite.createGroupDescription( RefactoringCoreMessages.ChangeSignatureRefactoring_change_signature), result); fMethodRef = decl; }
@Override public boolean visit(Name name) { StructuralPropertyDescriptor locationInParent = name.getLocationInParent(); if (locationInParent == ExpressionMethodReference.NAME_PROPERTY || locationInParent == TypeMethodReference.NAME_PROPERTY || locationInParent == SuperMethodReference.NAME_PROPERTY) { return false; } SimpleName leftmost = getLeftmost(name); IBinding leftmostBinding = leftmost.resolveBinding(); if (leftmostBinding instanceof IVariableBinding || leftmostBinding instanceof IMethodBinding || leftmostBinding instanceof ITypeBinding) { if (shouldUnqualify(leftmost)) unqualifyMemberName(leftmost); else qualifyUnqualifiedMemberNameIfNecessary(leftmost); } if (leftmostBinding instanceof ITypeBinding) { String addedImport = fNewLocationCuRewrite .getImportRewrite() .addImport((ITypeBinding) leftmostBinding, fNewLocationContext); fNewLocationCuRewrite.getImportRemover().registerAddedImport(addedImport); } return false; }
@Override public boolean visit(ExpressionMethodReference node) { evalQualifyingExpression(node.getExpression(), node.getName()); doVisitChildren(node.typeArguments()); return false; }
@Override public boolean visit(ExpressionMethodReference node) { return handleMethodReference(node); }
@Override public boolean visit(final ExpressionMethodReference node) { return false; }
@Override public boolean visit(final ExpressionMethodReference node) { return this.visitInstrumentable(node); }
protected ExpressionMethodRefUpdate(ExpressionMethodReference decl, CompilationUnitRewrite cuRewrite, RefactoringStatus result) { super(cuRewrite, cuRewrite.createGroupDescription(RefactoringCoreMessages.ChangeSignatureRefactoring_change_signature), result); fMethodRef= decl; }
@Override public void endVisit(ExpressionMethodReference node) { endVisitNode(node); }
@Override public boolean visit(ExpressionMethodReference node) { return visitNode(node); }