private static HighlightDisplayLevel calculatePreciseLevel(@Nullable RefEntity element,
                                                             @Nullable CommonProblemDescriptor descriptor,
                                                             @NotNull InspectionToolPresentation presentation) {
    if (element == null) return null;
    final InspectionProfileImpl profile = presentation.getContext().getCurrentProfile();
    String shortName = presentation.getToolWrapper().getShortName();
    if (descriptor instanceof ProblemDescriptor) {
      InspectionProfileManager inspectionProfileManager = profile.getProfileManager();
      RefElement refElement = (RefElement)element;
      SeverityRegistrar severityRegistrar = inspectionProfileManager.getSeverityRegistrar();
      HighlightSeverity severity = presentation.getSeverity(refElement);
      if (severity == null) return null;
      HighlightInfoType highlightInfoType = ProblemDescriptorUtil.highlightTypeFromDescriptor((ProblemDescriptor)descriptor, severity, severityRegistrar);
      HighlightSeverity highlightSeverity = highlightInfoType.getSeverity(refElement.getPsiElement());
      return HighlightDisplayLevel.find(highlightSeverity);
    }
    else {
      return profile.getTools(shortName, presentation.getContext().getProject()).getLevel();
    }
  }
private static HighlightDisplayLevel calculatePreciseLevel(@Nullable RefEntity element,
                                                             @Nullable CommonProblemDescriptor descriptor,
                                                             @NotNull InspectionToolPresentation presentation)