public abstract class AbstractSourceLookupDirector extends Object implements ISourceLookupDirector, ILaunchConfigurationListener, ILaunchListener
When a source director is initialized, it adds it self as a launch listener, and automatically disposes itself when its associated launch is removed from the launch manager. If a source director is instantiated by a client that is not part of a launch, that client is responsible for disposing the source director.
Clients may subclass this class.
ISourceLocator
,
ISourceContainer
,
ISourceContainerType
,
ISourcePathComputer
,
ISourceLookupParticipant
Modifier and Type | Field and Description |
---|---|
protected static String |
CONTAINER_MEMENTO_ATTR |
protected static String |
CONTAINER_NODE |
protected static String |
CONTAINER_TYPE_ATTR |
protected static String |
CONTAINERS_NODE |
protected static String |
DIRECTOR_ROOT_NODE |
protected static String |
DUPLICATES_ATTR |
protected ISourcePathComputer |
fComputer |
protected ILaunchConfiguration |
fConfig |
protected boolean |
fDuplicates |
protected String |
fId |
protected ArrayList<ISourceLookupParticipant> |
fParticipants |
protected static IStatus |
fPromptStatus |
protected Map<Object,Object> |
fResolvedElements
Cache of resolved source elements when duplicates exist.
|
protected static IStatus |
fResolveDuplicatesStatus |
protected ISourceContainer[] |
fSourceContainers |
Constructor and Description |
---|
AbstractSourceLookupDirector()
Constructs source lookup director
|
Modifier and Type | Method and Description |
---|---|
protected void |
abort(String message,
Throwable exception)
Throws an exception with the given message and underlying exception.
|
void |
addParticipants(ISourceLookupParticipant[] participants)
Adds the given source lookup participants to this director.
|
protected void |
cacheResolvedElement(List<Object> duplicates,
Object sourceElement)
Caches the resolved source element to use when one of the following
duplicates is found.
|
protected void |
clearCachedElement(Object duplicate)
Clears any cached source element associated with the given duplicate
is source element.
|
void |
clearSourceElements(Object element)
Clears any source lookup results associated with the given
debug artifact, such that a subsequent lookup will force a new search
to be performed.
|
void |
dispose()
Disposes this source locator.
|
protected void |
doInitializeFromMemento(String memento,
boolean dispose)
Initializes this source lookup director from the given memento.
|
protected List<Object> |
doSourceLookup(Object element)
Performs a source lookup query for the given element
returning the source elements associated with the element.
|
Object[] |
findSourceElements(Object object)
Returns a collection of source elements corresponding to the given debug
artifact (for example, a stack frame or breakpoint).
|
protected Object |
getCachedElement(Object duplicate)
Returns the cached source element to use when the given duplicate
is encountered.
|
ISourceLookupParticipant |
getCurrentParticipant()
Returns the participant currently looking up source or
null
if none. |
String |
getId()
Returns the identifier of this type of source locator.
|
ILaunchConfiguration |
getLaunchConfiguration()
Returns the launch configuration associated with this source
lookup director, or
null if none. |
String |
getMemento()
Returns a memento that can be used to reconstruct
this source locator
|
ISourceLookupParticipant[] |
getParticipants()
Returns the source lookup participants currently registered with
this director, possibly an empty collection.
|
ISourceContainer[] |
getSourceContainers()
Returns the source containers currently registered with this
director, possibly an empty collection.
|
Object |
getSourceElement(IStackFrame stackFrame)
Returns a source element that corresponds to the given stack frame, or
null if a source element could not be located. |
Object |
getSourceElement(Object element)
Returns a source element that corresponds to the given debug artifact, or
null if a source element could not be located. |
ISourcePathComputer |
getSourcePathComputer()
Returns the source path computer to use with this source lookup
director, possibly
null . |
void |
initializeDefaults(ILaunchConfiguration configuration)
Initializes this source locator to perform default
source lookup for the given launch configuration.
|
void |
initializeFromMemento(String memento)
Initializes this source locator based on the given
memento.
|
void |
initializeFromMemento(String memento,
ILaunchConfiguration configuration)
Initializes this source locator based on the given
memento, for the given launch configuration.
|
boolean |
isFindDuplicates()
Returns whether to search exhaustively for all source elements
with the same name in all registered source containers, or
whether to stop searching when the first source element matching
the required name is found.
|
void |
launchAdded(ILaunch launch)
Notifies this listener that the specified launch
has been added.
|
void |
launchChanged(ILaunch launch)
Notifies this listener that the specified launch
has changed.
|
void |
launchConfigurationAdded(ILaunchConfiguration configuration)
The given launch configuration has been created.
|
void |
launchConfigurationChanged(ILaunchConfiguration configuration)
The given launch configuration has changed in some way.
|
void |
launchConfigurationRemoved(ILaunchConfiguration configuration)
The given launch configuration has been deleted.
|
void |
launchRemoved(ILaunch launch)
Notifies this listener that the specified
launch has been removed.
|
void |
removeParticipants(ISourceLookupParticipant[] participants)
Removes the given source lookup participants from this director.
|
Object |
resolveSourceElement(Object element,
List<Object> sources)
Returns the source element to associate with the given element.
|
void |
setFindDuplicates(boolean duplicates)
Sets whether to search exhaustively for all source elements
with the same name in all registered source containers, or
whether to stop searching when the first source element matching
the required name is found.
|
void |
setId(String id)
Sets the type identifier for this source locator's type
|
protected void |
setLaunchConfiguration(ILaunchConfiguration configuration)
Sets the launch configuration associated with this source lookup
director.
|
void |
setSourceContainers(ISourceContainer[] containers)
Sets the source containers used by this source lookup
director.
|
void |
setSourcePathComputer(ISourcePathComputer computer)
Sets the source path computer for this source lookup director.
|
boolean |
supportsSourceContainerType(ISourceContainerType type)
Returns whether this source director supports the given type
of source location.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
initializeParticipants
protected String fId
protected ArrayList<ISourceLookupParticipant> fParticipants
protected ISourceContainer[] fSourceContainers
protected ILaunchConfiguration fConfig
protected boolean fDuplicates
protected ISourcePathComputer fComputer
protected Map<Object,Object> fResolvedElements
protected static final IStatus fPromptStatus
protected static final IStatus fResolveDuplicatesStatus
protected static final String DIRECTOR_ROOT_NODE
protected static final String CONTAINERS_NODE
protected static final String DUPLICATES_ATTR
protected static final String CONTAINER_NODE
protected static final String CONTAINER_TYPE_ATTR
protected static final String CONTAINER_MEMENTO_ATTR
public AbstractSourceLookupDirector()
public void setId(String id)
id
- corresponds to source locator type identifier for a
persistable source locatorpublic void dispose()
IPersistableSourceLocator2
dispose
in interface IPersistableSourceLocator2
protected void abort(String message, Throwable exception) throws CoreException
message
- error messageexception
- underlying exception, or null
CoreException
- if a problem is encounteredpublic ISourceContainer[] getSourceContainers()
ISourceLookupDirector
getSourceContainers
in interface ISourceLookupDirector
public boolean isFindDuplicates()
ISourceLookupDirector
isFindDuplicates
in interface ISourceLookupDirector
public void setFindDuplicates(boolean duplicates)
ISourceLookupDirector
setFindDuplicates
in interface ISourceLookupDirector
duplicates
- whether to search exhaustively for all source elements
with the same namepublic void launchConfigurationAdded(ILaunchConfiguration configuration)
ILaunchConfigurationListener
launchConfigurationAdded
in interface ILaunchConfigurationListener
configuration
- the newly created launch configurationpublic void launchConfigurationChanged(ILaunchConfiguration configuration)
ILaunchConfigurationListener
launchConfigurationChanged
in interface ILaunchConfigurationListener
configuration
- the launch configuration that has
changedpublic void launchConfigurationRemoved(ILaunchConfiguration configuration)
ILaunchConfigurationListener
The launch configuration no longer exists. Data stored in the configuration can no longer be accessed, however handle-only attributes of the launch configuration can be retrieved.
launchConfigurationRemoved
in interface ILaunchConfigurationListener
configuration
- the deleted launch configurationpublic String getMemento() throws CoreException
IPersistableSourceLocator
getMemento
in interface IPersistableSourceLocator
CoreException
- if unable to construct a mementopublic void initializeFromMemento(String memento) throws CoreException
IPersistableSourceLocator
initializeFromMemento
in interface IPersistableSourceLocator
memento
- a memento to initialize this source locatorCoreException
- on failure to initializeprotected void doInitializeFromMemento(String memento, boolean dispose) throws CoreException
memento
- source locator mementodispose
- whether to dispose any current source containers and participants
before initializingCoreException
- if an exception occurs during initializationpublic void setSourceContainers(ISourceContainer[] containers)
setSourceContainers
in interface ISourceLookupDirector
containers
- source containers to searchpublic Object getSourceElement(IStackFrame stackFrame)
ISourceLocator
null
if a source element could not be located. The object returned
by this method will be used by the debug UI plug-in to display source.
The debug UI uses the debug model presentation associated
with the given stack frame's debug model to translate a source object into an
{editor input, editor id} pair in which to display source.
For example, a java source locator could return an object representing a compilation unit or class file. The java debug model presentation would then be responsible for providing an editor input and editor id for each compilation unit and class file such that the debug UI could display source.
getSourceElement
in interface ISourceLocator
stackFrame
- the stack frame for which to locate sourceprotected List<Object> doSourceLookup(Object element)
element
- stack framepublic Object resolveSourceElement(Object element, List<Object> sources)
Subclasses should override this method as appropriate. For example, to prompt the user to choose a source element.
element
- the debug artifact for which source is being searched forsources
- the source elements found for the given elementpublic void initializeFromMemento(String memento, ILaunchConfiguration configuration) throws CoreException
IPersistableSourceLocator2
initializeFrom(String memento)
defined in IPersistableSourceLocator
when a source
locator implements this interface.initializeFromMemento
in interface IPersistableSourceLocator2
memento
- a memento to initialize this source locatorconfiguration
- the launch configuration this source locator is
being created forCoreException
- on failure to initializepublic void initializeDefaults(ILaunchConfiguration configuration) throws CoreException
IPersistableSourceLocator
initializeDefaults
in interface IPersistableSourceLocator
configuration
- launch configuration this source locator
will be performing source lookup forCoreException
- on failure to initializepublic ILaunchConfiguration getLaunchConfiguration()
ISourceLookupDirector
null
if none.getLaunchConfiguration
in interface ISourceLookupDirector
null
if noneprotected void setLaunchConfiguration(ILaunchConfiguration configuration)
configuration
- launch configuration to associate with this
source lookup director, or null
if nonepublic void launchAdded(ILaunch launch)
ILaunchListener
launchAdded
in interface ILaunchListener
launch
- the newly added launchpublic void launchChanged(ILaunch launch)
ILaunchListener
launchChanged
in interface ILaunchListener
launch
- the changed launchpublic void launchRemoved(ILaunch launch)
ILaunchListener
launchRemoved
in interface ILaunchListener
launch
- the removed launchpublic ISourceLookupParticipant[] getParticipants()
ISourceLookupDirector
getParticipants
in interface ISourceLookupDirector
public boolean supportsSourceContainerType(ISourceContainerType type)
ISourceLookupDirector
supportsSourceContainerType
in interface ISourceLookupDirector
type
- source container typeprotected void cacheResolvedElement(List<Object> duplicates, Object sourceElement)
duplicates
- duplicates source elementssourceElement
- chosen source element to use in place of the
duplicatesprotected Object getCachedElement(Object duplicate)
duplicate
- duplicates source elementprotected void clearCachedElement(Object duplicate)
duplicate
- duplicate source element to cache resolved results
forpublic void clearSourceElements(Object element)
ISourceLookupDirector
clearSourceElements
in interface ISourceLookupDirector
element
- debug artifact to clear source lookup results forpublic void addParticipants(ISourceLookupParticipant[] participants)
ISourceLookupDirector
addParticipants
in interface ISourceLookupDirector
participants
- participants to addpublic void removeParticipants(ISourceLookupParticipant[] participants)
ISourceLookupDirector
removeParticipants
in interface ISourceLookupDirector
participants
- participants to removepublic String getId()
ISourceLookupDirector
getId
in interface ISourceLookupDirector
public ISourcePathComputer getSourcePathComputer()
ISourceLookupDirector
null
. By default, the source path
computer returned is the one associated with this director's launch
configuration's type. However, the source path computer can be specified
programmatically by calling setSourcePathComputer(...)
.getSourcePathComputer
in interface ISourceLookupDirector
null
public void setSourcePathComputer(ISourcePathComputer computer)
ISourceLookupDirector
null
is specified
the default source path computer will be used (i.e. the one associated
with this director's launch configuration's type).setSourcePathComputer
in interface ISourceLookupDirector
computer
- source path computer or null
public Object[] findSourceElements(Object object) throws CoreException
ISourceLookupDirector
isFindDuplicates()
.
When false
the returned collection should contain at most one
source element.findSourceElements
in interface ISourceLookupDirector
object
- the debug artifact for which source needs to be found (e.g., stack frame)CoreException
- if an exception occurs while searching for sourcepublic Object getSourceElement(Object element)
ISourceLookupDirector
null
if a source element could not be located. This is a
generalization of getSourceElement(IStackFrame)
to allow
source to be found for other types of elements.getSourceElement
in interface ISourceLookupDirector
element
- the debug artifact for which to locate sourcepublic ISourceLookupParticipant getCurrentParticipant()
null
if none.null
if none
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.