private void calculateRoots() { final ModuleManager moduleManager = ModuleManager.getInstance(myProject); // assertion for read access inside final Module[] modules = ApplicationManager.getApplication() .runReadAction( new Computable<Module[]>() { public Module[] compute() { return moduleManager.getModules(); } }); final TreeSet<VirtualFile> checkSet = new TreeSet<VirtualFile>(FilePathComparator.getInstance()); myRoots = new HashSet<VirtualFile>(); myRoots.addAll(myInitialRoots); checkSet.addAll(myInitialRoots); for (Module module : modules) { final VirtualFile[] files = ModuleRootManager.getInstance(module).getContentRoots(); for (VirtualFile file : files) { final VirtualFile floor = checkSet.floor(file); if (floor != null) { myModulesSet.put(file, module.getName()); myRoots.add(file); } } } }
private void updateRightTreeModel() { Set<PsiFile> deps = new HashSet<PsiFile>(); Set<PsiFile> scope = getSelectedScope(myLeftTree); myIllegalsInRightTree = new HashSet<PsiFile>(); for (PsiFile psiFile : scope) { Map<DependencyRule, Set<PsiFile>> illegalDeps = myIllegalDependencies.get(psiFile); if (illegalDeps != null) { for (final DependencyRule rule : illegalDeps.keySet()) { myIllegalsInRightTree.addAll(illegalDeps.get(rule)); } } final Set<PsiFile> psiFiles = myDependencies.get(psiFile); if (psiFiles != null) { for (PsiFile file : psiFiles) { if (file != null && file.isValid()) { deps.add(file); } } } } deps.removeAll(scope); myRightTreeExpansionMonitor.freeze(); myRightTree.setModel(buildTreeModel(deps, myRightTreeMarker)); myRightTreeExpansionMonitor.restore(); expandFirstLevel(myRightTree); }
@NotNull public static List<GotoRelatedItem> collectRelatedItems( @NotNull PsiElement contextElement, @Nullable DataContext dataContext) { Set<GotoRelatedItem> items = ContainerUtil.newLinkedHashSet(); for (GotoRelatedProvider provider : Extensions.getExtensions(GotoRelatedProvider.EP_NAME)) { items.addAll(provider.getItems(contextElement)); if (dataContext != null) { items.addAll(provider.getItems(dataContext)); } } GotoRelatedItem[] result = items.toArray(new GotoRelatedItem[items.size()]); Arrays.sort( result, (i1, i2) -> { String o1 = i1.getGroup(); String o2 = i2.getGroup(); return StringUtil.isEmpty(o1) ? 1 : StringUtil.isEmpty(o2) ? -1 : o1.compareTo(o2); }); return Arrays.asList(result); }