Class 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.
    To toggle whether parameter assistance wraps your parameters in parens, use the setUseParensWithFunctions(boolean) method.
    Version:
    1.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addShorthandCompletions​(org.fife.ui.autocomplete.DefaultCompletionProvider codeCP)
      Adds shorthand completions to the code completion provider.
      private CodeBlock createAst​(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.CompletionProvider createCodeCompletionProvider()
      Returns the provider to use when editing code.
      protected org.fife.ui.autocomplete.CompletionProvider createStringCompletionProvider()
      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)  
      char getParameterListEnd()
      Overridden to return the null char (meaning "no end character") if the user doesn't want to use parens around their functions.
      char getParameterListStart()
      Overridden to return the null char (meaning "no start character") if the user doesn't want to use parens around their functions.
      boolean getUseParensWithFunctions()
      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.String getXmlResource()
      Returns the name of the XML resource to load (on classpath or a file).
      private void parseCodeBlock​(TokenScanner scanner, CodeBlock block)
      Recursively adds code blocks, remembering variables in them.
      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).
      void setUseParensWithFunctions​(boolean use)
      Sets whether the user wants to use parens around parameters to functions.
      • 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
      • Methods inherited from class org.fife.ui.autocomplete.CompletionProviderBase

        getCompletions, getListCellRenderer, getParameterChoicesProvider, getParent, setAutoActivationRules, setListCellRenderer, setParameterChoicesProvider, setParent
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PerlCompletionProvider

        public PerlCompletionProvider()
    • Method Detail

      • addShorthandCompletions

        protected void addShorthandCompletions​(org.fife.ui.autocomplete.DefaultCompletionProvider codeCP)
        Description copied from class: CCompletionProvider
        Adds shorthand completions to the code completion provider.
        Overrides:
        addShorthandCompletions in class CCompletionProvider
        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.
      • getCompletionsImpl

        protected java.util.List<org.fife.ui.autocomplete.Completion> getCompletionsImpl​(javax.swing.text.JTextComponent comp)
        Overrides:
        getCompletionsImpl in class org.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:
        getParameterListEnd in interface org.fife.ui.autocomplete.CompletionProvider
        Overrides:
        getParameterListEnd in class org.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:
        getParameterListStart in interface org.fife.ui.autocomplete.CompletionProvider
        Overrides:
        getParameterListStart in class org.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 null if there were none.
      • getXmlResource

        protected java.lang.String getXmlResource()
        Description copied from class: CCompletionProvider
        Returns the name of the XML resource to load (on classpath or a file).
        Overrides:
        getXmlResource in class CCompletionProvider
        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()