- All Known Implementing Classes:
AbstractCompletionProvider
,ChildrenCompletionProvider
,ClassCompletionProvider
,CompletionProviderBase
,DefaultCompletionProvider
,XLContextCompletionProvider
public interface CompletionProvider
Provides autocompletion values to an
AutoCompletion
.Completion providers can have an optional parent. Parents are searched for completions when their children are. This allows for chaining of completion providers.
- Version:
- 1.0
- Author:
- Robert Futrell
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Clears the values used to identify and insert "parameterized completions" (e.g. functions or methods).Returns the text just before the current caret position that could be the start of something auto-completable.Gets the possible completions for the text component at the current caret position.getCompletionsAt
(AutoCompletableTextArea comp, Point p) Returns the completions that have been entered at the specified visual location.Returns the cell renderer for completions returned from this provider.Returns an object that can return a list of completion choices for parameters.Returns a list of parameterized completions that have been entered at the current caret position of a text component (and thus can have their completion choices displayed).char
Returns the text that marks the end of a list of parameters to a function or method.Returns the text that separates parameters to a function or method.char
Returns the text that marks the start of a list of parameters to a function or method.Returns the parent completion provider.boolean
This method is called if auto-activation is enabled in the parentAutoCompletion
after the user types a single character.boolean
isValidChar
(char c) Test if a char is valid for this completionvoid
Sets the renderer to use when displaying completion choices.void
setParameterizedCompletionParams
(char listStart, String separator, char listEnd) Sets the values used to identify and insert "parameterized completions" (e.g. functions or methods).void
setParent
(CompletionProvider parent) Sets the parent completion provider.
-
Method Details
-
clearParameterizedCompletionParams
void clearParameterizedCompletionParams()Clears the values used to identify and insert "parameterized completions" (e.g. functions or methods). After this method is called, functions and methods will not have their parameters auto-completed. -
getAlreadyEnteredText
Returns the text just before the current caret position that could be the start of something auto-completable.- Parameters:
comp
- The text component.- Returns:
- The text. A return value of
null
means nothing should be auto-completed; a value of an empty string (""
) means auto-completion should still be considered (i.e., all possible choices are valid).
-
isValidChar
boolean isValidChar(char c) Test if a char is valid for this completion -
getCompletions
Gets the possible completions for the text component at the current caret position.- Parameters:
comp
- The text component.- Returns:
- The list of
Completion
s. If no completions are available, this method should return an empty list.
-
getCompletionsAt
Returns the completions that have been entered at the specified visual location. This can be used for tool tips when the user hovers the mouse over completed text.- Parameters:
comp
- The text component.p
- The position, usually from aMouseEvent
.- Returns:
- The completions, or an empty list if there are none.
-
getListCellRenderer
ListCellRenderer<Object> getListCellRenderer()Returns the cell renderer for completions returned from this provider.- Returns:
- The cell renderer, or
null
if the default should be used. - See Also:
-
getParameterChoicesProvider
ParameterChoicesProvider getParameterChoicesProvider()Returns an object that can return a list of completion choices for parameters. This is used when a user code-completes a parameterized completion, such as a function or method. For any parameter to the function/method, this object can return possible completions.- Returns:
- The parameter choices provider, or
null
if none is installed.
-
getParameterizedCompletions
Returns a list of parameterized completions that have been entered at the current caret position of a text component (and thus can have their completion choices displayed).- Parameters:
tc
- The text component.- Returns:
- The list of
ParameterizedCompletion
s. If no completions are available, this may benull
.
-
getParameterListEnd
char getParameterListEnd()Returns the text that marks the end of a list of parameters to a function or method.- Returns:
- The text for a parameter list end, for example,
'
)
', or0
if none. - See Also:
-
getParameterListSeparator
String getParameterListSeparator()Returns the text that separates parameters to a function or method.- Returns:
- The text that separates parameters, for example,
"
,
". - See Also:
-
getParameterListStart
char getParameterListStart()Returns the text that marks the start of a list of parameters to a function or method.- Returns:
- The text for a parameter list start, for example,
"
(
". - See Also:
-
getParent
CompletionProvider getParent()Returns the parent completion provider.- Returns:
- The parent completion provider.
- See Also:
-
isAutoActivateOkay
This method is called if auto-activation is enabled in the parentAutoCompletion
after the user types a single character. This provider should check the text at the current caret position of the text component, and decide whether auto-activation would be appropriate here. For example, aCompletionProvider
for Java might want to returntrue
for this method only if the last character typed was a '.
'.- Parameters:
tc
- The text component.- Returns:
- Whether auto-activation would be appropriate.
-
setListCellRenderer
Sets the renderer to use when displaying completion choices.- Parameters:
r
- The renderer to use.- See Also:
-
setParameterizedCompletionParams
Sets the values used to identify and insert "parameterized completions" (e.g. functions or methods). If this method isn't called, functions and methods will not have their parameters auto-completed.- Parameters:
listStart
- The character that marks the beginning of a list of parameters, such as '(
' in C or Java.separator
- Text that should separate parameters in a parameter list when one is inserted. For example, ",
".listEnd
- The character that marks the end of a list of parameters, such as ')
' in C or Java.- Throws:
IllegalArgumentException
- If eitherlistStart
orlistEnd
is not printable ASCII, or ifseparator
isnull
or an empty string.- See Also:
-
setParent
Sets the parent completion provider.- Parameters:
parent
- The parent provider.null
means there will be no parent provider.- See Also:
-