public static Set<String> gatherJavaMimeTypes() { Set<String> mimeTypes = new HashSet<String>(); final Collection<? extends IndexerInfo<CustomIndexerFactory>> indexers = IndexerCache.getCifCache().getIndexersByName(JavaIndex.NAME); if (indexers != null) { for (IndexerInfo<CustomIndexerFactory> i : indexers) { mimeTypes.addAll(i.getMimeTypes()); } } else { LOG.warning("No java indexer found."); //NOI18N } return mimeTypes; }
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 File getIndex(URL url) throws IOException { url = CachingArchiveProvider.getDefault().mapCtSymToJar(url); FileObject indexBaseFolder = CacheFolder.getDataFolder(url); String path = SPIAccessor.getInstance().getIndexerPath(NAME, VERSION); FileObject indexFolder = FileUtil.createFolder(indexBaseFolder, path); return FileUtil.toFile(indexFolder); }
@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; }
/** * * @param url of root to be indexed * @return result of indexing * @throws IOException * @throws IllegalArgumentException * @deprecated Only used by unit tests, the start method is used by impl dep by tests of several modules, safer to keep it. */ @Deprecated public final Changes analyse(@NonNull final URL url) throws IOException, IllegalArgumentException { return analyse( SPIAccessor.getInstance().createContext( FileUtil.createMemoryFileSystem().getRoot(), url, JavaIndex.NAME, JavaIndex.VERSION, null, false, false, false, SuspendSupport.NOP, null, null)); }
PathRegistry.getDefault().registerUnknownSourceRoots(src, unknown);
} else { toCompileRound = new ArrayList<CompileTuple>(compileResult.aptGenerated.size()); final SPIAccessor accessor = SPIAccessor.getInstance(); for (javax.tools.FileObject fo : compileResult.aptGenerated) { final PrefetchableJavaFileObject pfo = (PrefetchableJavaFileObject) fo; final Indexable i = accessor.create(new AptGeneratedIndexable(pfo)); CompileTuple ct = new CompileTuple(pfo, i, false, true, true); toCompileRound.add(ct);
public static URL getSourceRootForClassFolder(URL binaryRoot) { FileObject folder = URLMapper.findFileObject(binaryRoot); if (folder == null || !CLASSES.equals(folder.getName())) return null; folder = folder.getParent(); if (folder == null || !String.valueOf(VERSION).equals(folder.getName())) return null; folder = folder.getParent(); if (folder == null || !NAME.equals(folder.getName())) return null; folder = folder.getParent(); if (folder == null) return null; return CacheFolder.getSourceRootForDataFolder(folder); }
IndexingUtils.runAsScanWork(new Runnable() { @Override public void run() {
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) { URL[] srcRoots = null; if (translate) { srcRoots = preg.sourceForBinaryQuery(entry.getURL(), cp, false);
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(); } }
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); } } } }
final PathRegistry preg = PathRegistry.getDefault(); final Set<URL> unInitializedSourceRoots = new HashSet<URL>(); for (ClassPath.Entry entry : entries) { URL[] sourceUrls; if (translate) { sourceUrls = preg.sourceForBinaryQuery(url, this.cp, true);