use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.
the class RemoteServer method updateBreakpoints.
@Override
public void updateBreakpoints(ArrayList<Breakpoint> breakpoints, boolean set, boolean arm, ServerRequestCallback<Void> requestCallback) {
JSONArray bps = new JSONArray();
for (int i = 0; i < breakpoints.size(); i++) {
bps.set(i, new JSONObject(breakpoints.get(i)));
}
JSONArray params = new JSONArray();
params.set(0, bps);
params.set(1, JSONBoolean.getInstance(set));
params.set(2, JSONBoolean.getInstance(arm));
sendRequest(RPC_SCOPE, UPDATE_BREAKPOINTS, params, requestCallback);
}
use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.
the class AceEditorWidget method toggleBreakpointAtPosition.
private void toggleBreakpointAtPosition(Position pos) {
// rows are 0-based, but debug line numbers are 1-based
int lineNumber = lineFromRow(pos.getRow());
int breakpointIdx = getBreakpointIdxByLine(lineNumber);
// if there's already a breakpoint on that line, remove it
if (breakpointIdx >= 0) {
Breakpoint breakpoint = breakpoints_.get(breakpointIdx);
removeBreakpointMarker(breakpoint);
fireEvent(new BreakpointSetEvent(lineNumber, breakpoint.getBreakpointId(), false));
breakpoints_.remove(breakpointIdx);
} else // if there's no breakpoint on that line yet, create a new unset
// breakpoint there (the breakpoint manager will pick up the new
// breakpoint and attempt to set it on the server)
{
try {
// non-whitespace, non-comment token
if (editor_.getSession().getMode().getCodeModel() != null) {
Position tokenPos = editor_.getSession().getMode().getCodeModel().findNextSignificantToken(pos);
if (tokenPos != null) {
lineNumber = lineFromRow(tokenPos.getRow());
if (getBreakpointIdxByLine(lineNumber) >= 0) {
return;
}
} else {
// set a breakpoint
return;
}
}
} catch (Exception e) {
// If we failed at any point to fast-forward to the next line with
// a statement, we'll try to set a breakpoint on the line the user
// originally clicked.
}
fireEvent(new BreakpointSetEvent(lineNumber, BreakpointSetEvent.UNSET_BREAKPOINT_ID, true));
}
}
use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.
the class AceEditorWidget method updateBreakpoints.
private void updateBreakpoints(AceDocumentChangeEventNative changeEvent) {
// if there are no breakpoints, don't do any work to move them about
if (breakpoints_.size() == 0) {
return;
}
// see if we need to move any breakpoints around in response to
// this change to the document's text
String action = changeEvent.getAction();
Range range = changeEvent.getRange();
Position start = range.getStart();
Position end = range.getEnd();
// in a way that could change lines, we can't have moved anything
if (start.getRow() == end.getRow() || (!action.equals("insertText") && !action.equals("insertLines") && !action.equals("removeText") && !action.equals("removeLines"))) {
return;
}
int shiftedBy = 0;
int shiftStartRow = 0;
// compute how many rows to shift
if (action == "insertText" || action == "insertLines") {
shiftedBy = end.getRow() - start.getRow();
} else {
shiftedBy = start.getRow() - end.getRow();
}
// compute where to start shifting
shiftStartRow = start.getRow() + ((action == "insertText" && start.getColumn() > 0) ? 1 : 0);
// make a pass through the breakpoints and move them as appropriate:
// remove all the breakpoints after the row where the change
// happened, and add them back at their new position if they were
// not part of a deleted range.
ArrayList<Breakpoint> movedBreakpoints = new ArrayList<Breakpoint>();
for (int idx = 0; idx < breakpoints_.size(); idx++) {
Breakpoint breakpoint = breakpoints_.get(idx);
int breakpointRow = rowFromLine(breakpoint.getEditorLineNumber());
if (breakpointRow >= shiftStartRow) {
// remove the breakpoint from its old position
movedBreakpoints.add(breakpoint);
removeBreakpointMarker(breakpoint);
}
}
for (Breakpoint breakpoint : movedBreakpoints) {
// calculate the new position of the breakpoint
int oldBreakpointPosition = rowFromLine(breakpoint.getEditorLineNumber());
int newBreakpointPosition = oldBreakpointPosition + shiftedBy;
// breakpoint there
if (oldBreakpointPosition >= end.getRow() && !(oldBreakpointPosition == end.getRow() && shiftedBy < 0) && getBreakpointIdxByLine(lineFromRow(newBreakpointPosition)) < 0) {
breakpoint.moveToLineNumber(lineFromRow(newBreakpointPosition));
placeBreakpointMarker(breakpoint);
fireEvent(new BreakpointMoveEvent(breakpoint.getBreakpointId()));
} else {
breakpoints_.remove(breakpoint);
fireEvent(new BreakpointSetEvent(breakpoint.getEditorLineNumber(), breakpoint.getBreakpointId(), false));
}
}
}
use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.
the class TextEditingTarget method updateBreakpointWarningBar.
private void updateBreakpointWarningBar() {
// check to see if there are any inactive breakpoints in this file
boolean hasInactiveBreakpoints = false;
boolean hasDebugPendingBreakpoints = false;
boolean hasPackagePendingBreakpoints = false;
String pendingPackageName = "";
ArrayList<Breakpoint> breakpoints = breakpointManager_.getBreakpointsInFile(getPath());
for (Breakpoint breakpoint : breakpoints) {
if (breakpoint.getState() == Breakpoint.STATE_INACTIVE) {
if (breakpoint.isPendingDebugCompletion()) {
hasDebugPendingBreakpoints = true;
} else if (breakpoint.isPackageBreakpoint()) {
hasPackagePendingBreakpoints = true;
pendingPackageName = breakpoint.getPackageName();
} else {
hasInactiveBreakpoints = true;
}
break;
}
}
boolean showWarning = hasDebugPendingBreakpoints || hasInactiveBreakpoints || hasPackagePendingBreakpoints;
if (showWarning && !isBreakpointWarningVisible_) {
String message = "";
if (hasDebugPendingBreakpoints) {
message = "Breakpoints will be activated when the file or " + "function is finished executing.";
} else if (isPackageFile()) {
message = "Breakpoints will be activated when the package is " + "built and reloaded.";
} else if (hasPackagePendingBreakpoints) {
message = "Breakpoints will be activated when an updated version " + "of the " + pendingPackageName + " package is loaded";
} else {
message = "Breakpoints will be activated when this file is " + "sourced.";
}
view_.showWarningBar(message);
isBreakpointWarningVisible_ = true;
} else if (!showWarning && isBreakpointWarningVisible_) {
hideBreakpointWarningBar();
}
}
use of org.rstudio.studio.client.common.debugging.model.Breakpoint in project rstudio by rstudio.
the class AceEditorWidget method addOrUpdateBreakpoint.
public void addOrUpdateBreakpoint(Breakpoint breakpoint) {
int idx = getBreakpointIdxById(breakpoint.getBreakpointId());
if (idx >= 0) {
removeBreakpointMarker(breakpoint);
breakpoint.setEditorState(breakpoint.getState());
breakpoint.setEditorLineNumber(breakpoint.getLineNumber());
} else {
breakpoints_.add(breakpoint);
}
placeBreakpointMarker(breakpoint);
}
Aggregations