/** * Returns a Java line breakpoint that is already registered with the breakpoint manager for a * type with the given name at the given line number. * * @param typeName fully qualified type name * @param lineNumber line number * @return a Java line breakpoint that is already registered with the breakpoint manager for a * type with the given name at the given line number or <code>null</code> if no such * breakpoint is registered * @exception CoreException if unable to retrieve the associated marker attributes (line number). */ public static IJavaLineBreakpoint findStratumBreakpoint(IResource resource, int lineNumber) throws CoreException { String modelId = JDT_DEBUG_PLUGIN_ID; String markerType = "org.eclipse.jdt.debug.javaStratumLineBreakpointMarker"; IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager(); IBreakpoint[] breakpoints = manager.getBreakpoints(modelId); for (int i = 0; i < breakpoints.length; i++) { if (!(breakpoints[i] instanceof IJavaLineBreakpoint)) { continue; } IJavaLineBreakpoint breakpoint = (IJavaLineBreakpoint) breakpoints[i]; IMarker marker = breakpoint.getMarker(); if (marker != null && marker.exists() && marker.getType().equals(markerType)) { if (breakpoint.getLineNumber() == lineNumber && resource.equals(marker.getResource())) { return breakpoint; } } } return null; }
/** * Tests if a LineBreakPoint was moved appropriately. * * @throws Exception */ public void testLineBreakPoint() throws Exception { cleanTestFiles(); IJavaProject javaProject = get14Project(); ICompilationUnit cunit = getCompilationUnit(javaProject, "src", "a.b.c", "Movee.java"); IType type = cunit.getType("NonPublicType"); try { int lineNumber = 31; // create lineBreakpoint to test createLineBreakpoint(lineNumber, "a.b.c", "Movee.java", "NonPublicType"); refactor(javaProject, type); IBreakpoint[] breakpoints = getBreakpointManager().getBreakpoints(); assertEquals("wrong number of breakpoints", 1, breakpoints.length); IJavaLineBreakpoint lineBreakpoint = (IJavaLineBreakpoint) breakpoints[0]; assertTrue("Breakpoint Marker has ceased existing", lineBreakpoint.getMarker().exists()); assertEquals("wrong type name", "a.b.MoveeRecipient", lineBreakpoint.getTypeName()); assertEquals("wrong line number", lineNumber, lineBreakpoint.getLineNumber()); } catch (Exception e) { throw e; } finally { removeAllBreakpoints(); } } // end testLineBreakPoint