public boolean visit(MethodDeclaration node) { IMethodBinding binding= node.resolveBinding(); if (binding != null) { IMethodBinding method= Bindings.findOverriddenMethodInHierarchy(fSelectedType, binding); if (method != null) fResult.add(node.getName()); } return super.visit(node); }
/** * Finds a method in the hierarchy of <code>type</code> that is overridden by </code>binding</code>. * Returns <code>null</code> if no such method exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and than the implemented interfaces. * @param type The type to search the method in * @param binding The method that overrides * @return the method binding overridden the method */ public static IMethodBinding findOverriddenMethodInHierarchy(ITypeBinding type, IMethodBinding binding) { IMethodBinding method= findOverriddenMethodInType(type, binding); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findOverriddenMethodInHierarchy(superClass, binding); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findOverriddenMethodInHierarchy(interfaces[i], binding); if (method != null) return method; } return null; }
/** * Finds a method in the hierarchy of <code>type</code> that is overridden by <code>binding</code>. * Returns <code>null</code> if no such method exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and then the implemented interfaces. * @param type The type to search the method in * @param binding The method that overrides * @return the method binding overridden the method */ public static IMethodBinding findOverriddenMethodInHierarchy(ITypeBinding type, IMethodBinding binding) { IMethodBinding method= findOverriddenMethodInType(type, binding); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findOverriddenMethodInHierarchy(superClass, binding); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findOverriddenMethodInHierarchy(interfaces[i], binding); if (method != null) return method; } return null; }
/** * Finds a method in the hierarchy of <code>type</code> that is overridden by <code>binding</code>. * Returns <code>null</code> if no such method exists. If the method is defined in more than one super type only the first match is * returned. First the super class is examined and then the implemented interfaces. * @param type The type to search the method in * @param binding The method that overrides * @return the method binding overridden the method */ public static IMethodBinding findOverriddenMethodInHierarchy(ITypeBinding type, IMethodBinding binding) { IMethodBinding method= findOverriddenMethodInType(type, binding); if (method != null) return method; ITypeBinding superClass= type.getSuperclass(); if (superClass != null) { method= findOverriddenMethodInHierarchy(superClass, binding); if (method != null) return method; } ITypeBinding[] interfaces= type.getInterfaces(); for (int i= 0; i < interfaces.length; i++) { method= findOverriddenMethodInHierarchy(interfaces[i], binding); if (method != null) return method; } return null; }
@Override public boolean visit(MethodDeclaration node) { IMethodBinding binding= node.resolveBinding(); if (binding != null && !Modifier.isStatic(binding.getModifiers())) { IMethodBinding method= Bindings.findOverriddenMethodInHierarchy(fSelectedType, binding); if (method != null) { SimpleName name= node.getName(); fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription)); } } return super.visit(node); }
@Override public boolean visit(MethodDeclaration node) { IMethodBinding binding= node.resolveBinding(); if (binding != null && !Modifier.isStatic(binding.getModifiers())) { IMethodBinding method= Bindings.findOverriddenMethodInHierarchy(fSelectedType, binding); if (method != null) { SimpleName name= node.getName(); fResult.add(new OccurrenceLocation(name.getStartPosition(), name.getLength(), 0, fDescription)); } } return super.visit(node); }
private static IMethodBinding[] getDelegateCandidates(ITypeBinding binding, ITypeBinding hierarchy) { List<IMethodBinding> allMethods= new ArrayList<>(); boolean isInterface= binding.isInterface(); IMethodBinding[] typeMethods= binding.getDeclaredMethods(); for (int index= 0; index < typeMethods.length; index++) { final int modifiers= typeMethods[index].getModifiers(); if (!typeMethods[index].isConstructor() && !Modifier.isStatic(modifiers) && (isInterface || Modifier.isPublic(modifiers))) { IMethodBinding result= Bindings.findOverriddenMethodInHierarchy(hierarchy, typeMethods[index]); if (result != null && Flags.isFinal(result.getModifiers())) continue; ITypeBinding[] parameterBindings= typeMethods[index].getParameterTypes(); boolean upper= false; for (int offset= 0; offset < parameterBindings.length; offset++) { if (parameterBindings[offset].isWildcardType() && parameterBindings[offset].isUpperbound()) upper= true; } if (!upper) allMethods.add(typeMethods[index]); } } return allMethods.toArray(new IMethodBinding[allMethods.size()]); }
private static IMethodBinding[] getDelegateCandidates(ITypeBinding binding, ITypeBinding hierarchy) { List allMethods= new ArrayList(); boolean isInterface= binding.isInterface(); IMethodBinding[] typeMethods= binding.getDeclaredMethods(); for (int index= 0; index < typeMethods.length; index++) { final int modifiers= typeMethods[index].getModifiers(); if (!typeMethods[index].isConstructor() && !Modifier.isStatic(modifiers) && (isInterface || Modifier.isPublic(modifiers))) { IMethodBinding result= Bindings.findOverriddenMethodInHierarchy(hierarchy, typeMethods[index]); if (result != null && Flags.isFinal(result.getModifiers())) continue; ITypeBinding[] parameterBindings= typeMethods[index].getParameterTypes(); boolean upper= false; for (int offset= 0; offset < parameterBindings.length; offset++) { if (parameterBindings[offset].isWildcardType() && parameterBindings[offset].isUpperbound()) upper= true; } if (!upper) allMethods.add(typeMethods[index]); } } return (IMethodBinding[]) allMethods.toArray(new IMethodBinding[allMethods.size()]); }
private static IMethodBinding[] getDelegateCandidates(ITypeBinding binding, ITypeBinding hierarchy) { List<IMethodBinding> allMethods= new ArrayList<>(); boolean isInterface= binding.isInterface(); IMethodBinding[] typeMethods= binding.getDeclaredMethods(); for (int index= 0; index < typeMethods.length; index++) { final int modifiers= typeMethods[index].getModifiers(); if (!typeMethods[index].isConstructor() && !Modifier.isStatic(modifiers) && (isInterface || Modifier.isPublic(modifiers))) { IMethodBinding result= Bindings.findOverriddenMethodInHierarchy(hierarchy, typeMethods[index]); if (result != null && Flags.isFinal(result.getModifiers())) continue; ITypeBinding[] parameterBindings= typeMethods[index].getParameterTypes(); boolean upper= false; for (int offset= 0; offset < parameterBindings.length; offset++) { if (parameterBindings[offset].isWildcardType() && parameterBindings[offset].isUpperbound()) upper= true; } if (!upper) allMethods.add(typeMethods[index]); } } return allMethods.toArray(new IMethodBinding[allMethods.size()]); }
IMethodBinding res= findOverriddenMethodInHierarchy(type.getSuperclass(), overriding); if (res != null && !Modifier.isPrivate(res.getModifiers())) { if (!testVisibility || isVisibleInHierarchy(res, overriding.getDeclaringClass().getPackage())) { IMethodBinding res= findOverriddenMethodInHierarchy(interfaces[i], overriding); if (res != null) {
IMethodBinding res= findOverriddenMethodInHierarchy(type.getSuperclass(), overriding); if (res != null && !Modifier.isPrivate(res.getModifiers())) { if (!testVisibility || isVisibleInHierarchy(res, overriding.getDeclaringClass().getPackage())) { IMethodBinding res= findOverriddenMethodInHierarchy(interfaces[i], overriding); if (res != null) {
IMethodBinding res= findOverriddenMethodInHierarchy(type.getSuperclass(), overriding); if (res != null && !Modifier.isPrivate(res.getModifiers())) { if (!testVisibility || isVisibleInHierarchy(res, overriding.getDeclaringClass().getPackage())) { IMethodBinding res= findOverriddenMethodInHierarchy(interfaces[i], overriding); if (res != null) { return res; // methods from interfaces are always public and therefore visible