Package qupath.lib.scripting.languages
Interface AutoCompletions.Completion
- Enclosing class:
AutoCompletions
public static interface AutoCompletions.Completion
A single completion.
Instances must be able to determine whether they can provide a valid autocompletion,
given an input string and a caret position - and, if so, also supply the completion text to insert.
-
Method Summary
Modifier and TypeMethodDescriptionGet the text that should be inserted for the full completion.Get the text that should be displayed for this completion.getInsertion
(String text, int pos, String lastToken) Get the string to insert, given the provided text and position.Get the tokenizer needed to extract the relevant bit of the text to determine the validity and/or insertion for the completion.boolean
isCompatible
(String text, int pos, String lastToken) Test if this completion is compatible with the provided text.
-
Method Details
-
getCompletionText
String getCompletionText()Get the text that should be inserted for the full completion.- Returns:
-
getDisplayText
String getDisplayText()Get the text that should be displayed for this completion. This which may include additional information that isn't part of the completion itself (e.g. method parameters, return type).- Returns:
-
getInsertion
Get the string to insert, given the provided text and position. This involves stripping off any overlapping part of the completion, so that it can be inserted at pos.- Parameters:
text
- the full textpos
- the current caret positionlastToken
- the final token, as output bygetTokenizer()
. If null, the token will be calculated - but it can improve performance to precompute tokens whenever multiple completions use the same way of determining tokens.- Returns:
- the text to insert
-
isCompatible
Test if this completion is compatible with the provided text.- Parameters:
text
- the full textpos
- the current caret positionlastToken
- the final token, as output bygetTokenizer()
. If null, the token will be calculated - but it can improve performance to precompute tokens whenever multiple completions use the same way of determining tokens.- Returns:
-
getTokenizer
Get the tokenizer needed to extract the relevant bit of the text to determine the validity and/or insertion for the completion.Important! This exists for efficiency, so that if many completions use the same tokenizer, the (possibly long) text does not need to be re-tokenized each time. It is therefore important to return a shared instance, rather than a new object for each completion.
- Returns:
- the completion tokenizer, which must not be null
- See Also:
-