Search in sources :

Example 1 with Scripts

use of org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser.Scripts in project che by eclipse.

the class NodeJsDebugCommandsLibrary method getBreakpoints.

/**
     * Execute {@code breakpoints} command.
     * @see NodeJsBackTraceParser
     */
public List<Breakpoint> getBreakpoints() throws NodeJsDebuggerException {
    NodeJsDebugCommand<Breakpoints> breakpointsCommand = createCommand("breakpoints", NodeJsBreakpointsParser.INSTANCE);
    List<Breakpoint> breakpoints = doExecute(breakpointsCommand).getAll();
    NodeJsDebugCommand<Scripts> scriptsCommand = createCommand("scripts", NodeJsScriptsParser.INSTANCE);
    Map<Integer, String> scripts = doExecute(scriptsCommand).getAll();
    for (int i = 0; i < breakpoints.size(); i++) {
        Breakpoint breakpoint = breakpoints.get(i);
        Location location = breakpoint.getLocation();
        String newTarget;
        String[] target = location.getTarget().split(":");
        if (target.length != 2) {
            LOG.error(format("Illegal breakpoint location format %s", target[0]));
            continue;
        }
        if (target[0].equals("scriptId")) {
            newTarget = scripts.get((int) Double.parseDouble(target[1]));
        } else {
            newTarget = target[1];
        }
        Location newLocation = new LocationImpl(newTarget, location.getLineNumber());
        Breakpoint newBreakpoint = new BreakpointImpl(newLocation, breakpoint.isEnabled(), breakpoint.getCondition());
        breakpoints.set(i, newBreakpoint);
    }
    return breakpoints;
}
Also used : Breakpoints(org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBreakpointsParser.Breakpoints) Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) BreakpointImpl(org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl) Scripts(org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser.Scripts) Breakpoint(org.eclipse.che.api.debug.shared.model.Breakpoint) LocationImpl(org.eclipse.che.api.debug.shared.model.impl.LocationImpl) Location(org.eclipse.che.api.debug.shared.model.Location)

Aggregations

Breakpoint (org.eclipse.che.api.debug.shared.model.Breakpoint)1 Location (org.eclipse.che.api.debug.shared.model.Location)1 BreakpointImpl (org.eclipse.che.api.debug.shared.model.impl.BreakpointImpl)1 LocationImpl (org.eclipse.che.api.debug.shared.model.impl.LocationImpl)1 Breakpoints (org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsBreakpointsParser.Breakpoints)1 Scripts (org.eclipse.che.plugin.nodejsdbg.server.parser.NodeJsScriptsParser.Scripts)1