This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 223917
Collapse All | Expand All

(-)a/java.source/apichanges.xml (+14 lines)
Lines 108-113 Link Here
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
108
    <!-- ACTUAL CHANGES BEGIN HERE: -->
109
109
110
    <changes>
110
    <changes>
111
         <change id="SourceUtils-getDependentRoots">
112
             <api name="general"/>
113
             <summary>Added overloaded method <code>SourceUtils.getDependentRoots</code>.</summary>
114
             <version major="0" minor="110"/>
115
             <date day="24" month="12" year="2012"/>
116
             <author login="ralphbenjamin"/>
117
            <compatibility addition="yes" binary="compatible" deletion="no" deprecation="no" modification="no" semantic="compatible" source="compatible"/>
118
             <description>
119
                 Added a new overloaded method <code>getDependentRoots</code> to class <code>SourceUtils</code>,
120
                 that adds an option to filter non opened projects.
121
             </description>
122
             <class package="org.netbeans.api.java.source" name="SourceUtils"/>
123
             <issue number="223917"/>
124
        </change>
111
        <change id="WorkingCopy-resolveRewriteTarget">
125
        <change id="WorkingCopy-resolveRewriteTarget">
112
             <api name="general"/>
126
             <api name="general"/>
113
             <summary>Added <code>WorkingCopy.resolveRewriteTarget</code>.</summary>
127
             <summary>Added <code>WorkingCopy.resolveRewriteTarget</code>.</summary>
(-)a/java.source/nbproject/project.properties (-1 / +1 lines)
Lines 46-52 Link Here
46
javadoc.title=Java Source
46
javadoc.title=Java Source
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
49
spec.version.base=0.109.0
49
spec.version.base=0.110.0
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/nb-javac-api.jar
50
test.qa-functional.cp.extra=${refactoring.java.dir}/modules/ext/nb-javac-api.jar
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
51
test.unit.run.cp.extra=${o.n.core.dir}/core/core.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
52
    ${o.n.core.dir}/lib/boot.jar:\
(-)a/java.source/src/org/netbeans/api/java/source/SourceUtils.java (-9 / +29 lines)
Lines 96-101 Link Here
96
import org.netbeans.api.java.queries.SourceForBinaryQuery;
96
import org.netbeans.api.java.queries.SourceForBinaryQuery;
97
import org.netbeans.api.java.source.ClasspathInfo.PathKind;
97
import org.netbeans.api.java.source.ClasspathInfo.PathKind;
98
import org.netbeans.api.java.source.JavaSource.Phase;
98
import org.netbeans.api.java.source.JavaSource.Phase;
99
import static org.netbeans.api.java.source.SourceUtils.getDependentRootsImpl;
99
import org.netbeans.api.java.source.matching.Matcher;
100
import org.netbeans.api.java.source.matching.Matcher;
100
import org.netbeans.api.java.source.matching.Occurrence;
101
import org.netbeans.api.java.source.matching.Occurrence;
101
import org.netbeans.api.java.source.matching.Pattern;
102
import org.netbeans.api.java.source.matching.Pattern;
Lines 675-686 Link Here
675
    public static Set<URL> getDependentRoots (final URL root) {
676
    public static Set<URL> getDependentRoots (final URL root) {
676
        final Map<URL, List<URL>> sourceDeps = IndexingController.getDefault().getRootDependencies();
677
        final Map<URL, List<URL>> sourceDeps = IndexingController.getDefault().getRootDependencies();
677
        final Map<URL, List<URL>> binaryDeps = IndexingController.getDefault().getBinaryRootDependencies();
678
        final Map<URL, List<URL>> binaryDeps = IndexingController.getDefault().getBinaryRootDependencies();
678
        return getDependentRootsImpl (root, sourceDeps, binaryDeps);
679
        return getDependentRootsImpl (root, sourceDeps, binaryDeps, true);
679
    }
680
    }
680
    
681
    
682
    /**
683
     * Returns the dependent source path roots for given source root. It returns
684
     * all the source roots which have either direct or transitive dependency on
685
     * the given source root.
686
     *
687
     * @param root to find the dependent roots for
688
     * @param filterNonOpenedProjects true if the results should only contain roots for
689
     * opened projects
690
     * @return {@link Set} of {@link URL}s containing at least the incoming
691
     * root, never returns null.
692
     * @since 0.110
693
     */
694
    @org.netbeans.api.annotations.common.SuppressWarnings(value = {"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/)    //NOI18N
695
    public static Set<URL> getDependentRoots(final URL root, boolean filterNonOpenedProjects) {
696
        final Map<URL, List<URL>> sourceDeps = IndexingController.getDefault().getRootDependencies();
697
        final Map<URL, List<URL>> binaryDeps = IndexingController.getDefault().getBinaryRootDependencies();
698
        return getDependentRootsImpl(root, sourceDeps, binaryDeps, filterNonOpenedProjects);
699
    }
681
700
682
    @org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/)    //NOI18N
701
    @org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}/*,justification="URLs have never host part"*/)    //NOI18N
683
    static Set<URL> getDependentRootsImpl (final URL root, final Map<URL, List<URL>> sourceDeps, Map<URL, List<URL>> binaryDeps) {
702
    static Set<URL> getDependentRootsImpl (final URL root, final Map<URL, List<URL>> sourceDeps, Map<URL, List<URL>> binaryDeps, boolean filterNonOpenedProjects) {
684
        Set<URL> urls;
703
        Set<URL> urls;
685
704
686
        if (sourceDeps.containsKey(root)) {
705
        if (sourceDeps.containsKey(root)) {
Lines 703-717 Link Here
703
            }
722
            }
704
        }
723
        }
705
724
706
        //Filter non opened projects
725
        if(filterNonOpenedProjects) {
707
        Set<ClassPath> cps = GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE);
726
            Set<ClassPath> cps = GlobalPathRegistry.getDefault().getPaths(ClassPath.SOURCE);
708
        Set<URL> toRetain = new HashSet<URL>();
727
            Set<URL> toRetain = new HashSet<URL>();
709
        for (ClassPath cp : cps) {
728
            for (ClassPath cp : cps) {
710
            for (ClassPath.Entry e : cp.entries()) {
729
                for (ClassPath.Entry e : cp.entries()) {
711
                toRetain.add(e.getURL());
730
                    toRetain.add(e.getURL());
731
                }
712
            }
732
            }
733
            urls.retainAll(toRetain);
713
        }
734
        }
714
        urls.retainAll(toRetain);
715
        return urls;
735
        return urls;
716
    }    
736
    }    
717
    
737
    
(-)a/java.source/test/unit/src/org/netbeans/api/java/source/SourceUtilsTest.java (-5 / +5 lines)
Lines 268-287 Link Here
268
        deps.put (url4,deps2);
268
        deps.put (url4,deps2);
269
        deps.put (url5,deps3);
269
        deps.put (url5,deps3);
270
        
270
        
271
        Set<URL> result = SourceUtils.getDependentRootsImpl(url5, deps, Collections.<URL, List<URL>>emptyMap());
271
        Set<URL> result = SourceUtils.getDependentRootsImpl(url5, deps, Collections.<URL, List<URL>>emptyMap(), true);
272
        assertEquals (1, result.size());
272
        assertEquals (1, result.size());
273
        assertEquals (url5,result.iterator().next());
273
        assertEquals (url5,result.iterator().next());
274
        
274
        
275
        result = SourceUtils.getDependentRootsImpl(url4, deps, Collections.<URL, List<URL>>emptyMap());
275
        result = SourceUtils.getDependentRootsImpl(url4, deps, Collections.<URL, List<URL>>emptyMap(), true);
276
        assertEquals (new URL[] {url4, url5}, result);
276
        assertEquals (new URL[] {url4, url5}, result);
277
        
277
        
278
        result = SourceUtils.getDependentRootsImpl(url3, deps, Collections.<URL, List<URL>>emptyMap());
278
        result = SourceUtils.getDependentRootsImpl(url3, deps, Collections.<URL, List<URL>>emptyMap(), true);
279
        assertEquals (new URL[] {url3, url5}, result);
279
        assertEquals (new URL[] {url3, url5}, result);
280
        
280
        
281
        result = SourceUtils.getDependentRootsImpl(url2, deps, Collections.<URL, List<URL>>emptyMap());
281
        result = SourceUtils.getDependentRootsImpl(url2, deps, Collections.<URL, List<URL>>emptyMap(), true);
282
        assertEquals (new URL[] {url2, url3, url4, url5}, result);
282
        assertEquals (new URL[] {url2, url3, url4, url5}, result);
283
        
283
        
284
        result = SourceUtils.getDependentRootsImpl(url1, deps, Collections.<URL, List<URL>>emptyMap());
284
        result = SourceUtils.getDependentRootsImpl(url1, deps, Collections.<URL, List<URL>>emptyMap(), true);
285
        assertEquals (new URL[] {url1, url3, url5}, result);
285
        assertEquals (new URL[] {url1, url3, url5}, result);
286
    }
286
    }
287
    
287
    

Return to bug 223917