@Override
  public Optional<ReadError> read(DbFileSources.Line.Builder lineBuilder) {
    if (readError == null) {
      try {
        processHighlightings(lineBuilder);
      } catch (RangeOffsetConverterException e) {
        readError = new ReadError(HIGHLIGHTING, lineBuilder.getLine());
        LOG.debug(format("Inconsistency detected in Highlighting data. Highlighting will be ignored for file '%s'", file.getKey()), e);
      }
    }
    return Optional.ofNullable(readError);
  }
@Test
  public void read_many_syntax_highlighting_on_many_lines() {
    TextRange textRange1 = newTextRange(LINE_1, LINE_3);
    when(rangeOffsetConverter.offsetToString(textRange1, LINE_1, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_1);
    when(rangeOffsetConverter.offsetToString(textRange1, LINE_2, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_2);
    when(rangeOffsetConverter.offsetToString(textRange1, LINE_3, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_3);

    TextRange textRange2 = newTextRange(LINE_2, LINE_4);
    when(rangeOffsetConverter.offsetToString(textRange2, LINE_2, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_2);
    when(rangeOffsetConverter.offsetToString(textRange2, LINE_3, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_2);
    when(rangeOffsetConverter.offsetToString(textRange2, LINE_4, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_4);

    TextRange textRange3 = newTextRange(LINE_2, LINE_2);
    when(rangeOffsetConverter.offsetToString(textRange3, LINE_2, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_5);

    HighlightingLineReader highlightingLineReader = newReader(of(
      textRange1, ANNOTATION,
      textRange2, HIGHLIGHTING_STRING,
      textRange3, COMMENT));

    assertThat(highlightingLineReader.read(line1)).isEmpty();
    assertThat(highlightingLineReader.read(line2)).isEmpty();
    assertThat(highlightingLineReader.read(line3)).isEmpty();
    assertThat(highlightingLineReader.read(line4)).isEmpty();

    assertThat(line1.getHighlighting()).isEqualTo(RANGE_LABEL_1 + ",a");
    assertThat(line2.getHighlighting()).isEqualTo(RANGE_LABEL_2 + ",a;" + RANGE_LABEL_2 + ",s;" + RANGE_LABEL_5 + ",cd");
    assertThat(line3.getHighlighting()).isEqualTo(RANGE_LABEL_3 + ",a;" + RANGE_LABEL_2 + ",s");
    assertThat(line4.getHighlighting()).isEqualTo(RANGE_LABEL_4 + ",s");
  }