本文整理汇总了Java中org.sonar.api.batch.sensor.issue.NewIssue.addLocation方法的典型用法代码示例。如果您正苦于以下问题:Java NewIssue.addLocation方法的具体用法?Java NewIssue.addLocation怎么用?Java NewIssue.addLocation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.api.batch.sensor.issue.NewIssue
的用法示例。
在下文中一共展示了NewIssue.addLocation方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: savePreciseIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void savePreciseIssue(PreciseIssue issue) {
NewIssue newIssue = sensorContext.newIssue();
InputFile primaryFile = Preconditions.checkNotNull(fileSystem.inputFile(fileSystem.predicates().is(issue.primaryLocation().file())));
newIssue
.forRule(ruleKey(issue.check()))
.at(newLocation(primaryFile, newIssue, issue.primaryLocation()));
if (issue.cost() != null) {
newIssue.gap(issue.cost());
}
InputFile secondaryFile;
for (IssueLocation secondary : issue.secondaryLocations()) {
secondaryFile = fileSystem.inputFile(fileSystem.predicates().is(secondary.file()));
if (secondaryFile == null) {
secondaryFile = primaryFile;
}
newIssue.addLocation(newLocation(secondaryFile, newIssue, secondary));
}
newIssue.save();
}
示例2: addSecondaryLocation
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void addSecondaryLocation(final NewIssue issue, final XMLReportFinding xanFinding,
final SensorContext sensorContext) {
final InputFile secondaryFile = mkInputFileOrNull(xanFinding.getSecondaryLocationOrNull(),
sensorContext);
if (secondaryFile != null) {
final NewIssueLocation secondaryLocation = issue.newLocation();
secondaryLocation.on(secondaryFile);
secondaryLocation.message(xanFinding.getSecondaryLocationMessage());
final int secondaryLine = normalizeLineNo(
xanFinding.getSecondaryLocationOrNull().getLineNoOrMinus1());
if (secondaryLine <= secondaryFile.lines()) {
final TextRange textRange = secondaryFile.selectLine(secondaryLine);
secondaryLocation.at(textRange);
}
issue.addLocation(secondaryLocation);
LOG.debug("Added secondary location for finding " + xanFinding.getFindingID());
}
}
示例3: savePreciseIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void savePreciseIssue(PreciseIssue issue) {
NewIssue newIssue = sensorContext.newIssue();
InputFile primaryFile = Preconditions.checkNotNull(fileSystem.inputFile(fileSystem.predicates().is(issue.primaryLocation().file())));
newIssue
.forRule(ruleKey(issue.check()))
.at(newLocation(primaryFile, newIssue, issue.primaryLocation()));
if (issue.cost() != null) {
newIssue.gap(issue.cost());
}
InputFile secondaryFile;
for (org.sonar.plugins.json.api.visitors.issue.IssueLocation secondary : issue.secondaryLocations()) {
secondaryFile = fileSystem.inputFile(fileSystem.predicates().is(secondary.file()));
if (secondaryFile == null) {
secondaryFile = primaryFile;
}
newIssue.addLocation(newLocation(secondaryFile, newIssue, secondary));
}
newIssue.save();
}
示例4: saveFileIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void saveFileIssue(FileIssue issue) {
NewIssue newIssue = sensorContext.newIssue();
InputFile primaryFile = Preconditions.checkNotNull(fileSystem.inputFile(fileSystem.predicates().is(issue.file())));
NewIssueLocation primaryLocation = newIssue.newLocation()
.message(issue.message())
.on(primaryFile);
newIssue
.forRule(ruleKey(issue.check()))
.at(primaryLocation);
if (issue.cost() != null) {
newIssue.gap(issue.cost());
}
InputFile secondaryFile;
for (IssueLocation secondary : issue.secondaryLocations()) {
secondaryFile = fileSystem.inputFile(fileSystem.predicates().is(secondary.file()));
if (secondaryFile == null) {
secondaryFile = primaryFile;
}
newIssue.addLocation(newLocation(secondaryFile, newIssue, secondary));
}
newIssue.save();
}
示例5: saveFileIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
private void saveFileIssue(FileIssue issue) {
NewIssue newIssue = sensorContext.newIssue();
InputFile primaryFile = Preconditions.checkNotNull(fileSystem.inputFile(fileSystem.predicates().is(issue.file())));
NewIssueLocation primaryLocation = newIssue.newLocation()
.message(issue.message())
.on(primaryFile);
newIssue
.forRule(ruleKey(issue.check()))
.at(primaryLocation);
if (issue.cost() != null) {
newIssue.gap(issue.cost());
}
InputFile secondaryFile;
for (org.sonar.plugins.json.api.visitors.issue.IssueLocation secondary : issue.secondaryLocations()) {
secondaryFile = fileSystem.inputFile(fileSystem.predicates().is(secondary.file()));
if (secondaryFile == null) {
secondaryFile = primaryFile;
}
newIssue.addLocation(newLocation(secondaryFile, newIssue, secondary));
}
newIssue.save();
}
示例6: onIssue
import org.sonar.api.batch.sensor.issue.NewIssue; //导入方法依赖的package包/类
@Override
public void onIssue(String ruleId, Location primaryLocation, Collection<Location> secondaryLocations) {
String repositoryKey = repositoryKeyByRoslynRuleKey.get(ruleId);
if (repositoryKey == null) {
return;
}
InputFile inputFile = context.fileSystem().inputFile(context.fileSystem().predicates()
.hasAbsolutePath(primaryLocation.getAbsolutePath()));
if (inputFile == null) {
return;
}
NewIssue newIssue = context.newIssue();
newIssue
.forRule(RuleKey.of(repositoryKey, ruleId))
.at(newIssue.newLocation()
.on(inputFile)
.at(inputFile.newRange(primaryLocation.getStartLine(), primaryLocation.getStartColumn(),
primaryLocation.getEndLine(), primaryLocation.getEndColumn()))
.message(primaryLocation.getMessage()));
for (Location secondaryLocation : secondaryLocations) {
if (!inputFile.absolutePath().equalsIgnoreCase(secondaryLocation.getAbsolutePath())) {
inputFile = context.fileSystem().inputFile(context.fileSystem().predicates()
.hasAbsolutePath(secondaryLocation.getAbsolutePath()));
if (inputFile == null) {
return;
}
}
NewIssueLocation newIssueLocation = newIssue.newLocation()
.on(inputFile)
.at(inputFile.newRange(secondaryLocation.getStartLine(), secondaryLocation.getStartColumn(),
secondaryLocation.getEndLine(), secondaryLocation.getEndColumn()));
String secondaryLocationMessage = secondaryLocation.getMessage();
if (secondaryLocationMessage != null) {
newIssueLocation.message(secondaryLocationMessage);
}
newIssue.addLocation(newIssueLocation);
}
newIssue.save();
}