When things are remapped by the Symbian Source File Remapping only capture the directory the file was discovered in, not the entire drive.
authorryall
Fri, 17 Sep 2010 13:30:29 -0600
changeset 2046 f375c7305c9d
parent 2045 00e887c4a2c8
child 2047 c984a53977bd
When things are remapped by the Symbian Source File Remapping only capture the directory the file was discovered in, not the entire drive.
debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF
debuggercdi/com.nokia.cdt.debug.common/src/com/nokia/cdt/debug/common/internal/source/lookup/SymbianSourceContainer.java
--- a/debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF	Fri Sep 17 13:39:24 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.common/META-INF/MANIFEST.MF	Fri Sep 17 13:30:29 2010 -0600
@@ -11,7 +11,8 @@
  org.eclipse.debug.core;bundle-version="3.6.0",
  com.nokia.carbide.cdt.builder;bundle-version="2.0.0",
  org.eclipse.cdt.debug.edc,
- com.nokia.carbide.remoteConnections;bundle-version="1.4.0"
+ com.nokia.carbide.remoteConnections;bundle-version="1.4.0",
+ org.eclipse.core.filesystem;bundle-version="1.3.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Export-Package: com.nokia.cdt.debug.common.internal.api,
--- a/debuggercdi/com.nokia.cdt.debug.common/src/com/nokia/cdt/debug/common/internal/source/lookup/SymbianSourceContainer.java	Fri Sep 17 13:39:24 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.common/src/com/nokia/cdt/debug/common/internal/source/lookup/SymbianSourceContainer.java	Fri Sep 17 13:30:29 2010 -0600
@@ -17,9 +17,17 @@
 
 package com.nokia.cdt.debug.common.internal.source.lookup;
 
+import java.io.File;
+import java.io.IOException;
+import java.net.URI;
+
+import org.eclipse.cdt.debug.core.CDebugCorePlugin;
 import org.eclipse.cdt.debug.core.sourcelookup.AbsolutePathSourceContainer;
 import org.eclipse.cdt.debug.core.sourcelookup.MappingSourceContainer;
 import org.eclipse.cdt.debug.internal.core.sourcelookup.MapEntrySourceContainer;
+import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
+import org.eclipse.core.filesystem.URIUtil;
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -28,6 +36,7 @@
 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.containers.LocalFileStorage;
 
 import com.nokia.cdt.debug.common.CarbideCommonDebuggerPlugin;
 
@@ -56,6 +65,7 @@
 		return getSourceContainerType( TYPE_ID );
 	}
 
+	@SuppressWarnings("restriction")
 	protected Object[] findSourceElements(String name, ISourceContainer[] containers) throws CoreException {
 		Object[] result = super.findSourceElements(name, containers);
 		if (result.length == 0)
@@ -69,6 +79,9 @@
 			if (result.length > 0)
 			{
 				if (!mapping.getBackendPath().equals(mapping.getLocalPath())){
+					IPath compPath = sourcePath.removeLastSegments(1);
+					IPath newSourcePath = new Path(foundElementToPath(result[0])).removeLastSegments(1);
+					mapping = new MapEntrySourceContainer(compPath, newSourcePath);
 					addMapEntry(mapping);
 				}
 				if (director != null)
@@ -97,4 +110,52 @@
 		return epocRoot;
 	}
 
+	/**
+	 * Utility method to convert the element found by the source locators to a
+	 * canonical file path
+	 * 
+	 * @param foundElement
+	 *            the element found by the source locator, or null if not found
+	 * @return the canonical file path of the element
+	 */
+	@SuppressWarnings("restriction")
+	private static String foundElementToPath(Object foundElement) {
+		if (foundElement != null) {
+			try {
+				if (foundElement instanceof IFile) {
+					IPath path = ((IFile)foundElement).getLocation();
+					if (path != null) {
+						File file = path.toFile();
+						if (file != null) {
+								return file.getCanonicalPath();
+						}
+					}
+					
+				}
+				else if (foundElement instanceof LocalFileStorage) {
+					File file = ((LocalFileStorage)foundElement).getFile();
+					if (file != null) {
+						return file.getCanonicalPath();
+					}
+				}
+				else if (foundElement instanceof ExternalTranslationUnit) {
+					URI uri = ((ExternalTranslationUnit)foundElement).getLocationURI();
+					if (uri != null) {
+						IPath path = URIUtil.toPath(uri);
+						if (path != null) {
+							File file = path.toFile();
+							if (file != null) {
+								return file.getCanonicalPath();
+							}
+						}
+					}
+				}
+			} catch (IOException e) {
+				CDebugCorePlugin.log(e);
+			}
+		}
+		
+		return null;
+	}
+
 }