fixed bug #9618.
authorwpaul
Wed, 12 Aug 2009 16:32:51 -0500
changeset 65 025e91738d6a
parent 64 9dbd1c22938d
child 66 a3c8ab8bcb98
fixed bug #9618.
cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java
--- a/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java	Mon Aug 10 14:02:51 2009 -0500
+++ b/cdt/cdt_6_0_x/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CSourceLookupParticipant.java	Wed Aug 12 16:32:51 2009 -0500
@@ -29,16 +29,10 @@
 import org.eclipse.core.resources.IResource;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.debug.core.ILaunchConfiguration;
 import org.eclipse.debug.core.model.IBreakpoint;
 import org.eclipse.debug.core.model.IDebugElement;
-import org.eclipse.debug.core.model.IStackFrame;
 import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant;
-import org.eclipse.debug.core.sourcelookup.ISourceContainer;
-import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
-import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
-import org.eclipse.debug.core.sourcelookup.ISourcePathComputer;
  
 /**
  * A source lookup participant that searches for C/C++ source code.
@@ -82,6 +76,7 @@
 	/* (non-Javadoc)
 	 * @see org.eclipse.debug.core.sourcelookup.AbstractSourceLookupParticipant#findSourceElements(java.lang.Object)
 	 */
+	@Override
 	public Object[] findSourceElements( Object object ) throws CoreException {
 		
 		// Check the cache
@@ -89,10 +84,6 @@
 		if (results != null)
 			return results;
 		
-		// Workaround for BUG247977
-		// FIXME: Remove having switched to 3.5 platform
-		initContainersSourceDirector();
-
 		// Workaround for cases when the stack frame doesn't contain the source file name 
 		String name = null;
 		IBreakpoint breakpoint = null;
@@ -125,7 +116,6 @@
 
 		// Actually query the source containers for the requested resource
 		Object[] foundElements = super.findSourceElements(object);
-		fCachedResults.put(object, foundElements);
 		
 		// If none found, invoke the absolute path container directly
 		if (foundElements.length == 0 && (object instanceof IDebugElement)) {
@@ -151,10 +141,6 @@
 				}
 			}
 		}
-
-		// FIXME: remove when BUG247977 is fixed
-		endContainersSourceDirector();
-
 		fCachedResults.put(object, foundElements); 
 		return foundElements;
 	}
@@ -192,122 +178,12 @@
 	 */
 	@Override
 	public void sourceContainersChanged( ISourceLookupDirector director ) {
+		// clear the cache
+		fCachedResults.clear();
+		
 		Object[] listeners = fListeners.getListeners();
 		for ( int i = 0; i < listeners.length; ++i )
 			((ISourceLookupChangeListener)listeners[i]).sourceContainersChanged( director );
 		super.sourceContainersChanged( director );
 	}
-
-	/**
-	 * FIXME: Workaround for BUG247977
-	 * Remove before 3.5
-	 * Remove when ISourceLocator.isFindDuplicates() queries the source lookup participant
-	 * instead of the ISourceLookupDirector
-	 */
-	private ISourceContainer[] containers;
-	private void initContainersSourceDirector() {
-		ISourceLookupDirector dummySourceDirector = new ISourceLookupDirector() {
-
-			public void addParticipants(ISourceLookupParticipant[] participants) {
-				getDirector().addParticipants(participants);
-			}
-
-			public void clearSourceElements(Object element) {
-				getDirector().clearSourceElements(element);
-			}
-
-			public Object[] findSourceElements(Object object) throws CoreException {
-				return getDirector().findSourceElements(object);
-			}
-
-			public String getId() {
-				return getDirector().getId();
-			}
-
-			public ILaunchConfiguration getLaunchConfiguration() {
-				return getDirector().getLaunchConfiguration();
-			}
-
-			public ISourceLookupParticipant[] getParticipants() {
-				return getDirector().getParticipants();
-			}
-
-			public ISourceContainer[] getSourceContainers() {
-				return getDirector().getSourceContainers();
-			}
-
-			public Object getSourceElement(Object element) {
-				return getDirector().getSourceElement(element);
-			}
-
-			public ISourcePathComputer getSourcePathComputer() {
-				return getDirector().getSourcePathComputer();
-			}
-
-			public void initializeParticipants() {
-				getDirector().initializeParticipants();
-			}
-
-			public boolean isFindDuplicates() {
-				return CSourceLookupParticipant.this.isFindDuplicates();
-			}
-
-			public void removeParticipants(ISourceLookupParticipant[] participants) {
-				getDirector().removeParticipants(participants);
-			}
-
-			public void setFindDuplicates(boolean findDuplicates) {
-				getDirector().setFindDuplicates(findDuplicates);
-			}
-
-			public void setSourceContainers(ISourceContainer[] containers) {
-				getDirector().setSourceContainers(containers);
-			}
-
-			public void setSourcePathComputer(ISourcePathComputer computer) {
-				getDirector().setSourcePathComputer(computer);
-			}
-
-			public boolean supportsSourceContainerType(ISourceContainerType type) {
-				return getDirector().supportsSourceContainerType(type);
-			}
-
-			public void dispose() {
-				getDirector().dispose();
-			}
-
-			public void initializeFromMemento(String memento, ILaunchConfiguration configuration) throws CoreException {
-				getDirector().initializeFromMemento(memento, configuration);
-			}
-
-			public String getMemento() throws CoreException {
-				return getDirector().getMemento();
-			}
-
-			public void initializeDefaults(ILaunchConfiguration configuration) throws CoreException {
-				getDirector().initializeDefaults(configuration);
-			}
-
-			public void initializeFromMemento(String memento) throws CoreException {
-				getDirector().initializeFromMemento(memento);
-			}
-
-			public Object getSourceElement(IStackFrame stackFrame) {
-				return getDirector().getSourceElement(stackFrame);
-			}
-			
-		};
-		containers = getSourceContainers();
-		for (ISourceContainer cont : containers)
-			cont.init(dummySourceDirector);
-	}
-	
-	private void endContainersSourceDirector() {
-		if (containers != null)
-		{
-			for (ISourceContainer cont : containers)
-				cont.init(getDirector());
-		}
-		containers = null;
-	}
 }