private void gotoNextError(Project project, Editor editor, PsiFile file, int caretOffset) {
    SeverityRegistrar severityRegistrar = SeverityRegistrar.getSeverityRegistrar(project);
    DaemonCodeAnalyzerSettings settings = DaemonCodeAnalyzerSettings.getInstance();
    int maxSeverity = settings.isNextErrorActionGoesToErrorsFirst() ? severityRegistrar.getSeveritiesCount() - 1
                                                                    : SeverityRegistrar.SHOWN_SEVERITIES_OFFSET;

    for (int idx = maxSeverity; idx >= SeverityRegistrar.SHOWN_SEVERITIES_OFFSET; idx--) {
      HighlightSeverity minSeverity = severityRegistrar.getSeverityByIndex(idx);
      if (minSeverity == null) continue;
      HighlightInfo infoToGo = findInfo(project, editor, caretOffset, minSeverity);
      if (infoToGo != null) {
        navigateToError(project, editor, infoToGo, () -> {
          if (Registry.is("error.navigation.show.tooltip")) {
            // When there are multiple warnings at the same offset, this will return the HighlightInfo
            // containing all of them, not just the first one as found by findInfo()
            HighlightInfo fullInfo = ((DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(project))
              .findHighlightByOffset(editor.getDocument(), editor.getCaretModel().getOffset(), false);
            HighlightInfo info = fullInfo != null ? fullInfo : infoToGo;
            EditorMouseHoverPopupManager.getInstance().showInfoTooltip(editor, info, editor.getCaretModel().getOffset(), false, true);
          }
        });
        return;
      }
    }
    showMessageWhenNoHighlights(project, file, editor, caretOffset);
  }
private void gotoNextError(Project project, Editor editor, PsiFile file, int caretOffset)