use of org.rstudio.studio.client.events.GetEditorContextEvent.DocumentSelection in project rstudio by rstudio.
the class Source method getEditorContext.
private void getEditorContext(String id, String path, DocDisplay docDisplay) {
AceEditor editor = (AceEditor) docDisplay;
Selection selection = editor.getNativeSelection();
Range[] ranges = selection.getAllRanges();
JsArray<DocumentSelection> docSelections = JavaScriptObject.createArray().cast();
for (int i = 0; i < ranges.length; i++) {
docSelections.push(DocumentSelection.create(ranges[i], editor.getTextForRange(ranges[i])));
}
id = StringUtil.notNull(id);
path = StringUtil.notNull(path);
GetEditorContextEvent.SelectionData data = GetEditorContextEvent.SelectionData.create(id, path, editor.getCode(), docSelections);
server_.getEditorContextCompleted(data, new VoidServerRequestCallback());
}
Aggregations