use of org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList.ScopePredicate in project rstudio by rstudio.
the class TextEditingTargetScopeHelper method getSweaveChunks.
public Scope[] getSweaveChunks(Position startPosition, final int which) {
// provide default position based on selection if necessary
final Position position = startPosition != null ? startPosition : docDisplay_.getSelectionStart();
ScopeList scopeList = new ScopeList(docDisplay_);
scopeList.selectAll(ScopeList.CHUNK);
scopeList.selectAll(new ScopePredicate() {
@Override
public boolean test(Scope scope) {
if (!scope.isChunk())
return false;
int dir = scope.getEnd().compareTo(position);
if (which == PREVIOUS_CHUNKS)
return dir < 0;
else
return dir > 0;
}
});
return scopeList.getScopes();
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList.ScopePredicate in project rstudio by rstudio.
the class TextEditingTargetScopeHelper method getNextSweaveChunk.
public Scope getNextSweaveChunk() {
ScopeList scopeList = new ScopeList(docDisplay_);
scopeList.selectAll(ScopeList.CHUNK);
final Position selectionEnd = docDisplay_.getSelectionEnd();
return scopeList.findFirst(new ScopePredicate() {
@Override
public boolean test(Scope scope) {
return scope.getPreamble().compareTo(selectionEnd) > 0;
}
});
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList.ScopePredicate in project rstudio by rstudio.
the class TextEditingTargetScopeHelper method getNextFunction.
public Scope getNextFunction(final Position position) {
ScopeList scopeList = new ScopeList(docDisplay_);
scopeList.selectAll(ScopeList.FUNC);
return scopeList.findFirst(new ScopePredicate() {
@Override
public boolean test(Scope scope) {
return scope.getPreamble().compareTo(position) > 0;
}
});
}
use of org.rstudio.studio.client.workbench.views.source.editors.text.ScopeList.ScopePredicate in project rstudio by rstudio.
the class TextEditingTargetScopeHelper method getPreviousFunction.
public Scope getPreviousFunction(final Position position) {
ScopeList scopeList = new ScopeList(docDisplay_);
scopeList.selectAll(ScopeList.FUNC);
return scopeList.findLast(new ScopePredicate() {
@Override
public boolean test(Scope scope) {
return scope.getPreamble().compareTo(position) < 0;
}
});
}
Aggregations