void (final PsiDirectory psiDir, PsiElement[] children, List<? super AbstractTreeNode<?>> container, ProjectFileIndex projectFileIndex, @Nullable ModuleFileIndex moduleFileIndex, ViewSettings viewSettings, boolean withSubDirectories, @Nullable PsiFileSystemItemFilter filter) { for (PsiElement child : children) { LOG.assertTrue(child.isValid()); if (!(child instanceof PsiFileSystemItem)) { LOG.error("Either PsiFile or PsiDirectory expected as a child of " + child.getParent() + ", but was " + child); continue; } final VirtualFile vFile = ((PsiFileSystemItem) child).getVirtualFile(); if (vFile == null) { continue; } if (moduleFileIndex != null && !moduleFileIndex.isInContent(vFile)) { continue; } if (filter != null && !filter.shouldShow((PsiFileSystemItem)child)) { continue; } if (child instanceof PsiFile) { container.add(new PsiFileNode(child.getProject(), (PsiFile) child, viewSettings)); } else if (child instanceof PsiDirectory) { if (withSubDirectories) { PsiDirectory dir = (PsiDirectory)child; if (!vFile.equals(projectFileIndex.getSourceRootForFile(vFile))) { // if is not a source root if (viewSettings.isHideEmptyMiddlePackages() && !skipDirectory(psiDir) && isEmptyMiddleDirectory(dir, true, filter)) { processPsiDirectoryChildren( dir, directoryChildrenInProject(dir, viewSettings), container, projectFileIndex, moduleFileIndex, viewSettings, true, filter ); // expand it recursively continue; } } container.add(new PsiDirectoryNode(child.getProject(), (PsiDirectory)child, viewSettings, filter)); } } } }