public void checkLineMarkers(
      @NotNull Collection<LineMarkerInfo> markerInfos, @NotNull String text) {
    String fileName = myFile == null ? "" : myFile.getName() + ": ";
    String failMessage = "";

    for (LineMarkerInfo info : markerInfos) {
      if (!containsLineMarker(info, myLineMarkerInfos.values())) {
        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Extra line marker highlighted "
                + rangeString(text, info.startOffset, info.endOffset)
                + ": '"
                + info.getLineMarkerTooltip()
                + "'";
      }
    }

    for (LineMarkerInfo expectedLineMarker : myLineMarkerInfos.values()) {
      if (!markerInfos.isEmpty() && !containsLineMarker(expectedLineMarker, markerInfos)) {
        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Line marker was not highlighted "
                + rangeString(text, expectedLineMarker.startOffset, expectedLineMarker.endOffset)
                + ": '"
                + expectedLineMarker.getLineMarkerTooltip()
                + "'";
      }
    }

    if (!failMessage.isEmpty()) Assert.fail(failMessage);
  }
  private static boolean containsLineMarker(LineMarkerInfo info, Collection<LineMarkerInfo> where) {
    final String infoTooltip = info.getLineMarkerTooltip();

    for (LineMarkerInfo markerInfo : where) {
      String markerInfoTooltip;
      if (markerInfo.startOffset == info.startOffset
          && markerInfo.endOffset == info.endOffset
          && (Comparing.equal(infoTooltip, markerInfoTooltip = markerInfo.getLineMarkerTooltip())
              || ANY_TEXT.equals(markerInfoTooltip)
              || ANY_TEXT.equals(infoTooltip))) {
        return true;
      }
    }
    return false;
  }
 private void refreshLineMarkers() {
   for (Map.Entry<RangeMarker, LineMarkerInfo> entry : myLineMarkerInfos.entrySet()) {
     RangeMarker rangeMarker = entry.getKey();
     int startOffset = rangeMarker.getStartOffset();
     int endOffset = rangeMarker.getEndOffset();
     LineMarkerInfo value = entry.getValue();
     PsiElement element = value.getElement();
     assert element != null : value;
     TextRange range = new TextRange(startOffset, endOffset);
     final String tooltip = value.getLineMarkerTooltip();
     LineMarkerInfo markerInfo =
         new LineMarkerInfo<>(
             element,
             range,
             null,
             value.updatePass,
             e -> tooltip,
             null,
             GutterIconRenderer.Alignment.RIGHT);
     entry.setValue(markerInfo);
   }
 }
  public void checkLineMarkers(Collection<LineMarkerInfo> markerInfos, String text) {
    String fileName = myFile == null ? "" : myFile.getName() + ": ";
    String failMessage = "";

    if (markerInfos != null) {
      for (LineMarkerInfo info : markerInfos) {
        if (!containsLineMarker(info, lineMarkerInfos.values())) {
          final int startOffset = info.startOffset;
          final int endOffset = info.endOffset;

          int y1 = StringUtil.offsetToLineNumber(text, startOffset);
          int y2 = StringUtil.offsetToLineNumber(text, endOffset);
          int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0);
          int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0);

          if (!failMessage.isEmpty()) failMessage += '\n';
          failMessage +=
              fileName
                  + "Extra line marker highlighted "
                  + "("
                  + (x1 + 1)
                  + ", "
                  + (y1 + 1)
                  + ")"
                  + "-"
                  + "("
                  + (x2 + 1)
                  + ", "
                  + (y2 + 1)
                  + ")"
                  + ": '"
                  + info.getLineMarkerTooltip()
                  + "'";
        }
      }
    }

    for (LineMarkerInfo expectedLineMarker : lineMarkerInfos.values()) {
      if (markerInfos != null && !containsLineMarker(expectedLineMarker, markerInfos)) {
        final int startOffset = expectedLineMarker.startOffset;
        final int endOffset = expectedLineMarker.endOffset;

        int y1 = StringUtil.offsetToLineNumber(text, startOffset);
        int y2 = StringUtil.offsetToLineNumber(text, endOffset);
        int x1 = startOffset - StringUtil.lineColToOffset(text, y1, 0);
        int x2 = endOffset - StringUtil.lineColToOffset(text, y2, 0);

        if (!failMessage.isEmpty()) failMessage += '\n';
        failMessage +=
            fileName
                + "Line marker was not highlighted "
                + "("
                + (x1 + 1)
                + ", "
                + (y1 + 1)
                + ")"
                + "-"
                + "("
                + (x2 + 1)
                + ", "
                + (y2 + 1)
                + ")"
                + ": '"
                + expectedLineMarker.getLineMarkerTooltip()
                + "'";
      }
    }

    if (!failMessage.isEmpty()) Assert.fail(failMessage);
  }