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);
  }
 public void testRunnableMain() {
   List<LineMarkerInfo> infos = getInfos("runnable.py");
   assertEquals("Wrong number of line markers", 1, infos.size());
   LineMarkerInfo lineMarkerInfo = infos.get(0);
   PsiElement elementWithInfo = lineMarkerInfo.getElement();
   assertNotNull(elementWithInfo);
   assertTrue(elementWithInfo.getText().startsWith("if __name__ == \"__main__\""));
 }
  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;
  }
  @Nullable
  @Override
  public LineMarkerInfo getLineMarkerInfo(@NotNull final PsiElement element) {
    if (myDaemonSettings.SHOW_METHOD_SEPARATORS) {
      if (element instanceof DartMethodDeclaration
          || element instanceof DartFunctionDeclarationWithBody
          || element instanceof DartFunctionDeclarationWithBodyOrNative
          || element instanceof DartGetterDeclaration
          || element instanceof DartSetterDeclaration
          || element instanceof DartFactoryConstructorDeclaration
          || element instanceof AbstractDartMethodDeclarationImpl
          || element instanceof DartNamedConstructorDeclaration
          || element instanceof DartIncompleteDeclaration) {

        PsiElement markerLocation = element;
        while (markerLocation.getPrevSibling() != null
            && (markerLocation.getPrevSibling() instanceof PsiComment
                || (markerLocation.getPrevSibling() instanceof PsiWhiteSpace
                    && markerLocation.getPrevSibling().getPrevSibling() != null
                    && markerLocation.getPrevSibling().getPrevSibling() instanceof PsiComment))) {
          markerLocation = markerLocation.getPrevSibling();
        }

        LineMarkerInfo info =
            new LineMarkerInfo<PsiElement>(
                markerLocation,
                markerLocation.getTextRange(),
                null,
                Pass.UPDATE_ALL,
                FunctionUtil.<Object, String>nullConstant(),
                null,
                GutterIconRenderer.Alignment.RIGHT);
        EditorColorsScheme scheme = myColorsManager.getGlobalScheme();
        info.separatorColor = scheme.getColor(CodeInsightColors.METHOD_SEPARATORS_COLOR);
        info.separatorPlacement = SeparatorPlacement.TOP;
        return info;
      }
    }
    return null;
  }
 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);
   }
 }
 private void refreshLineMarkers() {
   for (Map.Entry<RangeMarker, LineMarkerInfo> entry : lineMarkerInfos.entrySet()) {
     RangeMarker rangeMarker = entry.getKey();
     int startOffset = rangeMarker.getStartOffset();
     int endOffset = rangeMarker.getEndOffset();
     final LineMarkerInfo value = entry.getValue();
     LineMarkerInfo markerInfo =
         new LineMarkerInfo<PsiElement>(
             value.getElement(),
             new TextRange(startOffset, endOffset),
             null,
             value.updatePass,
             new Function<PsiElement, String>() {
               @Override
               public String fun(PsiElement psiElement) {
                 return value.getLineMarkerTooltip();
               }
             },
             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);
  }