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

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    A comparator that compares the input text of two Completions lexicographically, ignoring case.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
     
    private boolean
     

    Fields inherited from class org.fife.ui.autocomplete.CompletionProviderBase

    EMPTY_STRING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    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
    Returns the provider to use when editing code.
    protected org.fife.ui.autocomplete.CompletionProvider
    Returns the completion provider to use when the caret is in a string.
    protected List<org.fife.ui.autocomplete.Completion>
     
    char
    Overridden to return the null char (meaning "no end character") if the user doesn't want to use parens around their functions.
    char
    Overridden to return the null char (meaning "no start character") if the user doesn't want to use parens around their functions.
    boolean
    Returns whether the user wants to use parens around parameters to functions.
    private SortedSet<org.fife.ui.autocomplete.Completion>
    Does a crude search for variables up to the caret position.
    protected String
    Returns the name of the XML resource to load (on classpath or a file).
    private void
    Recursively adds code blocks, remembering variables in them.
    private void
    recursivelyAddLocalVars(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
    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

    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
  • Field Details

  • Constructor Details

    • PerlCompletionProvider

      public PerlCompletionProvider()
  • Method Details

    • 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.
    • createCodeCompletionProvider

      protected org.fife.ui.autocomplete.CompletionProvider createCodeCompletionProvider()
      Description copied from class: CCompletionProvider
      Returns the provider to use when editing code.
      Overrides:
      createCodeCompletionProvider in class CCompletionProvider
      Returns:
      The provider.
      See Also:
    • createStringCompletionProvider

      protected org.fife.ui.autocomplete.CompletionProvider createStringCompletionProvider()
      Description copied from class: CCompletionProvider
      Returns the completion provider to use when the caret is in a string.
      Overrides:
      createStringCompletionProvider in class CCompletionProvider
      Returns:
      The provider.
      See Also:
    • getCompletionsImpl

      protected List<org.fife.ui.autocomplete.Completion> getCompletionsImpl(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:
    • 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

      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:
    • getVariableCompletions

      private SortedSet<org.fife.ui.autocomplete.Completion> getVariableCompletions(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 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(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: