Search in sources :

Example 6 with Breakpoint

use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.

the class AceEditorWidget method removeBreakpoint.

public void removeBreakpoint(Breakpoint breakpoint) {
    int idx = getBreakpointIdxById(breakpoint.getBreakpointId());
    if (idx >= 0) {
        removeBreakpointMarker(breakpoint);
        breakpoints_.remove(idx);
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 7 with Breakpoint

use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.

the class BreakpointManager method activateTopLevelBreakpoints.

private void activateTopLevelBreakpoints(String path) {
    for (Breakpoint breakpoint : breakpoints_) {
        ArrayList<Breakpoint> activatedBreakpoints = new ArrayList<Breakpoint>();
        if (breakpoint.isPendingDebugCompletion() && breakpoint.getState() == Breakpoint.STATE_INACTIVE && breakpoint.getType() == Breakpoint.TYPE_TOPLEVEL && breakpoint.getPath().equals(path)) {
            // If this is a top-level breakpoint in the file that we 
            // just finished sourcing, activate the breakpoint.
            breakpoint.setPendingDebugCompletion(false);
            breakpoint.setState(Breakpoint.STATE_ACTIVE);
            activatedBreakpoints.add(breakpoint);
        }
        if (activatedBreakpoints.size() > 0)
            notifyBreakpointsSaved(activatedBreakpoints, true);
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ArrayList(java.util.ArrayList)

Example 8 with Breakpoint

use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.

the class BreakpointManager method onContextDepthChanged.

@Override
public void onContextDepthChanged(ContextDepthChangedEvent event) {
    // When we move around in debug context and hit a breakpoint, the initial
    // evaluation state is a temporary construction that needs to be stepped
    // past to begin actually evaluating the function. Step past it
    // immediately.
    JsArray<CallFrame> frames = event.getCallFrames();
    Set<FileFunction> activeFunctions = new TreeSet<FileFunction>();
    boolean hasSourceEquiv = false;
    for (int idx = 0; idx < frames.length(); idx++) {
        CallFrame frame = frames.get(idx);
        String functionName = frame.getFunctionName();
        String fileName = frame.getFileName();
        if (functionName.equals(".doTrace") && event.isServerInitiated()) {
            events_.fireEvent(new SendToConsoleEvent(DebugCommander.NEXT_COMMAND, true));
        }
        activeFunctions.add(new FileFunction(functionName, fileName, "", false));
        if (frame.isSourceEquiv()) {
            activeSource_ = fileName;
            hasSourceEquiv = true;
        }
    }
    // For any functions that were previously active in the callstack but
    // are no longer active, enable any pending breakpoints for those 
    // functions.
    Set<FileFunction> enableFunctions = new TreeSet<FileFunction>();
    for (FileFunction function : activeFunctions_) {
        if (!activeFunctions.contains(function)) {
            for (Breakpoint breakpoint : breakpoints_) {
                if (breakpoint.isPendingDebugCompletion() && breakpoint.getState() == Breakpoint.STATE_INACTIVE && function.containsBreakpoint(breakpoint)) {
                    enableFunctions.add(function);
                }
            }
        }
    }
    for (FileFunction function : enableFunctions) {
        prepareAndSetFunctionBreakpoints(function);
    }
    // Record the new frame list.
    activeFunctions_ = activeFunctions;
    // breakpoints in the file we were sourcing.
    if (!hasSourceEquiv && activeSource_ != null) {
        activateTopLevelBreakpoints(activeSource_);
        activeSource_ = null;
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) TreeSet(java.util.TreeSet) CallFrame(org.rstudio.studio.client.workbench.views.environment.model.CallFrame) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 9 with Breakpoint

use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.

the class BreakpointManager method onRestartStatus.

@Override
public void onRestartStatus(RestartStatusEvent event) {
    if (event.getStatus() == RestartStatusEvent.RESTART_INITIATED) {
        // Restarting R unloads all the packages, so mark all active package
        // breakpoints as inactive when this happens.
        ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
        for (Breakpoint breakpoint : breakpoints_) {
            if (breakpoint.isPackageBreakpoint()) {
                breakpoint.setState(Breakpoint.STATE_INACTIVE);
                breakpoints.add(breakpoint);
            }
        }
        notifyBreakpointsSaved(breakpoints, true);
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ArrayList(java.util.ArrayList)

Example 10 with Breakpoint

use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.

the class BreakpointManager method updatePackageBreakpoints.

private void updatePackageBreakpoints(String packageName, boolean enable) {
    Set<FileFunction> functionsToBreak = new TreeSet<FileFunction>();
    ArrayList<Breakpoint> breakpointsToDisable = new ArrayList<Breakpoint>();
    for (Breakpoint breakpoint : breakpoints_) {
        if (breakpoint.isPackageBreakpoint() && breakpoint.getPackageName().equals(packageName)) {
            if (enable) {
                functionsToBreak.add(new FileFunction(breakpoint));
            } else {
                breakpoint.setState(Breakpoint.STATE_INACTIVE);
                breakpointsToDisable.add(breakpoint);
            }
        }
    }
    if (enable) {
        for (FileFunction function : functionsToBreak) {
            prepareAndSetFunctionBreakpoints(function);
        }
    } else {
        notifyBreakpointsSaved(breakpointsToDisable, true);
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList)

Aggregations

Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)22 ArrayList (java.util.ArrayList)9 ServerError (org.rstudio.studio.client.server.ServerError)4 TreeSet (java.util.TreeSet)3 Void (org.rstudio.studio.client.server.Void)3 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)3 JsArrayString (com.google.gwt.core.client.JsArrayString)2 FunctionSteps (org.rstudio.studio.client.common.debugging.model.FunctionSteps)2 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)2 JsArray (com.google.gwt.core.client.JsArray)1 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 JSONArray (com.google.gwt.json.client.JSONArray)1 JSONObject (com.google.gwt.json.client.JSONObject)1 Timer (com.google.gwt.user.client.Timer)1 JsObject (org.rstudio.core.client.js.JsObject)1 BreakpointsSavedEvent (org.rstudio.studio.client.common.debugging.events.BreakpointsSavedEvent)1 BreakpointState (org.rstudio.studio.client.common.debugging.model.BreakpointState)1 FunctionState (org.rstudio.studio.client.common.debugging.model.FunctionState)1 RoxygenHelper (org.rstudio.studio.client.common.r.roxygen.RoxygenHelper)1