本文整理汇总了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();
}
示例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;
}
});
}
}
示例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());
}
}
}
示例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;
}
});
}
示例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"));
}
}
}
示例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();
}
示例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;
}
});
}
}
示例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());
}
示例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;
}
示例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];
}
}
}
示例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;
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}