Search in sources :

Example 1 with CodeBrowserFinishedEvent

use of org.rstudio.studio.client.workbench.views.source.events.CodeBrowserFinishedEvent in project rstudio by rstudio.

the class EnvironmentPresenter method openOrUpdateFileBrowsePoint.

private void openOrUpdateFileBrowsePoint(boolean debugging, boolean sourceChanged) {
    String file = currentBrowseFile_;
    // if we have no file and no source code, we can do no navigation 
    if (!CallFrame.isNavigableFilename(file) && !useCurrentBrowseSource_) {
        return;
    }
    // file itself
    if (currentBrowsePosition_ != null && !useCurrentBrowseSource_) {
        FileSystemItem sourceFile = FileSystemItem.createFile(file);
        eventBus_.fireEvent(new OpenSourceFileEvent(sourceFile, (FilePosition) currentBrowsePosition_.cast(), FileTypeRegistry.R, debugging ? NavigationMethods.DEBUG_STEP : NavigationMethods.DEBUG_END));
    } else // the copy from the server into the code browser window
    if (useCurrentBrowseSource_ && currentBrowseSource_.length() > 0) {
        if (debugging) {
            // create the function name for the code browser by removing the
            // () indicator supplied by the server
            String functionName = environmentName_;
            int idx = functionName.indexOf('(');
            if (idx > 0) {
                functionName = functionName.substring(0, idx);
            }
            // omit qualifiers
            idx = functionName.indexOf("::");
            if (idx > 0) {
                functionName = functionName.substring(idx + 1);
                // :::, too
                if (functionName.startsWith(":"))
                    functionName = functionName.substring(1);
            }
            // create the function definition
            searchFunction_ = SearchPathFunctionDefinition.create(functionName, StringUtil.isNullOrEmpty(functionEnvName_) ? "debugging" : functionEnvName_, currentBrowseSource_, true);
            if (sourceChanged) {
                // if this is a different source file than we already have open,
                // open it 
                eventBus_.fireEvent(new CodeBrowserNavigationEvent(searchFunction_, currentBrowsePosition_.functionRelativePosition(currentFunctionLineNumber_), contextDepth_ == 1, false));
            } else if (currentBrowsePosition_.getLine() > 0) {
                // if this is the same one currently open, just move the 
                // highlight
                eventBus_.fireEvent(new CodeBrowserHighlightEvent(searchFunction_, currentBrowsePosition_.functionRelativePosition(currentFunctionLineNumber_)));
            }
        } else {
            eventBus_.fireEvent(new CodeBrowserFinishedEvent(searchFunction_));
        }
    }
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) CodeBrowserNavigationEvent(org.rstudio.studio.client.workbench.views.source.events.CodeBrowserNavigationEvent) OpenSourceFileEvent(org.rstudio.studio.client.common.filetypes.events.OpenSourceFileEvent) CodeBrowserHighlightEvent(org.rstudio.studio.client.workbench.views.source.events.CodeBrowserHighlightEvent) CodeBrowserFinishedEvent(org.rstudio.studio.client.workbench.views.source.events.CodeBrowserFinishedEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) DebugFilePosition(org.rstudio.core.client.DebugFilePosition) FilePosition(org.rstudio.core.client.FilePosition)

Aggregations

JsArrayString (com.google.gwt.core.client.JsArrayString)1 DebugFilePosition (org.rstudio.core.client.DebugFilePosition)1 FilePosition (org.rstudio.core.client.FilePosition)1 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)1 OpenSourceFileEvent (org.rstudio.studio.client.common.filetypes.events.OpenSourceFileEvent)1 CodeBrowserFinishedEvent (org.rstudio.studio.client.workbench.views.source.events.CodeBrowserFinishedEvent)1 CodeBrowserHighlightEvent (org.rstudio.studio.client.workbench.views.source.events.CodeBrowserHighlightEvent)1 CodeBrowserNavigationEvent (org.rstudio.studio.client.workbench.views.source.events.CodeBrowserNavigationEvent)1