Package org.fife.rsta.ac.perl
Class PerlCompletionProvider
- java.lang.Object
-
- org.fife.ui.autocomplete.CompletionProviderBase
-
- org.fife.ui.autocomplete.LanguageAwareCompletionProvider
-
- org.fife.rsta.ac.c.CCompletionProvider
-
- org.fife.rsta.ac.perl.PerlCompletionProvider
-
- All Implemented Interfaces:
org.fife.ui.autocomplete.CompletionProvider,org.fife.ui.rtextarea.ToolTipSupplier
public class PerlCompletionProvider extends CCompletionProvider
A completion provider for Perl. It provides:- Auto-completion for standard Perl 5.10 functions (read from an XML file).
- Crude auto-completion for variables. Only variables in scope at the current caret position are suggested, but there may still be issues with variable types, etc.
setUseParensWithFunctions(boolean)method.- Version:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classPerlCompletionProvider.CaseInsensitiveComparatorA comparator that compares the input text of twoCompletions lexicographically, ignoring case.
-
Field Summary
Fields Modifier and Type Field Description private PerlCompletionProvider.CaseInsensitiveComparatorcomparatorprivate booleanuseParensWithFunctions
-
Constructor Summary
Constructors Constructor Description PerlCompletionProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddShorthandCompletions(org.fife.ui.autocomplete.DefaultCompletionProvider codeCP)Adds shorthand completions to the code completion provider.private CodeBlockcreateAst(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)Creates an "AST" for Perl code, representing code blocks and variables inside those blocks.protected org.fife.ui.autocomplete.CompletionProvidercreateCodeCompletionProvider()Returns the provider to use when editing code.protected org.fife.ui.autocomplete.CompletionProvidercreateStringCompletionProvider()Returns the completion provider to use when the caret is in a string.protected java.util.List<org.fife.ui.autocomplete.Completion>getCompletionsImpl(javax.swing.text.JTextComponent comp)chargetParameterListEnd()Overridden to return the null char (meaning "no end character") if the user doesn't want to use parens around their functions.chargetParameterListStart()Overridden to return the null char (meaning "no start character") if the user doesn't want to use parens around their functions.booleangetUseParensWithFunctions()Returns whether the user wants to use parens around parameters to functions.private java.util.SortedSet<org.fife.ui.autocomplete.Completion>getVariableCompletions(javax.swing.text.JTextComponent comp)Does a crude search for variables up to the caret position.protected java.lang.StringgetXmlResource()Returns the name of the XML resource to load (on classpath or a file).private voidparseCodeBlock(TokenScanner scanner, CodeBlock block)Recursively adds code blocks, remembering variables in them.private voidrecursivelyAddLocalVars(java.util.SortedSet<org.fife.ui.autocomplete.Completion> completions, CodeBlock block, int dot, int firstChar)Recursively adds any local variables defined before the given caret offset, and in the given code block (and any nested children the caret is in).voidsetUseParensWithFunctions(boolean use)Sets whether the user wants to use parens around parameters to functions.-
Methods inherited from class org.fife.rsta.ac.c.CCompletionProvider
createCommentCompletionProvider, loadCodeCompletionsFromXml
-
Methods inherited from class org.fife.ui.autocomplete.LanguageAwareCompletionProvider
clearParameterizedCompletionParams, getAlreadyEnteredText, getCommentCompletionProvider, getCompletionsAt, getDefaultCompletionProvider, getDocCommentCompletionProvider, getParameterizedCompletions, getParameterListSeparator, getStringCompletionProvider, getToolTipText, isAutoActivateOkay, setCommentCompletionProvider, setDefaultCompletionProvider, setDocCommentCompletionProvider, setParameterizedCompletionParams, setStringCompletionProvider
-
-
-
-
Field Detail
-
useParensWithFunctions
private boolean useParensWithFunctions
-
comparator
private PerlCompletionProvider.CaseInsensitiveComparator comparator
-
-
Method Detail
-
addShorthandCompletions
protected void addShorthandCompletions(org.fife.ui.autocomplete.DefaultCompletionProvider codeCP)
Description copied from class:CCompletionProviderAdds shorthand completions to the code completion provider.- Overrides:
addShorthandCompletionsin classCCompletionProvider- Parameters:
codeCP- The code completion provider.
-
createAst
private CodeBlock createAst(org.fife.ui.rsyntaxtextarea.RSyntaxTextArea textArea)
Creates an "AST" for Perl code, representing code blocks and variables inside those blocks.- Parameters:
textArea- The text area.- Returns:
- A "code block" representing the entire Perl source file.
-
createCodeCompletionProvider
protected org.fife.ui.autocomplete.CompletionProvider createCodeCompletionProvider()
Description copied from class:CCompletionProviderReturns the provider to use when editing code.- Overrides:
createCodeCompletionProviderin classCCompletionProvider- Returns:
- The provider.
- See Also:
CCompletionProvider.createCommentCompletionProvider(),CCompletionProvider.createStringCompletionProvider(),CCompletionProvider.loadCodeCompletionsFromXml(DefaultCompletionProvider),CCompletionProvider.addShorthandCompletions(DefaultCompletionProvider)
-
createStringCompletionProvider
protected org.fife.ui.autocomplete.CompletionProvider createStringCompletionProvider()
Description copied from class:CCompletionProviderReturns the completion provider to use when the caret is in a string.- Overrides:
createStringCompletionProviderin classCCompletionProvider- Returns:
- The provider.
- See Also:
CCompletionProvider.createCodeCompletionProvider(),CCompletionProvider.createCommentCompletionProvider()
-
getCompletionsImpl
protected java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsImpl(javax.swing.text.JTextComponent comp)
- Overrides:
getCompletionsImplin classorg.fife.ui.autocomplete.LanguageAwareCompletionProvider
-
getParameterListEnd
public char getParameterListEnd()
Overridden to return the null char (meaning "no end character") if the user doesn't want to use parens around their functions.- Specified by:
getParameterListEndin interfaceorg.fife.ui.autocomplete.CompletionProvider- Overrides:
getParameterListEndin classorg.fife.ui.autocomplete.LanguageAwareCompletionProvider- Returns:
- The end character for parameters list, or the null char if none.
- See Also:
getUseParensWithFunctions()
-
getParameterListStart
public char getParameterListStart()
Overridden to return the null char (meaning "no start character") if the user doesn't want to use parens around their functions.- Specified by:
getParameterListStartin interfaceorg.fife.ui.autocomplete.CompletionProvider- Overrides:
getParameterListStartin classorg.fife.ui.autocomplete.LanguageAwareCompletionProvider- Returns:
- The start character for parameters list, or the null char if none.
- See Also:
getUseParensWithFunctions()
-
getUseParensWithFunctions
public boolean getUseParensWithFunctions()
Returns whether the user wants to use parens around parameters to functions.- Returns:
- Whether to use parens around parameters to functions.
- See Also:
setUseParensWithFunctions(boolean)
-
getVariableCompletions
private java.util.SortedSet<org.fife.ui.autocomplete.Completion> getVariableCompletions(javax.swing.text.JTextComponent comp)
Does a crude search for variables up to the caret position. This method does not care whether the variables are in scope at the caret position.- Parameters:
comp- The text area.- Returns:
- The completions for variables, or
nullif there were none.
-
getXmlResource
protected java.lang.String getXmlResource()
Description copied from class:CCompletionProviderReturns the name of the XML resource to load (on classpath or a file).- Overrides:
getXmlResourcein classCCompletionProvider- Returns:
- The resource to load.
-
parseCodeBlock
private void parseCodeBlock(TokenScanner scanner, CodeBlock block)
Recursively adds code blocks, remembering variables in them.- Parameters:
scanner- The scanner to read from.block- The code block update.
-
recursivelyAddLocalVars
private void recursivelyAddLocalVars(java.util.SortedSet<org.fife.ui.autocomplete.Completion> completions, CodeBlock block, int dot, int firstChar)Recursively adds any local variables defined before the given caret offset, and in the given code block (and any nested children the caret is in).- Parameters:
completions- The list to add to.block- The code block to search through.dot- The caret position.
-
setUseParensWithFunctions
public void setUseParensWithFunctions(boolean use)
Sets whether the user wants to use parens around parameters to functions.- Parameters:
use- Whether to use parens around parameters to functions.- See Also:
getUseParensWithFunctions()
-
-