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()]);
}
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;
}
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();
}
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;
}
});
}
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);
}
Aggregations