Search in sources :

Example 6 with ProjectFileIndex

use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.

the class ResourceBundleReference method getVariants.

@Override
@NotNull
public Object[] getVariants() {
    final ProjectFileIndex projectFileIndex = ProjectFileIndex.SERVICE.getInstance(getElement().getProject());
    final PropertiesReferenceManager referenceManager = PropertiesReferenceManager.getInstance(getElement().getProject());
    final Set<String> bundleNames = new HashSet<>();
    final List<LookupElement> variants = new SmartList<>();
    PropertiesFileProcessor processor = new PropertiesFileProcessor() {

        @Override
        public boolean process(String baseName, PropertiesFile propertiesFile) {
            if (!bundleNames.add(baseName))
                return true;
            final LookupElementBuilder builder = LookupElementBuilder.create(baseName).withIcon(AllIcons.Nodes.ResourceBundle);
            boolean isInContent = projectFileIndex.isInContent(propertiesFile.getVirtualFile());
            variants.add(isInContent ? PrioritizedLookupElement.withPriority(builder, Double.MAX_VALUE) : builder);
            return true;
        }
    };
    referenceManager.processPropertiesFiles(myElement.getResolveScope(), processor, this);
    return variants.toArray(new LookupElement[variants.size()]);
}
Also used : ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) LookupElementBuilder(com.intellij.codeInsight.lookup.LookupElementBuilder) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) SmartList(com.intellij.util.SmartList) LookupElement(com.intellij.codeInsight.lookup.LookupElement) PrioritizedLookupElement(com.intellij.codeInsight.completion.PrioritizedLookupElement) HashSet(java.util.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with ProjectFileIndex

use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.

the class XsltRunConfiguration method getEffectiveModule.

@Nullable
public Module getEffectiveModule() {
    //assert myJdkChoice == JdkChoice.FROM_MODULE;
    Module module = myJdkChoice == JdkChoice.FROM_MODULE ? getModule() : null;
    if (module == null && myXsltFile != null) {
        final VirtualFile file = myXsltFile.getFile();
        if (file != null) {
            final ProjectFileIndex index = ProjectRootManager.getInstance(getProject()).getFileIndex();
            module = index.getModuleForFile(file);
        }
    }
    return module;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with ProjectFileIndex

use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.

the class ResourceBundleFileReference method resolve.

public PsiElement resolve() {
    final Project project = myFile.getProject();
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    final VirtualFile formVirtualFile = myFile.getVirtualFile();
    if (formVirtualFile == null) {
        return null;
    }
    final Module module = fileIndex.getModuleForFile(formVirtualFile);
    if (module == null) {
        return null;
    }
    PropertiesFile propertiesFile = PropertiesUtilBase.getPropertiesFile(getRangeText(), module, null);
    return propertiesFile == null ? null : propertiesFile.getContainingFile();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) PropertiesFile(com.intellij.lang.properties.psi.PropertiesFile) Module(com.intellij.openapi.module.Module)

Example 9 with ProjectFileIndex

use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.

the class PyPackageUtil method collectPackageNames.

private static void collectPackageNames(@NotNull final Project project, @NotNull final VirtualFile root, @NotNull final List<String> results) {
    final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
    VfsUtilCore.visitChildrenRecursively(root, new VirtualFileVisitor() {

        @Override
        public boolean visitFile(@NotNull VirtualFile file) {
            if (!fileIndex.isExcluded(file) && file.isDirectory() && file.findChild(PyNames.INIT_DOT_PY) != null) {
                results.add(VfsUtilCore.getRelativePath(file, root, '.'));
            }
            return true;
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) VirtualFileVisitor(com.intellij.openapi.vfs.VirtualFileVisitor)

Example 10 with ProjectFileIndex

use of com.intellij.openapi.roots.ProjectFileIndex in project intellij-community by JetBrains.

the class GroovyCompilerConfigurable method createExcludedConfigurable.

private ExcludedEntriesConfigurable createExcludedConfigurable(final Project project) {
    final ExcludesConfiguration configuration = myConfig.getExcludeFromStubGeneration();
    final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex();
    final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, true) {

        @Override
        public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) {
            return super.isFileVisible(file, showHiddenFiles) && !index.isExcluded(file);
        }
    };
    descriptor.setRoots(ContainerUtil.concat(ContainerUtil.map(ModuleManager.getInstance(project).getModules(), new Function<Module, List<VirtualFile>>() {

        @Override
        public List<VirtualFile> fun(final Module module) {
            return ModuleRootManager.getInstance(module).getSourceRoots(JavaModuleSourceRootTypes.SOURCES);
        }
    })));
    return new ExcludedEntriesConfigurable(project, descriptor, configuration);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExcludedEntriesConfigurable(com.intellij.openapi.compiler.options.ExcludedEntriesConfigurable) ExcludesConfiguration(com.intellij.openapi.compiler.options.ExcludesConfiguration) ProjectFileIndex(com.intellij.openapi.roots.ProjectFileIndex) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) List(java.util.List) Module(com.intellij.openapi.module.Module)

Aggregations

ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)164 VirtualFile (com.intellij.openapi.vfs.VirtualFile)124 Module (com.intellij.openapi.module.Module)54 Project (com.intellij.openapi.project.Project)51 Nullable (org.jetbrains.annotations.Nullable)38 PsiDirectory (com.intellij.psi.PsiDirectory)24 NotNull (org.jetbrains.annotations.NotNull)24 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)16 PsiFile (com.intellij.psi.PsiFile)15 ArrayList (java.util.ArrayList)15 IdeView (com.intellij.ide.IdeView)11 OrderEntry (com.intellij.openapi.roots.OrderEntry)10 ProjectRootManager (com.intellij.openapi.roots.ProjectRootManager)7 THashSet (gnu.trove.THashSet)6 PropertiesFile (com.intellij.lang.properties.psi.PropertiesFile)5 AbstractTreeNode (com.intellij.ide.util.treeView.AbstractTreeNode)4 List (java.util.List)4 JSClass (com.intellij.lang.javascript.psi.ecmal4.JSClass)3 Presentation (com.intellij.openapi.actionSystem.Presentation)3 CompilerManager (com.intellij.openapi.compiler.CompilerManager)3