Search in sources :

Example 26 with Position

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));
}
Also used : InputEditorPosition(org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 27 with Position

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);
    }
}
Also used : AceFold(org.rstudio.studio.client.workbench.views.source.editors.text.ace.AceFold) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)

Example 28 with Position

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);
        }
    });
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 29 with Position

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));
}
Also used : TokenCursor(org.rstudio.studio.client.workbench.views.source.editors.text.ace.TokenCursor) Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)

Example 30 with Position

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);
        }
    });
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString)

Aggregations

Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)64 InputEditorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorPosition)20 JsArrayString (com.google.gwt.core.client.JsArrayString)16 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)11 Range (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Range)11 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)7 FileChangeHandler (org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)7 TokenCursor (org.rstudio.studio.client.workbench.views.source.editors.text.ace.TokenCursor)7 SourcePosition (org.rstudio.studio.client.workbench.views.source.model.SourcePosition)7 Handler (org.rstudio.core.client.command.Handler)6 EnsureHeightHandler (org.rstudio.core.client.events.EnsureHeightHandler)6 EnsureVisibleHandler (org.rstudio.core.client.events.EnsureVisibleHandler)6 ChangeFontSizeHandler (org.rstudio.studio.client.application.events.ChangeFontSizeHandler)6 ServerError (org.rstudio.studio.client.server.ServerError)6 AceEditor (org.rstudio.studio.client.workbench.views.source.editors.text.AceEditor)6 Token (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Token)6 HideMessageHandler (org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler)6 RecordNavigationPositionHandler (org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler)6 InputEditorLineWithCursorPosition (org.rstudio.studio.client.workbench.views.console.shell.editor.InputEditorLineWithCursorPosition)4 CodeModel (org.rstudio.studio.client.workbench.views.source.editors.text.ace.CodeModel)4