Java 类com.intellij.psi.search.searches.DeepestSuperMethodsSearch 实例源码

项目:tools-idea    文件:SuperMethodWarningUtil.java   
@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;
}
项目:consulo-java    文件:PsiSuperMethodImplUtil.java   
@Nullable
public static PsiMethod findDeepestSuperMethod(@NotNull PsiMethod method)
{
    if(!canHaveSuperMethod(method, true, false))
    {
        return null;
    }
    return DeepestSuperMethodsSearch.search(method).findFirst();
}
项目:consulo-java    文件:PsiSuperMethodImplUtil.java   
@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()]);
}
项目:consulo-java    文件:SuperMethodWarningUtil.java   
@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;
}
项目:intellij-ce-playground    文件:PsiSuperMethodImplUtil.java   
@Nullable
public static PsiMethod findDeepestSuperMethod(@NotNull PsiMethod method) {
  if (!canHaveSuperMethod(method, true, false)) return null;
  return DeepestSuperMethodsSearch.search(method).findFirst();
}
项目:intellij-ce-playground    文件:PsiSuperMethodImplUtil.java   
@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()]);
}
项目:intellij-ce-playground    文件:SuperMethodWarningUtil.java   
@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;
}
项目:tools-idea    文件:PsiSuperMethodImplUtil.java   
@Nullable
public static PsiMethod findDeepestSuperMethod(PsiMethod method) {
  if (!canHaveSuperMethod(method, true, false)) return null;
  return DeepestSuperMethodsSearch.search(method).findFirst();
}
项目:tools-idea    文件:PsiSuperMethodImplUtil.java   
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()]);
}
项目:tools-idea    文件:RecursionWeigher.java   
@NotNull
public static PsiMethod findDeepestSuper(@NotNull final PsiMethod method) {
  final PsiMethod first = DeepestSuperMethodsSearch.search(method).findFirst();
  return first == null ? method : first;
}
项目:intellij-haxe    文件:HaxeMethodUtils.java   
@Nullable
public static PsiMethod findDeepestSuperMethod(PsiMethod method) {
  if (!canHaveSuperMethod(method, false)) return null;
  return DeepestSuperMethodsSearch.search(method).findFirst();
}
项目:intellij-haxe    文件:HaxeMethodUtils.java   
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()]);
}