Java 类com.intellij.openapi.vfs.VirtualFileVisitor 实例源码

项目:AppleScript-IDEA    文件:AppleScriptSystemDictionaryRegistryService.java   
@Nullable
private File findApplicationFileRecursively(@NotNull final VirtualFile appDirectory,
                                            @NotNull final String applicationName) {
  final VirtualFileVisitor<VirtualFile> fileVisitor = new VirtualFileVisitor<VirtualFile>(VirtualFileVisitor
      .limit(APP_DEPTH_SEARCH), VirtualFileVisitor.SKIP_ROOT, VirtualFileVisitor.NO_FOLLOW_SYMLINKS) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (ApplicationDictionary.SUPPORTED_APPLICATION_EXTENSIONS.contains(file.getExtension())) {
        if (applicationName.equals(file.getNameWithoutExtension())) {
          throw new MyStopVisitingException(file);
        }
        return false; //do not search inside application bundles
      }
      return true;
    }
  };
  try {
    VfsUtilCore.visitChildrenRecursively(appDirectory, fileVisitor, MyStopVisitingException.class);
  } catch (MyStopVisitingException e) {
    LOG.debug("Application file found for application " + applicationName + " : " + e.getResult());
    return new File(e.getResult().getPath());
  }
  return null;
}
项目:magento2-phpstorm-plugin    文件:VfsUtil.java   
public static Collection<VirtualFile> getAllSubFiles(VirtualFile virtualFile)
{
    Collection<VirtualFile> list = new ArrayList<>();

    VfsUtilCore.visitChildrenRecursively(virtualFile, new VirtualFileVisitor() {
        @Override
        public boolean visitFile(@NotNull VirtualFile file) {
            if (!file.isDirectory()) {
                list.add(file);
            }
            return super.visitFile(file);
        }
    });

    return list;
}
项目:intellij-ce-playground    文件:ModuleTestCase.java   
@Nullable
protected Module loadAllModulesUnder(@NotNull VirtualFile rootDir, @Nullable final Consumer<Module> moduleConsumer) {
  final Ref<Module> result = Ref.create();

  VfsUtilCore.visitChildrenRecursively(rootDir, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory() && file.getName().endsWith(ModuleFileType.DOT_DEFAULT_EXTENSION)) {
        ModuleImpl module = (ModuleImpl)loadModule(file.getPath());
        if (moduleConsumer != null) {
          moduleConsumer.consume(module);
        }
        result.setIfNull(module);
      }
      return true;
    }
  });

  return result.get();
}
项目:intellij-ce-playground    文件:SpellCheckerDictionaryGenerator.java   
protected void processFolder(final HashSet<String> seenNames, final PsiManager manager, final VirtualFile folder) {
  VfsUtilCore.visitChildrenRecursively(folder, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (myExcludedFolders.contains(file)) {
        return false;
      }
      if (!file.isDirectory()) {
        final PsiFile psiFile = manager.findFile(file);
        if (psiFile != null) {
          processFile(psiFile, seenNames);
        }
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:RemoveBomAction.java   
private static void getFilesWithBom(@NotNull VirtualFile root, @NotNull final List<VirtualFile> result, final boolean all) {
  VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (file.isDirectory()) {
        if (!all && !result.isEmpty()) {
          return false;
        }
      }
      else if (file.getBOM() != null) {
        result.add(file);
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:FileBasedIndex.java   
public static void iterateRecursively(@Nullable final VirtualFile root,
                                      @NotNull final ContentIterator processor,
                                      @Nullable final ProgressIndicator indicator,
                                      @Nullable final Set<VirtualFile> visitedRoots,
                                      @Nullable final ProjectFileIndex projectFileIndex) {
  if (root == null) {
    return;
  }

  VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (visitedRoots != null && !root.equals(file) && file.isDirectory() && !visitedRoots.add(file)) {
        return false; // avoid visiting files more than once, e.g. additional indexed roots intersect sometimes
      }
      if (projectFileIndex != null && projectFileIndex.isExcluded(file)) {
        return false;
      }
      if (indicator != null) indicator.checkCanceled();

      processor.processFile(file);
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:FileManagerImpl.java   
void removeFilesAndDirsRecursively(@NotNull VirtualFile vFile) {
  DebugUtil.startPsiModification("removeFilesAndDirsRecursively");
  try {
    VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
      @Override
      public boolean visitFile(@NotNull VirtualFile file) {
        if (file.isDirectory()) {
          myVFileToPsiDirMap.remove(file);
        }
        else {
          FileViewProvider viewProvider = myVFileToViewProviderMap.remove(file);
          if (viewProvider instanceof SingleRootFileViewProvider) {
            ((SingleRootFileViewProvider)viewProvider).markInvalidated();
          }
        }
        return true;
      }
    });
  }
  finally {
    DebugUtil.finishPsiModification();
  }
}
项目:idea-php-laravel-plugin    文件:NewViewNameCompletionProvider.java   
public NewViewNameCompletionProvider(VirtualFile targetDirectory) {

        completions = new ArrayList<>();

        VfsUtil.visitChildrenRecursively(targetDirectory, new VirtualFileVisitor() {
            @Override
            public boolean visitFile(@NotNull VirtualFile file) {

                if(!file.isDirectory()) {
                    return true;
                }

                String path = StringUtils.stripStart(file.getPath().replace(targetDirectory.getPath(), ""), "\\/");

                completions.add(LookupElementBuilder.create(path.replace("\\", ".").replace("/", ".") + "."));

                return true;
            }
        });
    }
项目:tools-idea    文件:ModuleTestCase.java   
@Nullable
protected Module loadAllModulesUnder(@NotNull VirtualFile rootDir) throws Exception {
  final Ref<Module> result = Ref.create();

  VfsUtilCore.visitChildrenRecursively(rootDir, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory() && file.getName().endsWith(ModuleFileType.DOT_DEFAULT_EXTENSION)) {
        ModuleImpl module = (ModuleImpl)loadModule(new File(file.getPath()));
        readJdomExternalizables(module);
        result.setIfNull(module);
      }
      return true;
    }
  });

  return result.get();
}
项目:tools-idea    文件:SpellCheckerDictionaryGenerator.java   
protected void processFolder(final HashSet<String> seenNames, final PsiManager manager, final VirtualFile folder) {
  VfsUtilCore.visitChildrenRecursively(folder, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (myExcludedFolders.contains(file)) {
        return false;
      }
      if (!file.isDirectory()) {
        final PsiFile psiFile = manager.findFile(file);
        if (psiFile != null) {
          processFile(psiFile, seenNames);
        }
      }
      return true;
    }
  });
}
项目:tools-idea    文件:RemoveBomAction.java   
private static void getFilesWithBom(@NotNull VirtualFile root, @NotNull final List<VirtualFile> result, final boolean all) {
  VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (file.isDirectory()) {
        if (!all && !result.isEmpty()) {
          return false;
        }
      }
      else if (file.getBOM() != null) {
        result.add(file);
      }
      return true;
    }
  });
}
项目:consulo    文件:RemoveBomAction.java   
private static void getFilesWithBom(@Nonnull VirtualFile root, @Nonnull final List<VirtualFile> result, final boolean all) {
  VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@Nonnull VirtualFile file) {
      if (file.isDirectory()) {
        if (!all && !result.isEmpty()) {
          return false;
        }
      }
      else if (file.getBOM() != null) {
        result.add(file);
      }
      return true;
    }
  });
}
项目:consulo    文件:FileManagerImpl.java   
void removeFilesAndDirsRecursively(@Nonnull VirtualFile vFile) {
  DebugUtil.performPsiModification("removeFilesAndDirsRecursively", () -> {
    VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
      @Override
      public boolean visitFile(@Nonnull VirtualFile file) {
        if (file.isDirectory()) {
          getVFileToPsiDirMap().remove(file);
        }
        else {
          FileViewProvider viewProvider = getVFileToViewProviderMap().remove(file);
          if (viewProvider != null) {
            markInvalidated(viewProvider);
          }
        }
        return true;
      }
    });
  });
}
项目:idea-exclude-symlinks-plugin    文件:MarkSymlinksAsExcludedAction.java   
@Override
protected void modifyRoots(@NotNull VirtualFile vFile, @NotNull ContentEntry entry) {
    VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
        @Override
        public boolean visitFile(@NotNull VirtualFile file) {
            if (file.isDirectory() && file.is(VFileProperty.SYMLINK)) {
                entry.addExcludeFolder(file);
                return false;
            } else {
                return true;
            }
        }
    });
}
项目:AppleScript-IDEA    文件:AppleScriptSystemDictionaryRegistryService.java   
private void discoverApplicationsInDirectory(@NotNull VirtualFile appsDirVFile) {
  VfsUtilCore.visitChildrenRecursively(appsDirVFile, new VirtualFileVisitor(VirtualFileVisitor.limit(APP_DEPTH_SEARCH)) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (ApplicationDictionaryImpl.extensionSupported(file.getExtension())) {
        if (!"xml".equals(file.getExtension())) {
          discoveredApplicationNames.add(file.getNameWithoutExtension());
        }
        return false;
      }
      return file.isDirectory();
    }
  });
}
项目:intellij-ce-playground    文件:BytecodeAnalysisIntegrationTest.java   
private void setUpExternalUpAnnotations() {
  String annotationsPath = PathManagerEx.getTestDataPath() + "/codeInspection/bytecodeAnalysis/annotations";
  final VirtualFile annotationsDir = LocalFileSystem.getInstance().refreshAndFindFileByPath(annotationsPath);
  assertNotNull(annotationsDir);

  ModuleRootModificationUtil.updateModel(myModule, new AsynchConsumer<ModifiableRootModel>() {
    @Override
    public void finished() {
    }

    @Override
    public void consume(ModifiableRootModel modifiableRootModel) {
      final LibraryTable libraryTable = modifiableRootModel.getModuleLibraryTable();
      Library[] libs = libraryTable.getLibraries();
      for (Library library : libs) {
        final Library.ModifiableModel libraryModel = library.getModifiableModel();
        libraryModel.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
        libraryModel.commit();
      }
      Sdk sdk = modifiableRootModel.getSdk();
      if (sdk != null) {
        SdkModificator sdkModificator = sdk.getSdkModificator();
        sdkModificator.addRoot(annotationsDir, AnnotationOrderRootType.getInstance());
        sdkModificator.commitChanges();
      }
    }
  });

  VfsUtilCore.visitChildrenRecursively(annotationsDir, new VirtualFileVisitor() { });
  annotationsDir.refresh(false, true);
}
项目:intellij-ce-playground    文件:JavaVfsSourceRootDetectionUtil.java   
/**
 * Scan directory and detect java source roots within it. The source root is detected as the following:
 * <ol>
 * <li>It contains at least one Java file.</li>
 * <li>Java file is located in the sub-folder that matches package statement in the file.</li>
 * </ol>
 *
 * @param dir a directory to scan
 * @param progressIndicator
 * @return a list of found source roots within directory. If no source roots are found, a empty list is returned.
 */
@NotNull
public static List<VirtualFile> suggestRoots(@NotNull VirtualFile dir, @NotNull final ProgressIndicator progressIndicator) {
  if (!dir.isDirectory()) {
    return ContainerUtil.emptyList();
  }

  final FileTypeManager typeManager = FileTypeManager.getInstance();
  final ArrayList<VirtualFile> foundDirectories = new ArrayList<VirtualFile>();
  try {
    VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
      @NotNull
      @Override
      public Result visitFileEx(@NotNull VirtualFile file) {
        progressIndicator.checkCanceled();

        if (file.isDirectory()) {
          if (typeManager.isFileIgnored(file) || StringUtil.startsWithIgnoreCase(file.getName(), "testData")) {
            return SKIP_CHILDREN;
          }
        }
        else {
          FileType type = typeManager.getFileTypeByFileName(file.getName());
          if (StdFileTypes.JAVA == type) {
            VirtualFile root = suggestRootForJavaFile(file);
            if (root != null) {
              foundDirectories.add(root);
              return skipTo(root);
            }
          }
        }

        return CONTINUE;
      }
    });
  }
  catch (ProcessCanceledException ignore) { }

  return foundDirectories;
}
项目:intellij-ce-playground    文件:FileSetCompileScope.java   
private static void addRecursively(final Collection<VirtualFile> container, VirtualFile fromDirectory, final FileType fileType) {
  VfsUtilCore.visitChildrenRecursively(fromDirectory, new VirtualFileVisitor(VirtualFileVisitor.SKIP_ROOT) {
    @Override
    public boolean visitFile(@NotNull VirtualFile child) {
      if (!child.isDirectory() && (fileType == null || fileType.equals(child.getFileType()))) {
        container.add(child);
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:LibraryImpl.java   
public static void collectJarFiles(final VirtualFile dir, final List<VirtualFile> container, final boolean recursively) {
  VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor(SKIP_ROOT, recursively ? null : ONE_LEVEL_DEEP) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      final VirtualFile jarRoot = file.isDirectory() ? null : StandardFileSystems.getJarRootForLocalFile(file);
      if (jarRoot != null) {
        container.add(jarRoot);
        return false;
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:AnalysisScope.java   
protected void initFilesSet() {
  if (myType == FILE) {
    myFilesSet = new HashSet<VirtualFile>(1);
    myFilesSet.add(((PsiFileSystemItem)myElement).getVirtualFile());
  }
  else if (myType == DIRECTORY || myType == PROJECT || myType == MODULES || myType == MODULE || myType == CUSTOM) {
    myFilesSet = new HashSet<VirtualFile>();
    accept(createFileSearcher(), false);
  }
  else if (myType == VIRTUAL_FILES) {
    myFilesSet = new HashSet<VirtualFile>();
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
    for (Iterator<VirtualFile> iterator = myVFiles.iterator(); iterator.hasNext(); ) {
      final VirtualFile vFile = iterator.next();
      VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
        @NotNull
        @Override
        public Result visitFileEx(@NotNull VirtualFile file) {
          boolean ignored = fileIndex.isExcluded(file);
          if (!ignored && !file.isDirectory()) {
            myFilesSet.add(file);
          }
          return ignored ? SKIP_CHILDREN : CONTINUE;
        }
      });

      if (vFile.isDirectory()) {
        iterator.remove();
      }
    }
  }
}
项目:intellij-ce-playground    文件:FixLineSeparatorsAction.java   
private static void fixSeparators(VirtualFile vFile) {
  VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory() && !file.getFileType().isBinary()) {
        final Document document = FileDocumentManager.getInstance().getDocument(file);
        if (areSeparatorsBroken(document)) {
          fixSeparators(document);
        }
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:PatchProjectUtil.java   
public static void iterate(VirtualFile contentRoot, final ContentIterator iterator, final ProjectFileIndex idx) {
  VfsUtilCore.visitChildrenRecursively(contentRoot, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!iterator.processFile(file)) return false;
      if (idx.getModuleForFile(file) == null) return false;  // already excluded
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:PyPackageUtil.java   
private static void collectPackageNames(@NotNull final Project project,
                                        @NotNull final VirtualFile root,
                                        @NotNull final List<String> results) {
  final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
  VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!fileIndex.isExcluded(file) && file.isDirectory() && file.findChild(PyNames.INIT_DOT_PY) != null) {
        results.add(VfsUtilCore.getRelativePath(file, root, '.'));
      }
      return true;
    }
  });
}
项目:intellij-ce-playground    文件:RecipeContext.java   
/**
 * VfsUtil#copyDirectory messes up the undo stack, most likely by trying to
 * create a directory even if it already exists. This is an undo-friendly
 * replacement.
 */
private void copyDirectory(@NotNull final VirtualFile src, @NotNull final VirtualFile dest) throws IOException {
  final File destinationFile = VfsUtilCore.virtualToIoFile(dest);
  VfsUtilCore.visitChildrenRecursively(src, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      try {
        return copyFile(file, src, destinationFile, dest);
      }
      catch (IOException e) {
        throw new VisitorException(e);
      }
    }
  }, IOException.class);
}
项目:intellij-ce-playground    文件:SearchScope.java   
private static void iterateRecursively(VirtualFile virtualFile, final Processor<VirtualFile> processor, boolean recursive) {
  VfsUtilCore.visitChildrenRecursively(virtualFile, new VirtualFileVisitor(recursive ? null : VirtualFileVisitor.ONE_LEVEL_DEEP) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory()) {
        processor.process(file);
      }
      return true;
    }
  });
}
项目:idea-php-oxid-plugin    文件:ModuleUtil.java   
public static void visitModuleFile(@NotNull PsiFile metaFile, final @NotNull ModuleFileVisitor visitor) {

        final VirtualFile moduleFolder = MetadataUtil.getModuleVendorFolderFromMetadata(metaFile.getVirtualFile());
        if(moduleFolder == null) {
            return;
        }

        PsiDirectory parent = metaFile.getParent();
        if(parent == null) {
            return;
        }

        VfsUtil.visitChildrenRecursively(parent.getVirtualFile(), new VirtualFileVisitor() {
            @Override
            public boolean visitFile(@NotNull VirtualFile file) {

                if (file.isDirectory()) {
                    return super.visitFile(file);
                }

                String relativePath = VfsUtil.getRelativePath(file, moduleFolder.getParent(), '/');
                if(relativePath == null) {
                    return super.visitFile(file);
                }

                visitor.visit(file, relativePath);

                return super.visitFile(file);
            }
        });
    }
项目:DLangPlugin    文件:DLangLibRootDetector.java   
private static boolean containsDLangFiles(final VirtualFile dir) {
    final VirtualFileVisitor.Result result = VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
        @NotNull
        @Override
        public Result visitFileEx(@NotNull VirtualFile file) {
            return !file.isDirectory() && DFileType.DEFAULT_EXTENSION.equalsIgnoreCase(file.getExtension()) ? skipTo(dir) : CONTINUE;
        }
    });
    return result.skipToParent != null;
}
项目:idea-php-laravel-plugin    文件:AssetUtil.java   
public static Collection<LookupElement> getLookupElements(@NotNull Project project) {
    Collection<LookupElement> lookupElements = new ArrayList<>();

    PsiManager psiManager = PsiManager.getInstance(project);

    for (String folder : FOLDERS) {
        VirtualFile assetDir = VfsUtil.findRelativeFile(project.getBaseDir(), folder);
        if(assetDir == null) {
            continue;
        }

        VfsUtil.visitChildrenRecursively(assetDir, new VirtualFileVisitor() {
            @Override
            public boolean visitFile(@NotNull VirtualFile virtualFile) {
                if(virtualFile.isDirectory()) {
                    return true;
                }

                String filename = VfsUtil.getRelativePath(virtualFile, assetDir, '/');
                if(filename == null || filename.startsWith(".")) {
                    return true;
                }

                PsiFile psiFile = psiManager.findFile(virtualFile);
                if(psiFile != null) {
                    LookupElementBuilder lookupElementBuilder = LookupElementBuilder.create(filename);
                    lookupElementBuilder = lookupElementBuilder.withIcon(psiFile.getIcon(0));

                    lookupElements.add(lookupElementBuilder);
                }

                return true;
            }
        });
    }

    return lookupElements;
}
项目:idea-php-shopware-plugin    文件:ThemeUtil.java   
public static void visitThemeAssetsFile(@NotNull PhpClass phpClass, final @NotNull ThemeAssetVisitor themeAssetVisitor) {

        PsiDirectory parent = phpClass.getContainingFile().getParent();
        if(parent == null) {
            return;
        }

        final VirtualFile publicFolder = VfsUtil.findRelativeFile(parent.getVirtualFile(), "frontend", "_public");
        if(publicFolder == null) {
            return;
        }

        // collect on project template dir
        VfsUtil.visitChildrenRecursively(publicFolder, new VirtualFileVisitor() {
            @Override
            public boolean visitFile(@NotNull VirtualFile virtualFile) {

                if(!"js".equals(virtualFile.getExtension())) {
                    return true;
                }

                String relative = VfsUtil.getRelativePath(virtualFile, publicFolder, '/');
                if(relative == null) {
                    return true;
                }

                return themeAssetVisitor.visit(virtualFile, relative);
            }
        });


    }
项目:idea-php-shopware-plugin    文件:TemplateUtil.java   
private static void collectPluginTemplates(Project project, final SmartyTemplateVisitor smartyTemplateVisitor, final List<String> exts) {
    Collection<PhpClass> phpClasses = PhpIndex.getInstance(project).getAllSubclasses("\\Shopware_Components_Plugin_Bootstrap");
    for(PhpClass phpClass: phpClasses) {

        PsiDirectory psiDirectory = phpClass.getContainingFile().getContainingDirectory();
        final VirtualFile virtualViewDir = VfsUtil.findRelativeFile("Views", psiDirectory.getVirtualFile());
        if(virtualViewDir != null) {
            VfsUtil.visitChildrenRecursively(virtualViewDir, new VirtualFileVisitor() {
                @Override
                public boolean visitFile(@NotNull VirtualFile file) {

                    if(!isValidTemplateFile(file, exts)) {
                        return true;
                    }

                    String frontendName = VfsUtil.getRelativePath(file, virtualViewDir, '/');
                    if(frontendName == null) {
                        return true;
                    }

                    smartyTemplateVisitor.visitFile(file, frontendName);

                    return true;
                }
            });
        }

    }
}
项目:tools-idea    文件:JavaVfsSourceRootDetectionUtil.java   
/**
 * Scan directory and detect java source roots within it. The source root is detected as the following:
 * <ol>
 * <li>It contains at least one Java file.</li>
 * <li>Java file is located in the sub-folder that matches package statement in the file.</li>
 * </ol>
 *
 * @param dir a directory to scan
 * @param progressIndicator
 * @return a list of found source roots within directory. If no source roots are found, a empty list is returned.
 */
@NotNull
public static List<VirtualFile> suggestRoots(@NotNull VirtualFile dir, @NotNull final ProgressIndicator progressIndicator) {
  if (!dir.isDirectory()) {
    return ContainerUtil.emptyList();
  }

  final FileTypeManager typeManager = FileTypeManager.getInstance();
  final ArrayList<VirtualFile> foundDirectories = new ArrayList<VirtualFile>();
  try {
    VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor() {
      @NotNull
      @Override
      public Result visitFileEx(@NotNull VirtualFile file) {
        progressIndicator.checkCanceled();

        if (file.isDirectory()) {
          if (typeManager.isFileIgnored(file) || StringUtil.startsWithIgnoreCase(file.getName(), "testData")) {
            return SKIP_CHILDREN;
          }
        }
        else {
          FileType type = typeManager.getFileTypeByFileName(file.getName());
          if (StdFileTypes.JAVA == type) {
            VirtualFile root = suggestRootForJavaFile(file);
            if (root != null) {
              foundDirectories.add(root);
              return skipTo(root);
            }
          }
        }

        return CONTINUE;
      }
    });
  }
  catch (ProcessCanceledException ignore) { }

  return foundDirectories;
}
项目:tools-idea    文件:FileSetCompileScope.java   
private static void addRecursively(final Collection<VirtualFile> container, VirtualFile fromDirectory, final FileType fileType) {
  VfsUtilCore.visitChildrenRecursively(fromDirectory, new VirtualFileVisitor(VirtualFileVisitor.SKIP_ROOT) {
    @Override
    public boolean visitFile(@NotNull VirtualFile child) {
      if (!child.isDirectory() && (fileType == null || fileType.equals(child.getFileType()))) {
        container.add(child);
      }
      return true;
    }
  });
}
项目:tools-idea    文件:LibraryImpl.java   
public static void collectJarFiles(final VirtualFile dir, final List<VirtualFile> container, final boolean recursively) {
  VfsUtilCore.visitChildrenRecursively(dir, new VirtualFileVisitor(SKIP_ROOT, (recursively ? null : ONE_LEVEL_DEEP)) {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      final VirtualFile jarRoot = StandardFileSystems.getJarRootForLocalFile(file);
      if (jarRoot != null) {
        container.add(jarRoot);
        return false;
      }
      return true;
    }
  });
}
项目:tools-idea    文件:FixLineSeparatorsAction.java   
private static void fixSeparators(VirtualFile vFile) {
  VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory() && !file.getFileType().isBinary()) {
        final Document document = FileDocumentManager.getInstance().getDocument(file);
        if (areSeparatorsBroken(document)) {
          fixSeparators(document);
        }
      }
      return true;
    }
  });
}
项目:tools-idea    文件:SymlinkTestCase.java   
protected void refresh(boolean recursive) {
  assertTrue(myTempDir.getPath(), myTempDir.isDirectory() || myTempDir.mkdirs());
  VirtualFile tempDir = myFileSystem.refreshAndFindFileByIoFile(myTempDir);
  assertNotNull(myTempDir.getPath(), tempDir);
  tempDir.getChildren();
  tempDir.refresh(false, true);
  if (recursive) {
    VfsUtilCore.visitChildrenRecursively(tempDir, new VirtualFileVisitor() { });
  }
}
项目:tools-idea    文件:FileManagerImpl.java   
void removeFilesAndDirsRecursively(VirtualFile vFile) {
  VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (file.isDirectory()) {
        myVFileToPsiDirMap.remove(file);
      }
      else {
        myVFileToViewProviderMap.remove(file);
      }
      return true;
    }
  });
}
项目:tools-idea    文件:BaseAnalysisAction.java   
private static void collectFilesUnder(@NotNull VirtualFile vFile, @NotNull final Set<VirtualFile> files) {
  VfsUtilCore.visitChildrenRecursively(vFile, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!file.isDirectory()) {
        files.add(file);
      }
      return true;
    }
  });
}
项目:tools-idea    文件:PatchProjectUtil.java   
public static void iterate(VirtualFile contentRoot, final ContentIterator iterator, final ProjectFileIndex idx) {
  VfsUtilCore.visitChildrenRecursively(contentRoot, new VirtualFileVisitor() {
    @Override
    public boolean visitFile(@NotNull VirtualFile file) {
      if (!iterator.processFile(file)) return false;
      if (idx.getModuleForFile(file) == null) return false;  // already excluded
      return true;
    }
  });
}
项目:tools-idea    文件:SearchScope.java   
private static void iterateRecursively(VirtualFile virtualFile, final Processor<VirtualFile> processor, boolean recursive) {
    VfsUtilCore.visitChildrenRecursively(virtualFile, new VirtualFileVisitor(recursive ? null : VirtualFileVisitor.ONE_LEVEL_DEEP) {
        @Override
        public boolean visitFile(@NotNull VirtualFile file) {
            if (!file.isDirectory()) {
                processor.process(file);
            }
            return true;
        }
    });
}
项目:consulo-csharp    文件:CSharpCreateFileAction.java   
@RequiredReadAction
private static boolean isCreationOfAssemblyFileAvailable(PsiDirectory directory)
{
    Module module = ModuleUtilCore.findModuleForPsiElement(directory);
    if(module != null)
    {
        DotNetModuleExtension extension = ModuleUtilCore.getExtension(module, DotNetModuleExtension.class);
        if(extension != null && extension.isAllowSourceRoots())
        {
            return false;
        }
    }
    if(module == null || ModuleUtilCore.getExtension(module, CSharpSimpleModuleExtension.class) == null)
    {
        return false;
    }

    final Ref<VirtualFile> ref = Ref.create();
    VirtualFile moduleDir = module.getModuleDir();
    if(moduleDir == null)
    {
        return false;
    }
    VfsUtil.visitChildrenRecursively(moduleDir, new VirtualFileVisitor<Object>()
    {
        @Override
        public boolean visitFile(@NotNull VirtualFile file)
        {
            if(file.getName().equals(CSharpAssemblyConstants.FileName))
            {
                ref.set(file);
                return false;
            }
            return true;
        }
    });

    return ref.get() == null;
}