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:
parent
a104dc4f6d
commit
ce15475828
1 changed files with 44 additions and 20 deletions
|
@ -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.actions.breakpoints.EnableDisableBreakpointRulerAction;
|
||||||
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
|
import org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointContext;
|
||||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
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.internal.ui.util.ExternalEditorInput;
|
||||||
import org.eclipse.cdt.ui.CDTUITools;
|
import org.eclipse.cdt.ui.CDTUITools;
|
||||||
import org.eclipse.core.filesystem.URIUtil;
|
import org.eclipse.core.filesystem.URIUtil;
|
||||||
|
@ -646,31 +647,37 @@ abstract public class AbstractToggleBreakpointAdapter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the resource being edited in the given workbench part.
|
* 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.
|
* @return Resource being edited.
|
||||||
*/
|
*/
|
||||||
protected static IResource getResource( IWorkbenchPart part ) {
|
protected static IResource getResource( IWorkbenchPart part ) {
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
if ( part instanceof IEditorPart ) {
|
if ( part instanceof IEditorPart ) {
|
||||||
IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
|
IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
|
||||||
IResource resource = null;
|
return getResource(editorInput);
|
||||||
if ( editorInput instanceof IFileEditorInput ) {
|
}
|
||||||
resource = ((IFileEditorInput)editorInput).getFile();
|
return root;
|
||||||
}
|
}
|
||||||
else if ( editorInput instanceof ExternalEditorInput ) {
|
|
||||||
resource = ((ExternalEditorInput)editorInput).getMarkerResource();
|
private static IResource getResource(IEditorInput editorInput) {
|
||||||
}
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
if ( resource != null )
|
IResource resource = null;
|
||||||
return resource;
|
if ( editorInput instanceof IFileEditorInput ) {
|
||||||
/* This file is not in a project, let default case handle it */
|
resource = ((IFileEditorInput)editorInput).getFile();
|
||||||
ILocationProvider provider = (ILocationProvider)editorInput.getAdapter( ILocationProvider.class );
|
}
|
||||||
if ( provider != null ) {
|
else if ( editorInput instanceof ExternalEditorInput ) {
|
||||||
IPath location = provider.getPath( editorInput );
|
resource = ((ExternalEditorInput)editorInput).getMarkerResource();
|
||||||
if ( location != null ) {
|
}
|
||||||
IFile[] files = root.findFilesForLocationURI( URIUtil.toURI( location ) );
|
if ( resource != null )
|
||||||
if ( files.length > 0 && files[0].isAccessible())
|
return resource;
|
||||||
return files[0];
|
/* This file is not in a project, let default case handle it */
|
||||||
}
|
ILocationProvider provider = (ILocationProvider)editorInput.getAdapter( ILocationProvider.class );
|
||||||
|
if ( provider != null ) {
|
||||||
|
IPath location = provider.getPath( editorInput );
|
||||||
|
if ( location != null ) {
|
||||||
|
IFile[] files = root.findFilesForLocationURI( URIUtil.toURI( location ) );
|
||||||
|
if ( files.length > 0 && files[0].isAccessible())
|
||||||
|
return files[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return root;
|
return root;
|
||||||
|
@ -691,8 +698,25 @@ abstract public class AbstractToggleBreakpointAdapter
|
||||||
return ""; //$NON-NLS-1$
|
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 ) {
|
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 ) {
|
private String getFunctionName( IFunction function ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue