use of org.rstudio.core.client.FilePosition 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.core.client.FilePosition in project rstudio by rstudio.
the class FileTypeRegistry method satelliteEditFile.
private void satelliteEditFile(JavaScriptObject file, JavaScriptObject position, boolean highlightLine) {
FileSystemItem fsi = file.cast();
FilePosition pos = position.cast();
editFile(fsi, pos);
}
use of org.rstudio.core.client.FilePosition in project rstudio by rstudio.
the class ProfilerEditingTarget method onGotoProfileSource.
@Handler
public void onGotoProfileSource() {
FilePosition filePosition = FilePosition.create(selectedLine_, 0);
fileTypeRegistry_.editFile(FileSystemItem.createFile(selectedPath_), filePosition);
}
use of org.rstudio.core.client.FilePosition in project rstudio by rstudio.
the class PresentationDispatcher method performSourceCommand.
private void performSourceCommand(String param1, String param2) {
if (param1 != null) {
// get filename and type
FileSystemItem file = FileSystemItem.createFile(getPresentationPath(param1));
TextFileType fileType = fileTypeRegistry_.getTextTypeForFile(file);
// check for a file position and/or pattern
FilePosition pos = null;
String pattern = null;
if (param2 != null) {
if (param2.length() > 2 && param2.startsWith("/") && param2.endsWith("/")) {
pattern = param2.substring(1, param2.length() - 1);
} else {
int line = StringUtil.parseInt(param2, 0);
if (line > 0)
pos = FilePosition.create(line, 1);
}
}
// dispatch
fireOpenSourceFileEvent(new OpenPresentationSourceFileEvent(file, fileType, pos, pattern));
}
}
use of org.rstudio.core.client.FilePosition in project rstudio by rstudio.
the class CodeSearchOracle method navigationTarget.
public CodeNavigationTarget navigationTarget(String query, Suggestion suggestion) {
CodeSearchSuggestion codeSearchSuggestion = (CodeSearchSuggestion) suggestion;
// Allow queries of the form e.g. 'foo:15' to go to line '15' of a file.
// We parse the integer following the ':' if possible.
FilePosition filePos = codeSearchSuggestion.getNavigationTarget().getPosition();
if (codeSearchSuggestion.isFileTarget()) {
int colonIndex = query.indexOf(":");
if (colonIndex > 0) {
String[] splat = query.split(":");
if (splat.length > 1) {
int rowToNavigateTo = 0;
try {
rowToNavigateTo = Integer.parseInt(splat[1]);
} catch (Exception e) {
}
int colToNavigateTo = 0;
if (splat.length > 2) {
try {
colToNavigateTo = Integer.parseInt(splat[2]);
} catch (Exception e) {
}
}
filePos = FilePosition.create(rowToNavigateTo, colToNavigateTo);
}
}
}
String fileName = codeSearchSuggestion.getNavigationTarget().getFile();
CodeNavigationTarget target = new CodeNavigationTarget(fileName, filePos);
return target;
}
Aggregations