| java.lang.Object org.netbeans.modules.gsfpath.api.classpath.GlobalPathRegistry
GlobalPathRegistry | final public class GlobalPathRegistry (Code) | | Maintains a global registry of "interesting" classpaths of various kinds.
You may add and remove different kinds of
ClassPath s to the registry
and listen to changes in them.
It is permitted to register the same classpath more than once; unregistration
keeps track of the number of registrations so that the operation is symmetric.
However
GlobalPathRegistry.getPaths only ever returns one copy of the classpath, and
listeners are only notified the first time a given classpath is added to the
registry, or the last time it is removed.
(Classpath identity is object identity, so there could be multiple paths
returned that at the time share the same list of roots. There may also be
several paths which contain some shared roots.)
The registry is not persisted between JVM sessions.
Intended usage patterns:
When a project is opened using
org.netbeans.spi.project.ui.ProjectOpenedHook it should add any paths
it defines, i.e. paths it might return from a
org.netbeans.modules.gsfpath.spi.classpath.ClassPathProvider .
When closed it should remove them.
The Fast Open feature of the editor and other features which
require a global list of relevant sources should use
GlobalPathRegistry.getSourceRoots or
the equivalent.
The Javadoc Index Search feature and View →
Documentation Indices submenu should operate on open Javadoc paths,
meaning that Javadoc corresponding to registered compile and boot classpaths
(according to
org.netbeans.modules.gsfpath.api.queries.JavadocForBinaryQuery ).
Stack trace hyperlinking can use the global list of source paths
to find sources, in case no more specific information about their origin is
available. The same would be true of debugging: if the debugger cannot find
Java-like sources using more precise means (
SourceForBinaryQuery ), it
can use
GlobalPathRegistry.findResource as a fallback.
author: Jesse Glick since: org.netbeans.modules.gsfpath.api/1 1.4 |
addGlobalPathRegistryListener | public synchronized void addGlobalPathRegistryListener(GlobalPathRegistryListener l)(Code) | | Add a listener to the registry.
Parameters: l - a listener to add |
clear | void clear()(Code) | | for use from unit test
|
findResource | public FileObject findResource(String resource)(Code) | | Convenience method to find a particular source file by resource path.
This simply uses
GlobalPathRegistry.getSourceRoots to find possible roots and
looks up the resource among them.
In case more than one source root contains the resource, one is chosen
arbitrarily.
As with
ClassPath.findResource , include/exclude lists can affect the result.
Parameters: resource - a resource path, e.g. somepkg/Foo.java some file found with that path, or null |
getDefault | public static GlobalPathRegistry getDefault()(Code) | | Get the singleton instance of the registry.
the default instance |
getPaths | public synchronized Set<ClassPath> getPaths(String id)(Code) | | Find all paths of a certain type.
Parameters: id - a classpath type, e.g. ClassPath.SOURCE an immutable set of all registered ClassPaths of that type (may be empty but not null) |
getSourceRoots | public Set<FileObject> getSourceRoots()(Code) | | Convenience method to find all relevant source roots.
This consists of:
- Roots of all registered
ClassPath.SOURCE paths.
- Sources (according to
SourceForBinaryQuery ) of all registered
ClassPath.COMPILE paths.
- Sources of all registered
ClassPath.BOOT paths.
Order is not significant.
Currently there is no reliable way to listen for changes in the
value of this method: while you can listen to changes in the paths
mentioned, it is possible for
SourceForBinaryQuery results to
change. In the future a change listener might be added for the value
of the source roots.
Note that this method takes no account of package includes/excludes.
an immutable set of FileObject source roots |
register | public void register(String id, ClassPath[] paths)(Code) | | Register some classpaths of a certain type.
Parameters: id - a classpath type, e.g. ClassPath.SOURCE Parameters: paths - a list of classpaths to add to the registry |
removeGlobalPathRegistryListener | public synchronized void removeGlobalPathRegistryListener(GlobalPathRegistryListener l)(Code) | | Remove a listener to the registry.
Parameters: l - a listener to remove |
|
|