public class LanguageAwareCompletionProvider extends CompletionProviderBase implements org.fife.ui.rtextarea.ToolTipSupplier
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).
EMPTY_STRING
Modifier | Constructor and Description |
---|---|
protected |
LanguageAwareCompletionProvider()
Constructor subclasses can use when they don't have their default
provider created at construction time.
|
|
LanguageAwareCompletionProvider(CompletionProvider defaultProvider)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
clearParameterizedCompletionParams()
Calling this method will result in an
UnsupportedOperationException being thrown. |
String |
getAlreadyEnteredText(JTextComponent comp)
Returns the text just before the current caret position that could be
the start of something auto-completable.
|
CompletionProvider |
getCommentCompletionProvider()
Returns the completion provider to use for comments.
|
List<Completion> |
getCompletionsAt(JTextComponent tc,
Point p)
Returns the completions that have been entered at the specified visual
location.
|
protected List<Completion> |
getCompletionsImpl(JTextComponent comp)
Does the dirty work of creating a list of completions.
|
CompletionProvider |
getDefaultCompletionProvider()
Returns the completion provider used when one isn't defined for a
particular token type.
|
CompletionProvider |
getDocCommentCompletionProvider()
Returns the completion provider to use for documentation comments.
|
List<ParameterizedCompletion> |
getParameterizedCompletions(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.
|
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 |
getStringCompletionProvider()
Returns the completion provider to use for strings.
|
String |
getToolTipText(org.fife.ui.rtextarea.RTextArea textArea,
MouseEvent e)
Returns the tool tip to display for a mouse event.
|
boolean |
isAutoActivateOkay(JTextComponent tc)
This method is called if auto-activation is enabled in the parent
AutoCompletion after the user types a single character. |
void |
setCommentCompletionProvider(CompletionProvider provider)
Sets the comment completion provider.
|
void |
setDefaultCompletionProvider(CompletionProvider provider)
Sets the default completion provider.
|
void |
setDocCommentCompletionProvider(CompletionProvider provider)
Sets the documentation comment completion provider.
|
void |
setParameterizedCompletionParams(char listStart,
String separator,
char listEnd)
Calling this method will result in an
UnsupportedOperationException being thrown. |
void |
setStringCompletionProvider(CompletionProvider provider)
Sets the completion provider to use while in a string.
|
getCompletions, getListCellRenderer, getParameterChoicesProvider, getParent, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParent
protected LanguageAwareCompletionProvider()
setDefaultCompletionProvider(CompletionProvider)
in this
constructor.public LanguageAwareCompletionProvider(CompletionProvider defaultProvider)
defaultProvider
- The provider to use when no provider is assigned
to a particular token type. This cannot be null
.public void clearParameterizedCompletionParams()
UnsupportedOperationException
being thrown. To set the
parameter completion parameters, do so on the provider returned by
getDefaultCompletionProvider()
.clearParameterizedCompletionParams
in interface CompletionProvider
clearParameterizedCompletionParams
in class CompletionProviderBase
UnsupportedOperationException
- Always.setParameterizedCompletionParams(char, String, char)
public String getAlreadyEnteredText(JTextComponent comp)
getAlreadyEnteredText
in interface CompletionProvider
comp
- The text component.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).public CompletionProvider getCommentCompletionProvider()
setCommentCompletionProvider(CompletionProvider)
public List<Completion> getCompletionsAt(JTextComponent tc, Point p)
getCompletionsAt
in interface CompletionProvider
tc
- The text component.p
- The position, usually from a MouseEvent.protected List<Completion> getCompletionsImpl(JTextComponent comp)
getCompletionsImpl
in class CompletionProviderBase
comp
- The text component to look in.public CompletionProvider getDefaultCompletionProvider()
setDefaultCompletionProvider(CompletionProvider)
public CompletionProvider getDocCommentCompletionProvider()
setDocCommentCompletionProvider(CompletionProvider)
public List<ParameterizedCompletion> getParameterizedCompletions(JTextComponent tc)
getParameterizedCompletions
in interface CompletionProvider
tc
- The text component.ParameterizedCompletion
s. If no completions
are available, this may be null
.public char getParameterListEnd()
getParameterListEnd
in interface CompletionProvider
getParameterListEnd
in class CompletionProviderBase
)
'.CompletionProvider.getParameterListStart()
,
CompletionProvider.getParameterListSeparator()
,
CompletionProvider.setParameterizedCompletionParams(char, String, char)
public String getParameterListSeparator()
getParameterListSeparator
in interface CompletionProvider
getParameterListSeparator
in class CompletionProviderBase
,
".CompletionProvider.getParameterListStart()
,
CompletionProvider.getParameterListEnd()
,
CompletionProvider.setParameterizedCompletionParams(char, String, char)
public char getParameterListStart()
getParameterListStart
in interface CompletionProvider
getParameterListStart
in class CompletionProviderBase
(
".CompletionProvider.getParameterListEnd()
,
CompletionProvider.getParameterListSeparator()
,
CompletionProvider.setParameterizedCompletionParams(char, String, char)
public CompletionProvider getStringCompletionProvider()
setStringCompletionProvider(CompletionProvider)
public boolean isAutoActivateOkay(JTextComponent tc)
AutoCompletion
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, a CompletionProvider
for Java might
want to return true
for this method only if the last
character typed was a '.
'.isAutoActivateOkay
in interface CompletionProvider
isAutoActivateOkay
in class CompletionProviderBase
tc
- The text component.public void setCommentCompletionProvider(CompletionProvider provider)
provider
- The provider to use in comments.getCommentCompletionProvider()
public void setDefaultCompletionProvider(CompletionProvider provider)
provider
- The provider to use when no provider is assigned to a
particular token type. This cannot be null
.getDefaultCompletionProvider()
public void setDocCommentCompletionProvider(CompletionProvider provider)
provider
- The provider to use in comments.getDocCommentCompletionProvider()
public void setParameterizedCompletionParams(char listStart, String separator, char listEnd)
UnsupportedOperationException
being thrown. To set the
parameter completion parameters, do so on the provider returned by
getDefaultCompletionProvider()
.setParameterizedCompletionParams
in interface CompletionProvider
setParameterizedCompletionParams
in class CompletionProviderBase
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.UnsupportedOperationException
- Always.clearParameterizedCompletionParams()
public void setStringCompletionProvider(CompletionProvider provider)
provider
- The provider to use.getStringCompletionProvider()
public String getToolTipText(org.fife.ui.rtextarea.RTextArea textArea, MouseEvent e)
For this method to be called, the RSyntaxTextArea must be registered with the javax.swing.ToolTipManager like so:
ToolTipManager.sharedInstance().registerComponent(textArea);
getToolTipText
in interface org.fife.ui.rtextarea.ToolTipSupplier
textArea
- The text area.e
- The mouse event.null
if none.