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 184168
Collapse All | Expand All

(-)a/java.source/src/org/netbeans/api/java/source/ElementUtilities.java (+37 lines)
Lines 70-77 Link Here
70
import com.sun.tools.javac.util.Context;
70
import com.sun.tools.javac.util.Context;
71
import com.sun.tools.javac.util.Names;
71
import com.sun.tools.javac.util.Names;
72
import com.sun.tools.javadoc.DocEnv;
72
import com.sun.tools.javadoc.DocEnv;
73
import java.io.IOException;
74
import java.net.URL;
73
75
74
import java.util.ArrayList;
76
import java.util.ArrayList;
77
import java.util.Collection;
75
import java.util.Collections;
78
import java.util.Collections;
76
import java.util.EnumSet;
79
import java.util.EnumSet;
77
import java.util.HashMap;
80
import java.util.HashMap;
Lines 80-85 Link Here
80
import java.util.LinkedList;
83
import java.util.LinkedList;
81
import java.util.List;
84
import java.util.List;
82
import java.util.ListIterator;
85
import java.util.ListIterator;
86
import java.util.Map;
87
import java.util.Set;
83
import javax.lang.model.element.Element;
88
import javax.lang.model.element.Element;
84
import javax.lang.model.element.ElementKind;
89
import javax.lang.model.element.ElementKind;
85
import javax.lang.model.element.ExecutableElement;
90
import javax.lang.model.element.ExecutableElement;
Lines 96-101 Link Here
96
101
97
import org.netbeans.modules.java.source.builder.ElementsService;
102
import org.netbeans.modules.java.source.builder.ElementsService;
98
import org.netbeans.modules.java.source.JavadocEnv;
103
import org.netbeans.modules.java.source.JavadocEnv;
104
import org.netbeans.modules.java.source.tasklist.TasklistSettings.DependencyTracking;
105
import org.netbeans.modules.java.source.util.FindUsagesUtils;
106
import org.openide.filesystems.FileObject;
107
import org.openide.util.Exceptions;
99
108
100
/**
109
/**
101
 *
110
 *
Lines 536-541 Link Here
536
        return findUnimplementedMethods(impl, impl);
545
        return findUnimplementedMethods(impl, impl);
537
    }
546
    }
538
547
548
    /**
549
     * Finds all subtypes of given types in all known source roots that depend on the current source root.
550
     *
551
     * @param handles types for which the subtypes should be found
552
     * @return all found subtypes for the given types, classified by source root and original type. <code>null</code> may be returned if current the task is canceled.
553
     * @since 0.59
554
     */
555
    public Map<URL, Map<ElementHandle<TypeElement>, Set<ElementHandle<TypeElement>>>> findSubTypes(Collection<? extends ElementHandle<TypeElement>> handles) {
556
        FileObject owner = info.getClasspathInfo().getClassPath(ClasspathInfo.PathKind.SOURCE).findOwnerRoot(info.getFileObject());
557
558
        if (owner == null) {
559
            return Collections.emptyMap();//TODO: log?
560
        }
561
562
        Map<URL, Map<ElementHandle<TypeElement>, Set<ElementHandle<TypeElement>>>> result = new HashMap<URL, Map<ElementHandle<TypeElement>, Set<ElementHandle<TypeElement>>>>();
563
564
        try {
565
            if (FindUsagesUtils.findUsages(owner.getURL(), new LinkedList<ElementHandle<TypeElement>>(handles), result, false, true, false, DependencyTracking.ENABLED) == null) {
566
                return null;
567
            }
568
        } catch (IOException ex) {
569
            //should not normally happen:
570
            Exceptions.printStackTrace(ex);
571
        }
572
573
        return result;
574
    }
575
539
    // private implementation --------------------------------------------------
576
    // private implementation --------------------------------------------------
540
577
541
578

Return to bug 184168