public void apply(@Nullable Project project, @NotNull Document document) {
    MarkupModelEx model = (MarkupModelEx)DocumentMarkupModel.forDocument(document, project, true);

    for (Element piece : myPieces) {
      RangeHighlighterEx delegate = piece.getDelegate();
      if (!delegate.isValid()) continue;

      model.addRangeHighlighterAndChangeAttributes(
        delegate.getTextAttributesKey(), piece.getStart(), piece.getEnd(), delegate.getLayer(),
        delegate.getTargetArea(), false, ex -> {
          ex.copyFrom(delegate);
        });
    }
  }
public void apply(@Nullable Project project, @NotNull Document document)