Skip to main content
summaryrefslogtreecommitdiffstats
path: root/dsf
diff options
context:
space:
mode:
authorJonah Graham2016-01-06 13:05:03 -0500
committerMarc Khouzam2016-01-17 10:11:41 -0500
commit28b1830acf942216ae99d4d167b6c3b2133aaec6 (patch)
tree9c49d339395c514092db317793939293a6f12821 /dsf
parentc3bfd4daeea93f054b3988ebac2bcbeaded9b316 (diff)
downloadorg.eclipse.cdt-28b1830acf942216ae99d4d167b6c3b2133aaec6.tar.gz
org.eclipse.cdt-28b1830acf942216ae99d4d167b6c3b2133aaec6.tar.xz
org.eclipse.cdt-28b1830acf942216ae99d4d167b6c3b2133aaec6.zip
Bug 484911: Clean up source directors
Includes: - CSourceLookupParticipant only did one useful thing (For DSF). When the object being looked up is a String, as is the case when disassembly view/editor is doing a lookup, the CSourceLookupParticipant would be the one to do the resolution. Updated DsfSourceLookupParticipant.getSourceName to be able to handle a String - Changed super of DsfSourceLookupParticipant to AbstractSourceLookupParticipant, saves duplicate code, and adds comment about what is different about findSourceElements - a previously missing test for an unusual case (no containers) - Some of these methods that are only part of CDI have been marked as such for eventual removal in Bug 484900 Change-Id: I9954b4469e9db9cb46eb117f3beba9e01634689b Signed-off-by: Jonah Graham <jonah@kichwacoders.com>
Diffstat (limited to 'dsf')
-rw-r--r--dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupDirector.java19
-rw-r--r--dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupParticipant.java76
2 files changed, 26 insertions, 69 deletions
diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupDirector.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupDirector.java
index 76f3cc5af2..236171fd11 100644
--- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupDirector.java
+++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupDirector.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2009 QNX Software Systems and others.
+ * Copyright (c) 2004, 2015 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -19,22 +19,23 @@ import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
/**
* DSF source lookup director.
*
+ * When a launch (or the global) source lookup containers are being edited it is
+ * an instance of CSourceLookupDirector that is created. However, when using DSF
+ * launch, the subclass DsfSourceLookupDirector is actually instantiated because
+ * connection to the DsfSession is needed.
+ *
* @since 1.0
*/
public class DsfSourceLookupDirector extends CSourceLookupDirector {
private final DsfSession fSession;
- public DsfSourceLookupDirector(DsfSession session) {
- fSession = session;
- }
+ public DsfSourceLookupDirector(DsfSession session) {
+ fSession = session;
+ }
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourceLookupDirector#initializeParticipants()
- */
@Override
- public void initializeParticipants() {
- super.initializeParticipants();
+ public void initializeParticipants() {
addParticipants( new ISourceLookupParticipant[]{ new DsfSourceLookupParticipant(fSession) } );
}
diff --git a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupParticipant.java b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupParticipant.java
index 262a7111f6..b99cc34819 100644
--- a/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupParticipant.java
+++ b/dsf/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/sourcelookup/DsfSourceLookupParticipant.java
@@ -37,23 +37,20 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
-import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
/**
* Source lookup participant that should be used with DSF-based debuggers.
- *
+ *
* @since 1.0
*/
@ThreadSafe
-public class DsfSourceLookupParticipant implements ISourceLookupParticipant {
- protected static final Object[] EMPTY = new Object[0];
-
+public class DsfSourceLookupParticipant extends AbstractSourceLookupParticipant {
private DsfExecutor fExecutor;
private String fSessionId;
private DsfServicesTracker fServicesTracker;
- private ISourceLookupDirector fDirector;
private Map<String, List<Object>> fLookupCache = Collections.synchronizedMap(new HashMap<String, List<Object>>());
public DsfSourceLookupParticipant(DsfSession session) {
@@ -61,27 +58,19 @@ public class DsfSourceLookupParticipant implements ISourceLookupParticipant {
fExecutor = session.getExecutor();
fServicesTracker = new DsfServicesTracker(DsfPlugin.getBundleContext(), fSessionId);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#init(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
- */
- @Override
- public void init(ISourceLookupDirector director) {
- fDirector = director;
- }
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#dispose()
- */
@Override
public void dispose() {
fServicesTracker.dispose();
- fDirector = null;
+ super.dispose();
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#findSourceElements(java.lang.Object)
- */
+ /**
+ * This method does the same thing (is almost copy-and-paste) as
+ * {@link AbstractSourceLookupParticipant#findSourceElements(Object), but it
+ * surrounds the lookup with a cache (#fLookupCache) that needs to be
+ * cleared if the source containers change.
+ */
@Override
public Object[] findSourceElements(Object object) throws CoreException {
CoreException single = null;
@@ -102,7 +91,7 @@ public class DsfSourceLookupParticipant implements ISourceLookupParticipant {
containers = new ISourceContainer[] { new AbsolutePathSourceContainer() };
for (int i = 0; i < containers.length; i++) {
try {
- ISourceContainer container = containers[i];
+ ISourceContainer container = getDelegateContainer(containers[i]);
if (container != null) {
Object[] objects = container.findSourceElements(name);
if (objects.length > 0) {
@@ -145,50 +134,17 @@ public class DsfSourceLookupParticipant implements ISourceLookupParticipant {
return results.toArray();
}
- /**
- * Returns whether this participant's source lookup director is configured
- * to search for duplicate source elements.
- *
- * @return whether this participant's source lookup director is configured
- * to search for duplicate source elements
- */
- protected boolean isFindDuplicates() {
- ISourceLookupDirector director = fDirector;
- if (director != null) {
- return director.isFindDuplicates();
- }
- return false;
- }
-
- /**
- * Returns the source containers currently registered with this participant's
- * source lookup director.
- *
- * @return the source containers currently registered with this participant's
- * source lookup director
- */
- protected ISourceContainer[] getSourceContainers() {
- ISourceLookupDirector director = fDirector;
- if (director != null) {
- return director.getSourceContainers();
- }
- return new ISourceContainer[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant#sourceContainersChanged(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector)
- */
@Override
public void sourceContainersChanged(ISourceLookupDirector director) {
fLookupCache.clear();
}
- /* (non-Javadoc)
- * @see org.eclipse.debug.internal.core.sourcelookup.ISourceLookupParticipant#getSourceName(java.lang.Object)
- */
@Override
- public String getSourceName(Object object) throws CoreException {
- if ( !(object instanceof IDMContext) ||
+ public String getSourceName(Object object) throws CoreException {
+ if (object instanceof String) {
+ return (String)object;
+ }
+ if ( !(object instanceof IDMContext) ||
!((IDMContext)object).getSessionId().equals(fSessionId) )
{
return null;

Back to the top