Search in sources :

Example 11 with Breakpoint

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

the class BreakpointManager method moveBreakpoint.

public void moveBreakpoint(int breakpointId) {
    // because of Java(Script)'s reference semantics, the editor's instance
    // of the breakpoint object is the same one we have here, so we don't
    // need to update the line number--we just need to persist the new state.
    breakpointStateDirty_ = true;
    // the breakpoint knows its position in the function, which needs to be
    // recalculated; do that the next time we set breakpoints on this function
    Breakpoint breakpoint = getBreakpoint(breakpointId);
    if (breakpoint != null) {
        breakpoint.markStepsNeedUpdate();
        notifyServer(breakpoint, true, false);
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 12 with Breakpoint

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

the class BreakpointManager method notifyServer.

private void notifyServer(Breakpoint breakpoint, boolean added, boolean arm) {
    ArrayList<Breakpoint> bps = new ArrayList<Breakpoint>();
    bps.add(breakpoint);
    server_.updateBreakpoints(bps, added, arm, new VoidServerRequestCallback());
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ArrayList(java.util.ArrayList) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback)

Example 13 with Breakpoint

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

the class BreakpointManager method setTopLevelBreakpoint.

// Public methods ---------------------------------------------------------
public Breakpoint setTopLevelBreakpoint(final String path, final int lineNumber) {
    final Breakpoint breakpoint = addBreakpoint(Breakpoint.create(currentBreakpointId_++, path, "toplevel", lineNumber, path.equals(activeSource_) ? Breakpoint.STATE_INACTIVE : Breakpoint.STATE_ACTIVE, Breakpoint.TYPE_TOPLEVEL));
    // it just yet
    if (path.equals(activeSource_))
        breakpoint.setPendingDebugCompletion(true);
    notifyServer(breakpoint, true, true);
    ArrayList<Breakpoint> bps = new ArrayList<Breakpoint>();
    bps.add(breakpoint);
    return breakpoint;
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ArrayList(java.util.ArrayList)

Example 14 with Breakpoint

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

the class BreakpointManager method setFunctionBreakpoints.

// Private methods ---------------------------------------------------------
private void setFunctionBreakpoints(FileFunction function) {
    ArrayList<String> steps = new ArrayList<String>();
    final ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
    for (Breakpoint breakpoint : breakpoints_) {
        if (function.containsBreakpoint(breakpoint)) {
            steps.add(breakpoint.getFunctionSteps());
            breakpoints.add(breakpoint);
        }
    }
    server_.setFunctionBreakpoints(function.functionName, function.fileName, function.packageName, steps, new ServerRequestCallback<Void>() {

        @Override
        public void onResponseReceived(Void v) {
            for (Breakpoint breakpoint : breakpoints) {
                breakpoint.setState(Breakpoint.STATE_ACTIVE);
            }
            notifyBreakpointsSaved(breakpoints, true);
        }

        @Override
        public void onError(ServerError error) {
            discardUnsettableBreakpoints(breakpoints);
        }
    });
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) Void(org.rstudio.studio.client.server.Void)

Example 15 with Breakpoint

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

the class BreakpointManager method clearAllBreakpoints.

private void clearAllBreakpoints() {
    Set<FileFunction> functions = new TreeSet<FileFunction>();
    for (Breakpoint breakpoint : breakpoints_) {
        breakpoint.setState(Breakpoint.STATE_REMOVING);
        if (breakpoint.getType() == Breakpoint.TYPE_FUNCTION)
            functions.add(new FileFunction(breakpoint));
    }
    // set previously
    for (FileFunction function : functions) {
        server_.setFunctionBreakpoints(function.functionName, function.fileName, function.packageName, new ArrayList<String>(), new ServerRequestCallback<Void>() {

            @Override
            public void onError(ServerError error) {
            // There's a possibility here that the breakpoints were
            // not successfully cleared, so we may be in a temporarily
            // confusing state, but no error message will be less 
            // confusing. 
            }
        });
    }
    server_.removeAllBreakpoints(new VoidServerRequestCallback());
    notifyBreakpointsSaved(new ArrayList<Breakpoint>(breakpoints_), false);
    breakpoints_.clear();
    onBreakpointAddOrRemove();
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) TreeSet(java.util.TreeSet) ServerError(org.rstudio.studio.client.server.ServerError) VoidServerRequestCallback(org.rstudio.studio.client.server.VoidServerRequestCallback) Void(org.rstudio.studio.client.server.Void)

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