use of org.rstudio.studio.client.common.filetypes.events.OpenSourceFileEvent 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_));
}
}
}
use of org.rstudio.studio.client.common.filetypes.events.OpenSourceFileEvent in project rstudio by rstudio.
the class ConsoleErrorFrame method showSourceForFrame.
private void showSourceForFrame(ErrorFrame frame) {
FileSystemItem sourceFile = FileSystemItem.createFile(frame.getFileName());
RStudioGinjector.INSTANCE.getEventBus().fireEvent(new OpenSourceFileEvent(sourceFile, FilePosition.create(frame.getLineNumber(), frame.getCharacterNumber()), FileTypeRegistry.R, NavigationMethods.HIGHLIGHT_LINE));
}
use of org.rstudio.studio.client.common.filetypes.events.OpenSourceFileEvent in project rstudio by rstudio.
the class DebugCommander method highlightDebugPosition.
// Private methods ---------------------------------------------------------
private void highlightDebugPosition(LineData lineData, boolean finished) {
FileSystemItem sourceFile = FileSystemItem.createFile(debugFile_);
DebugFilePosition position = DebugFilePosition.create(lineData.getLineNumber(), lineData.getEndLineNumber(), lineData.getCharacterNumber(), lineData.getEndCharacterNumber());
eventBus_.fireEvent(new OpenSourceFileEvent(sourceFile, (FilePosition) position.cast(), FileTypeRegistry.R, finished ? NavigationMethods.DEBUG_END : NavigationMethods.DEBUG_STEP));
}
Aggregations