1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Bug 445357 Fix breakpoint set on external files

- In case IDeclaration has no underlining resource, get resource from
editor utility support, in the same way as toggle by line

Change-Id: Ic0de58e9f8c1e671911b56f131b01937d8b982fd
Signed-off-by: Teodor Madan <teodor.madan@freescale.com>
Reviewed-on: https://git.eclipse.org/r/34050
Tested-by: Hudson CI
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
Tested-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Teodor Madan 2014-09-29 11:56:18 +03:00
parent a104dc4f6d
commit ce15475828

View file

@ -39,6 +39,7 @@ import org.eclipse.cdt.debug.internal.ui.actions.ActionMessages;
import org.eclipse.cdt.debug.internal.ui.actions.breakpoints.EnableDisableBreakpointRulerAction;
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.cdt.internal.ui.util.EditorUtility;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CDTUITools;
import org.eclipse.core.filesystem.URIUtil;
@ -646,13 +647,20 @@ abstract public class AbstractToggleBreakpointAdapter
/**
* Returns the resource being edited in the given workbench part.
* @param part Workbench part to checm.
* @param part Workbench part to check.
* @return Resource being edited.
*/
protected static IResource getResource( IWorkbenchPart part ) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
if ( part instanceof IEditorPart ) {
IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
return getResource(editorInput);
}
return root;
}
private static IResource getResource(IEditorInput editorInput) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IResource resource = null;
if ( editorInput instanceof IFileEditorInput ) {
resource = ((IFileEditorInput)editorInput).getFile();
@ -672,7 +680,6 @@ abstract public class AbstractToggleBreakpointAdapter
return files[0];
}
}
}
return root;
}
@ -691,8 +698,25 @@ abstract public class AbstractToggleBreakpointAdapter
return ""; //$NON-NLS-1$
}
/**
* Returns the resource file containing the C model element.
*
* @param declaration model element
* @return resource for c model element. Cannot be null, will return workspace root when no resource file can be found.
*/
protected IResource getElementResource( IDeclaration declaration ) {
return declaration.getUnderlyingResource();
IResource resource = declaration.getUnderlyingResource();
if (resource != null)
return resource;
try {
IEditorInput editorInput = EditorUtility.getEditorInput(declaration);
return getResource(editorInput);
} catch (CModelException e) {
DebugPlugin.log(e);
}
return ResourcesPlugin.getWorkspace().getRoot();
}
private String getFunctionName( IFunction function ) {