@NotNull private static List<PsiMethod> findMethodsBySignature( @NotNull PsiClass aClass, @NotNull PsiMethod patternMethod, boolean checkBases, boolean stopOnFirst) { final PsiMethod[] methodsByName = aClass.findMethodsByName(patternMethod.getName(), checkBases); if (methodsByName.length == 0) return Collections.emptyList(); final List<PsiMethod> methods = new SmartList<PsiMethod>(); final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (final PsiMethod method : methodsByName) { final PsiClass superClass = method.getContainingClass(); final PsiSubstitutor substitutor; if (checkBases && !aClass.equals(superClass)) { substitutor = TypeConversionUtil.getSuperClassSubstitutor(superClass, aClass, PsiSubstitutor.EMPTY); } else { substitutor = PsiSubstitutor.EMPTY; } final MethodSignature signature = method.getSignature(substitutor); if (signature.equals(patternSignature)) { methods.add(method); if (stopOnFirst) { break; } } } return methods; }
@Nullable public static PsiMethod findMethodBySignature( GrTypeDefinition grType, PsiMethod patternMethod, boolean checkBases) { final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod method : findMethodsByName(grType, patternMethod.getName(), checkBases, false)) { MethodSignature signature = getSignatureForInheritor(method, grType); if (patternSignature.equals(signature)) return method; } return null; }
private static PsiMethod[] findMethodsBySignature( GrTypeDefinition grType, PsiMethod patternMethod, boolean checkBases, boolean includeSynthetic) { ArrayList<PsiMethod> result = new ArrayList<PsiMethod>(); final MethodSignature patternSignature = patternMethod.getSignature(PsiSubstitutor.EMPTY); for (PsiMethod method : findMethodsByName(grType, patternMethod.getName(), checkBases, includeSynthetic)) { MethodSignature signature = getSignatureForInheritor(method, grType); if (patternSignature.equals(signature)) { result.add(method); } } return result.toArray(new PsiMethod[result.size()]); }
@Nullable private static List<MethodSignature> hasSubsignature(List<MethodSignature> signatures) { for (MethodSignature signature : signatures) { boolean subsignature = true; for (MethodSignature methodSignature : signatures) { if (!signature.equals(methodSignature)) { if (!MethodSignatureUtil.isSubsignature(signature, methodSignature)) { subsignature = false; break; } } } if (subsignature) return Collections.singletonList(signature); } return signatures; }