private Optional<DbIssues.Location> convertLocation(ScannerReport.IssueLocation source) { DbIssues.Location.Builder target = DbIssues.Location.newBuilder(); if (source.getComponentRef() != 0 && source.getComponentRef() != component.getReportAttributes().getRef()) { // SONAR-10781 Component might not exist because on short living branch and PR, only changed components are included in the report Optional<Component> optionalComponent = treeRootHolder.getOptionalComponentByRef(source.getComponentRef()); if (!optionalComponent.isPresent()) { return Optional.empty(); } target.setComponentId(optionalComponent.get().getUuid()); } if (isNotEmpty(source.getMsg())) { target.setMsg(source.getMsg()); } if (source.hasTextRange()) { ScannerReport.TextRange sourceRange = source.getTextRange(); DbCommons.TextRange.Builder targetRange = convertTextRange(sourceRange); target.setTextRange(targetRange); } return Optional.of(target.build()); }
private Optional<DbIssues.Location> convertLocation(ScannerReport.IssueLocation source) { DbIssues.Location.Builder target = DbIssues.Location.newBuilder(); if (source.getComponentRef() != 0 && source.getComponentRef() != component.getReportAttributes().getRef()) { // SONAR-10781 Component might not exist because on short living branch and PR, only changed components are included in the report Optional<Component> optionalComponent = treeRootHolder.getOptionalComponentByRef(source.getComponentRef()); if (!optionalComponent.isPresent()) { return Optional.empty(); } target.setComponentId(optionalComponent.get().getUuid()); } if (isNotEmpty(source.getMsg())) { target.setMsg(source.getMsg()); } if (source.hasTextRange()) { ScannerReport.TextRange sourceRange = source.getTextRange(); DbCommons.TextRange.Builder targetRange = convertTextRange(sourceRange); target.setTextRange(targetRange); } return Optional.of(target.build()); }
/** * <code>repeated .sonarqube.db.issues.Location location = 1;</code> */ public Builder addLocation( org.sonar.db.protobuf.DbIssues.Location.Builder builderForValue) { if (locationBuilder_ == null) { ensureLocationIsMutable(); location_.add(builderForValue.build()); onChanged(); } else { locationBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Location location = 1;</code> */ public Builder setLocation( int index, org.sonar.db.protobuf.DbIssues.Location.Builder builderForValue) { if (locationBuilder_ == null) { ensureLocationIsMutable(); location_.set(index, builderForValue.build()); onChanged(); } else { locationBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Location location = 1;</code> */ public Builder addLocation( int index, org.sonar.db.protobuf.DbIssues.Location.Builder builderForValue) { if (locationBuilder_ == null) { ensureLocationIsMutable(); location_.add(index, builderForValue.build()); onChanged(); } else { locationBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
public org.sonar.db.protobuf.DbIssues.Location build() { org.sonar.db.protobuf.DbIssues.Location result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
@java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**
DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder().addFlow(DbIssues.Flow.newBuilder().addAllLocation(Arrays.asList( DbIssues.Location.newBuilder() .setComponentId(file.uuid()) .setMsg("FLOW MESSAGE") .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(1) .setEndLine(1) .setEndOffset(12) .build()) .build(), DbIssues.Location.newBuilder() .setComponentId(anotherFile.uuid()) .setMsg("ANOTHER FLOW MESSAGE") .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(1) .setEndLine(1) .setEndOffset(12) .build()) .build(), DbIssues.Location.newBuilder() .setMsg("FLOW MESSAGE WITHOUT FILE UUID") .setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(1) .setEndLine(1) .setEndOffset(12)
private static Location newLocation(int startLine, int endLine) { return Location.newBuilder().setTextRange(range(startLine, endLine)).build(); }
private static Location newLocation(int startLine, int endLine, String componentUuid) { return Location.newBuilder().setTextRange(range(startLine, endLine)).setComponentId(componentUuid).build(); }
private static DbIssues.Location newLocation(int line) { return DbIssues.Location.newBuilder() .setComponentId(FILE.getUuid()) .setTextRange(DbCommons.TextRange.newBuilder().setStartLine(line).setEndLine(line).build()).build(); }
private static DbIssues.Location newLocation(@Nullable String componentId, int startLine, int endLine) { DbIssues.Location.Builder builder = DbIssues.Location.newBuilder() .setTextRange(DbCommons.TextRange.newBuilder().setStartLine(startLine).setEndLine(endLine).build()); ofNullable(componentId).ifPresent(builder::setComponentId); return builder.build(); } }