Package org.fife.ui.autocomplete
Class CompletionProviderBase
- java.lang.Object
-
- org.fife.ui.autocomplete.CompletionProviderBase
-
- All Implemented Interfaces:
CompletionProvider
- Direct Known Subclasses:
AbstractCompletionProvider
,LanguageAwareCompletionProvider
public abstract class CompletionProviderBase extends Object implements CompletionProvider
A base class for all standard completion providers. This class implements functionality that should be sharable across all CompletionProvider implementations.- Version:
- 1.0
- Author:
- Robert Futrell
- See Also:
AbstractCompletionProvider
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
EMPTY_STRING
-
Constructor Summary
Constructors Constructor Description CompletionProviderBase()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
clearParameterizedCompletionParams()
Clears the values used to identify and insert "parameterized completions" (e.g. functions or methods).List<Completion>
getCompletions(JTextComponent comp)
Gets the possible completions for the text component at the current caret position.protected abstract List<Completion>
getCompletionsImpl(JTextComponent comp)
Does the dirty work of creating a list of completions.ListCellRenderer
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.char
getParameterListEnd()
Returns the text that marks the end of a list of parameters to a function or method.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(JTextComponent tc)
This method is called if auto-activation is enabled in the parentAutoCompletion
after the user types a single character.void
setAutoActivationRules(boolean letters, String others)
Sets the characters that auto-activation should occur after.void
setListCellRenderer(ListCellRenderer r)
Sets the renderer to use when displaying completion choices.void
setParameterChoicesProvider(ParameterChoicesProvider pcp)
Sets the param choices provider.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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.fife.ui.autocomplete.CompletionProvider
getAlreadyEnteredText, getCompletionsAt, getParameterizedCompletions
-
-
-
-
Field Detail
-
EMPTY_STRING
protected static final String EMPTY_STRING
- See Also:
- Constant Field Values
-
-
Method Detail
-
clearParameterizedCompletionParams
public 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.- Specified by:
clearParameterizedCompletionParams
in interfaceCompletionProvider
- See Also:
CompletionProvider.setParameterizedCompletionParams(char, String, char)
-
getCompletions
public List<Completion> getCompletions(JTextComponent comp)
Gets the possible completions for the text component at the current caret position.- Specified by:
getCompletions
in interfaceCompletionProvider
- Parameters:
comp
- The text component.- Returns:
- The list of
Completion
s. If no completions are available, this method should return an empty list.
-
getCompletionsImpl
protected abstract List<Completion> getCompletionsImpl(JTextComponent comp)
Does the dirty work of creating a list of completions.- Parameters:
comp
- The text component to look in.- Returns:
- The list of possible completions, or an empty list if there are none.
-
getListCellRenderer
public ListCellRenderer getListCellRenderer()
Returns the cell renderer for completions returned from this provider.- Specified by:
getListCellRenderer
in interfaceCompletionProvider
- Returns:
- The cell renderer, or
null
if the default should be used. - See Also:
CompletionProvider.setListCellRenderer(ListCellRenderer)
-
getParameterChoicesProvider
public 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.- Specified by:
getParameterChoicesProvider
in interfaceCompletionProvider
- Returns:
- The parameter choices provider, or
null
if none is installed.
-
getParameterListEnd
public char getParameterListEnd()
Returns the text that marks the end of a list of parameters to a function or method.- Specified by:
getParameterListEnd
in interfaceCompletionProvider
- Returns:
- The text for a parameter list end, for example,
'
)
'. - See Also:
CompletionProvider.getParameterListStart()
,CompletionProvider.getParameterListSeparator()
,CompletionProvider.setParameterizedCompletionParams(char, String, char)
-
getParameterListSeparator
public String getParameterListSeparator()
Returns the text that separates parameters to a function or method.- Specified by:
getParameterListSeparator
in interfaceCompletionProvider
- Returns:
- The text that separates parameters, for example,
"
,
". - See Also:
CompletionProvider.getParameterListStart()
,CompletionProvider.getParameterListEnd()
,CompletionProvider.setParameterizedCompletionParams(char, String, char)
-
getParameterListStart
public char getParameterListStart()
Returns the text that marks the start of a list of parameters to a function or method.- Specified by:
getParameterListStart
in interfaceCompletionProvider
- Returns:
- The text for a parameter list start, for example,
"
(
". - See Also:
CompletionProvider.getParameterListEnd()
,CompletionProvider.getParameterListSeparator()
,CompletionProvider.setParameterizedCompletionParams(char, String, char)
-
getParent
public CompletionProvider getParent()
Returns the parent completion provider.- Specified by:
getParent
in interfaceCompletionProvider
- Returns:
- The parent completion provider.
- See Also:
CompletionProvider.setParent(CompletionProvider)
-
isAutoActivateOkay
public boolean isAutoActivateOkay(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 '.
'.- Specified by:
isAutoActivateOkay
in interfaceCompletionProvider
- Parameters:
tc
- The text component.- Returns:
- Whether auto-activation would be appropriate.
-
setAutoActivationRules
public void setAutoActivationRules(boolean letters, String others)
Sets the characters that auto-activation should occur after. A Java completion provider, for example, might want to setothers
to ".
", to allow auto-activation for members of an object.- Parameters:
letters
- Whether auto-activation should occur after any letter.others
- A string of (non-letter) chars that auto-activation should occur after. This may benull
.
-
setParameterChoicesProvider
public void setParameterChoicesProvider(ParameterChoicesProvider pcp)
Sets the param choices provider. 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.- Parameters:
pcp
- The parameter choices provider, ornull
for none.- See Also:
getParameterChoicesProvider()
-
setListCellRenderer
public void setListCellRenderer(ListCellRenderer r)
Sets the renderer to use when displaying completion choices.- Specified by:
setListCellRenderer
in interfaceCompletionProvider
- Parameters:
r
- The renderer to use.- See Also:
CompletionProvider.getListCellRenderer()
-
setParameterizedCompletionParams
public void setParameterizedCompletionParams(char listStart, 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.- Specified by:
setParameterizedCompletionParams
in interfaceCompletionProvider
- 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.- See Also:
CompletionProvider.clearParameterizedCompletionParams()
-
setParent
public void setParent(CompletionProvider parent)
Sets the parent completion provider.- Specified by:
setParent
in interfaceCompletionProvider
- Parameters:
parent
- The parent provider.null
means there will be no parent provider.- See Also:
CompletionProvider.getParent()
-
-