当前位置: 首页>>代码示例>>Java>>正文


Java VirtualFileVisitor类代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.VirtualFileVisitor的典型用法代码示例。如果您正苦于以下问题:Java VirtualFileVisitor类的具体用法?Java VirtualFileVisitor怎么用?Java VirtualFileVisitor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VirtualFileVisitor类属于com.intellij.openapi.vfs包,在下文中一共展示了VirtualFileVisitor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findApplicationFileRecursively

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
@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;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:25,代码来源:AppleScriptSystemDictionaryRegistryService.java

示例2: getAllSubFiles

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:17,代码来源:VfsUtil.java

示例3: loadAllModulesUnder

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
@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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:ModuleTestCase.java

示例4: processFolder

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SpellCheckerDictionaryGenerator.java

示例5: getFilesWithBom

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:RemoveBomAction.java

示例6: iterateRecursively

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:FileBasedIndex.java

示例7: removeFilesAndDirsRecursively

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:FileManagerImpl.java

示例8: NewViewNameCompletionProvider

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
            }
        });
    }
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:21,代码来源:NewViewNameCompletionProvider.java

示例9: loadAllModulesUnder

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
@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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ModuleTestCase.java

示例10: getFilesWithBom

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:RemoveBomAction.java

示例11: removeFilesAndDirsRecursively

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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;
      }
    });
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:FileManagerImpl.java

示例12: modifyRoots

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
@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;
            }
        }
    });
}
 
开发者ID:NeoFusion,项目名称:idea-exclude-symlinks-plugin,代码行数:15,代码来源:MarkSymlinksAsExcludedAction.java

示例13: discoverApplicationsInDirectory

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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();
    }
  });
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:15,代码来源:AppleScriptSystemDictionaryRegistryService.java

示例14: setUpExternalUpAnnotations

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:BytecodeAnalysisIntegrationTest.java

示例15: suggestRoots

import com.intellij.openapi.vfs.VirtualFileVisitor; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:51,代码来源:JavaVfsSourceRootDetectionUtil.java


注:本文中的com.intellij.openapi.vfs.VirtualFileVisitor类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。