todo: don't skip source roots outside of java (IDEA-159909)

This commit is contained in:
Anna.Kozlova
2016-11-03 09:57:12 +01:00
parent 29edb9cb44
commit 64e7499b24
2 changed files with 21 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -133,7 +133,9 @@ public class TodoJavaTreeHelper extends TodoTreeHelper {
}
}
}
super.addPackagesToChildren(children, module, builder);
final List<VirtualFile> roots = collectContentRoots(module);
roots.removeAll(sourceRoots);
addDirsToChildren(roots, children, builder);
}
@Nullable
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -51,21 +51,25 @@ public class TodoTreeHelper {
}
public void addPackagesToChildren(ArrayList<AbstractTreeNode> children,
Module module,
TodoTreeBuilder builder) {
final PsiManager psiManager = PsiManager.getInstance(myProject);
Module module,
TodoTreeBuilder builder) {
addDirsToChildren(collectContentRoots(module), children, builder);
}
protected List<VirtualFile> collectContentRoots(Module module) {
final List<VirtualFile> roots = new ArrayList<>();
final List<VirtualFile> sourceRoots = new ArrayList<>();
if (module == null) {
final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(myProject);
ContainerUtil.addAll(roots, projectRootManager.getContentRoots());
ContainerUtil.addAll(sourceRoots, projectRootManager.getContentSourceRoots());
ContainerUtil.addAll(roots, ProjectRootManager.getInstance(myProject).getContentRoots());
} else {
ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
ContainerUtil.addAll(roots, moduleRootManager.getContentRoots());
ContainerUtil.addAll(sourceRoots, moduleRootManager.getSourceRoots());
ContainerUtil.addAll(roots, ModuleRootManager.getInstance(module).getContentRoots());
}
roots.removeAll(sourceRoots);
return roots;
}
protected void addDirsToChildren(List<VirtualFile> roots,
ArrayList<AbstractTreeNode> children,
TodoTreeBuilder builder) {
final PsiManager psiManager = PsiManager.getInstance(myProject);
for (VirtualFile dir : roots) {
final PsiDirectory directory = psiManager.findDirectory(dir);
if (directory == null) {
@@ -80,7 +84,7 @@ public class TodoTreeHelper {
}
}
public Collection<AbstractTreeNode> getDirectoryChildren(PsiDirectory psiDirectory, TodoTreeBuilder builder, boolean isFlatten) {
public Collection<AbstractTreeNode> getDirectoryChildren(PsiDirectory psiDirectory, TodoTreeBuilder builder, boolean isFlatten) {
ArrayList<AbstractTreeNode> children = new ArrayList<>();
if (!isFlatten || !skipDirectory(psiDirectory)) {
final Iterator<PsiFile> iterator = builder.getFiles(psiDirectory);