use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.
the class TextEditingTarget method onExecuteCurrentSection.
@Handler
void onExecuteCurrentSection() {
docDisplay_.focus();
// Determine the current section.
docDisplay_.getScopeTree();
Scope currentSection = docDisplay_.getCurrentSection();
if (currentSection == null)
return;
// Determine the start and end of the section
Position start = currentSection.getBodyStart();
if (start == null)
start = Position.create(0, 0);
Position end = currentSection.getEnd();
if (end == null)
end = endPosition();
codeExecution_.executeRange(Range.fromPoints(start, end));
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.
the class Fold method collect.
private static void collect(AceFold fold, ArrayList<Fold> results, Position parentOffset) {
results.add(fromAceFold(fold, parentOffset));
JsArray<AceFold> subFolds = fold.getSubFolds();
for (int i = 0; i < subFolds.length(); i++) {
AceFold subFold = subFolds.get(i);
Position offset = Position.create(fold.getStart().getRow() + parentOffset.getRow(), fold.getStart().getColumn() + parentOffset.getColumn());
collect(subFold, results, offset);
}
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.
the class RoxygenHelper method insertRoxygenSkeletonSetRefClass.
private void insertRoxygenSkeletonSetRefClass(TokenCursor cursor) {
final Position startPos = cursor.currentPosition();
String call = extractCall(cursor);
if (call == null)
return;
server_.getSetRefClassCall(call, new ServerRequestCallback<SetRefClassCall>() {
@Override
public void onResponseReceived(SetRefClassCall response) {
if (hasRoxygenBlock(startPos)) {
amendExistingRoxygenBlock(startPos.getRow() - 1, response.getClassName(), response.getFieldNames(), response.getFieldTypes(), "field", RE_ROXYGEN_FIELD);
} else {
insertRoxygenTemplate(response.getClassName(), response.getFieldNames(), response.getFieldTypes(), "field", "reference class", startPos);
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.
the class RoxygenHelper method extractCall.
private String extractCall(TokenCursor cursor) {
// Force document tokenization
editor_.getSession().getMode().getCodeModel().tokenizeUpToRow(editor_.getSession().getDocument().getLength());
TokenCursor clone = cursor.cloneCursor();
final Position startPos = clone.currentPosition();
if (!clone.moveToNextToken())
return null;
if (!clone.currentValue().equals("("))
return null;
if (!clone.fwdToMatchingToken())
return null;
Position endPos = clone.currentPosition();
endPos.setColumn(endPos.getColumn() + 1);
return editor_.getSession().getTextRange(Range.fromPoints(startPos, endPos));
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position in project rstudio by rstudio.
the class RoxygenHelper method insertRoxygenSkeletonSetGeneric.
private void insertRoxygenSkeletonSetGeneric(TokenCursor cursor) {
final Position startPos = cursor.currentPosition();
String call = extractCall(cursor);
if (call == null)
return;
server_.getSetGenericCall(call, new ServerRequestCallback<SetGenericCall>() {
@Override
public void onResponseReceived(SetGenericCall response) {
if (hasRoxygenBlock(startPos)) {
amendExistingRoxygenBlock(startPos.getRow() - 1, response.getGeneric(), response.getParameters(), null, "param", RE_ROXYGEN_PARAM);
} else {
insertRoxygenTemplate(response.getGeneric(), response.getParameters(), null, "param", "generic function", startPos);
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
}
Aggregations