private static boolean isExternal(final Match match, final PsiMethod method) {
    final PsiElement matchStart = match.getMatchStart();
    final PsiClass containingClass = method.getContainingClass();
    if (PsiTreeUtil.isAncestor(containingClass, matchStart, false)) {
      return false;
    }
    PsiClass psiClass = PsiTreeUtil.getParentOfType(matchStart, PsiClass.class);
    while (psiClass != null) {
      if (InheritanceUtil.isInheritorOrSelf(psiClass, containingClass, true)) return false;
      psiClass = PsiTreeUtil.getParentOfType(psiClass, PsiClass.class);
    }
    return true;
  }
private static boolean isExternal(final Match match, final PsiMethod method)