Package org.fife.ui.autocomplete
Interface CompletionProvider
-
- All Known Implementing Classes:
AbstractCompletionProvider
,CompletionProviderBase
,DefaultCompletionProvider
,LanguageAwareCompletionProvider
public interface CompletionProvider
Provides autocompletion values to anAutoCompletion
.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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
clearParameterizedCompletionParams()
Clears the values used to identify and insert "parameterized completions" (e.g.java.lang.String
getAlreadyEnteredText(javax.swing.text.JTextComponent comp)
Returns the text just before the current caret position that could be the start of something auto-completable.java.util.List<Completion>
getCompletions(javax.swing.text.JTextComponent comp)
Gets the possible completions for the text component at the current caret position.java.util.List<Completion>
getCompletionsAt(javax.swing.text.JTextComponent comp, java.awt.Point p)
Returns the completions that have been entered at the specified visual location.javax.swing.ListCellRenderer<java.lang.Object>
getListCellRenderer()
Returns the cell renderer for completions returned from this provider.ParameterChoicesProvider
getParameterChoicesProvider()
Returns an object that can return a list of completion choices for parameters.java.util.List<ParameterizedCompletion>
getParameterizedCompletions(javax.swing.text.JTextComponent tc)
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
getParameterListEnd()
Returns the text that marks the end of a list of parameters to a function or method.java.lang.String
getParameterListSeparator()
Returns the text that separates parameters to a function or method.char
getParameterListStart()
Returns the text that marks the start of a list of parameters to a function or method.CompletionProvider
getParent()
Returns the parent completion provider.boolean
isAutoActivateOkay(javax.swing.text.JTextComponent tc)
This method is called if auto-activation is enabled in the parentAutoCompletion
after the user types a single character.void
setListCellRenderer(javax.swing.ListCellRenderer<java.lang.Object> r)
Sets the renderer to use when displaying completion choices.void
setParameterizedCompletionParams(char listStart, java.lang.String separator, char listEnd)
Sets the values used to identify and insert "parameterized completions" (e.g.void
setParent(CompletionProvider parent)
Sets the parent completion provider.
-
-
-
Method Detail
-
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
java.lang.String getAlreadyEnteredText(javax.swing.text.JTextComponent comp)
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).
-
getCompletions
java.util.List<Completion> getCompletions(javax.swing.text.JTextComponent comp)
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
java.util.List<Completion> getCompletionsAt(javax.swing.text.JTextComponent comp, java.awt.Point p)
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
javax.swing.ListCellRenderer<java.lang.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:
setListCellRenderer(ListCellRenderer)
-
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
java.util.List<ParameterizedCompletion> getParameterizedCompletions(javax.swing.text.JTextComponent tc)
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:
getParameterListStart()
,getParameterListSeparator()
,setParameterizedCompletionParams(char, String, char)
-
getParameterListSeparator
java.lang.String getParameterListSeparator()
Returns the text that separates parameters to a function or method.- Returns:
- The text that separates parameters, for example,
"
,
". - See Also:
getParameterListStart()
,getParameterListEnd()
,setParameterizedCompletionParams(char, String, char)
-
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:
getParameterListEnd()
,getParameterListSeparator()
,setParameterizedCompletionParams(char, String, char)
-
getParent
CompletionProvider getParent()
Returns the parent completion provider.- Returns:
- The parent completion provider.
- See Also:
setParent(CompletionProvider)
-
isAutoActivateOkay
boolean isAutoActivateOkay(javax.swing.text.JTextComponent tc)
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
void setListCellRenderer(javax.swing.ListCellRenderer<java.lang.Object> r)
Sets the renderer to use when displaying completion choices.- Parameters:
r
- The renderer to use.- See Also:
getListCellRenderer()
-
setParameterizedCompletionParams
void setParameterizedCompletionParams(char listStart, java.lang.String separator, char listEnd)
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:
java.lang.IllegalArgumentException
- If eitherlistStart
orlistEnd
is not printable ASCII, or ifseparator
isnull
or an empty string.- See Also:
clearParameterizedCompletionParams()
-
setParent
void setParent(CompletionProvider parent)
Sets the parent completion provider.- Parameters:
parent
- The parent provider.null
means there will be no parent provider.- See Also:
getParent()
-
-