use of org.eclipse.debug.core.model.IBreakpoint in project dbeaver by dbeaver.
the class ToggleProcedureBreakpointTarget method toggleLineBreakpoints.
@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
IEditorPart editorPart = (IEditorPart) part;
IResource resource = extractResource(editorPart, selection);
if (resource == null) {
return;
}
DBSObject databaseObject = DebugUI.extractDatabaseObject(editorPart);
if (databaseObject == null) {
return;
}
DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(databaseObject);
if (node == null) {
return;
}
String nodeItemPath = node.getNodeItemPath();
ITextSelection textSelection = (ITextSelection) selection;
int lineNumber = textSelection.getStartLine();
IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DebugCore.MODEL_IDENTIFIER_DATABASE);
for (int i = 0; i < breakpoints.length; i++) {
IBreakpoint breakpoint = breakpoints[i];
if (breakpoint instanceof IDatabaseBreakpoint) {
IDatabaseBreakpoint databaseBreakpoint = (IDatabaseBreakpoint) breakpoint;
if (nodeItemPath.equals(databaseBreakpoint.getNodePath())) {
if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, part.getSite().getShell(), null);
return;
}
}
}
}
int charstart = -1, charend = -1;
// create line breakpoint (doc line numbers start at 0)
new DatabaseLineBreakpoint(databaseObject, node, resource, lineNumber + 1, charstart, charend, true);
}
use of org.eclipse.debug.core.model.IBreakpoint in project xtext-eclipse by eclipse.
the class StratumBreakpointAdapterFactory method findExistingBreakpoint.
protected IJavaStratumLineBreakpoint findExistingBreakpoint(IResource res, SourceRelativeURI uri, final int line) throws CoreException {
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
IBreakpoint[] breakpoints = manager.getBreakpoints();
if (uri == null) {
for (IBreakpoint breakpoint : breakpoints) {
IMarker marker = breakpoint.getMarker();
if (breakpoint instanceof IJavaStratumLineBreakpoint && marker.getResource().equals(res)) {
final IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) breakpoint;
if (stratumBreakpoint.getLineNumber() == line) {
return stratumBreakpoint;
}
}
}
} else {
String uriString = uri.toString();
for (IBreakpoint breakpoint : breakpoints) {
IMarker marker = breakpoint.getMarker();
if (breakpoint instanceof IJavaStratumLineBreakpoint && marker.getResource().equals(res) && uriString.equals(marker.getAttribute(JarFileMarkerAnnotationModel.MARKER_URI))) {
final IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) breakpoint;
if (stratumBreakpoint.getLineNumber() == line) {
return stratumBreakpoint;
}
}
}
}
return null;
}
use of org.eclipse.debug.core.model.IBreakpoint in project erlide_eclipse by erlang.
the class ErlLineBreakpointAdapter method toggleLineBreakpoints.
@Override
public void toggleLineBreakpoints(final IWorkbenchPart part, final ISelection selection) throws CoreException {
final ITextEditor textEditor = getEditor(part);
if (textEditor != null) {
final IResource resource = textEditor.getEditorInput().getAdapter(IResource.class);
if (resource == null) {
return;
}
final ITextSelection textSelection = (ITextSelection) selection;
final int lineNumber = textSelection.getStartLine();
final IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL);
for (final IBreakpoint breakpoint : breakpoints) {
if (resource.equals(breakpoint.getMarker().getResource())) {
if (breakpoint instanceof ILineBreakpoint) {
final ILineBreakpoint lineBr = (ILineBreakpoint) breakpoint;
if (lineBr.getLineNumber() == lineNumber + 1) {
breakpoint.delete();
return;
}
}
}
}
// create line breakpoint (doc line numbers start at 0)
final ErlangLineBreakpoint lineBreakpoint = new ErlangLineBreakpoint();
lineBreakpoint.createMarker(resource, lineNumber + 1);
DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
}
}
use of org.eclipse.debug.core.model.IBreakpoint in project erlide_eclipse by erlang.
the class BreakpointMarkerUpdater method updateMarker.
@Override
public boolean updateMarker(final IMarker marker, final IDocument document, final Position position) {
if (position.isDeleted()) {
return false;
}
try {
final int line = MarkerUtilities.getLineNumber(marker);
final int newLine = document.getLineOfOffset(position.getOffset()) + 1;
if (line == newLine) {
return true;
}
final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint breakpoint = manager.getBreakpoint(marker);
if (breakpoint == null) {
return false;
}
if (breakpoint instanceof ErlangLineBreakpoint) {
final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) breakpoint;
final ErlangDebugTarget target = erlangLineBreakpoint.getTarget();
erlangLineBreakpoint.remove(target);
MarkerUtilities.setLineNumber(marker, newLine);
erlangLineBreakpoint.install(target);
return true;
}
// if there exists a breakpoint on the line remove this one
if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker)) {
ensureRanges(document, marker, line);
return lineBreakpointExists(marker.getResource(), line, marker) == null;
}
// a line breakpoint must be removed
if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker) && line == -1) {
return false;
}
MarkerUtilities.setLineNumber(marker, line);
if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker)) {
ensureRanges(document, marker, line);
}
return true;
} catch (final BadLocationException e) {
ErlLogger.error(e);
} catch (final CoreException e) {
ErlLogger.error(e);
}
return false;
}
use of org.eclipse.debug.core.model.IBreakpoint in project erlide_eclipse by erlang.
the class BreakpointMarkerUpdater method lineBreakpointExists.
/**
* Searches for an existing line breakpoint on the specified line in the
* current type that does not match the id of the specified marker
*
* @param resource
* the resource to care about
* @param typeName
* the name of the type the breakpoint is in
* @param lineNumber
* the number of the line the breakpoint is on
* @param currentmarker
* the current marker we are comparing to see if it will be moved
* onto an existing one
* @return an existing line breakpoint on the current line of the given
* resource and type if there is one
* @throws CoreException
*
* @since 3.4
*/
private IErlangBreakpoint lineBreakpointExists(final IResource resource, final int lineNumber, final IMarker currentmarker) throws CoreException {
final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint[] breakpoints = manager.getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL);
final String markerType = currentmarker.getType();
for (IBreakpoint breakpoint1 : breakpoints) {
if (!(breakpoint1 instanceof IErlangBreakpoint)) {
continue;
}
final IErlangBreakpoint breakpoint = (IErlangBreakpoint) breakpoint1;
final IMarker marker = breakpoint.getMarker();
if (marker != null && marker.exists() && marker.getType().equals(markerType) && currentmarker.getId() != marker.getId()) {
if (marker instanceof ErlangLineBreakpoint) {
final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) marker;
if (erlangLineBreakpoint.getLineNumber() == lineNumber) {
return erlangLineBreakpoint;
}
}
}
}
return null;
}
Aggregations