All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javarepl.completion.StringCompleter Maven / Gradle / Ivy

There is a newer version: 431
Show newest version
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