Lines 115-120
Link Here
|
115 |
|
115 |
|
116 |
import org.openide.filesystems.FileObject; |
116 |
import org.openide.filesystems.FileObject; |
117 |
import org.openide.filesystems.FileUtil; |
117 |
import org.openide.filesystems.FileUtil; |
|
|
118 |
import org.openide.filesystems.URLMapper; |
118 |
import org.openide.util.Exceptions; |
119 |
import org.openide.util.Exceptions; |
119 |
import org.openide.util.Lookup; |
120 |
import org.openide.util.Lookup; |
120 |
import org.openide.util.Parameters; |
121 |
import org.openide.util.Parameters; |
Lines 600-613
Link Here
|
600 |
*/ |
601 |
*/ |
601 |
@org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/) //NOI18N |
602 |
@org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/) //NOI18N |
602 |
public static Set<URL> getDependentRoots (final URL root) { |
603 |
public static Set<URL> getDependentRoots (final URL root) { |
603 |
final Map<URL, List<URL>> deps = IndexingController.getDefault().getRootDependencies(); |
604 |
final Map<URL, List<URL>> sourceDeps = IndexingController.getDefault().getRootDependencies(); |
604 |
return getDependentRootsImpl (root, deps); |
605 |
final Map<URL, List<URL>> binaryDeps = IndexingController.getDefault().getBinaryRootDependencies(); |
|
|
606 |
return getDependentRootsImpl (root, sourceDeps, binaryDeps); |
605 |
} |
607 |
} |
606 |
|
608 |
|
607 |
|
609 |
|
608 |
@org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/) //NOI18N |
610 |
@org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/) //NOI18N |
609 |
static Set<URL> getDependentRootsImpl (final URL root, final Map<URL, List<URL>> deps) { |
611 |
static Set<URL> getDependentRootsImpl (final URL root, final Map<URL, List<URL>> sourceDeps, Map<URL, List<URL>> binaryDeps) { |
610 |
//Create inverse dependencies |
612 |
Set<URL> urls; |
|
|
613 |
|
614 |
if (sourceDeps.containsKey(root)) { |
615 |
urls = findReverseSourceRoots(root, sourceDeps); |
616 |
} else { |
617 |
FileObject rootFO = URLMapper.findFileObject(root); |
618 |
|
619 |
if (rootFO != null) { |
620 |
urls = new HashSet<URL>(); |
621 |
|
622 |
for (URL binary : findBinaryRootsForSourceRoot(rootFO, binaryDeps)) { |
623 |
List<URL> deps = binaryDeps.get(binary); |
624 |
|
625 |
if (deps != null) { |
626 |
urls.addAll(deps); |
627 |
} |
628 |
} |
629 |
} else { |
630 |
urls = new HashSet<URL>(); |
631 |
} |
632 |
} |
633 |
|
634 |
//Filter non opened projects |
635 |
Set<ClassPath> cps = GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE); |
636 |
Set<URL> toRetain = new HashSet<URL>(); |
637 |
for (ClassPath cp : cps) { |
638 |
for (ClassPath.Entry e : cp.entries()) { |
639 |
toRetain.add(e.getURL()); |
640 |
} |
641 |
} |
642 |
urls.retainAll(toRetain); |
643 |
return urls; |
644 |
} |
645 |
|
646 |
private static Set<URL> findReverseSourceRoots(final URL thisSourceRoot, Map<URL, List<URL>> deps) { |
647 |
//Create inverse dependencies |
611 |
final Map<URL, List<URL>> inverseDeps = new HashMap<URL, List<URL>> (); |
648 |
final Map<URL, List<URL>> inverseDeps = new HashMap<URL, List<URL>> (); |
612 |
for (Map.Entry<URL,List<URL>> entry : deps.entrySet()) { |
649 |
for (Map.Entry<URL,List<URL>> entry : deps.entrySet()) { |
613 |
final URL u1 = entry.getKey(); |
650 |
final URL u1 = entry.getKey(); |
Lines 624-630
Link Here
|
624 |
//Collect dependencies |
661 |
//Collect dependencies |
625 |
final Set<URL> result = new HashSet<URL>(); |
662 |
final Set<URL> result = new HashSet<URL>(); |
626 |
final LinkedList<URL> todo = new LinkedList<URL> (); |
663 |
final LinkedList<URL> todo = new LinkedList<URL> (); |
627 |
todo.add (root); |
664 |
todo.add (thisSourceRoot); |
628 |
while (!todo.isEmpty()) { |
665 |
while (!todo.isEmpty()) { |
629 |
final URL u = todo.removeFirst(); |
666 |
final URL u = todo.removeFirst(); |
630 |
if (!result.contains(u)) { |
667 |
if (!result.contains(u)) { |
Lines 635-653
Link Here
|
635 |
} |
672 |
} |
636 |
} |
673 |
} |
637 |
} |
674 |
} |
638 |
//Filter non opened projects |
675 |
|
639 |
Set<ClassPath> cps = GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE); |
676 |
return result; |
640 |
Set<URL> toRetain = new HashSet<URL>(); |
677 |
} |
641 |
for (ClassPath cp : cps) { |
678 |
|
642 |
for (ClassPath.Entry e : cp.entries()) { |
679 |
private static Set<URL> findBinaryRootsForSourceRoot(FileObject sourceRoot, Map<URL, List<URL>> binaryDeps) { |
643 |
toRetain.add(e.getURL()); |
680 |
Set<URL> result = new HashSet<URL>(); |
|
|
681 |
|
682 |
for (URL bin : binaryDeps.keySet()) { |
683 |
for (FileObject s : SourceForBinaryQuery.findSourceRoots(bin).getRoots()) { |
684 |
if (s == sourceRoot) { |
685 |
result.add(bin); |
686 |
} |
644 |
} |
687 |
} |
645 |
} |
688 |
} |
646 |
result.retainAll(toRetain); |
689 |
|
647 |
return result; |
690 |
return result; |
648 |
} |
691 |
} |
649 |
|
692 |
|
650 |
//Helper methods |
693 |
//Helper methods |
651 |
|
694 |
|
652 |
/** |
695 |
/** |
653 |
* Returns classes declared in the given source file which have the main method. |
696 |
* Returns classes declared in the given source file which have the main method. |