public InvocationFinder(IMethodBinding binding) { Assert.isNotNull(binding); fBinding= binding.getMethodDeclaration(); Assert.isNotNull(fBinding); } @Override
private boolean matches(IBinding binding) { if (!(binding instanceof IMethodBinding)) return false; return fBinding.isEqualTo(((IMethodBinding)binding).getMethodDeclaration()); } }
private IMethodBinding getBinding() { IMethodBinding result= fDeclaration.resolveBinding(); if (result != null) return result.getMethodDeclaration(); return result; } }
private boolean matches(IBinding binding) { if (!(binding instanceof IMethodBinding)) return false; if (BUG_CORE_130317) return fBinding.getKey().equals(((IMethodBinding)binding).getMethodDeclaration().getKey()); else return fBinding.isEqualTo(((IMethodBinding)binding).getMethodDeclaration()); } }
private IMethodBinding getBinding() { IMethodBinding result= fDeclaration.resolveBinding(); if (result != null) return result.getMethodDeclaration(); return result; } }
private static IBinding getDeclaration(IBinding binding) { if (binding instanceof ITypeBinding) { return ((ITypeBinding) binding).getTypeDeclaration(); } else if (binding instanceof IMethodBinding) { return ((IMethodBinding) binding).getMethodDeclaration(); } else if (binding instanceof IVariableBinding) { return ((IVariableBinding) binding).getVariableDeclaration(); } return binding; } }
private static IMethodBinding findOverridenMethod(String methodName, String[] parameterTypesQualifiedNames, IMethodBinding[] declaredMethods) { for (IMethodBinding methodBinding : declaredMethods) { final IMethodBinding methodDecl = methodBinding.getMethodDeclaration(); if (methodBinding.getName().equals(methodName) && methodDecl != null && concreteTypesMatch(methodDecl.getParameterTypes(), parameterTypesQualifiedNames)) { return methodBinding; } } return null; }
private boolean isSpecialCloneInvocation(IMethodBinding methodBinding, Expression receiver) { return fAssumeCloneReturnsSameType && "clone".equals(methodBinding.getName()) //$NON-NLS-1$ && methodBinding.getParameterTypes().length == 0 && receiver != null && receiver.resolveTypeBinding() != methodBinding.getMethodDeclaration().getReturnType(); }
private CAstNode visit(SuperConstructorInvocation n, WalkContext context) { // FIXME: use expression?! polyglot doesn't handle it and it seems to be a very rare case. // class E { class X {} } // class Y extends E.X { Y(E e) { e.super(); } } // GENERICS getMethodDeclaration() return createConstructorInvocation(n.resolveConstructorBinding().getMethodDeclaration(), n.arguments(), n, context, true); }
private boolean isSpecialCloneInvocation(IMethodBinding methodBinding, Expression receiver) { return fAssumeCloneReturnsSameType && "clone".equals(methodBinding.getName()) //$NON-NLS-1$ && methodBinding.getParameterTypes().length == 0 && receiver != null && receiver.resolveTypeBinding() != methodBinding.getMethodDeclaration().getReturnType(); }
private IBinding getBindingDeclaration(IBinding binding) { switch (binding.getKind()) { case IBinding.TYPE : return ((ITypeBinding)binding).getTypeDeclaration(); case IBinding.METHOD : return ((IMethodBinding)binding).getMethodDeclaration(); case IBinding.VARIABLE : return ((IVariableBinding)binding).getVariableDeclaration(); default: return binding; } }
private boolean isSpecialCloneInvocation(IMethodBinding methodBinding, Expression receiver) { return fAssumeCloneReturnsSameType && "clone".equals(methodBinding.getName()) //$NON-NLS-1$ && methodBinding.getParameterTypes().length == 0 && receiver != null && receiver.resolveTypeBinding() != methodBinding.getMethodDeclaration().getReturnType(); }
public static IBinding getDeclaration(IBinding binding) { switch (binding.getKind()) { case IBinding.TYPE: return ((ITypeBinding) binding).getTypeDeclaration(); case IBinding.VARIABLE: return ((IVariableBinding) binding).getVariableDeclaration(); case IBinding.METHOD: return ((IMethodBinding) binding).getMethodDeclaration(); } return binding; }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer = new ScopeAnalyzer(cu); IBinding[] declarationsInScope = analyzer.getDeclarationsInScope(startPosition, flags); for (int i = 0; i < declarationsInScope.length; i++) { IBinding decl = declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) { return true; } } return false; }
private static boolean hasConflict(int startPosition, IMethodBinding referredMethodBinding, int flags, CompilationUnit cu) { ScopeAnalyzer analyzer= new ScopeAnalyzer(cu); IBinding[] declarationsInScope= analyzer.getDeclarationsInScope(startPosition, flags); for (int i= 0; i < declarationsInScope.length; i++) { IBinding decl= declarationsInScope[i]; if (decl.getName().equals(referredMethodBinding.getName()) && !referredMethodBinding.getMethodDeclaration().isEqualTo(decl)) return true; } return false; }
public boolean visit(MethodInvocation node) { IMethodBinding binding= node.resolveMethodBinding(); if (binding != null) { binding= binding.getMethodDeclaration(); if (isMovedMember(binding)) rewrite(node, fTarget); } return super.visit(node); }
@Override public boolean visit(MethodInvocation node) { IMethodBinding methodBinding= node.resolveMethodBinding(); if (methodBinding != null) methodBinding.getMethodDeclaration(); if (fBinding != null && methodBinding != null && fBinding.isEqualTo(methodBinding) && !status.hasFatalError()) { status.addFatalError(RefactoringCoreMessages.InlineMethodRefactoring_SourceAnalyzer_recursive_call); return false; } return true; } @Override
public boolean visit(MethodInvocation node) { IMethodBinding methodBinding= node.resolveMethodBinding(); if (methodBinding != null) methodBinding.getMethodDeclaration(); if (fBinding != null && methodBinding != null && fBinding.isEqualTo(methodBinding) && !status.hasFatalError()) { status.addFatalError(RefactoringCoreMessages.InlineMethodRefactoring_SourceAnalyzer_recursive_call); return false; } return true; } public boolean visit(SimpleName node) {
@Override public boolean visit(MethodInvocation node) { IMethodBinding binding= node.resolveMethodBinding(); if (binding != null) { binding= binding.getMethodDeclaration(); if (isMovedMember(binding)) rewrite(node, fTarget); } return super.visit(node); }
private CAstNode visit(SuperMethodInvocation n, WalkContext context) { CAstNode target; if (n.getQualifier() == null) target = makeNode(context, fFactory, n, CAstNode.SUPER); else { TypeReference owningTypeRef = fIdentityMapper.getTypeRef(n.getQualifier().resolveTypeBinding()); target = makeNode(context, fFactory, n, CAstNode.SUPER, fFactory.makeConstant(owningTypeRef)); } // GENERICS getMethodDeclaration() return createMethodInvocation(n, n.resolveMethodBinding().getMethodDeclaration(), target, n.arguments(), context); }