public static void sourceRootRegistered(FileObject root, URL rootURL) { if ( root == null || knownSourceRootsMap.containsKey(rootURL) //XXX hack unknown roots are also scanned (and consequently registered), but never sourceRootUnregistered(rootsRemoved): || PathRegistry.getDefault().getUnknownRoots().contains(rootURL)) { return; } Reference<APTUtils> utilsRef = auxiliarySourceRootsMap.remove(root); APTUtils utils = utilsRef != null ? utilsRef.get() : null; knownSourceRootsMap.put(rootURL, utils); }
public static void sourceRootUnregistered(Iterable<? extends URL> roots) { for (URL root : roots) { knownSourceRootsMap.remove(root); } //XXX hack make sure we are not holding APTUtils for any unknown roots //just in case something goes wrong: for (URL unknown : PathRegistry.getDefault().getUnknownRoots()) { knownSourceRootsMap.remove(unknown); } final Project[] projects = OpenProjects.getDefault().getOpenProjects(); if (projects.length == 0 && !knownSourceRootsMap.isEmpty()) { LOG.log( Level.WARNING, "Non removed known roots: {0}", //NOI18N knownSourceRootsMap.keySet()); knownSourceRootsMap.clear(); } }
@org.netbeans.api.annotations.common.SuppressWarnings(value={"DMI_COLLECTION_OF_URLS"}, justification="URLs have never host part") //NOI18N private boolean containsRoot (final ClassPath cp, final Set<? extends URL> roots, final List<? super URL> affectedRoots, final boolean translate) { final List<ClassPath.Entry> entries = cp.entries(); final PathRegistry preg = PathRegistry.getDefault(); boolean result = false; for (ClassPath.Entry entry : entries) { URL url = entry.getURL(); URL[] srcRoots = null; if (translate) { srcRoots = preg.sourceForBinaryQuery(entry.getURL(), cp, false); } if (srcRoots == null) { if (roots.contains(url)) { affectedRoots.add(url); result = true; } } else { for (URL _url : srcRoots) { if (roots.contains(_url)) { affectedRoots.add(url); result = true; } } } } return result; }
final Set<? super URL> attachListener, final boolean translate) throws IOException { final List<ClassPath.Entry> entries = cp.entries(); final PathRegistry preg = PathRegistry.getDefault(); boolean result = false; for (ClassPath.Entry entry : entries) {
final PathRegistry preg = PathRegistry.getDefault(); final Set<URL> unInitializedSourceRoots = new HashSet<URL>(); for (ClassPath.Entry entry : entries) {
private void createQueriesForRoots (final ClassPath cp, final boolean sources, final Set<? super ClassIndexImpl> queries, final Set<? super URL> oldState) { final PathRegistry preg = PathRegistry.getDefault(); List<ClassPath.Entry> entries = cp.entries(); for (ClassPath.Entry entry : entries) { URL[] srcRoots; if (!sources) { srcRoots = preg.sourceForBinaryQuery(entry.getURL(), cp, true); if (srcRoots == null) { srcRoots = new URL[] {entry.getURL()}; } } else { srcRoots = new URL[] {entry.getURL()}; } for (URL srcRoot : srcRoots) { oldState.add (srcRoot); ClassIndexImpl ci = ClassIndexManager.getDefault().getUsagesQuery(srcRoot, true); if (ci != null) { ci.addClassIndexImplListener(spiListener); queries.add (ci); } } } }
PathRegistry.getDefault().registerUnknownSourceRoots(src, unknown);