Package org.fife.ui.autocomplete
Class LanguageAwareCompletionProvider
java.lang.Object
org.fife.ui.autocomplete.CompletionProviderBase
org.fife.ui.autocomplete.LanguageAwareCompletionProvider
- All Implemented Interfaces:
CompletionProvider,org.fife.ui.rtextarea.ToolTipSupplier
public class LanguageAwareCompletionProvider
extends CompletionProviderBase
implements org.fife.ui.rtextarea.ToolTipSupplier
A completion provider for the C programming language (and other languages
with similar syntax). This provider simply delegates to another provider,
depending on whether the caret is in:
- Code (plain text)
- A string
- A comment
- A documentation comment
This provider also implements the
org.fife.ui.rtextarea.ToolTipSupplier interface, which allows it
to display tooltips for completion choices. Thus, the standard
VariableCompletion and FunctionCompletion completions should
be able to display tooltips with the variable declaration or function
definition (provided the RSyntaxTextArea was registered with the
javax.swing.ToolTipManager).
-
Field Summary
Fields inherited from class org.fife.ui.autocomplete.CompletionProviderBase
EMPTY_STRING -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConstructor subclasses can use when they don't have their default provider created at construction time.LanguageAwareCompletionProvider(CompletionProvider defaultProvider) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidCalling this method will result in anUnsupportedOperationExceptionbeing thrown.Returns the text just before the current caret position that could be the start of something auto-completable.Returns the completion provider to use for comments.getCompletionsAt(JTextComponent tc, Point p) Returns the completions that have been entered at the specified visual location.protected List<Completion>Does the dirty work of creating a list of completions.Returns the completion provider used when one isn't defined for a particular token type.Returns the completion provider to use for documentation comments.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).charReturns 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.charReturns the text that marks the start of a list of parameters to a function or method.Returns the completion provider to use for strings.getToolTipText(org.fife.ui.rtextarea.RTextArea textArea, MouseEvent e) Returns the tool tip to display for a mouse event.booleanThis method is called if auto-activation is enabled in the parentAutoCompletionafter the user types a single character.voidSets the comment completion provider.voidSets the default completion provider.voidSets the documentation comment completion provider.voidsetParameterizedCompletionParams(char listStart, String separator, char listEnd) Calling this method will result in anUnsupportedOperationExceptionbeing thrown.voidSets the completion provider to use while in a string.Methods inherited from class org.fife.ui.autocomplete.CompletionProviderBase
getCompletions, getListCellRenderer, getParameterChoicesProvider, getParent, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParent
-
Constructor Details
-
LanguageAwareCompletionProvider
protected LanguageAwareCompletionProvider()Constructor subclasses can use when they don't have their default provider created at construction time. They should callsetDefaultCompletionProvider(CompletionProvider)in this constructor. -
LanguageAwareCompletionProvider
Constructor.- Parameters:
defaultProvider- The provider to use when no provider is assigned to a particular token type. This cannot benull.
-
-
Method Details
-
clearParameterizedCompletionParams
public void clearParameterizedCompletionParams()Calling this method will result in anUnsupportedOperationExceptionbeing thrown. To set the parameter completion parameters, do so on the provider returned bygetDefaultCompletionProvider().- Specified by:
clearParameterizedCompletionParamsin interfaceCompletionProvider- Overrides:
clearParameterizedCompletionParamsin classCompletionProviderBase- Throws:
UnsupportedOperationException- Always.- See Also:
-
getAlreadyEnteredText
Description copied from interface:CompletionProviderReturns the text just before the current caret position that could be the start of something auto-completable.- Specified by:
getAlreadyEnteredTextin interfaceCompletionProvider- Parameters:
comp- The text component.- Returns:
- The text. A return value of
nullmeans 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).
-
getCommentCompletionProvider
Returns the completion provider to use for comments.- Returns:
- The completion provider to use.
- See Also:
-
getCompletionsAt
Description copied from interface:CompletionProviderReturns 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.- Specified by:
getCompletionsAtin interfaceCompletionProvider- Parameters:
tc- The text component.p- The position, usually from aMouseEvent.- Returns:
- The completions, or an empty list if there are none.
-
getCompletionsImpl
Does the dirty work of creating a list of completions.- Specified by:
getCompletionsImplin classCompletionProviderBase- Parameters:
comp- The text component to look in.- Returns:
- The list of possible completions, or an empty list if there are none.
-
getDefaultCompletionProvider
Returns the completion provider used when one isn't defined for a particular token type.- Returns:
- The completion provider to use.
- See Also:
-
getDocCommentCompletionProvider
Returns the completion provider to use for documentation comments.- Returns:
- The completion provider to use.
- See Also:
-
getParameterizedCompletions
Description copied from interface:CompletionProviderReturns 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).- Specified by:
getParameterizedCompletionsin interfaceCompletionProvider- Parameters:
tc- The text component.- Returns:
- The list of
ParameterizedCompletions. If no completions are available, this may benull.
-
getParameterListEnd
public char getParameterListEnd()Description copied from interface:CompletionProviderReturns the text that marks the end of a list of parameters to a function or method.- Specified by:
getParameterListEndin interfaceCompletionProvider- Overrides:
getParameterListEndin classCompletionProviderBase- Returns:
- The text for a parameter list end, for example,
'
)', or0if none. - See Also:
-
getParameterListSeparator
Description copied from interface:CompletionProviderReturns the text that separates parameters to a function or method.- Specified by:
getParameterListSeparatorin interfaceCompletionProvider- Overrides:
getParameterListSeparatorin classCompletionProviderBase- Returns:
- The text that separates parameters, for example,
"
,". - See Also:
-
getParameterListStart
public char getParameterListStart()Description copied from interface:CompletionProviderReturns the text that marks the start of a list of parameters to a function or method.- Specified by:
getParameterListStartin interfaceCompletionProvider- Overrides:
getParameterListStartin classCompletionProviderBase- Returns:
- The text for a parameter list start, for example,
"
(". - See Also:
-
getStringCompletionProvider
Returns the completion provider to use for strings.- Returns:
- The completion provider to use.
- See Also:
-
isAutoActivateOkay
Description copied from interface:CompletionProviderThis method is called if auto-activation is enabled in the parentAutoCompletionafter 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, aCompletionProviderfor Java might want to returntruefor this method only if the last character typed was a '.'.- Specified by:
isAutoActivateOkayin interfaceCompletionProvider- Overrides:
isAutoActivateOkayin classCompletionProviderBase- Parameters:
tc- The text component.- Returns:
- Whether auto-activation would be appropriate.
-
setCommentCompletionProvider
Sets the comment completion provider.- Parameters:
provider- The provider to use in comments.- See Also:
-
setDefaultCompletionProvider
Sets the default completion provider.- Parameters:
provider- The provider to use when no provider is assigned to a particular token type. This cannot benull.- See Also:
-
setDocCommentCompletionProvider
Sets the documentation comment completion provider.- Parameters:
provider- The provider to use in comments.- See Also:
-
setParameterizedCompletionParams
Calling this method will result in anUnsupportedOperationExceptionbeing thrown. To set the parameter completion parameters, do so on the provider returned bygetDefaultCompletionProvider().- Specified by:
setParameterizedCompletionParamsin interfaceCompletionProvider- Overrides:
setParameterizedCompletionParamsin classCompletionProviderBase- 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:
UnsupportedOperationException- Always.- See Also:
-
setStringCompletionProvider
Sets the completion provider to use while in a string.- Parameters:
provider- The provider to use.- See Also:
-
getToolTipText
Returns the tool tip to display for a mouse event.For this method to be called, the
RSyntaxTextAreamust be registered with thejavax.swing.ToolTipManagerlike so:ToolTipManager.sharedInstance().registerComponent(textArea);
- Specified by:
getToolTipTextin interfaceorg.fife.ui.rtextarea.ToolTipSupplier- Parameters:
textArea- The text area.e- The mouse event.- Returns:
- The tool tip text, or
nullif none.
-