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()); } } } } }
private static Location convertLocation(Issue.Builder issueBuilder, DbIssues.Location source, SearchResponseData data) { Location.Builder target = Location.newBuilder(); if (source.hasMsg()) { target.setMsg(source.getMsg()); } if (source.hasTextRange()) { DbCommons.TextRange sourceRange = source.getTextRange(); Common.TextRange.Builder targetRange = convertTextRange(sourceRange); target.setTextRange(targetRange); } if (source.hasComponentId()) { ofNullable(data.getComponentByUuid(source.getComponentId())).ifPresent(c -> target.setComponent(c.getKey())); } else { target.setComponent(issueBuilder.getComponent()); } return target.build(); }
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);
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()); }
private static Location convertLocation(Issue.Builder issueBuilder, DbIssues.Location source, SearchResponseData data) { Location.Builder target = Location.newBuilder(); if (source.hasMsg()) { target.setMsg(source.getMsg()); } if (source.hasTextRange()) { DbCommons.TextRange sourceRange = source.getTextRange(); Common.TextRange.Builder targetRange = convertTextRange(sourceRange); target.setTextRange(targetRange); } if (source.hasComponentId()) { setNullable(data.getComponentByUuid(source.getComponentId()), c -> target.setComponent(c.getKey())); } else { target.setComponent(issueBuilder.getComponent()); } return target.build(); }
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()); } } } } }
/** * <code>optional string component_id = 1;</code> */ public Builder clearComponentId() { bitField0_ = (bitField0_ & ~0x00000001); componentId_ = getDefaultInstance().getComponentId(); onChanged(); return this; } /**
private static String componentIdOf(DefaultIssue issue, DbIssues.Location location) { if (location.hasComponentId()) { return StringUtils.defaultIfEmpty(location.getComponentId(), issue.componentUuid()); } return issue.componentUuid(); } }