Get all completions for a token.
Get all completions for a token. The context
argument bears
some explaining. It's designed to allow the completer to locate the
cursor (and the nearest token) via Scala pattern matching, and it
consists of a stream of abstract tokens:
- LineToken
is a token parsed from the line, in an object that's
similar to Some
: LineToken.value
returns the token's string.
- Cursor
indicates the location of the cursor
- Delim
indicates the presence of a token delimiter (typically
white space)
The input line is broken into these tokens, which can then be matched. For example, consider the following input lines, with the cursor where the caret is:
Line: ^
(empty)
Tokens:
Cursor
Line: cm^
Tokens:
LineToken("cm") Cursor
Line: cmd ^
Tokens:
LineToken("cmd") Delim Cursor
Line: `cmd arg1^`
Tokens: `LineToken("cmd") Delim Token("arg1") Cursor`
Line: `cmd arg1^`
Tokens: `LineToken("cmd") Delim Token("arg1") Delim Cursor`
Line: `cmd^ arg1`
Tokens: `LineToken("cmd") Cursor Delim Token("arg1")`
Line: `cm^d arg1`
Tokens: `LineToken("cmd") Cursor Delim Token("arg1")`
the token being completed
all the tokens in the line, broken out, with the cursor inserted (i.e., the token context)
the current unparsed input line, which includes the token
a list of completions, or Nil if there are no matches
Get the delimiters that should be used to break a line into tokens.
Get the delimiters that should be used to break a line into tokens. The default is white space.
the delimiters
Models a completer: An object that, given a line of input and a token within that line, finds possible completions for the token.
Use JLine <https://github.com/jline/jline2>