public static IntStream allLinesFor(DefaultIssue issue, String componentUuid) {
    DbIssues.Locations locations = issue.getLocations();
    if (locations == null) {
      return IntStream.empty();
    }

    Stream<DbCommons.TextRange> textRanges = Stream.concat(
      locations.hasTextRange() ? Stream.of(locations.getTextRange()) : Stream.empty(),
      locations.getFlowList().stream()
        .flatMap(f -> f.getLocationList().stream())
        .filter(l -> Objects.equals(componentIdOf(issue, l), componentUuid))
        .map(DbIssues.Location::getTextRange));
    return textRanges.flatMapToInt(range -> IntStream.rangeClosed(range.getStartLine(), range.getEndLine()));
  }
@Test
  public void allLinesFor_default_component_of_location_is_the_issue_component() {
    DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder();
    locations.addFlowBuilder()
      .addLocation(newLocation("", 5, 5))
      .addLocation(newLocation(null, 7, 7))
      .addLocation(newLocation("file2", 9, 9))
      .build();
    DefaultIssue issue = new DefaultIssue()
      .setComponentUuid("file1")
      .setLocations(locations.build());

    assertThat(IssueLocations.allLinesFor(issue, "file1")).containsExactlyInAnyOrder(5, 7);
    assertThat(IssueLocations.allLinesFor(issue, "file2")).containsExactlyInAnyOrder(9);
    assertThat(IssueLocations.allLinesFor(issue, "file3")).isEmpty();
  }