Package org.fife.ui.autocomplete
Class FunctionCompletion
- java.lang.Object
-
- org.fife.ui.autocomplete.AbstractCompletion
-
- org.fife.ui.autocomplete.BasicCompletion
-
- org.fife.ui.autocomplete.VariableCompletion
-
- org.fife.ui.autocomplete.FunctionCompletion
-
- All Implemented Interfaces:
java.lang.Comparable<Completion>,Completion,ParameterizedCompletion
public class FunctionCompletion extends VariableCompletion implements ParameterizedCompletion
A completion choice representing a function.In order to use any instance of a
ParameterizedCompletion, you need to callAutoCompletion.setParameterAssistanceEnabled(boolean)with a value oftruefirst. Otherwise, any completion choices will be visible in the completion list, but won't insert anything when selected.- Version:
- 1.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.fife.ui.autocomplete.ParameterizedCompletion
ParameterizedCompletion.Parameter
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringcompareStringUsed to improve performance of sorting FunctionCompletions.private java.util.List<ParameterizedCompletion.Parameter>paramsParameters to the function.private java.lang.StringreturnValDescA description of the return value of this function.
-
Constructor Summary
Constructors Constructor Description FunctionCompletion(CompletionProvider provider, java.lang.String name, java.lang.String returnType)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddDefinitionString(java.lang.StringBuilder sb)protected voidaddParameters(java.lang.StringBuilder sb)Adds HTML describing the parameters to this function to a buffer.intcompareTo(Completion c2)Overridden to compare methods by their comparison strings.booleanequals(java.lang.Object other)Overridden to match the behavior ofcompareTo(Completion).private java.lang.StringgetCompareString()Returns a string used to compare this method completion to another.java.lang.StringgetDefinitionString()Returns the "definition string" for this function completion.ParameterizedCompletionInsertionInfogetInsertionInfo(javax.swing.text.JTextComponent tc, boolean replaceTabsWithSpaces)Returns completion information for this parameterized completion, given the specified text component.ParameterizedCompletion.ParametergetParam(int index)Returns the specifiedParameterizedCompletion.Parameter.intgetParamCount()Returns the number of parameters to this function.private java.lang.StringgetParamText(ParameterizedCompletion.Parameter param)Returns the text to insert for a parameter.java.lang.StringgetReturnValueDescription()Returns the description of the return value of this function.booleangetShowParameterToolTip()Returns whether a tool tip displaying assistance for each parameter while it is being edited is appropriate for this completion.java.lang.StringgetSummary()Returns the description of this auto-complete choice.java.lang.StringgetToolTipText()Returns the tool tip text to display for mouse hovers over this completion.inthashCode()voidsetParams(java.util.List<ParameterizedCompletion.Parameter> params)Sets the parameters to this function.voidsetReturnValueDescription(java.lang.String desc)Sets the description of the return value of this function.-
Methods inherited from class org.fife.ui.autocomplete.VariableCompletion
getDefinedIn, getName, getType, possiblyAddDefinedIn, possiblyAddDescription, setDefinedIn, toString
-
Methods inherited from class org.fife.ui.autocomplete.BasicCompletion
getReplacementText, getShortDescription, setShortDescription, setSummary
-
Methods inherited from class org.fife.ui.autocomplete.AbstractCompletion
getAlreadyEntered, getIcon, getInputText, getProvider, getRelevance, setIcon, setRelevance
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.fife.ui.autocomplete.Completion
getAlreadyEntered, getIcon, getInputText, getProvider, getRelevance, getReplacementText
-
-
-
-
Field Detail
-
params
private java.util.List<ParameterizedCompletion.Parameter> params
Parameters to the function.
-
returnValDesc
private java.lang.String returnValDesc
A description of the return value of this function.
-
compareString
private java.lang.String compareString
Used to improve performance of sorting FunctionCompletions.
-
-
Constructor Detail
-
FunctionCompletion
public FunctionCompletion(CompletionProvider provider, java.lang.String name, java.lang.String returnType)
Constructor.- Parameters:
provider- The parent provider.name- The name of this function.returnType- The return type of this function.
-
-
Method Detail
-
addDefinitionString
protected void addDefinitionString(java.lang.StringBuilder sb)
- Overrides:
addDefinitionStringin classVariableCompletion
-
addParameters
protected void addParameters(java.lang.StringBuilder sb)
Adds HTML describing the parameters to this function to a buffer.- Parameters:
sb- The buffer to append to.
-
compareTo
public int compareTo(Completion c2)
Overridden to compare methods by their comparison strings.- Specified by:
compareToin interfacejava.lang.Comparable<Completion>- Specified by:
compareToin interfaceCompletion- Overrides:
compareToin classAbstractCompletion- Parameters:
c2- ACompletionto compare to.- Returns:
- The sort order.
-
equals
public boolean equals(java.lang.Object other)
Overridden to match the behavior ofcompareTo(Completion).- Overrides:
equalsin classjava.lang.Object- Parameters:
other- Another object.- Returns:
- Whether these two objects are equal.
-
getCompareString
private java.lang.String getCompareString()
Returns a string used to compare this method completion to another.- Returns:
- The comparison string.
-
getDefinitionString
public java.lang.String getDefinitionString()
Returns the "definition string" for this function completion. For example, for the C "printf" function, this would return "int printf(const char *, ...)".- Specified by:
getDefinitionStringin interfaceParameterizedCompletion- Overrides:
getDefinitionStringin classVariableCompletion- Returns:
- The definition string.
-
getInsertionInfo
public ParameterizedCompletionInsertionInfo getInsertionInfo(javax.swing.text.JTextComponent tc, boolean replaceTabsWithSpaces)
Description copied from interface:ParameterizedCompletionReturns completion information for this parameterized completion, given the specified text component.- Specified by:
getInsertionInfoin interfaceParameterizedCompletion- Parameters:
tc- The text component.replaceTabsWithSpaces- Whether to replace tabs with spaces.- Returns:
- The completion info.
-
getParam
public ParameterizedCompletion.Parameter getParam(int index)
Description copied from interface:ParameterizedCompletionReturns the specifiedParameterizedCompletion.Parameter.- Specified by:
getParamin interfaceParameterizedCompletion- Parameters:
index- The index of the parameter to retrieve.- Returns:
- The parameter.
- See Also:
ParameterizedCompletion.getParamCount()
-
getParamCount
public int getParamCount()
Returns the number of parameters to this function.- Specified by:
getParamCountin interfaceParameterizedCompletion- Returns:
- The number of parameters to this function.
- See Also:
getParam(int)
-
getShowParameterToolTip
public boolean getShowParameterToolTip()
Description copied from interface:ParameterizedCompletionReturns whether a tool tip displaying assistance for each parameter while it is being edited is appropriate for this completion.- Specified by:
getShowParameterToolTipin interfaceParameterizedCompletion- Returns:
- Whether the tool tip is appropriate to display.
-
getParamText
private java.lang.String getParamText(ParameterizedCompletion.Parameter param)
Returns the text to insert for a parameter.- Parameters:
param- The parameter.- Returns:
- The text.
-
getReturnValueDescription
public java.lang.String getReturnValueDescription()
Returns the description of the return value of this function.- Returns:
- The description, or
nullif there is none. - See Also:
setReturnValueDescription(String)
-
getSummary
public java.lang.String getSummary()
Description copied from interface:CompletionReturns the description of this auto-complete choice. This can be used in a popup "description window."- Specified by:
getSummaryin interfaceCompletion- Overrides:
getSummaryin classVariableCompletion- Returns:
- This item's description. This should be HTML. It may be
nullif there is no description for this completion.
-
getToolTipText
public java.lang.String getToolTipText()
Description copied from class:VariableCompletionReturns the tool tip text to display for mouse hovers over this completion.Note that for this functionality to be enabled, a
JTextComponentmust be registered with theToolTipManager, and the text component must know to search for this value. In the case of an RSyntaxTextArea, this can be done with aorg.fife.ui.rtextarea.ToolTipSupplierthat calls intoCompletionProvider.getCompletionsAt(JTextComponent, java.awt.Point).- Specified by:
getToolTipTextin interfaceCompletion- Overrides:
getToolTipTextin classVariableCompletion- Returns:
- The tool tip text for this completion, or
nullif none.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
setParams
public void setParams(java.util.List<ParameterizedCompletion.Parameter> params)
Sets the parameters to this function.- Parameters:
params- The parameters. This should be a list ofParameterizedCompletion.Parameters.- See Also:
getParam(int),getParamCount()
-
setReturnValueDescription
public void setReturnValueDescription(java.lang.String desc)
Sets the description of the return value of this function.- Parameters:
desc- The description.- See Also:
getReturnValueDescription()
-
-