int (PackageElement packageElement) { int count = 0; if (getSettings().isFlattenPackages()){ final PsiPackage aPackage = packageElement.getPackage(); final Module module = packageElement.getModule(); GlobalSearchScope scope = module != null ? GlobalSearchScope.moduleScope(module) : GlobalSearchScope.projectScope(aPackage.getProject()); final PsiDirectory[] directories = aPackage.getDirectories(scope); for (PsiDirectory directory : directories) { Iterator<PsiFile> iterator = myBuilder.getFilesUnderDirectory(directory); while(iterator.hasNext()){ PsiFile psiFile = iterator.next(); count+=getStructure().getTodoItemCount(psiFile); } } } else { Iterator<PsiFile> iterator = getFiles(packageElement); while(iterator.hasNext()){ PsiFile psiFile = iterator.next(); count+=getStructure().getTodoItemCount(psiFile); } } return count; }