@NotNull public static PsiMethod[] checkSuperMethods(final PsiMethod method, String actionString, Collection<PsiElement> ignore) { PsiClass aClass = method.getContainingClass(); if (aClass == null) return new PsiMethod[]{method}; final Collection<PsiMethod> superMethods = DeepestSuperMethodsSearch.search(method).findAll(); if (ignore != null) { superMethods.removeAll(ignore); } if (superMethods.isEmpty()) return new PsiMethod[]{method}; Set<String> superClasses = new HashSet<String>(); boolean superAbstract = false; boolean parentInterface = false; for (final PsiMethod superMethod : superMethods) { final PsiClass containingClass = superMethod.getContainingClass(); superClasses.add(containingClass.getQualifiedName()); final boolean isInterface = containingClass.isInterface(); superAbstract |= isInterface || superMethod.hasModifierProperty(PsiModifier.ABSTRACT); parentInterface |= isInterface; } SuperMethodWarningDialog dialog = new SuperMethodWarningDialog(method.getProject(), DescriptiveNameUtil.getDescriptiveName(method), actionString, superAbstract, parentInterface, aClass.isInterface(), ArrayUtil.toStringArray(superClasses)); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { return superMethods.toArray(new PsiMethod[superMethods.size()]); } if (dialog.getExitCode() == SuperMethodWarningDialog.NO_EXIT_CODE) { return new PsiMethod[]{method}; } return PsiMethod.EMPTY_ARRAY; }
@Nullable public static PsiMethod findDeepestSuperMethod(@NotNull PsiMethod method) { if(!canHaveSuperMethod(method, true, false)) { return null; } return DeepestSuperMethodsSearch.search(method).findFirst(); }
@NotNull public static PsiMethod[] findDeepestSuperMethods(@NotNull PsiMethod method) { if(!canHaveSuperMethod(method, true, false)) { return PsiMethod.EMPTY_ARRAY; } Collection<PsiMethod> collection = DeepestSuperMethodsSearch.search(method).findAll(); return collection.toArray(new PsiMethod[collection.size()]); }
@Nullable public static PsiMethod findDeepestSuperMethod(@NotNull PsiMethod method) { if (!canHaveSuperMethod(method, true, false)) return null; return DeepestSuperMethodsSearch.search(method).findFirst(); }
@NotNull public static PsiMethod[] findDeepestSuperMethods(@NotNull PsiMethod method) { if (!canHaveSuperMethod(method, true, false)) return PsiMethod.EMPTY_ARRAY; Collection<PsiMethod> collection = DeepestSuperMethodsSearch.search(method).findAll(); return collection.toArray(new PsiMethod[collection.size()]); }
@NotNull public static PsiMethod[] checkSuperMethods(@NotNull PsiMethod method, @NotNull String actionString, @NotNull Collection<PsiElement> ignore) { PsiClass aClass = method.getContainingClass(); if (aClass == null) return new PsiMethod[]{method}; final Collection<PsiMethod> superMethods = DeepestSuperMethodsSearch.search(method).findAll(); superMethods.removeAll(ignore); if (superMethods.isEmpty()) { PsiMethod siblingSuperMethod = FindSuperElementsHelper.getSiblingInheritedViaSubClass(method); if (siblingSuperMethod != null) { superMethods.add(siblingSuperMethod); } } if (superMethods.isEmpty()) return new PsiMethod[]{method}; Set<String> superClasses = new HashSet<String>(); boolean superAbstract = false; boolean parentInterface = false; for (final PsiMethod superMethod : superMethods) { final PsiClass containingClass = superMethod.getContainingClass(); superClasses.add(containingClass.getQualifiedName()); final boolean isInterface = containingClass.isInterface(); superAbstract |= isInterface || superMethod.hasModifierProperty(PsiModifier.ABSTRACT); parentInterface |= isInterface; } SuperMethodWarningDialog dialog = new SuperMethodWarningDialog(method.getProject(), DescriptiveNameUtil.getDescriptiveName(method), actionString, superAbstract, parentInterface, aClass.isInterface(), ArrayUtil.toStringArray(superClasses)); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { return superMethods.toArray(new PsiMethod[superMethods.size()]); } if (dialog.getExitCode() == SuperMethodWarningDialog.NO_EXIT_CODE) { return new PsiMethod[]{method}; } return PsiMethod.EMPTY_ARRAY; }
@Nullable public static PsiMethod findDeepestSuperMethod(PsiMethod method) { if (!canHaveSuperMethod(method, true, false)) return null; return DeepestSuperMethodsSearch.search(method).findFirst(); }
public static PsiMethod[] findDeepestSuperMethods(PsiMethod method) { if (!canHaveSuperMethod(method, true, false)) return PsiMethod.EMPTY_ARRAY; Collection<PsiMethod> collection = DeepestSuperMethodsSearch.search(method).findAll(); return collection.toArray(new PsiMethod[collection.size()]); }
@NotNull public static PsiMethod findDeepestSuper(@NotNull final PsiMethod method) { final PsiMethod first = DeepestSuperMethodsSearch.search(method).findFirst(); return first == null ? method : first; }
@Nullable public static PsiMethod findDeepestSuperMethod(PsiMethod method) { if (!canHaveSuperMethod(method, false)) return null; return DeepestSuperMethodsSearch.search(method).findFirst(); }
public static PsiMethod[] findDeepestSuperMethods(PsiMethod method) { if (!canHaveSuperMethod(method, false)) return PsiMethod.EMPTY_ARRAY; Collection<PsiMethod> collection = DeepestSuperMethodsSearch.search(method).findAll(); return collection.toArray(new PsiMethod[collection.size()]); }