org.sonar.api.resources.File.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.7k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中org.sonar.api.resources.File.getParent()方法的一些代码示例,展示了File.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。File.getParent()方法的具体详情如下:
包路径:org.sonar.api.resources.File
类名称:File
方法名:getParent

File.getParent介绍

暂无

代码示例

代码示例来源:origin: org.sonarsource.java/java-squid

public void addResource(File resource, String fileKey) {
 directories.put(resource.getParent(), resource);
 fileKeyByResource.put(resource, fileKey);
}

代码示例来源:origin: org.codehaus.sonar-plugins.java/java-squid

public void addResource(File resource, String fileKey) {
 directories.put(resource.getParent(), resource);
 fileKeyByResource.put(resource, fileKey);
}

代码示例来源:origin: org.codehaus.sonar/sonar-batch

@Override
public void store(org.sonar.api.batch.sensor.dependency.Dependency dep) {
 BatchResource fromBatchResource = resourceCache.get(dep.fromKey());
 BatchResource toBatchResource = resourceCache.get(dep.toKey());
 Preconditions.checkNotNull(fromBatchResource, "Unable to find origin resource " + dep.fromKey());
 Preconditions.checkNotNull(toBatchResource, "Unable to find destination resource " + dep.toKey());
 File fromResource = (File) fromBatchResource.resource();
 File toResource = (File) toBatchResource.resource();
 if (sonarIndex.getEdge(fromResource, toResource) != null) {
  throw new IllegalStateException("Dependency between " + dep.fromKey() + " and " + dep.toKey() + " was already saved.");
 }
 Directory fromParent = fromResource.getParent();
 Directory toParent = toResource.getParent();
 Dependency parentDep = null;
 if (!fromParent.equals(toParent)) {
  parentDep = sonarIndex.getEdge(fromParent, toParent);
  if (parentDep != null) {
   parentDep.setWeight(parentDep.getWeight() + 1);
  } else {
   parentDep = new Dependency(fromParent, toParent).setUsage(USES).setWeight(1);
   parentDep = sonarIndex.addDependency(parentDep);
  }
 }
 sonarIndex.addDependency(new Dependency(fromResource, toResource)
  .setUsage(USES)
  .setWeight(dep.weight())
  .setParent(parentDep));
}

代码示例来源:origin: org.codehaus.sonar.plugins/sonar-xoo-plugin

@Override
public void analyse(Project module, org.sonar.api.batch.SensorContext context) {
 createIssueOnDir(new Directory(""));
 File src = module.getFileSystem().getSourceDirs().get(0);
 for (File f : fileSystem.files(FileQuery.onMain().onLanguage(Xoo.KEY))) {
  String relativePathFromSourceDir = new PathResolver().relativePath(src, f);
  org.sonar.api.resources.File sonarFile = new org.sonar.api.resources.File(relativePathFromSourceDir);
  Issuable issuable = perspectives.as(Issuable.class, sonarFile);
  issuable.addIssue(issuable.newIssueBuilder()
   .ruleKey(RuleKey.of(XooRulesDefinition.XOO_REPOSITORY, RULE_KEY))
   .message("Issue created using deprecated API")
   .line(1)
   .build());
  sonarFile = context.getResource(sonarFile);
  Directory parent = sonarFile.getParent();
  createIssueOnDir(parent);
 }
}

相关文章