Package org.sonar.api.scan.filesystem

Examples of org.sonar.api.scan.filesystem.PathResolver


  @Test
  public void testBlameOnModifiedFile() throws IOException {
    File projectDir = temp.newFolder();
    javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);

    JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());

    File baseDir = new File(projectDir, "dummy-git");
    fs.setBaseDir(baseDir);
    String relativePath = DUMMY_JAVA;
    DefaultInputFile inputFile = new DefaultInputFile("foo", relativePath)
View Full Code Here


  @Test
  public void testBlameOnNewFile() throws IOException {
    File projectDir = temp.newFolder();
    javaUnzip(new File("test-repos/dummy-git.zip"), projectDir);

    JGitBlameCommand jGitBlameCommand = new JGitBlameCommand(new PathResolver());

    File baseDir = new File(projectDir, "dummy-git");
    fs.setBaseDir(baseDir);
    String relativePath = DUMMY_JAVA;
    String relativePath2 = "src/main/java/org/dummy/Dummy2.java";
View Full Code Here

    }
  }

  private void logPaths(Logger logger, String label, File baseDir, List<File> paths) {
    if (!paths.isEmpty()) {
      PathResolver resolver = new PathResolver();
      StringBuilder sb = new StringBuilder(label);
      for (Iterator<File> it = paths.iterator(); it.hasNext();) {
        File file = it.next();
        String relativePathToBaseDir = resolver.relativePath(baseDir, file);
        if (relativePathToBaseDir == null) {
          sb.append(file);
        } else if (StringUtils.isBlank(relativePathToBaseDir)) {
          sb.append(".");
        } else {
View Full Code Here

  }

  @Override
  public InputDir inputDir(File dir) {
    doPreloadFiles();
    String relativePath = PathUtils.sanitize(new PathResolver().relativePath(baseDir, dir));
    if (relativePath == null) {
      return null;
    }
    return cache.inputDir(relativePath);
  }
View Full Code Here

  private void addModule(Project parent, Project module) {
    ProjectDefinition parentDefinition = projectTree.getProjectDefinition(parent);
    java.io.File parentBaseDir = parentDefinition.getBaseDir();
    ProjectDefinition moduleDefinition = projectTree.getProjectDefinition(module);
    java.io.File moduleBaseDir = moduleDefinition.getBaseDir();
    module.setPath(new PathResolver().relativePath(parentBaseDir, moduleBaseDir));
    addResource(module);
    for (Project submodule : module.getModules()) {
      addModule(module, submodule);
    }
  }
View Full Code Here

      public Void call() throws Exception {
        InputFile completedFile = inputFileBuilder.complete(inputFile, type);
        if (completedFile != null && accept(completedFile)) {
          status.markAsIndexed(inputFile);
          File parentDir = inputFile.file().getParentFile();
          String relativePath = new PathResolver().relativePath(fs.baseDir(), parentDir);
          if (relativePath != null) {
            DefaultInputDir inputDir = new DefaultInputDir(fs.moduleKey(), relativePath);
            inputDir.setFile(parentDir);
            status.markAsIndexed(inputDir);
          }
View Full Code Here

   * @deprecated since 4.2 use {@link #fromIOFile(java.io.File, Project)}
   */
  @Deprecated
  @CheckForNull
  public static File fromIOFile(java.io.File file, List<java.io.File> sourceDirs) {
    PathResolver.RelativePath relativePath = new PathResolver().relativePath(sourceDirs, file);
    if (relativePath != null) {
      return new File(relativePath.path());
    }
    return null;
  }
View Full Code Here

   * @deprecated since 4.5 use {@link FileSystem#inputFile(org.sonar.api.batch.fs.FilePredicate)}
   */
  @Deprecated
  @CheckForNull
  public static File fromIOFile(java.io.File file, Project module) {
    String relativePathFromBasedir = new PathResolver().relativePath(module.getFileSystem().getBasedir(), file);
    if (relativePathFromBasedir != null) {
      return File.create(relativePathFromBasedir);
    }
    return null;
  }
View Full Code Here

   * @return null if the directory is not under module basedir.
   * @since 4.2
   */
  @CheckForNull
  public static Directory fromIOFile(java.io.File dir, Project module) {
    String relativePathFromBasedir = new PathResolver().relativePath(module.getFileSystem().getBasedir(), dir);
    if (relativePathFromBasedir != null) {
      return Directory.create(relativePathFromBasedir);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.scan.filesystem.PathResolver

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.