public class TemplateCompletion extends AbstractCompletion implements ParameterizedCompletion
The format of a template is similar to those in Eclipse. The following example would be the format for a for-loop template:
for (int ${i} = 0; ${i} < ${array}.length; ${i}++) {
${cursor}
}
In the above example, the first ${i} is a parameter for the
user to type into; all the other ${i} instances are
automatically changed to what the user types in the first one. The parameter
named ${cursor} is the "ending position" of the template. It's
where the caret moves after it cycles through all other parameters. If the
user types into it, template mode terminates. If more than one
${cursor} parameter is specified, behavior is undefined.
Two dollar signs in a row ("$$") will be evaluated as a single
dollar sign. Otherwise, the template parsing is pretty straightforward and
fault-tolerant.
Leading whitespace is automatically added to lines if the template spans
more than one line, and if used with a text component using a
PlainDocument, tabs will be converted to spaces if requested.
ParameterizedCompletion.Parameter| Constructor and Description |
|---|
TemplateCompletion(CompletionProvider provider,
java.lang.String inputText,
java.lang.String definitionString,
java.lang.String template) |
TemplateCompletion(CompletionProvider provider,
java.lang.String inputText,
java.lang.String definitionString,
java.lang.String template,
java.lang.String shortDescription,
java.lang.String summary) |
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getDefinitionString()
Returns the "definition string" for this completion.
|
java.lang.String |
getInputText()
Returns the text the user has to (start) typing for this completion
to be offered.
|
org.fife.ui.autocomplete.ParameterizedCompletionInsertionInfo |
getInsertionInfo(javax.swing.text.JTextComponent tc,
boolean replaceTabsWithSpaces) |
ParameterizedCompletion.Parameter |
getParam(int index)
Returns the specified
ParameterizedCompletion.Parameter. |
int |
getParamCount()
Returns the number of parameters this completion takes.
|
java.lang.String |
getReplacementText()
Returns
null; template completions insert all of their
text via getInsertionInfo(). |
java.lang.String |
getShortDescription() |
boolean |
getShowParameterToolTip()
Returns whether a tool tip displaying assistance for each parameter
while it is being edited is appropriate for this completion.
|
java.lang.String |
getSummary()
Returns the description of this auto-complete choice.
|
void |
setShortDescription(java.lang.String shortDesc)
Sets the short description of this template completion.
|
java.lang.String |
toString()
Returns a string representation of this completion.
|
compareTo, getAlreadyEntered, getIcon, getProvider, getRelevance, getToolTipText, setIcon, setRelevanceclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcompareTo, getAlreadyEntered, getIcon, getProvider, getRelevance, getToolTipTextpublic TemplateCompletion(CompletionProvider provider, java.lang.String inputText, java.lang.String definitionString, java.lang.String template)
public TemplateCompletion(CompletionProvider provider, java.lang.String inputText, java.lang.String definitionString, java.lang.String template, java.lang.String shortDescription, java.lang.String summary)
public java.lang.String getInputText()
AbstractCompletionCompletion.getReplacementText().getInputText in interface CompletiongetInputText in class AbstractCompletionCompletion.getReplacementText()public java.lang.String getReplacementText()
null; template completions insert all of their
text via getInsertionInfo().getReplacementText in interface Completionnull always.Completion.getInputText()public java.lang.String getSummary()
CompletiongetSummary in interface Completionnull if there is no description for this
completion.public java.lang.String getDefinitionString()
ParameterizedCompletionprintf" function, this would return
"int printf(const char *, ...)".getDefinitionString in interface ParameterizedCompletionpublic java.lang.String getShortDescription()
public boolean getShowParameterToolTip()
getShowParameterToolTip in interface ParameterizedCompletionpublic org.fife.ui.autocomplete.ParameterizedCompletionInsertionInfo getInsertionInfo(javax.swing.text.JTextComponent tc,
boolean replaceTabsWithSpaces)
getInsertionInfo in interface ParameterizedCompletionpublic ParameterizedCompletion.Parameter getParam(int index)
ParameterizedCompletion.Parameter.getParam in interface ParameterizedCompletionindex - The index of the parameter to retrieve.ParameterizedCompletion.getParamCount()public int getParamCount()
getParamCount in interface ParameterizedCompletionParameterizedCompletion.getParam(int)public void setShortDescription(java.lang.String shortDesc)
shortDesc - The new short description.getShortDescription()public java.lang.String toString()
AbstractCompletionAbstractCompletion.getInputText().toString in class AbstractCompletion