Module platform

Interface CompletionProvider

All Known Implementing Classes:
AbstractCompletionProvider, ChildrenCompletionProvider, ClassCompletionProvider, CompletionProviderBase, DefaultCompletionProvider, XLContextCompletionProvider

public interface CompletionProvider
Provides autocompletion values to an AutoCompletion.

Completion providers can have an optional parent. Parents are searched for completions when their children are. This allows for chaining of completion providers.

Version:
1.0
Author:
Robert Futrell
  • Method Details

    • clearParameterizedCompletionParams

      void clearParameterizedCompletionParams()
      Clears the values used to identify and insert "parameterized completions" (e.g. functions or methods). After this method is called, functions and methods will not have their parameters auto-completed.
      See Also:
    • getAlreadyEnteredText

      String getAlreadyEnteredText(AutoCompletableTextArea comp)
      Returns the text just before the current caret position that could be the start of something auto-completable.
      Parameters:
      comp - The text component.
      Returns:
      The text. A return value of null means nothing should be auto-completed; a value of an empty string ("") means auto-completion should still be considered (i.e., all possible choices are valid).
    • isValidChar

      boolean isValidChar(char c)
      Test if a char is valid for this completion
    • getCompletions

      List<Completion> getCompletions(AutoCompletableTextArea comp)
      Gets the possible completions for the text component at the current caret position.
      Parameters:
      comp - The text component.
      Returns:
      The list of Completions. If no completions are available, this method should return an empty list.
    • getCompletionsAt

      List<Completion> getCompletionsAt(AutoCompletableTextArea comp, Point p)
      Returns the completions that have been entered at the specified visual location. This can be used for tool tips when the user hovers the mouse over completed text.
      Parameters:
      comp - The text component.
      p - The position, usually from a MouseEvent.
      Returns:
      The completions, or an empty list if there are none.
    • getListCellRenderer

      ListCellRenderer<Object> getListCellRenderer()
      Returns the cell renderer for completions returned from this provider.
      Returns:
      The cell renderer, or null if the default should be used.
      See Also:
    • getParameterChoicesProvider

      ParameterChoicesProvider getParameterChoicesProvider()
      Returns an object that can return a list of completion choices for parameters. This is used when a user code-completes a parameterized completion, such as a function or method. For any parameter to the function/method, this object can return possible completions.
      Returns:
      The parameter choices provider, or null if none is installed.
    • getParameterizedCompletions

      List<ParameterizedCompletion> getParameterizedCompletions(AutoCompletableTextArea tc)
      Returns a list of parameterized completions that have been entered at the current caret position of a text component (and thus can have their completion choices displayed).
      Parameters:
      tc - The text component.
      Returns:
      The list of ParameterizedCompletions. If no completions are available, this may be null.
    • getParameterListEnd

      char getParameterListEnd()
      Returns the text that marks the end of a list of parameters to a function or method.
      Returns:
      The text for a parameter list end, for example, ')', or 0 if none.
      See Also:
    • getParameterListSeparator

      String getParameterListSeparator()
      Returns the text that separates parameters to a function or method.
      Returns:
      The text that separates parameters, for example, ", ".
      See Also:
    • getParameterListStart

      char getParameterListStart()
      Returns the text that marks the start of a list of parameters to a function or method.
      Returns:
      The text for a parameter list start, for example, "(".
      See Also:
    • getParent

      CompletionProvider getParent()
      Returns the parent completion provider.
      Returns:
      The parent completion provider.
      See Also:
    • isAutoActivateOkay

      boolean isAutoActivateOkay(AutoCompletableTextArea tc)
      This method is called if auto-activation is enabled in the parent AutoCompletion after the user types a single character. This provider should check the text at the current caret position of the text component, and decide whether auto-activation would be appropriate here. For example, a CompletionProvider for Java might want to return true for this method only if the last character typed was a '.'.
      Parameters:
      tc - The text component.
      Returns:
      Whether auto-activation would be appropriate.
    • setListCellRenderer

      void setListCellRenderer(ListCellRenderer<Object> r)
      Sets the renderer to use when displaying completion choices.
      Parameters:
      r - The renderer to use.
      See Also:
    • setParameterizedCompletionParams

      void setParameterizedCompletionParams(char listStart, String separator, char listEnd)
      Sets the values used to identify and insert "parameterized completions" (e.g. functions or methods). If this method isn't called, functions and methods will not have their parameters auto-completed.
      Parameters:
      listStart - The character that marks the beginning of a list of parameters, such as '(' in C or Java.
      separator - Text that should separate parameters in a parameter list when one is inserted. For example, ", ".
      listEnd - The character that marks the end of a list of parameters, such as ')' in C or Java.
      Throws:
      IllegalArgumentException - If either listStart or listEnd is not printable ASCII, or if separator is null or an empty string.
      See Also:
    • setParent

      void setParent(CompletionProvider parent)
      Sets the parent completion provider.
      Parameters:
      parent - The parent provider. null means there will be no parent provider.
      See Also: