Search in sources :

Example 1 with ILineBreakpoint

use of org.eclipse.debug.core.model.ILineBreakpoint in project erlide_eclipse by erlang.

the class BreakpointUtils method getElement.

public static IErlElement getElement(final ILineBreakpoint breakpoint) {
    final IErlElementLocator model = ErlangEngine.getInstance().getModel();
    final IErlElement element = model.findElement(breakpoint.getMarker().getResource());
    if (element instanceof IErlModule) {
        final IErlModule m = (IErlModule) element;
        try {
            m.open(null);
            final int lineNumber = breakpoint.getLineNumber();
            return m.getElementAtLine(lineNumber - 1);
        } catch (final Exception e) {
            ErlLogger.warn(e);
        }
    }
    return null;
}
Also used : IErlElement(org.erlide.engine.model.IErlElement) IErlModule(org.erlide.engine.model.root.IErlModule) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint)

Example 2 with ILineBreakpoint

use of org.eclipse.debug.core.model.ILineBreakpoint in project liferay-ide by liferay.

the class FMDebugTarget method getEnabledLineBreakpoints.

private ILineBreakpoint[] getEnabledLineBreakpoints() {
    List<ILineBreakpoint> breakpoints = new ArrayList<ILineBreakpoint>();
    final IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
    if (breakpointManager.isEnabled()) {
        IBreakpoint[] fmBreakpoints = breakpointManager.getBreakpoints(getModelIdentifier());
        for (IBreakpoint fmBreakpoint : fmBreakpoints) {
            try {
                if (fmBreakpoint instanceof ILineBreakpoint && supportsBreakpoint(fmBreakpoint) && fmBreakpoint.isEnabled()) {
                    breakpoints.add((ILineBreakpoint) fmBreakpoint);
                }
            } catch (CoreException e) {
            }
        }
    }
    return breakpoints.toArray(new ILineBreakpoint[0]);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ArrayList(java.util.ArrayList) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 3 with ILineBreakpoint

use of org.eclipse.debug.core.model.ILineBreakpoint in project webtools.sourceediting by eclipse.

the class JAXPDebugTarget method breakpointHit.

private void breakpointHit(String event) {
    // determine which breakpoint was hit, and set the thread's breakpoint
    int lastSpace = event.lastIndexOf(' ');
    if (lastSpace > 0) {
        String line = event.substring(lastSpace + 1);
        int lineNumber = Integer.parseInt(line);
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IXSLConstants.ID_XSL_DEBUG_MODEL);
        for (IBreakpoint breakpoint : breakpoints) {
            if (supportsBreakpoint(breakpoint)) {
                if (breakpoint instanceof ILineBreakpoint) {
                    ILineBreakpoint lineBreakpoint = (ILineBreakpoint) breakpoint;
                    try {
                        if (lineBreakpoint.getLineNumber() == lineNumber) {
                            thread.setBreakpoints(new IBreakpoint[] { breakpoint });
                            break;
                        }
                    } catch (CoreException e) {
                    }
                }
            }
        }
    }
    suspended(DebugEvent.BREAKPOINT);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 4 with ILineBreakpoint

use of org.eclipse.debug.core.model.ILineBreakpoint in project dbeaver by serge-rider.

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 = DBWorkbench.getPlatform().getNavigatorModel().getNodeByObject(new VoidProgressMonitor(), databaseObject, false);
    if (node == null) {
        return;
    }
    String nodeItemPath = node.getNodeItemPath();
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DBGConstants.MODEL_IDENTIFIER_DATABASE);
    for (IBreakpoint breakpoint : breakpoints) {
        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;
    DBGBreakpointDescriptor breakpointDescriptor = GeneralUtils.adapt(databaseObject, DBGBreakpointDescriptor.class);
    if (breakpointDescriptor == null) {
        throw new CoreException(GeneralUtils.makeErrorStatus("Object '" + DBUtils.getObjectFullName(databaseObject, DBPEvaluationContext.UI) + "' doesn't support breakpoints"));
    }
    // create line breakpoint (doc line numbers start at 0)
    new DatabaseLineBreakpoint(databaseObject, node, resource, breakpointDescriptor, lineNumber + 1, charstart, charend, true);
}
Also used : DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) IEditorPart(org.eclipse.ui.IEditorPart) DBGBreakpointDescriptor(org.jkiss.dbeaver.debug.DBGBreakpointDescriptor) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) CoreException(org.eclipse.core.runtime.CoreException) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource)

Example 5 with ILineBreakpoint

use of org.eclipse.debug.core.model.ILineBreakpoint in project erlide_eclipse by erlang.

the class ErlDebugModelPresentation method getEditorInput.

@Override
public IEditorInput getEditorInput(final Object element) {
    if (element instanceof IFile) {
        return new FileEditorInput((IFile) element);
    }
    if (element instanceof ILineBreakpoint) {
        return new FileEditorInput((IFile) ((ILineBreakpoint) element).getMarker().getResource());
    }
    if (element instanceof LocalFileStorage) {
        final LocalFileStorage lfs = (LocalFileStorage) element;
        try {
            final IErlElementLocator model = ErlangEngine.getInstance().getModel();
            final IErlModule module = ErlangEngine.getInstance().getModelFindService().findModule(model, null, null, lfs.getFullPath().toString(), IErlElementLocator.Scope.ALL_PROJECTS);
            return EditorUtility.getEditorInput(module);
        } catch (final CoreException e) {
            ErlLogger.error(e);
        }
    }
    return null;
}
Also used : IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) LocalFileStorage(org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage) IErlModule(org.erlide.engine.model.root.IErlModule) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IErlElementLocator(org.erlide.engine.model.root.IErlElementLocator)

Aggregations

ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)13 CoreException (org.eclipse.core.runtime.CoreException)9 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)8 IResource (org.eclipse.core.resources.IResource)5 ITextSelection (org.eclipse.jface.text.ITextSelection)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 IMarker (org.eclipse.core.resources.IMarker)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IErlElement (org.erlide.engine.model.IErlElement)2 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)2 IErlModule (org.erlide.engine.model.root.IErlModule)2 DBGBreakpointDescriptor (org.jkiss.dbeaver.debug.DBGBreakpointDescriptor)2 DatabaseLineBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint)2 IDatabaseBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 VoidProgressMonitor (org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2