.setCloseDate(parseDate("2015-10-03")); DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10)
/** * Extract the lines of all the locations in the specified component. All the flows and secondary locations * are taken into account. The lines present in multiple flows and locations are kept * duplicated. Ordering of results is not guaranteed. * <p> * TODO should be a method of DefaultIssue, as soon as it's no * longer in sonar-core and can access sonar-db-dao. */ public static IntStream allLinesFor(DefaultIssue issue, String componentId) { 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), componentId)) .map(DbIssues.Location::getTextRange)); return textRanges.flatMapToInt(range -> IntStream.rangeClosed(range.getStartLine(), range.getEndLine())); }
@CheckForNull public DbIssues.Locations parseLocations() { if (locations != null) { try { return DbIssues.Locations.parseFrom(locations); } catch (InvalidProtocolBufferException e) { throw new IllegalStateException(String.format("Fail to read ISSUES.LOCATIONS [KEE=%s]", kee), e); } } return null; }
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
issue.setGap(reportIssue.getGap()); DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
public Builder mergeFrom(org.sonar.db.protobuf.DbIssues.Locations other) { if (other == org.sonar.db.protobuf.DbIssues.Locations.getDefaultInstance()) return this; if (other.hasTextRange()) { mergeTextRange(other.getTextRange());
private static Optional<Changeset> getChangeset(Component component, ScmInfo scmInfo, DefaultIssue issue) { Set<Integer> involvedLines = new HashSet<>(); DbIssues.Locations locations = issue.getLocations(); if (locations != null) { if (locations.hasTextRange()) { addLines(involvedLines, locations.getTextRange()); } for (Flow f : locations.getFlowList()) { for (Location l : f.getLocationList()) { if (Objects.equals(l.getComponentId(), component.getUuid())) { // Ignore locations in other files, since it is currently not very common, and this is hard to load SCM by component UUID. addLines(involvedLines, l.getTextRange()); } } } if (!involvedLines.isEmpty()) { return involvedLines.stream() .filter(scmInfo::hasChangesetForLine) .map(scmInfo::getChangesetForLine) .max(Comparator.comparingLong(Changeset::getDate)); } } return Optional.of(scmInfo.getLatestChangeset()); }
public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; size = 0; if (((bitField0_ & 0x00000001) == 0x00000001)) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(1, getTextRange()); } for (int i = 0; i < flow_.size(); i++) { size += com.google.protobuf.CodedOutputStream .computeMessageSize(2, flow_.get(i)); } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; }
private static void completeIssueLocations(IssueDto dto, Issue.Builder issueBuilder, SearchResponseData data) { DbIssues.Locations locations = dto.parseLocations(); if (locations == null) { return; } if (locations.hasTextRange()) { DbCommons.TextRange textRange = locations.getTextRange(); issueBuilder.setTextRange(convertTextRange(textRange)); } for (DbIssues.Flow flow : locations.getFlowList()) { Flow.Builder targetFlow = Flow.newBuilder(); for (DbIssues.Location flowLocation : flow.getLocationList()) { targetFlow.addLocations(convertLocation(issueBuilder, flowLocation, data)); } issueBuilder.addFlows(targetFlow); } }
public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
private void collectComponentsFromIssueLocations(IssueDto issue) { DbIssues.Locations locations = issue.parseLocations(); if (locations != null) { for (DbIssues.Flow flow : locations.getFlowList()) { for (DbIssues.Location location : flow.getLocationList()) { if (location.hasComponentId()) { componentUuids.add(location.getComponentId()); } } } } }
public IssueDto setLocations(@Nullable DbIssues.Locations locations) { if (locations == null) { this.locations = null; } else { this.locations = locations.toByteArray(); } return this; }
public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (((bitField0_ & 0x00000001) == 0x00000001)) { output.writeMessage(1, getTextRange()); } for (int i = 0; i < flow_.size(); i++) { output.writeMessage(2, flow_.get(i)); } unknownFields.writeTo(output); }
@CheckForNull public DbIssues.Locations parseLocations() { if (locations != null) { try { return DbIssues.Locations.parseFrom(locations); } catch (InvalidProtocolBufferException e) { throw new IllegalStateException(String.format("Fail to read ISSUES.LOCATIONS [KEE=%s]", kee), e); } } return null; }
.setCloseDate(parseDate("2015-10-03")); DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10)
.setCloseDate(parseDate("2015-10-03")); DbIssues.Locations issueLocations = DbIssues.Locations.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10)
ComponentDto file = db.components().insertComponent(newFileDto(project)); ComponentDto anotherFile = db.components().insertComponent(newFileDto(project)); DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder().addFlow(DbIssues.Flow.newBuilder().addAllLocation(Arrays.asList( DbIssues.Location.newBuilder() .setComponentId(file.uuid())
issue.setGap(reportIssue.getGap()); DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange()));
assertThat(locations.getFlowList()).hasSize(1); assertThat(locations.getFlow(0).getLocationList()).hasSize(2); assertThat(locations.getFlow(0).getLocation(0).getComponentId()).isEmpty(); assertThat(locations.getFlow(0).getLocation(1).getComponentId()).isEqualTo(ANOTHER_FILE_UUID);
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportExternalIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportExternalIssue.getTextRange()));