Search in sources :

Example 1 with FunctionSteps

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

the class BreakpointManager method processFunctionSteps.

private void processFunctionSteps(ArrayList<Breakpoint> breakpoints, JsArray<FunctionSteps> stepList) {
    ArrayList<Breakpoint> unSettableBreakpoints = new ArrayList<Breakpoint>();
    // each breakpoint with its steps.
    for (int i = 0; i < breakpoints.size() && i < stepList.length(); i++) {
        FunctionSteps steps = stepList.get(i);
        Breakpoint breakpoint = breakpoints.get(i);
        if (steps.getSteps().length() > 0) {
            // line; if there is, discard this one.
            if (breakpoint.getLineNumber() != steps.getLineNumber()) {
                for (Breakpoint possibleDupe : breakpoints_) {
                    if (breakpoint.getPath().equals(possibleDupe.getPath()) && steps.getLineNumber() == possibleDupe.getLineNumber() && breakpoint.getBreakpointId() != possibleDupe.getBreakpointId()) {
                        breakpoint.setState(Breakpoint.STATE_REMOVING);
                        unSettableBreakpoints.add(breakpoint);
                    }
                }
            }
            breakpoint.addFunctionSteps(steps.getName(), steps.getLineNumber(), steps.getSteps());
        } else {
            unSettableBreakpoints.add(breakpoint);
        }
    }
    discardUnsettableBreakpoints(unSettableBreakpoints);
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) FunctionSteps(org.rstudio.studio.client.common.debugging.model.FunctionSteps) ArrayList(java.util.ArrayList) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Example 2 with FunctionSteps

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

the class BreakpointManager method prepareAndSetFunctionBreakpoints.

private void prepareAndSetFunctionBreakpoints(final FileFunction function) {
    // look over the list of breakpoints in this function and see if any are
    // marked inactive, or if they need their steps refreshed (necessary
    // when a function has had steps added or removed in the editor)
    final ArrayList<Breakpoint> inactiveBreakpoints = new ArrayList<Breakpoint>();
    int[] inactiveLines = new int[] {};
    int numLines = 0;
    for (Breakpoint breakpoint : breakpoints_) {
        if (function.containsBreakpoint(breakpoint) && (breakpoint.getState() != Breakpoint.STATE_ACTIVE || breakpoint.needsUpdatedSteps())) {
            inactiveBreakpoints.add(breakpoint);
            inactiveLines[numLines++] = breakpoint.getLineNumber();
        }
    }
    // corresponding steps from the function 
    if (inactiveBreakpoints.size() > 0) {
        server_.getFunctionSteps(function.functionName, function.fileName, function.packageName, inactiveLines, new ServerRequestCallback<JsArray<FunctionSteps>>() {

            @Override
            public void onResponseReceived(JsArray<FunctionSteps> response) {
                // ask the server to set the breakpoint
                if (response.length() > 0) {
                    processFunctionSteps(inactiveBreakpoints, response);
                    setFunctionBreakpoints(function);
                } else // no results: discard the breakpoints
                {
                    discardUnsettableBreakpoints(inactiveBreakpoints);
                }
            }

            @Override
            public void onError(ServerError error) {
                discardUnsettableBreakpoints(inactiveBreakpoints);
            }
        });
    } else {
        setFunctionBreakpoints(function);
    }
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) FunctionSteps(org.rstudio.studio.client.common.debugging.model.FunctionSteps) JsArray(com.google.gwt.core.client.JsArray) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint)

Aggregations

ArrayList (java.util.ArrayList)2 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)2 FunctionSteps (org.rstudio.studio.client.common.debugging.model.FunctionSteps)2 JsArray (com.google.gwt.core.client.JsArray)1 ServerError (org.rstudio.studio.client.server.ServerError)1