本文整理汇总了Java中com.intellij.openapi.roots.ContentIterator类的典型用法代码示例。如果您正苦于以下问题:Java ContentIterator类的具体用法?Java ContentIterator怎么用?Java ContentIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentIterator类属于com.intellij.openapi.roots包,在下文中一共展示了ContentIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: iterateContent
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
@Override
public boolean iterateContent(@NotNull ContentIterator iterator) {
Module[] modules = ApplicationManager.getApplication().runReadAction(new Computable<Module[]>() {
@Override
public Module[] compute() {
return ModuleManager.getInstance(myProject).getModules();
}
});
for (final Module module : modules) {
for (VirtualFile contentRoot : getRootsToIterate(module)) {
boolean finished = VfsUtilCore.iterateChildrenRecursively(contentRoot, myContentFilter, iterator);
if (!finished) return false;
}
}
return true;
}
示例2: iterateRecursively
import com.intellij.openapi.roots.ContentIterator; //导入依赖的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;
}
});
}
示例3: countFiles
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
private void countFiles(Project project) {
final Integer fileCount = project.getUserData(FILE_COUNT);
if (fileCount == null) {
myFileIndex.iterateContent(new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
if (!fileOrDir.isDirectory()) {
counting();
}
return true;
}
});
project.putUserData(FILE_COUNT, myTotalFileCount);
} else {
myTotalFileCount = fileCount.intValue();
}
}
示例4: reparseFiles
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
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();
}
示例5: findFiles
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
protected static void findFiles(final Module module, final List<PsiFile> files) {
final ModuleFileIndex idx = ModuleRootManager.getInstance(module).getFileIndex();
final VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
for (final VirtualFile root : roots) {
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
idx.iterateContentUnderDirectory(root, new ContentIterator() {
@Override
public boolean processFile(final VirtualFile dir) {
if (dir.isDirectory()) {
final PsiDirectory psiDir = PsiManager.getInstance(module.getProject()).findDirectory(dir);
if (psiDir != null) {
findFiles(files, psiDir, false);
}
}
return true;
}
});
}
});
}
}
示例6: iterateContent
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
@Override
public boolean iterateContent(@NotNull ContentIterator iterator) {
Module[] modules = ModuleManager.getInstance(myProject).getModules();
for (Module module : modules) {
if (module.isDisposed()) continue;
VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile contentRoot : contentRoots) {
DirectoryInfo info = getInfoForFileOrDirectory(contentRoot);
if (info == null) continue; // is excluded or ignored
if (!module.equals(info.getModule())) continue; // maybe 2 modules have the same content root?
VirtualFile parent = contentRoot.getParent();
if (parent != null) {
DirectoryInfo parentInfo = getInfoForFileOrDirectory(parent);
if (parentInfo != null && parentInfo.getModule() != null) continue; // inner content - skip it
}
boolean finished = VfsUtilCore.iterateChildrenRecursively(contentRoot, myContentFilter, iterator);
if (!finished) return false;
}
}
return true;
}
示例7: iterateContent
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
@Override
public boolean iterateContent(@NotNull ContentIterator iterator) {
VirtualFile[] contentRoots = ModuleRootManager.getInstance(myModule).getContentRoots();
for (VirtualFile contentRoot : contentRoots) {
VirtualFile parent = contentRoot.getParent();
if (parent != null) {
DirectoryInfo parentInfo = myDirectoryIndex.getInfoForDirectory(parent);
if (parentInfo != null && myModule.equals(parentInfo.getModule())) continue; // inner content - skip it
}
boolean finished = VfsUtilCore.iterateChildrenRecursively(contentRoot, myContentFilter, iterator);
if (!finished) return false;
}
return true;
}
示例8: hasCustomCompile
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
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() {
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()) {
if (!fileIndex.iterateContentUnderDirectory(file, groovyFileSearcher)) {
return true;
}
}
}
}
return false;
}
示例9: enumerateGroovyFiles
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
protected Set<VirtualFile> enumerateGroovyFiles(final Module module) {
final Set<VirtualFile> moduleClasses = new THashSet<VirtualFile>();
ModuleRootManager.getInstance(module).getFileIndex().iterateContent(new ContentIterator() {
public boolean processFile(final VirtualFile vfile) {
if (!vfile.isDirectory() &&
GroovyFileType.GROOVY_FILE_TYPE.equals(vfile.getFileType())) {
AccessToken accessToken = ApplicationManager.getApplication().acquireReadActionLock();
try {
if (PsiManager.getInstance(myProject).findFile(vfile) instanceof GroovyFile) {
moduleClasses.add(vfile);
}
}
finally {
accessToken.finish();
}
}
return true;
}
});
return moduleClasses;
}
示例10: findFiles
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
protected static void findFiles(final Module module, final List<PsiFile> files) {
final ModuleFileIndex idx = ModuleRootManager.getInstance(module).getFileIndex();
final VirtualFile[] roots = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile root : roots) {
idx.iterateContentUnderDirectory(root, new ContentIterator() {
public boolean processFile(final VirtualFile dir) {
if (dir.isDirectory()) {
final PsiDirectory psiDir = PsiManager.getInstance(module.getProject()).findDirectory(dir);
if (psiDir != null) {
findFiles(files, psiDir, false);
}
}
return true;
}
});
}
}
示例11: reparseProjectFiles
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
public static void reparseProjectFiles(@NotNull final Project project) {
Task.Backgroundable task = new Task.Backgroundable(project, HaxeBundle.message("haxe.project.reparsing"), false) {
public void run(@NotNull ProgressIndicator indicator) {
final Collection<VirtualFile> haxeFiles = new ArrayList<VirtualFile>();
final VirtualFile baseDir = project.getBaseDir();
if (baseDir != null) {
FileBasedIndex.getInstance().iterateIndexableFiles(new ContentIterator() {
public boolean processFile(VirtualFile file) {
if (HaxeFileType.HAXE_FILE_TYPE == file.getFileType()) {
haxeFiles.add(file);
}
return true;
}
}, project, indicator);
}
ApplicationManager.getApplication().invokeAndWait(new Runnable() {
public void run() {
FileContentUtil.reparseFiles(project, haxeFiles, !project.isDefault());
}
}, ModalityState.NON_MODAL);
}
};
ProgressManager.getInstance().run(task);
}
示例12: getAllNestedFilePaths
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
public static ArrayList<String> getAllNestedFilePaths(VirtualFile vFile) {
final ArrayList<String> filePaths = new ArrayList<String>();
if (!vFile.isDirectory()) {
filePaths.add(vFile.getPath());
return filePaths;
}
VfsUtil.iterateChildrenRecursively(vFile, null, new ContentIterator() {
@Override
public boolean processFile(VirtualFile file) {
if (!file.isDirectory()) {
filePaths.add(file.getPath());
}
return true;
}
});
return filePaths;
}
示例13: iterateContent
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
@Override
public boolean iterateContent(@Nonnull ContentIterator iterator) {
Module[] modules = ModuleManager.getInstance(myProject).getModules();
for (Module module : modules) {
if (module.isDisposed()) continue;
VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();
for (VirtualFile contentRoot : contentRoots) {
DirectoryInfo info = getInfoForFileOrDirectory(contentRoot);
if (!module.equals(info.getModule())) continue; // maybe 2 modules have the same content root?
VirtualFile parent = contentRoot.getParent();
if (parent != null) {
DirectoryInfo parentInfo = getInfoForFileOrDirectory(parent);
if (parentInfo.getModule() != null) continue; // inner content - skip it
}
boolean finished = VfsUtilCore.iterateChildrenRecursively(contentRoot, myContentFilter, iterator);
if (!finished) return false;
}
}
return true;
}
示例14: findFileDeclaringClass
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
/**
* Iterate through the project files until the file declaring the namespace is found.
*
* @param namespace The class name you are looking for.
* @return The document declaring the namespace.
*/
private Document findFileDeclaringClass(final String namespace) {
final List<Document> hierarchy = new ArrayList<Document>();
iterateFiles(new ContentIterator() {
@Override
public boolean processFile(VirtualFile fileOrDir) {
boolean continueSearch = true;
if (fileContainsClass(fileOrDir, namespace)) {
// Stop the search.
continueSearch = false;
hierarchy.add(getDocument(fileOrDir));
}
return continueSearch;
}
});
return hierarchy.size() > 0 ? hierarchy.get(0) : null;
}
示例15: collectFilePaths
import com.intellij.openapi.roots.ContentIterator; //导入依赖的package包/类
@NotNull
static <T> List<T> collectFilePaths(@NotNull PsiElement element, @NotNull final Function<PsiFile, T> converter) {
final List<T> allFiles = new SmartList<T>();
final PsiManager psiManager = element.getManager();
ModuleFileIndex fileIndex = ModuleRootManager.getInstance(ModuleUtil.findModuleForPsiElement(element)).getFileIndex();
fileIndex.iterateContent(new ContentIterator() {
public boolean processFile(VirtualFile fileOrDir) {
PsiFile psiFile = psiManager.findFile(fileOrDir);
if (psiFile != null) {
ContainerUtil.addIfNotNull(converter.fun(psiFile), allFiles);
}
return true;
}
});
return allFiles;
}