本文整理汇总了Java中com.intellij.openapi.roots.ModuleRootManager.getFileIndex方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleRootManager.getFileIndex方法的具体用法?Java ModuleRootManager.getFileIndex怎么用?Java ModuleRootManager.getFileIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.roots.ModuleRootManager
的用法示例。
在下文中一共展示了ModuleRootManager.getFileIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildren
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
Module module = getValue();
if (module == null || module.isDisposed()) { // module has been disposed
return Collections.emptyList();
}
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
ModuleFileIndex moduleFileIndex = rootManager.getFileIndex();
final VirtualFile[] contentRoots = rootManager.getContentRoots();
final List<AbstractTreeNode> children = new ArrayList<AbstractTreeNode>(contentRoots.length + 1);
final PsiManager psiManager = PsiManager.getInstance(module.getProject());
for (final VirtualFile contentRoot : contentRoots) {
if (!moduleFileIndex.isInContent(contentRoot)) continue;
if (contentRoot.isDirectory()) {
PsiDirectory directory = psiManager.findDirectory(contentRoot);
if (directory != null) {
children.add(new PsiDirectoryNode(getProject(), directory, getSettings()));
}
}
else {
PsiFile file = psiManager.findFile(contentRoot);
if (file != null) {
children.add(new PsiFileNode(getProject(), file, getSettings()));
}
}
}
/*
if (getSettings().isShowLibraryContents()) {
children.add(new LibraryGroupNode(getProject(), new LibraryGroupElement(getValue()), getSettings()));
}
*/
return children;
}
示例2: hasCustomCompile
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
/**
* {@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;
}
示例3: ModulePackageIndexImpl
import com.intellij.openapi.roots.ModuleRootManager; //导入方法依赖的package包/类
public ModulePackageIndexImpl(ModuleRootManager moduleRootManager, DirectoryIndex directoryIndex) {
myModuleFileIndex = moduleRootManager.getFileIndex();
myDirectoryIndex = directoryIndex;
}