Search in sources :

Example 1 with IBreakpoint

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

the class ErlangProcess method getBreakpoints.

@Override
public IBreakpoint[] getBreakpoints() {
    IStackFrame top = null;
    try {
        top = getTopStackFrame();
    } catch (final DebugException e1) {
    // can never happen
    }
    if (top instanceof ErlangStackFrame) {
        final ErlangStackFrame topFrame = (ErlangStackFrame) top;
        final IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
        final IBreakpoint[] breakpoints = breakpointManager.getBreakpoints();
        for (final IBreakpoint breakpoint : breakpoints) {
            if (breakpoint instanceof ErlangLineBreakpoint) {
                final ErlangLineBreakpoint lineBreakpoint = (ErlangLineBreakpoint) breakpoint;
                try {
                    if (lineBreakpoint.getModule().equals(topFrame.getModule()) && lineBreakpoint.getLineNumber() == topFrame.getLineNumber()) {
                        return new IBreakpoint[] { lineBreakpoint };
                    }
                } catch (final DebugException e) {
                    ErlLogger.warn(e);
                } catch (final CoreException e) {
                    ErlLogger.warn(e);
                }
            }
        }
    }
    return new IBreakpoint[0];
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) IStackFrame(org.eclipse.debug.core.model.IStackFrame) CoreException(org.eclipse.core.runtime.CoreException) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) DebugException(org.eclipse.debug.core.DebugException) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 2 with IBreakpoint

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

the class BackendData method addBreakpointProjectsAndModules.

public static Set<String> addBreakpointProjectsAndModules(final Collection<IProject> projects, final List<String> interpretedModules) {
    final IBreakpointManager bpm = DebugPlugin.getDefault().getBreakpointManager();
    final Set<String> result = new HashSet<>(interpretedModules);
    for (final IBreakpoint bp : bpm.getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL)) {
        final IMarker m = bp.getMarker();
        final IResource r = m.getResource();
        final String name = r.getName();
        if (SourceKind.hasErlExtension(name)) {
            final IProject p = r.getProject();
            if (projects == null || projects.contains(p)) {
                final String s = p.getName() + ":" + name;
                result.add(s);
            }
        }
    }
    return result;
}
Also used : IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IMarker(org.eclipse.core.resources.IMarker) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Example 3 with IBreakpoint

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

the class ErlangBreakpointPropertiesRulerAction method update.

/**
 * @see IUpdate#update()
 */
@Override
public void update() {
    fBreakpoint = null;
    final IBreakpoint breakpoint = getBreakpoint();
    if (breakpoint instanceof IErlangBreakpoint) {
        fBreakpoint = breakpoint;
    }
    setEnabled(fBreakpoint != null);
}
Also used : IErlangBreakpoint(org.erlide.backend.debug.IErlangBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 4 with IBreakpoint

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

the class RemoteJSPBreakpointProvider method addBreakpoint.

@Override
public IStatus addBreakpoint(IDocument document, IEditorInput input, int editorLineNumber, int offset) throws CoreException {
    // check if there is a valid position to set breakpoint
    int pos = getValidPosition(document, editorLineNumber);
    IStatus status = null;
    if (pos >= 0) {
        IResource res = getResourceFromInput(input);
        if (res != null) {
            String path = null;
            // IDE-648 IDE-110
            // get docroot relative path
            final IWebProject lrproject = LiferayCore.create(IWebProject.class, res.getProject());
            if (lrproject != null) {
                final IFolder webappRoot = lrproject.getDefaultDocrootFolder();
                if (webappRoot != null && webappRoot.exists()) {
                    IPath relativePath = res.getFullPath().makeRelativeTo(webappRoot.getFullPath());
                    if (relativePath != null && relativePath.segmentCount() > 0) {
                        // $NON-NLS-1$
                        path = "/" + relativePath.toPortableString();
                    }
                }
                IBreakpoint point = JDIDebugModel.createStratumBreakpoint(res, "JSP", res.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, null);
                if (point == null) {
                    status = new Status(IStatus.ERROR, JSPUIPlugin.ID, IStatus.ERROR, "unsupported input type", null);
                }
            }
        } else if (input instanceof IStorageEditorInput) {
            // For non-resources, use the workspace root and a coordinated
            // attribute that is used to
            // prevent unwanted (breakpoint) markers from being loaded
            // into the editors.
            res = ResourcesPlugin.getWorkspace().getRoot();
            String id = input.getName();
            if (input instanceof IStorageEditorInput && ((IStorageEditorInput) input).getStorage() != null && ((IStorageEditorInput) input).getStorage().getFullPath() != null) {
                id = ((IStorageEditorInput) input).getStorage().getFullPath().toString();
            }
            Map attributes = new HashMap();
            attributes.put(StructuredResourceMarkerAnnotationModel.SECONDARY_ID_KEY, id);
            String path = null;
            IBreakpoint point = JDIDebugModel.createStratumBreakpoint(res, "JSP", input.getName(), path, getClassPattern(res), editorLineNumber, pos, pos, 0, true, // $NON-NLS-1$
            attributes);
            if (point == null) {
                // $NON-NLS-1$
                status = new Status(IStatus.ERROR, JSPUIPlugin.ID, IStatus.ERROR, "unsupported input type", null);
            }
        }
    } else {
        status = new Status(IStatus.INFO, JSPUIPlugin.ID, IStatus.INFO, JSPUIMessages.BreakpointNotAllowed, null);
    }
    if (status == null) {
        status = new Status(IStatus.OK, JSPUIPlugin.ID, IStatus.OK, JSPUIMessages.OK, null);
    }
    return status;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStorageEditorInput(org.eclipse.ui.IStorageEditorInput) IPath(org.eclipse.core.runtime.IPath) HashMap(java.util.HashMap) IWebProject(com.liferay.ide.core.IWebProject) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) HashMap(java.util.HashMap) Map(java.util.Map) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with IBreakpoint

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

the class PortalSourceLookupParticipant method getTemplateName.

private String getTemplateName(IStackFrame frame) throws DebugException {
    String retval = null;
    IThread thread = frame.getThread();
    IBreakpoint[] bps = thread.getBreakpoints();
    if (bps.length == 1) {
        IBreakpoint bp = thread.getBreakpoints()[0];
        retval = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, null);
    } else {
        if (thread instanceof FMThread) {
            FMThread fmThread = (FMThread) thread;
            Breakpoint stepBp = fmThread.getStepBreakpoint();
            if (stepBp != null) {
                // $NON-NLS-1$
                retval = stepBp.getTemplateName().replaceAll(FMDebugTarget.FM_TEMPLATE_SERVLET_CONTEXT, "");
            }
        }
    }
    return retval;
}
Also used : Breakpoint(freemarker.debug.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) FMThread(com.liferay.ide.portal.core.debug.fm.FMThread) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IThread(org.eclipse.debug.core.model.IThread)

Aggregations

IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)37 CoreException (org.eclipse.core.runtime.CoreException)14 IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)12 IResource (org.eclipse.core.resources.IResource)10 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)10 Breakpoint (nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint)9 ArrayList (java.util.ArrayList)6 IJavaBreakpoint (org.eclipse.jdt.debug.core.IJavaBreakpoint)6 IJavaLineBreakpoint (org.eclipse.jdt.debug.core.IJavaLineBreakpoint)6 ITextSelection (org.eclipse.jface.text.ITextSelection)6 IStatus (org.eclipse.core.runtime.IStatus)5 Test (org.junit.Test)5 Breakpoint (freemarker.debug.Breakpoint)4 IMarker (org.eclipse.core.resources.IMarker)4 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)4 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)4 RemoteException (java.rmi.RemoteException)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3