当前位置: 首页>>代码示例>>Java>>正文


Java NewIssue.addLocation方法代码示例

本文整理汇总了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();
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:24,代码来源:IssueSaver.java

示例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());
	}
}
 
开发者ID:RIGS-IT,项目名称:sonar-xanitizer,代码行数:20,代码来源:XanitizerSensor.java

示例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();
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:24,代码来源:IssueSaver.java

示例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();
}
 
开发者ID:racodond,项目名称:sonar-css-plugin,代码行数:28,代码来源:IssueSaver.java

示例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();
}
 
开发者ID:racodond,项目名称:sonar-json-plugin,代码行数:28,代码来源:IssueSaver.java

示例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();
}
 
开发者ID:SonarSource,项目名称:sonar-dotnet-shared-library,代码行数:47,代码来源:AbstractSensor.java


注:本文中的org.sonar.api.batch.sensor.issue.NewIssue.addLocation方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。