
javarepl.completion.StringCompleter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javarepl Show documentation
Show all versions of javarepl Show documentation
Java REPL is a simple Read-Eval-Print-Loop for Java language.
package javarepl.completion;
import com.googlecode.totallylazy.Sequence;
import static com.googlecode.totallylazy.Strings.startsWith;
import static javarepl.completion.CompletionCandidate.asCompletionCandidate;
public class StringCompleter extends Completer {
private final Sequence candidates;
public StringCompleter(Sequence candidates) {
this.candidates = candidates;
}
@Override
public CompletionResult call(String expression) throws Exception {
int lastSpace = expression.lastIndexOf(" ") + 1;
return new CompletionResult(expression, lastSpace,
candidates.filter(startsWith(expression.substring(lastSpace))).map(asCompletionCandidate()));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy