Optional<TextRange> mapRegion(@Nullable Region region, InputFile file) {
    if (region == null) {
      return Optional.empty();
    }
    int startLine = Objects.requireNonNull(region.getStartLine(), "No start line defined for the region.");
    int endLine = Optional.ofNullable(region.getEndLine()).orElse(startLine);
    int startColumn = Optional.ofNullable(region.getStartColumn()).map(RegionMapper::adjustSarifColumnIndexToSqIndex).orElse(0);
    int endColumn = Optional.ofNullable(region.getEndColumn()).map(RegionMapper::adjustSarifColumnIndexToSqIndex)
      .orElseGet(() -> file.selectLine(endLine).end().lineOffset());
    if (rangeIsEmpty(startLine, endLine, startColumn, endColumn)) {
      return Optional.of(file.selectLine(startLine));
    } else {
      return Optional.of(file.newRange(startLine, startColumn, endLine, endColumn));
    }
  }
@Test
  public void mapRegion_whenStartEndLinesDefinedAndStartColumn() {
    Region fullRegion = mockRegion(8, null, 3, 8);

    Optional<TextRange> optTextRange = regionMapper.mapRegion(fullRegion, INPUT_FILE);

    assertThat(optTextRange).isPresent();
    TextRange textRange = optTextRange.get();
    assertThat(textRange.start().line()).isEqualTo(fullRegion.getStartLine());
    assertThat(textRange.start().lineOffset()).isEqualTo(7);
    assertThat(textRange.end().line()).isEqualTo(fullRegion.getEndLine());
    assertThat(textRange.end().lineOffset()).isEqualTo(LINE_END_OFFSET);
  }