use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.
the class AbstractCreateFormAction method update.
public void update(final AnActionEvent e) {
super.update(e);
final Project project = e.getData(CommonDataKeys.PROJECT);
final Presentation presentation = e.getPresentation();
if (presentation.isEnabled()) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
if (view != null) {
final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex();
final PsiDirectory[] dirs = view.getDirectories();
for (final PsiDirectory dir : dirs) {
if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && JavaDirectoryService.getInstance().getPackage(dir) != null) {
return;
}
}
}
presentation.setEnabled(false);
presentation.setVisible(false);
}
}
use of com.intellij.openapi.roots.ProjectFileIndex 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.ProjectFileIndex in project intellij-community by JetBrains.
the class ValidationConfigurable method createExcludedConfigurable.
private static ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
final ExcludesConfiguration configuration = ValidationConfiguration.getExcludedEntriesConfiguration(project);
final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {
public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
return super.isFileVisible(file, showHiddenFiles) && (project.isDefault() || !index.isExcluded(file));
}
};
List<VirtualFile> allContentRoots = new ArrayList<>();
for (final Module module : ModuleManager.getInstance(project).getModules()) {
final VirtualFile[] moduleContentRoots = ModuleRootManager.getInstance(module).getContentRoots();
Collections.addAll(allContentRoots, moduleContentRoots);
}
descriptor.setRoots(allContentRoots);
return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.
the class ChangeListManagerImpl method convertExcludedToIgnored.
void convertExcludedToIgnored() {
for (DirectoryIndexExcludePolicy policy : DirectoryIndexExcludePolicy.EP_NAME.getExtensions(myProject)) {
for (VirtualFile file : policy.getExcludeRootsForProject()) {
addDirectoryToIgnoreImplicitly(file.getPath());
}
}
ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(myProject);
VirtualFileManager virtualFileManager = VirtualFileManager.getInstance();
for (Module module : ModuleManager.getInstance(myProject).getModules()) {
for (String url : ModuleRootManager.getInstance(module).getExcludeRootUrls()) {
VirtualFile file = virtualFileManager.findFileByUrl(url);
if (file != null && !fileIndex.isExcluded(file)) {
//root is included into some inner module so it shouldn't be ignored
continue;
}
addDirectoryToIgnoreImplicitly(VfsUtilCore.urlToPath(url));
}
}
}
use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.
the class ChangesModuleGroupingPolicy method getParentNodeFor.
@Override
@Nullable
public ChangesBrowserNode getParentNodeFor(final StaticFilePath node, final ChangesBrowserNode subtreeRoot) {
if (myProject.isDefault())
return null;
ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();
VirtualFile vFile = node.getVf();
if (vFile == null) {
vFile = LocalFileSystem.getInstance().findFileByIoFile(new File(node.getPath()));
}
boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
if (vFile != null && Comparing.equal(vFile, index.getContentRootForFile(vFile, hideExcludedFiles))) {
Module module = index.getModuleForFile(vFile, hideExcludedFiles);
return getNodeForModule(module, subtreeRoot);
}
return null;
}
Aggregations