DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportExternalIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportExternalIssue.getTextRange())); convertLocation(location).ifPresent(dbFlowBuilder::addLocation); dbLocationsBuilder.addFlow(dbFlowBuilder); issue.setLocations(dbLocationsBuilder.build()); issue.setType(toRuleType(reportExternalIssue.getType()));
@Test public void allLinesFor_traverses_all_flows() { DbIssues.Locations.Builder locations = DbIssues.Locations.newBuilder(); locations.addFlowBuilder() .addLocation(newLocation("file1", 5, 5)) .addLocation(newLocation("file2", 10, 11)) .build(); locations.addFlowBuilder() .addLocation(newLocation("file1", 7, 9)) .addLocation(newLocation("file2", 12, 12)) .build(); DefaultIssue issue = new DefaultIssue().setLocations(locations.build()); assertThat(IssueLocations.allLinesFor(issue, "file1")).containsExactlyInAnyOrder(5, 7, 8, 9); assertThat(IssueLocations.allLinesFor(issue, "file2")).containsExactlyInAnyOrder(10, 11, 12); }
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()); bitField0_ = (bitField0_ & ~0x00000002); } else { ensureFlowIsMutable(); flow_.addAll(other.flow_); onChanged(); flowBuilder_ = com.google.protobuf.GeneratedMessage.alwaysUseFieldBuilders ? getFlowFieldBuilder() : null; } else { flowBuilder_.addAllMessages(other.flow_); this.mergeUnknownFields(other.unknownFields); onChanged(); return this;
DbIssues.Locations.Builder dbLocationsBuilder = DbIssues.Locations.newBuilder(); if (reportIssue.hasTextRange()) { dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange())); convertLocation(location).ifPresent(dbFlowBuilder::addLocation); dbLocationsBuilder.addFlow(dbFlowBuilder); issue.setLocations(dbLocationsBuilder.build()); issue.setType(toRuleType(reportIssue.getType()));
dbLocationsBuilder.setTextRange(convertTextRange(reportIssue.getTextRange())); convertLocation(location).ifPresent(dbFlowBuilder::addLocation); dbLocationsBuilder.addFlow(dbFlowBuilder); issue.setLocations(dbLocationsBuilder.build()); return issue;
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder setFlow( int index, org.sonar.db.protobuf.DbIssues.Flow value) { if (flowBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureFlowIsMutable(); flow_.set(index, value); onChanged(); } else { flowBuilder_.setMessage(index, value); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder addFlow( int index, org.sonar.db.protobuf.DbIssues.Flow value) { if (flowBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureFlowIsMutable(); flow_.add(index, value); onChanged(); } else { flowBuilder_.addMessage(index, value); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder addFlow(org.sonar.db.protobuf.DbIssues.Flow value) { if (flowBuilder_ == null) { if (value == null) { throw new NullPointerException(); } ensureFlowIsMutable(); flow_.add(value); onChanged(); } else { flowBuilder_.addMessage(value); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder addAllFlow( java.lang.Iterable<? extends org.sonar.db.protobuf.DbIssues.Flow> values) { if (flowBuilder_ == null) { ensureFlowIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll( values, flow_); onChanged(); } else { flowBuilder_.addAllMessages(values); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder setFlow( int index, org.sonar.db.protobuf.DbIssues.Flow.Builder builderForValue) { if (flowBuilder_ == null) { ensureFlowIsMutable(); flow_.set(index, builderForValue.build()); onChanged(); } else { flowBuilder_.setMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder addFlow( org.sonar.db.protobuf.DbIssues.Flow.Builder builderForValue) { if (flowBuilder_ == null) { ensureFlowIsMutable(); flow_.add(builderForValue.build()); onChanged(); } else { flowBuilder_.addMessage(builderForValue.build()); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder addFlow( int index, org.sonar.db.protobuf.DbIssues.Flow.Builder builderForValue) { if (flowBuilder_ == null) { ensureFlowIsMutable(); flow_.add(index, builderForValue.build()); onChanged(); } else { flowBuilder_.addMessage(index, builderForValue.build()); } return this; } /**
/** * <code>repeated .sonarqube.db.issues.Flow flow = 2;</code> */ public Builder removeFlow(int index) { if (flowBuilder_ == null) { ensureFlowIsMutable(); flow_.remove(index); onChanged(); } else { flowBuilder_.remove(index); } return this; } /**
@java.lang.Override protected Builder newBuilderForType( com.google.protobuf.GeneratedMessage.BuilderParent parent) { Builder builder = new Builder(parent); return builder; } /**
public org.sonar.db.protobuf.DbIssues.Locations build() { org.sonar.db.protobuf.DbIssues.Locations result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
.setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10) .setEndLine(12) .build()) .build(); DefaultIssue base = new DefaultIssue() .setKey("BASE_KEY")
.setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10) .setEndLine(12) .build()) .build(); DefaultIssue base = new DefaultIssue() .setKey("BASE_KEY")
.setTextRange(DbCommons.TextRange.newBuilder() .setStartLine(10) .setEndLine(12) .build()) .build(); DefaultIssue base = new DefaultIssue() .setKey("BASE_KEY")
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()) .build()))); RuleDefinitionDto rule = newRule().getDefinition(); db.issues().insert(rule, project, file, i -> i.setLocations(locations.build())); indexIssues();