diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java index d16a84ceb0b..ccc281115cf 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java @@ -13,10 +13,11 @@ import java.util.Map; import java.util.StringTokenizer; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.IBinary; import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.ICFile; +import org.eclipse.cdt.core.model.IParent; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.ICBreakpointManager; @@ -89,6 +90,7 @@ import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugEvent; import org.eclipse.debug.core.DebugException; @@ -2252,7 +2254,7 @@ public class CDebugTarget extends CDebugElement { if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) { - ICFile cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); + ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); if ( cFile instanceof IBinary ) { ((IBinary)cFile).isLittleEndian(); @@ -2279,16 +2281,16 @@ public class CDebugTarget extends CDebugElement ArrayList list = new ArrayList(); if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) { - ICFile cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); - if ( cFile instanceof IBinary ) + ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); + if ( cFile instanceof IParent ) { - list.addAll( getCFileGlobals( cFile ) ); + list.addAll( getCFileGlobals( (IParent)cFile ) ); } } return (IGlobalVariable[])list.toArray( new IGlobalVariable[list.size()] ); } - private List getCFileGlobals( ICFile file ) + private List getCFileGlobals( IParent file ) { ArrayList list = new ArrayList(); ICElement[] elements = file.getChildren(); @@ -2298,9 +2300,9 @@ public class CDebugTarget extends CDebugElement { list.add( createGlobalVariable( (org.eclipse.cdt.core.model.IVariable)elements[i] ) ); } - else if ( elements[i] instanceof org.eclipse.cdt.core.model.ICFile ) + else if ( elements[i] instanceof org.eclipse.cdt.core.model.IParent ) { - list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.ICFile)elements[i] ) ); + list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) ); } } return list; @@ -2317,14 +2319,18 @@ public class CDebugTarget extends CDebugElement public IPath getPath() { - IPath path = null; - if ( var.getParent() != null && var.getParent() instanceof ICFile ) - { - if ( !(var.getParent() instanceof IBinary) && ((ICFile)var.getParent()).getFile() != null ) - { - path = ((ICFile)var.getParent()).getFile().getLocation(); - } - } + IPath path = new Path(""); + try + { + IResource res = var.getUnderlyingResource(); + if ( res != null ) + { + path = res.getLocation(); + } + } + catch (CModelException e) + { + } return path; } }; diff --git a/debug/org.eclipse.cdt.debug.ui.tests/src/org/eclipse/cdt/debug/testplugin/CProjectHelper.java b/debug/org.eclipse.cdt.debug.ui.tests/src/org/eclipse/cdt/debug/testplugin/CProjectHelper.java index b976f0f2316..40b9582a43e 100644 --- a/debug/org.eclipse.cdt.debug.ui.tests/src/org/eclipse/cdt/debug/testplugin/CProjectHelper.java +++ b/debug/org.eclipse.cdt.debug.ui.tests/src/org/eclipse/cdt/debug/testplugin/CProjectHelper.java @@ -9,7 +9,7 @@ import org.eclipse.cdt.core.CProjectNature; import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.IArchiveContainer; import org.eclipse.cdt.core.model.IBinaryContainer; -import org.eclipse.cdt.core.model.ICFolder; +import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IArchive; @@ -93,7 +93,7 @@ public class CProjectHelper { /** * Adds a source container to a ICProject. */ - public static ICFolder addSourceContainer(ICProject cproject, String containerName) throws CoreException { + public static ICContainer addSourceContainer(ICProject cproject, String containerName) throws CoreException { IProject project= cproject.getProject(); IContainer container= null; if (containerName == null || containerName.length() == 0) { @@ -106,15 +106,15 @@ public class CProjectHelper { container= folder; } - return (ICFolder)container; + return (ICContainer)container; } /** * Adds a source container to a ICProject and imports all files contained * in the given Zip file. */ - public static ICFolder addSourceContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile) throws InvocationTargetException, CoreException { - ICFolder root= addSourceContainer(cproject, containerName); + public static ICContainer addSourceContainerWithImport(ICProject cproject, String containerName, ZipFile zipFile) throws InvocationTargetException, CoreException { + ICContainer root= addSourceContainer(cproject, containerName); importFilesFromZip(zipFile, root.getPath(), null); return root; }