@Override
 public void onInitialize(RefElement refElement) {
   if (refElement instanceof RefMethod) {
     final PsiElement element = refElement.getElement();
     if (!(element instanceof PsiMethod)) return;
     if (!PsiType.BOOLEAN.equals(((PsiMethod) element).getReturnType())) return;
     refElement.putUserData(ALWAYS_INVERTED, Boolean.TRUE); // initial mark boolean methods
   }
 }
  protected HighlightSeverity getSeverity(@NotNull RefElement element) {
    final PsiElement psiElement = element.getPointer().getContainingFile();
    if (psiElement != null) {
      final GlobalInspectionContextImpl context = getContext();
      final String shortName = getSeverityDelegateName();
      final Tools tools = context.getTools().get(shortName);
      if (tools != null) {
        for (ScopeToolState state : tools.getTools()) {
          InspectionToolWrapper toolWrapper = state.getTool();
          if (toolWrapper == getToolWrapper()) {
            return context
                .getCurrentProfile()
                .getErrorLevel(HighlightDisplayKey.find(shortName), psiElement)
                .getSeverity();
          }
        }
      }

      final InspectionProfile profile =
          InspectionProjectProfileManager.getInstance(context.getProject()).getInspectionProfile();
      final HighlightDisplayLevel level =
          profile.getErrorLevel(HighlightDisplayKey.find(shortName), psiElement);
      return level.getSeverity();
    }
    return null;
  }
  @Override
  public CommonProblemDescriptor[] checkElement(
      @NotNull RefEntity refEntity,
      @NotNull AnalysisScope scope,
      @NotNull final InspectionManager manager,
      @NotNull final GlobalInspectionContext globalContext) {
    if (refEntity instanceof RefMethod) {
      RefMethod refMethod = (RefMethod) refEntity;
      if (!refMethod.isReferenced()) return null;
      if (hasNonInvertedCalls(refMethod)) return null;
      if (!refMethod.getSuperMethods().isEmpty()) return null;
      final PsiMethod psiMethod = (PsiMethod) refMethod.getElement();
      final PsiIdentifier psiIdentifier = psiMethod.getNameIdentifier();
      if (psiIdentifier != null) {
        final Collection<RefElement> inReferences = refMethod.getInReferences();
        if (inReferences.size() == 1) {
          final RefElement refElement = inReferences.iterator().next();
          final PsiElement usagesContainer = refElement.getElement();
          if (usagesContainer == null) return null;
          if (ReferencesSearch.search(psiMethod, new LocalSearchScope(usagesContainer))
              .forEach(
                  new Processor<PsiReference>() {
                    private final Set<PsiReference> myFoundRefs = new HashSet<>();

                    @Override
                    public boolean process(PsiReference reference) {
                      myFoundRefs.add(reference);
                      return myFoundRefs.size() < 2;
                    }
                  })) return null;
        }
        return new ProblemDescriptor[] {
          manager.createProblemDescriptor(
              psiIdentifier,
              InspectionsBundle.message("boolean.method.is.always.inverted.problem.descriptor"),
              (LocalQuickFix) getQuickFix(null),
              ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
              false)
        };
      }
    }
    return null;
  }
 @Override
 public void onMarkReferenced(
     RefElement refWhat, RefElement refFrom, boolean referencedFromClassInitializer) {
   checkMethodCall(refWhat, refFrom.getElement());
 }