private AliasCache getAliasCache(VirtualFile file) { ProjectFileIndex fileIndex = TreeNavigator.INSTANCE.getProjectFileIndex(project); Module module = fileIndex.getModuleForFile(file); return module == null ? null : AliasCache.getCache(module); }
private NamespaceCache getNamespaceCache(VirtualFile file) { if (disposed) { return null; } ProjectFileIndex fileIndex = TreeNavigator.INSTANCE.getProjectFileIndex(project); Module module = fileIndex.getModuleForFile(file); return module == null ? null : NamespaceCache.getCache(module); }
private DelegatePackageCache getDelegatePackageCache(VirtualFile file) { if (disposed) { return null; } ProjectFileIndex fileIndex = TreeNavigator.INSTANCE.getProjectFileIndex(project); Module module = fileIndex.getModuleForFile(file); return module == null ? null : DelegatePackageCache.getCache(module); }
@CheckForNull public Module findModuleForFile(VirtualFile file, Project project) { ApplicationManager.getApplication().assertReadAccessAllowed(); return ProjectFileIndex.SERVICE.getInstance(project).getModuleForFile(file, false); }
void getModulesToSearch(@NotNull PsiElement element, @NotNull Set<Module> modules) { ProjectFileIndex fileIndex = TreeNavigator.INSTANCE.getProjectFileIndex(element.getProject()); VirtualFile virtualFile = element.getContainingFile().getVirtualFile(); if (virtualFile != null) { Module module = fileIndex.getModuleForFile(virtualFile); if (module != null && !modules.contains(module)) { modules.add(module); collectModuleDependencies(module, modules); } } }
@Override public void fileOpenedSync(@NotNull FileEditorManager source, @NotNull VirtualFile file, @NotNull Pair<FileEditor[], FileEditorProvider[]> editors) { if (file.getName().endsWith(ProtoFileType.INSTANCE.getDefaultExtension())) { Project project = source.getProject(); Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(file); if (module == null) { return; } addLibrary(module); } } });
@Nullable @Override public Module getModule() { if (module != null || moduleIsNull) return module; VirtualFile file = getVirtualFile(); if (file == null) return null; Project project = getProject(); ProjectFileIndex fileIndex = TreeNavigator.INSTANCE.getProjectFileIndex(project); module = fileIndex.getModuleForFile(file); moduleIsNull = module == null; return module; } }
public static GlobalSearchScope moduleScope(PsiFile file) { VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) { return GlobalSearchScope.EMPTY_SCOPE; } Module module = ProjectRootManager.getInstance(file.getProject()).getFileIndex().getModuleForFile(virtualFile); if (module == null) { return GlobalSearchScope.fileScope(file); } //the module scope returned by getModuleScope() just contains the files in the configured source and test source directories, //module content scope includes all files in the module directory return module.getModuleContentScope(); }
private List<String> getCompilerSourcePaths(final PsiFile file) { Module module = ProjectRootManager.getInstance(file.getProject()).getFileIndex().getModuleForFile(file.getVirtualFile()); final ArrayList<String> compilerSourcePaths = new ArrayList<>(); final ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module); final Sdk sdk = moduleRootManager.getSdk(); if (sdk != null && (sdk.getSdkType() instanceof DlangSdkType)) { for (VirtualFile f: sdk.getSdkModificator().getRoots(OrderRootType.SOURCES)) { if (f.exists() && f.isDirectory()) { compilerSourcePaths.add(f.getPath()); } } } return compilerSourcePaths; }
return; final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(vf); if (module == null) { return;
VirtualFile file = event.getData(PlatformDataKeys.VIRTUAL_FILE); final ProjectFileIndex index = ProjectRootManager.getInstance(project).getFileIndex(); Module moduleForFile = index.getModuleForFile(file); String modulePath = moduleForFile.getModuleFilePath(); Path parent = Paths.get(modulePath).getParent();