use of com.intellij.openapi.roots.ContentIterator in project intellij-community by JetBrains.
the class GroovyAntCustomCompilerProvider method hasCustomCompile.
/**
* {@inheritDoc}
*/
@Override
public boolean hasCustomCompile(ModuleChunk chunk) {
for (Module m : chunk.getModules()) {
if (LibrariesUtil.hasGroovySdk(m)) {
final Set<String> scriptExtensions = GroovyFileTypeLoader.getCustomGroovyScriptExtensions();
final ContentIterator groovyFileSearcher = new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
ProgressManager.checkCanceled();
if (isCompilableGroovyFile(fileOrDir, scriptExtensions)) {
return false;
}
return true;
}
};
final ModuleRootManager rootManager = ModuleRootManager.getInstance(m);
final ModuleFileIndex fileIndex = rootManager.getFileIndex();
for (VirtualFile file : rootManager.getSourceRoots(JavaModuleSourceRootTypes.SOURCES)) {
if (!fileIndex.iterateContentUnderDirectory(file, groovyFileSearcher)) {
return true;
}
}
}
}
return false;
}
use of com.intellij.openapi.roots.ContentIterator in project intellij-community by JetBrains.
the class PyIntegratedToolsConfigurable method reparseFiles.
public void reparseFiles(final List<String> extensions) {
final List<VirtualFile> filesToReparse = Lists.newArrayList();
ProjectRootManager.getInstance(myProject).getFileIndex().iterateContent(new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
if (!fileOrDir.isDirectory() && extensions.contains(fileOrDir.getExtension())) {
filesToReparse.add(fileOrDir);
}
return true;
}
});
FileContentUtilCore.reparseFiles(filesToReparse);
PyUtil.rehighlightOpenEditors(myProject);
DaemonCodeAnalyzer.getInstance(myProject).restart();
}
use of com.intellij.openapi.roots.ContentIterator in project intellij-community by JetBrains.
the class SearchScope method iterateContent.
public void iterateContent(@NotNull final Project project, final Processor<VirtualFile> processor) {
switch(getScopeType()) {
case PROJECT:
//noinspection unchecked
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
break;
case MODULE:
final Module module = ModuleManager.getInstance(project).findModuleByName(getModuleName());
assert module != null;
ModuleRootManager.getInstance(module).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
break;
case DIRECTORY:
final String dirName = getPath();
assert dirName != null;
final VirtualFile virtualFile = findFile(dirName);
if (virtualFile != null) {
iterateRecursively(virtualFile, processor, isRecursive());
}
break;
case CUSTOM:
assert myCustomScope != null;
final ContentIterator iterator;
if (myCustomScope instanceof GlobalSearchScope) {
final GlobalSearchScope searchScope = (GlobalSearchScope) myCustomScope;
iterator = new MyFileIterator(processor, virtualFile13 -> searchScope.contains(virtualFile13));
if (searchScope.isSearchInLibraries()) {
final OrderEnumerator enumerator = OrderEnumerator.orderEntries(project).withoutModuleSourceEntries().withoutDepModules();
final Collection<VirtualFile> libraryFiles = new THashSet<>();
Collections.addAll(libraryFiles, enumerator.getClassesRoots());
Collections.addAll(libraryFiles, enumerator.getSourceRoots());
final Processor<VirtualFile> adapter = virtualFile1 -> iterator.processFile(virtualFile1);
for (final VirtualFile file : libraryFiles) {
iterateRecursively(file, adapter, true);
}
}
} else {
final PsiManager manager = PsiManager.getInstance(project);
iterator = new MyFileIterator(processor, virtualFile12 -> {
final PsiFile element = manager.findFile(virtualFile12);
return element != null && PsiSearchScopeUtil.isInScope(myCustomScope, element);
});
}
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator);
}
}
use of com.intellij.openapi.roots.ContentIterator in project intellij-community by JetBrains.
the class OneProjectItemCompileScope method getFiles.
@NotNull
public VirtualFile[] getFiles(final FileType fileType, final boolean inSourceOnly) {
final List<VirtualFile> files = new ArrayList<>(1);
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(myProject).getFileIndex();
final ContentIterator iterator = new CompilerContentIterator(fileType, projectFileIndex, inSourceOnly, files);
if (myFile.isDirectory()) {
projectFileIndex.iterateContentUnderDirectory(myFile, iterator);
} else {
iterator.processFile(myFile);
}
return VfsUtil.toVirtualFileArray(files);
}
use of com.intellij.openapi.roots.ContentIterator in project intellij-community by JetBrains.
the class IndexedFilesListener method buildIndicesForFileRecursively.
protected void buildIndicesForFileRecursively(@NotNull final VirtualFile file, final boolean contentChange) {
if (file.isDirectory()) {
final ContentIterator iterator = fileOrDir -> {
buildIndicesForFile(fileOrDir, contentChange);
return true;
};
iterateIndexableFiles(file, iterator);
} else {
buildIndicesForFile(file, contentChange);
}
}
Aggregations