From 8a1df72b32d13765ec6e719f211a79d27a86667c Mon Sep 17 00:00:00 2001 From: Sarika Sinha Date: Thu, 9 Oct 2014 13:47:12 +0200 Subject: Fixed bug 333891: [breakpoints] Breakpoint Undo doesn't handle duplicates Signed-off-by: Sarika Sinha --- .../debug/internal/core/BreakpointManager.java | 35 ++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'org.eclipse.debug.core/core') diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java index 1ff798226..01e69a787 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/internal/core/BreakpointManager.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2013 IBM Corporation and others. + * Copyright (c) 2000, 2014 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -847,7 +847,14 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis handleChangeBreakpoint(marker, mDelta); fPostChangMarkersChanged.remove(marker); } else if (marker.getAttribute(DebugPlugin.ATTR_BREAKPOINT_IS_DELETED, false) && getBreakpoint(marker) == null) { - try { + try { /* + * There may be breakpoints with matching resource + * and same line number + */ + IBreakpoint breakpoint = findMatchingBreakpoint(marker); + if (breakpoint != null) { + removeBreakpoint(breakpoint, true); + } fAdded.add(createBreakpoint(marker)); } catch (CoreException e) { DebugPlugin.log(e); @@ -858,6 +865,30 @@ public class BreakpointManager implements IBreakpointManager, IResourceChangeLis } } + /** + * To find a breakpoint with matching marker resources and line number. + * + * @param marker the {@link IMarker} for which existing breakpoint is + * retrieved + * @return matching breakpoint if exists else return null + */ + private IBreakpoint findMatchingBreakpoint(IMarker marker) { + Vector breakpoints = getBreakpoints0(); + try { + Integer line = (Integer) marker.getAttribute(IMarker.LINE_NUMBER); + for (int i = 0; i < breakpoints.size(); i++) { + IBreakpoint breakpoint = breakpoints.get(i); + IMarker bpMarker = breakpoint.getMarker(); + if (bpMarker != null && marker.getResource().equals(bpMarker.getResource()) && (Integer) bpMarker.getAttribute(IMarker.LINE_NUMBER) == (line == null ? -1 : line.intValue())) { + return breakpoint; + } + } + } catch (CoreException e) { + e.printStackTrace(); + } + return null; + } + /** * Wrapper for handling removes * @param marker the {@link IMarker} -- cgit v1.2.3