boolean (final PsiElement element, final Set<PsiElement> victims, final PsiSearchHelper helper) { PsiMethod method; PsiParameter parameter = null; int index = 0; if (element instanceof PsiMethod) { method = (PsiMethod)element; } else if (element instanceof PsiParameter) { parameter = (PsiParameter)element; method = (PsiMethod)parameter.getDeclarationScope(); index = method.getParameterList().getParameterIndex(parameter); } else { LOG.error("Parameter or method expected, but found " + (element == null ? "null" : element.getClass().getName())); return false; } final PsiMethod superMethod = method.findDeepestSuperMethod(); PsiMethod keyMethod; PsiParameter keyParameter = null; if (superMethod != null) { Boolean good = myMethodCache.get(superMethod); if (good != null && !good.booleanValue()) { return false; } final PsiElement e = parameter == null ? superMethod : superMethod.getParameterList().getParameters()[index]; if (!victims.contains(e)) { myMethodCache.put(superMethod, Boolean.FALSE); return false; } keyMethod = superMethod; myMethods.put(method, keyMethod); if (parameter != null) { keyParameter = (PsiParameter)e; } } else { Boolean good = myMethodCache.get(method); if (good != null && good.booleanValue()) { myMethods.putIfAbsent(method, method); if (parameter != null && myParameters.get(parameter) == null) { myParameters.put(parameter, parameter); } return true; } keyMethod = method; keyParameter = parameter; } final PsiMethod[] overriders = OverridingMethodsSearch.search(keyMethod).toArray(PsiMethod.EMPTY_ARRAY); for (final PsiMethod overrider : overriders) { final PsiElement e = parameter != null ? overrider.getParameterList().getParameters()[index] : overrider; if (!victims.contains(e)) { myMethodCache.put(keyMethod, Boolean.FALSE); return false; } } for (final PsiMethod overrider : overriders) { final PsiElement e = parameter != null ? overrider.getParameterList().getParameters()[index] : overrider; myMethods.put(overrider, keyMethod); if (parameter != null) { myParameters.put((PsiParameter)e, keyParameter); } } myMethods.put(method, keyMethod); if (parameter != null) { myParameters.put(parameter, keyParameter); } myMethodCache.put(keyMethod, Boolean.TRUE); return true; }