當前位置: 首頁>>代碼示例>>Java>>正文


Java FileUtil.processFilesRecursively方法代碼示例

本文整理匯總了Java中com.intellij.openapi.util.io.FileUtil.processFilesRecursively方法的典型用法代碼示例。如果您正苦於以下問題:Java FileUtil.processFilesRecursively方法的具體用法?Java FileUtil.processFilesRecursively怎麽用?Java FileUtil.processFilesRecursively使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.intellij.openapi.util.io.FileUtil的用法示例。


在下文中一共展示了FileUtil.processFilesRecursively方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: findProject

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Nullable
private Project findProject(String file) {
  LocalFileSystem localFileSystem = LocalFileSystem.getInstance();
  ProjectLocator projectLocator = ProjectLocator.getInstance();
  AtomicReference<Project> ret = new AtomicReference<>();
  FileUtil.processFilesRecursively(
      new File(file),
      (f) -> {
        VirtualFile vf = localFileSystem.findFileByIoFile(f);
        if (vf != null) {
          ret.set(projectLocator.guessProjectForFile(vf));
          return false;
        }
        return true;
      });
  return ret.get();
}
 
開發者ID:google,項目名稱:ijaas,代碼行數:18,代碼來源:JavaGetImportCandidatesHandler.java

示例2: processFilesRecursively

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public static void processFilesRecursively(final String rootPath, final Consumer<String> consumer){
  final File rootFile = new File(rootPath);
  if (rootFile.exists() && rootFile.isDirectory()){
    FileUtil.processFilesRecursively(rootFile, new Processor<File>() {
      public boolean process(final File file) {
        if (!file.isDirectory()){
          final String path = file.getPath();
          if (path.endsWith(".dic")){
            consumer.consume(path);
          }
        }
        return true;
      }
    });
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:SPFileUtil.java

示例3: AndroidFileSetState

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public AndroidFileSetState(@NotNull Collection<String> roots, @NotNull final Condition<File> filter, boolean recursively) {
  myTimestamps = new HashMap<String, Long>();

  for (String rootPath : roots) {
    final File root = new File(rootPath);

    if (recursively) {
      FileUtil.processFilesRecursively(root, new Processor<File>() {
        @Override
        public boolean process(File file) {
          if (filter.value(file)) {
            myTimestamps.put(FileUtil.toSystemIndependentName(file.getPath()), file.lastModified());
          }
          return true;
        }
      });
    }
    else if (filter.value(root)) {
      myTimestamps.put(FileUtil.toSystemIndependentName(root.getPath()), root.lastModified());
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:23,代碼來源:AndroidFileSetState.java

示例4: processClassFilesAndJarsRecursively

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
public static void processClassFilesAndJarsRecursively(@NotNull File root, @NotNull final Processor<File> processor) {
  FileUtil.processFilesRecursively(root, new Processor<File>() {
    @Override
    public boolean process(File file) {
      if (file.isFile()) {
        String fileName = file.getName();

        // NOTE: we should ignore apklib dependencies (IDEA-82976)
        if (FileUtilRt.extensionEquals(fileName, "jar") || FileUtilRt.extensionEquals(fileName, "class")) {
          if (!processor.process(file)) {
            return false;
          }
        }
      }
      return true;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:AndroidJpsUtil.java

示例5: warnUserAboutForciblyExcludedRoots

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void warnUserAboutForciblyExcludedRoots(@NotNull Set<String> paths, @NotNull CompileContext context) {
  for (String dir : paths) {
    final boolean hasFileToCopy = !FileUtil.processFilesRecursively(new File(dir), new Processor<File>() {
      @Override
      public boolean process(File file) {
        try {
          return !shouldBeCopied(file);
        }
        catch (IOException e) {
          return false;
        }
      }
    });

    if (hasFileToCopy) {
      context.processMessage(new CompilerMessage(ANDROID_GENERATED_SOURCES_PROCESSOR, BuildMessage.Kind.WARNING,
                                                 "Source root " + FileUtil.toSystemDependentName(dir) +
                                                 " was forcibly excluded by the IDE, so custom generated files won't be compiled"));
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:22,代碼來源:AndroidSourceGeneratingBuilder.java

示例6: markDirtyRecursively

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static boolean markDirtyRecursively(@NotNull File dir,
                                            @NotNull final CompileContext context,
                                            @NotNull final String compilerName,
                                            final boolean javaFilesOnly) {
  final Ref<Boolean> success = Ref.create(true);

  FileUtil.processFilesRecursively(dir, new Processor<File>() {
    @Override
    public boolean process(File file) {
      if (file.isFile() && (!javaFilesOnly || FileUtilRt.extensionEquals(file.getName(), "java"))) {
        try {
          FSOperations.markDirty(context, CompilationRound.CURRENT, file);
        }
        catch (IOException e) {
          AndroidJpsUtil.reportExceptionError(context, null, e, compilerName);
          success.set(false);
          return false;
        }
      }
      return true;
    }
  });
  return success.get();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:AndroidSourceGeneratingBuilder.java

示例7: collectAllowedRoots

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
protected void collectAllowedRoots(final List<String> roots) throws IOException {
  JavaSdk javaSdk = JavaSdk.getInstance();
  final List<String> jdkPaths = Lists.newArrayList(javaSdk.suggestHomePaths());
  jdkPaths.add(SystemProperties.getJavaHome());
  roots.addAll(jdkPaths);

  for (final String jdkPath : jdkPaths) {
    FileUtil.processFilesRecursively(new File(jdkPath), new Processor<File>() {
      @Override
      public boolean process(File file) {
        try {
          String path = file.getCanonicalPath();
          if (!FileUtil.isAncestor(jdkPath, path, false)) {
            roots.add(path);
          }
        }
        catch (IOException ignore) { }
        return true;
      }
    });
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:NewModuleWizardTest.java

示例8: collectAllowedRoots

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
protected void collectAllowedRoots(final List<String> roots) throws IOException {
  roots.add(myJdkHome);
  FileUtil.processFilesRecursively(new File(myJdkHome), new Processor<File>() {
    @Override
    public boolean process(File file) {
      try {
        String path = file.getCanonicalPath();
        if (!FileUtil.isAncestor(myJdkHome, path, false)) {
          roots.add(path);
        }
      }
      catch (IOException ignore) { }
      return true;
    }
  });

  roots.add(PathManager.getConfigPath());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:GradleImportingTestCase.java

示例9: readFromBranchFiles

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@NotNull
private Map<String, String> readFromBranchFiles(@NotNull File rootDir) {
  if (!rootDir.exists()) {
    return Collections.emptyMap();
  }
  final Map<String, String> result = new HashMap<String, String>();
  FileUtil.processFilesRecursively(rootDir, new Processor<File>() {
    @Override
    public boolean process(File file) {
      if (!file.isDirectory() && !isHidden(file)) {
        String relativePath = FileUtil.getRelativePath(myGitDir, file);
        if (relativePath != null) {
          String branchName = FileUtil.toSystemIndependentName(relativePath);
          String hash = loadHashFromBranchFile(file);
          if (hash != null) {
            result.put(branchName, hash);
          }
        }
      }
      return true;
    }
  }, NOT_HIDDEN_DIRECTORIES);
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:GitRepositoryReader.java

示例10: copyUnversionedMembersOfDirectory

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void copyUnversionedMembersOfDirectory(final File src, final File dst) throws SvnBindException {
  if (src.isDirectory()) {
    final SvnBindException[] exc = new SvnBindException[1];
    FileUtil.processFilesRecursively(src, new Processor<File>() {
      @Override
      public boolean process(File file) {
        String relativePath = FileUtil.getRelativePath(src, file);
        File newFile = new File(dst, relativePath);
        if (!newFile.exists()) {
          try {
            FileUtil.copyFileOrDir(src, dst);
          }
          catch (IOException e) {
            exc[0] = new SvnBindException(e);
            return false;
          }
        }
        return true;
      }
    });
    if (exc[0] != null) {
      throw exc[0];
    }
  }
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:26,代碼來源:SvnFileSystemListener.java

示例11: testCheckoutImpl

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private File testCheckoutImpl(final String url) throws IOException {
  final File root = FileUtil.createTempDirectory("checkoutRoot", "");
  root.deleteOnExit();
  Assert.assertTrue(root.exists());
  SvnCheckoutProvider
    .checkout(myProject, root, url, SVNRevision.HEAD, Depth.INFINITY, false, new CheckoutProvider.Listener() {
      @Override
      public void directoryCheckedOut(File directory, VcsKey vcs) {
      }

      @Override
      public void checkoutCompleted() {
      }
    }, WorkingCopyFormat.ONE_DOT_SEVEN);
  final int[] cnt = new int[1];
  cnt[0] = 0;
  FileUtil.processFilesRecursively(root, new Processor<File>() {
    @Override
    public boolean process(File file) {
      ++ cnt[0];
      return ! (cnt[0] > 1);
    }
  });
  Assert.assertTrue(cnt[0] > 1);
  return root;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:SvnProtocolsTest.java

示例12: findFileByNameInDirectory

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@Override
@Nullable
public File findFileByNameInDirectory(
    @NotNull final File directory,
    @NotNull final String fileName,
    @Nullable final TaskProgressProcessor<File> progressListenerProcessor
) throws InterruptedException {
    Validate.notNull(directory);
    Validate.isTrue(directory.isDirectory());
    Validate.notNull(fileName);

    final Ref<File> result = Ref.create();
    final Ref<Boolean> interrupted = Ref.create(false);

    FileUtil.processFilesRecursively(directory, file -> {
        if (progressListenerProcessor != null && !progressListenerProcessor.shouldContinue(directory)) {
            interrupted.set(true);
            return false;
        }
        if (StringUtils.endsWith(file.getAbsolutePath(), fileName)) {
            result.set(file);
            return false;
        }
        return true;
    });

    if (interrupted.get()) {
        throw new InterruptedException("Modules scanning has been interrupted.");
    }
    return result.get();
}
 
開發者ID:AlexanderBartash,項目名稱:hybris-integration-intellij-idea-plugin,代碼行數:32,代碼來源:DefaultVirtualFileSystemService.java

示例13: collectPycFiles

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void collectPycFiles(File directory, final List<File> pycFiles) {
  FileUtil.processFilesRecursively(directory, new Processor<File>() {
    @Override
    public boolean process(File file) {
      if (file.getParentFile().getName().equals(PyNames.PYCACHE) ||
          FileUtilRt.extensionEquals(file.getName(), "pyc") ||
          FileUtilRt.extensionEquals(file.getName(), "pyo") ||
          file.getName().endsWith("$py.class")) {
        pycFiles.add(file);
      }
      return true;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:CleanPycAction.java

示例14: deletePycFiles

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
private static void deletePycFiles(@NotNull final File directory) {
  FileUtil.processFilesRecursively(directory, new Processor<File>() {
    @Override
    public boolean process(File file) {
      if (file.getParentFile().getName().equals(PyNames.PYCACHE) ||
          FileUtilRt.extensionEquals(file.getName(), "pyc") ||
          FileUtilRt.extensionEquals(file.getName(), "pyo") ||
          file.getName().endsWith("$py.class")) {
        FileUtil.delete(file);
      }
      return true;
    }
  });
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:15,代碼來源:PyUnitTestTask.java

示例15: collectJavaFilesRecursively

import com.intellij.openapi.util.io.FileUtil; //導入方法依賴的package包/類
@NotNull
private static List<File> collectJavaFilesRecursively(@NotNull File dir) {
  final List<File> result = new ArrayList<File>();

  FileUtil.processFilesRecursively(dir, new Processor<File>() {
    @Override
    public boolean process(File file) {
      if (file.isFile() && FileUtilRt.extensionEquals(file.getName(), "java")) {
        result.add(file);
      }
      return true;
    }
  });
  return result;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:16,代碼來源:AndroidSourceGeneratingBuilder.java


注:本文中的com.intellij.openapi.util.io.FileUtil.processFilesRecursively方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。