Interface CompletionProvider

All Superinterfaces:
Proxy
All Known Implementing Classes:
CompletionProvider.CompletionProvider$Impl, CompletionSnippets, CompletionWords

@Generated("org.javagi.JavaGI") public interface CompletionProvider extends Proxy

Completion provider interface.

You must implement this interface to provide proposals to Completion.

In most cases, implementations of this interface will want to use populateAsync(CompletionContext, Cancellable, AsyncReadyCallback) to asynchronously populate the results to avoid blocking the main loop.

  • Method Details

    • getType

      static @Nullable Type getType()
      Get the GType of the CompletionProvider class.
      Returns:
      the GType
    • activate

      default void activate(CompletionContext context, CompletionProposal proposal)

      This function requests proposal to be activated by the GtkSourceCompletionProvider.

      What the provider does to activate the proposal is specific to that provider. Many providers may choose to insert a GtkSourceSnippet with edit points the user may cycle through.

      See also: Snippet, SnippetChunk, View.pushSnippet(Snippet, TextIter)

      Parameters:
      context - a GtkSourceCompletionContext
      proposal - a GtkSourceCompletionProposal
    • display

      default void display(CompletionContext context, CompletionProposal proposal, CompletionCell cell)

      This function requests that the GtkSourceCompletionProvider prepares cell to display the contents of proposal.

      Based on cells column type, you may want to display different information.

      This allows for columns of information among completion proposals resulting in better alignment of similar content (icons, return types, method names, and parameter lists).

      Parameters:
      context - a GtkSourceCompletionContext
      proposal - a GtkSourceCompletionProposal
      cell - a GtkSourceCompletionCell
    • getPriority

      default int getPriority(CompletionContext context)

      This function should return the priority of this CompletionProvider in context.

      The priority is used to sort groups of completion proposals by provider so that higher priority providers results are shown above lower priority providers.

      Higher value indicates higher priority.

      Parameters:
      context - a GtkSourceCompletionContext
    • getTitle

      default @Nullable String getTitle()

      Gets the title of the completion provider, if any.

      Currently, titles are not displayed in the completion results, but may be at some point in the future when non-null.

      Returns:
      a title for the provider or null
    • isTrigger

      default boolean isTrigger(TextIter iter, int ch)

      This function is used to determine if a character inserted into the text editor should cause a new completion request to be triggered.

      An example would be period '.' which might indicate that the user wants to complete method or field names of an object.

      This method will only trigger when text is inserted into the GtkTextBuffer while the completion list is visible and a proposal is selected. Incremental key-presses (like shift, control, or alt) are not triggerable.

      Parameters:
      iter - a GtkTextIter
      ch - a gunichar of the character inserted
    • keyActivates

      default boolean keyActivates(CompletionContext context, CompletionProposal proposal, int keyval, Set<ModifierType> state)

      This function is used to determine if a key typed by the user should activate proposal (resulting in committing the text to the editor).

      This is useful when using languages where convention may lead to less typing by the user. One example may be the use of "." or "-" to expand a field access in the C programming language.

      Parameters:
      context - a GtkSourceCompletionContext
      proposal - a GtkSourceCompletionProposal
      keyval - a keyval such as Gdk.KEY_period
      state - a GdkModifierType or 0
    • keyActivates

      default boolean keyActivates(CompletionContext context, CompletionProposal proposal, int keyval, ModifierType... state)

      This function is used to determine if a key typed by the user should activate proposal (resulting in committing the text to the editor).

      This is useful when using languages where convention may lead to less typing by the user. One example may be the use of "." or "-" to expand a field access in the C programming language.

      Parameters:
      context - a GtkSourceCompletionContext
      proposal - a GtkSourceCompletionProposal
      keyval - a keyval such as Gdk.KEY_period
      state - a GdkModifierType or 0
    • listAlternates

      default @Nullable CompletionProposal @Nullable [] listAlternates(CompletionContext context, CompletionProposal proposal)

      Providers should return a list of alternates to proposal or null if there are no alternates available.

      This can be used by the completion view to allow the user to move laterally through similar proposals, such as overrides of methods by the same name.

      Parameters:
      context - a GtkSourceCompletionContext
      proposal - a GtkSourceCompletionProposal
      Returns:
      a GPtrArray of GtkSourceCompletionProposal or null.
    • populateAsync

      default void populateAsync(CompletionContext context, @Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously requests that the provider populates the completion results for context.

      For providers that would like to populate a ListModel while those results are displayed to the user, CompletionContext.setProposalsForProvider(CompletionProvider, ListModel) may be used to reduce latency until the user sees results.

      Parameters:
      context - a GtkSourceCompletionContext
      cancellable - a GCancellable or null
      callback - a callback to execute upon completion
    • populateFinish

      default ListModel populateFinish(AsyncResult result) throws GErrorException
      Completes an asynchronous operation to populate a completion provider.
      Parameters:
      result - a GAsyncResult provided to callback
      Returns:
      a GListModel of GtkSourceCompletionProposal
      Throws:
      GErrorException - see GError
    • refilter

      default void refilter(CompletionContext context, ListModel model)

      This function can be used to filter results previously provided to the CompletionContext by the GtkSourceCompletionProvider.

      This can happen as the user types additional text onto the word so that previously matched items may be removed from the list instead of generating new ListModel of results.

      Parameters:
      context - a GtkSourceCompletionContext
      model - a GListModel