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_));
}
}
}
Aggregations