Java Code Examples for com.intellij.openapi.vfs.VfsUtil#processFilesRecursively()

The following examples show how to use com.intellij.openapi.vfs.VfsUtil#processFilesRecursively() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CamelPropertyPlaceholderSmartCompletionExtension.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public void addCompletions(@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet resultSet, @NotNull String[] query) {
    Project project = parameters.getOriginalFile().getManager().getProject();

    List<VirtualFile> resourceRoots = ProjectRootManager.getInstance(project).getModuleSourceRoots(JavaModuleSourceRootTypes.PRODUCTION);
    resourceRoots.addAll(ProjectRootManager.getInstance(project).getModuleSourceRoots(JavaModuleSourceRootTypes.TESTS));
    ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    for (final VirtualFile sourceRoot : resourceRoots) {
        if (sourceRoot.isValid() && sourceRoot.getCanonicalFile() != null) {
            VfsUtil.processFilesRecursively(sourceRoot.getCanonicalFile(), virtualFile -> {
                propertyCompletionProviders.stream()
                    .filter(p -> p.isValidExtension(virtualFile.getCanonicalPath()) && !projectFileIndex.isExcluded(sourceRoot))
                    .forEach(p -> p.buildResultSet(resultSet, virtualFile));
                return true;
            });
        }
    }
}
 
Example 2
Source File: ShopwareUtil.java    From idea-php-shopware-plugin with MIT License 6 votes vote down vote up
public static void collectBootstrapFiles(StringLiteralExpression literalExpression, final BootstrapFileVisitor visitor) {

        MethodReference methodReference = PsiElementUtils.getPrevSiblingOfType(literalExpression, PlatformPatterns.psiElement(MethodReference.class).withText(PlatformPatterns.string().contains("Path()")));
        if(methodReference == null) {
            return;
        }

        PsiFile currentFile = literalExpression.getContainingFile();
        final PsiDirectory psiDirectory = currentFile.getParent();
        if(psiDirectory == null) {
            return;
        }

        VfsUtil.processFilesRecursively(psiDirectory.getVirtualFile(), virtualFile -> {

            if(virtualFile.isDirectory() || "php".equalsIgnoreCase(virtualFile.getExtension())) {
                String relativePath = VfsUtil.getRelativePath(virtualFile, psiDirectory.getVirtualFile(), '/');
                if(StringUtils.isNotBlank(relativePath)) {
                    visitor.visitVariable(virtualFile, relativePath);
                }
            }

            return true;
        });
    }
 
Example 3
Source File: FileTypeBasedRootFilter.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean containsFileOfType(VirtualFile rootCandidate, final ProgressIndicator progressIndicator) {
  return !VfsUtil.processFilesRecursively(rootCandidate, new Processor<VirtualFile>() {
    @Override
    public boolean process(VirtualFile virtualFile) {
      progressIndicator.checkCanceled();
      if (virtualFile.isDirectory()) {
        progressIndicator.setText2(virtualFile.getPath());
        return true;
      }
      return !isFileAccepted(virtualFile);
    }
  });
}