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(MemberRef node) { IBinding binding= node.resolveBinding(); if (isSourceAccess(binding)) { if (isMovedMember(binding)) { if (node.getQualifier() != null) rewrite(node, fTarget); } else rewrite(node, fSource); } else if (isTargetAccess(binding)) { // remove qualifier: SimpleName replace= (SimpleName)fCuRewrite.getASTRewrite().createCopyTarget(node.getName()); fCuRewrite.getASTRewrite().replace(node, replace, null); fCuRewrite.getImportRemover().registerRemovedNode(node); } return super.visit(node); }
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 return new NullOccurrenceUpdate(node, cuRewrite, result); }
@Override public boolean visit(MemberRef node) { Name qualifier= node.getQualifier(); if (qualifier != null) { typeRefFound(qualifier); } return false; }
@Override public boolean visit(MemberRef node) { Name qualifier = node.getQualifier(); if (qualifier != null) { typeRefFound(qualifier); } return false; }
@Override protected SimpleName getMethodNameNode() { if (fNode instanceof MemberRef) return ((MemberRef) fNode).getName(); if (fNode instanceof MethodRef) return ((MethodRef) fNode).getName(); return null; }
@Override protected ASTNode createDocReference(BodyDeclaration declaration) { MemberRef ref = getAst().newMemberRef(); ref.setName(getAst().newSimpleName(getNewElementName())); if (isMoveToAnotherFile()) ref.setQualifier(createDestinationTypeName()); return ref; }
protected void rewrite(MemberRef node, ITypeBinding type) { Name qualifier= node.getQualifier(); if (qualifier == null) { ImportRewriteContext context= new ContextSensitiveImportRewriteContext(node, fCuRewrite.getImportRewrite()); Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST(), context); fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName()); qualifier= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result)); fCuRewrite.getASTRewrite().set(node, MemberRef.QUALIFIER_PROPERTY, qualifier, fCuRewrite.createGroupDescription(REFERENCE_UPDATE)); fNeedsImport= true; } else { rewriteName(qualifier, type); } fProcessed.add(node.getName()); }
@Override protected ASTNode createDocReference(BodyDeclaration declaration) { MemberRef ref= getAst().newMemberRef(); ref.setName(getAst().newSimpleName(getNewElementName())); if (isMoveToAnotherFile()) ref.setQualifier(createDestinationTypeName()); return ref; }
@Override public boolean visit(MemberRef node) { if (node.getQualifier() != null) { node.getQualifier().accept(this); } this.fBuffer.append("#");//$NON-NLS-1$ node.getName().accept(this); return false; }
public boolean visit(MemberRef node) { if (node.getQualifier() != null) { node.getQualifier().accept(this); } this.buffer.append("#");//$NON-NLS-1$ node.getName().accept(this); return false; }
@Override public boolean visit(MemberRef memberRef) { if (currentClassifier == null) { CreatorActivator.log(IStatus.WARNING, "Visit a memberRef whithout currentClassifier should not appended"); } return super.visit(memberRef); }
/** {@inheritDoc} */ @Override public void endVisit(MemberRef node) { logger.warn("Method endVisitMemberRef for " + node + " for " + node + " not implemented!"); super.endVisit(node); }
/** {@inheritDoc} */ @Override public boolean visit(MemberRef node) { logger.warn("Method visitMemberValuePair for " + node + " not implemented!"); return super.visit(node); }
@Override public boolean visit(final MemberRef node) { return false; }
@Override public boolean visit(final MemberRef node) { // will never be visited assert false; return false; }
@Override public boolean visit(MemberRef node) { if (isMovedMember(node.resolveBinding())) rewrite(node, fTarget); return false; }
@Override public boolean visit(MemberRef node) { if (node.subtreeMatch(fMatcher, fNodeToMatch)) return matches(node); return super.visit(node); }
@Override public void endVisit(MemberRef node) { endVisitNode(node); }
@Override public boolean visit(MemberRef node) { return visitNode(node); }
private Object getSelectedElement(JavaEditor editor) { ISourceViewer viewer= editor.getViewer(); if (viewer == null) return null; Point selectedRange= viewer.getSelectedRange(); int length= selectedRange.y; int offset= selectedRange.x; ITypeRoot element= JavaUI.getEditorInputTypeRoot(editor.getEditorInput()); if (element == null) return null; CompilationUnit ast= SharedASTProvider.getAST(element, SharedASTProvider.WAIT_YES, null); if (ast == null) return null; NodeFinder finder= new NodeFinder(ast, offset, length); ASTNode node= finder.getCoveringNode(); IBinding binding= null; if (node instanceof Name) { binding= getConstructorBindingIfAvailable((Name)node); if (binding != null) return binding; binding= ((Name)node).resolveBinding(); } else if (node instanceof MethodInvocation) { binding= ((MethodInvocation)node).resolveMethodBinding(); } else if (node instanceof MethodDeclaration) { binding= ((MethodDeclaration)node).resolveBinding(); } else if (node instanceof Type) { binding= ((Type)node).resolveBinding(); } else if (node instanceof AnonymousClassDeclaration) { binding= ((AnonymousClassDeclaration)node).resolveBinding(); } else if (node instanceof TypeDeclaration) { binding= ((TypeDeclaration)node).resolveBinding(); } else if (node instanceof CompilationUnit) { return ((CompilationUnit)node).getJavaElement(); } else if (node instanceof Expression) { binding= ((Expression)node).resolveTypeBinding(); } else if (node instanceof ImportDeclaration) { binding= ((ImportDeclaration)node).resolveBinding(); } else if (node instanceof MemberRef) { binding= ((MemberRef)node).resolveBinding(); } else if (node instanceof MemberValuePair) { binding= ((MemberValuePair)node).resolveMemberValuePairBinding(); } else if (node instanceof PackageDeclaration) { binding= ((PackageDeclaration)node).resolveBinding(); } else if (node instanceof TypeParameter) { binding= ((TypeParameter)node).resolveBinding(); } else if (node instanceof VariableDeclaration) { binding= ((VariableDeclaration)node).resolveBinding(); } if (binding != null) return binding.getJavaElement(); return null; }
@Override public boolean visit(MemberRef node) { return visit((ASTNode)node); }
@Override public void endVisit(MemberRef node) { endVisit((ASTNode)node); }
@Override public boolean visit(final MemberRef node) { return this.internalVisit(node); }
@Override public boolean visit(MemberRef node) { System.out.println("Found: " + node.getClass()); return super.visit(node); }