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

Bug 432503: Should not create two bps at same line with "Add breakpoint"

Change-Id: I30d70c5500687f5169e6dcb738bde9b4e60a5ff0
Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/24851
Tested-by: Hudson CI
Reviewed-by: Teodor Madan <teodor.madan@freescale.com>
Tested-by: Teodor Madan <teodor.madan@freescale.com>
This commit is contained in:
Marc Khouzam 2014-04-10 10:24:49 -04:00
parent 839905a802
commit d199768e64
2 changed files with 28 additions and 4 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Mentor Graphics and others. * Copyright (c) 2011, 2014 Mentor Graphics and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Mentor Graphics - Initial API and implementation * Mentor Graphics - Initial API and implementation
* Marc Khouzam (Ericsson) - Don't allow to set two bps at same line (bug 432503)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.debug.ui.breakpoints; package org.eclipse.cdt.debug.ui.breakpoints;
@ -172,7 +173,7 @@ abstract public class AbstractToggleBreakpointAdapter
@Override @Override
public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
return canToggleLineBreakpoints( part, selection ); return canToggleLineBreakpoints( part, selection ) && !hasBreakpoint( part );
} }
@Override @Override
@ -244,6 +245,16 @@ abstract public class AbstractToggleBreakpointAdapter
} }
} }
private boolean hasBreakpoint(IWorkbenchPart part) {
if (part instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) part;
IVerticalRulerInfo rulerInfo = (IVerticalRulerInfo) textEditor.getAdapter(IVerticalRulerInfo.class);
IBreakpoint breakpoint = CDebugUIUtils.getBreakpointFromEditor(textEditor, rulerInfo);
return breakpoint != null;
}
return false;
}
/** /**
* Updates the breakpoint for given part and selection. * Updates the breakpoint for given part and selection.
* Depending on the flags and on whether a breakpoint exists, this method * Depending on the flags and on whether a breakpoint exists, this method

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2011 Mentor Graphics and others. * Copyright (c) 2011, 2014 Mentor Graphics and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* Mentor Graphics - Initial API and implementation * Mentor Graphics - Initial API and implementation
* Marc Khouzam (Ericsson) - Don't allow to set two bps at same line (bug 432503)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.debug.ui.actions; package org.eclipse.cdt.dsf.debug.ui.actions;
@ -180,7 +181,7 @@ public abstract class AbstractDisassemblyBreakpointsTarget
*/ */
@Override @Override
public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) { public boolean canCreateLineBreakpointsInteractive(IWorkbenchPart part, ISelection selection) {
return canToggleLineBreakpoints(part, selection); return canToggleLineBreakpoints(part, selection) && !hasBreakpoint(part, selection);
} }
/** /**
@ -268,6 +269,18 @@ public abstract class AbstractDisassemblyBreakpointsTarget
createAddressBreakpoint(resource, address); createAddressBreakpoint(resource, address);
} }
private boolean hasBreakpoint(IWorkbenchPart part, ISelection selection) {
assert part instanceof IDisassemblyPart && selection instanceof ITextSelection;
if ( !(selection instanceof IDisassemblySelection) ) {
selection = new DisassemblySelection( (ITextSelection)selection, (IDisassemblyPart)part );
}
IDisassemblySelection disassemblySelection = (IDisassemblySelection)selection;
int line = disassemblySelection.getStartLine();
IBreakpoint[] bp = getBreakpointsAtLine( (IDisassemblyPart)part, line );
return bp != null && bp.length > 0;
}
private IBreakpoint[] getBreakpointsAtLine( IDisassemblyPart part, int line ) { private IBreakpoint[] getBreakpointsAtLine( IDisassemblyPart part, int line ) {
List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>(); List<IBreakpoint> breakpoints = new ArrayList<IBreakpoint>();
IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel(); IAnnotationModel annotationModel = part.getTextViewer().getAnnotationModel();