Search in sources :

Example 1 with FunctionState

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

the class BreakpointManager method setBreakpoint.

public Breakpoint setBreakpoint(final String path, final String functionName, int lineNumber, final boolean immediately) {
    // create the new breakpoint and arguments for the server call
    final Breakpoint breakpoint = addBreakpoint(Breakpoint.create(currentBreakpointId_++, path, functionName, lineNumber, immediately ? Breakpoint.STATE_PROCESSING : Breakpoint.STATE_INACTIVE, Breakpoint.TYPE_FUNCTION));
    notifyServer(breakpoint, true, false);
    // expectations. Process it when the function is no longer executing.
    if (activeFunctions_.contains(new FileFunction(breakpoint))) {
        breakpoint.setPendingDebugCompletion(true);
        markInactiveBreakpoint(breakpoint);
    } else {
        server_.getFunctionState(functionName, path, lineNumber, new ServerRequestCallback<FunctionState>() {

            @Override
            public void onResponseReceived(FunctionState state) {
                if (state.isPackageFunction()) {
                    breakpoint.markAsPackageBreakpoint(state.getPackageName());
                }
                // stop processing now
                if (!immediately)
                    return;
                // the breakpoint now
                if (state.getSyncState()) {
                    prepareAndSetFunctionBreakpoints(new FileFunction(breakpoint));
                } else // otherwise, save an inactive breakpoint--we'll revisit the
                // marker the next time the file is sourced or the package is
                // rebuilt
                {
                    markInactiveBreakpoint(breakpoint);
                }
            }

            @Override
            public void onError(ServerError error) {
                // if we can't figure out whether the function is in sync, 
                // leave it inactive for now
                markInactiveBreakpoint(breakpoint);
            }
        });
    }
    breakpointStateDirty_ = true;
    return breakpoint;
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ServerError(org.rstudio.studio.client.server.ServerError) FunctionState(org.rstudio.studio.client.common.debugging.model.FunctionState)

Aggregations

Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)1 FunctionState (org.rstudio.studio.client.common.debugging.model.FunctionState)1 ServerError (org.rstudio.studio.client.server.ServerError)1