IdeCompletionProvider: Builder SDK Reference

## IdeCompletionProvider IdeCompletionProvider |

## Functions

GIcon * | ide_completion_provider_get_icon ()
gint | ide_completion_provider_get_priority ()
gchar * | ide_completion_provider_get_title ()
void | ide_completion_provider_populate_async ()
GListModel * | ide_completion_provider_populate_finish ()
void | ide_completion_provider_display_proposal ()
void | ide_completion_provider_activate_poposal ()
gboolean | ide_completion_provider_refilter ()
gboolean | ide_completion_provider_is_trigger ()
gboolean | ide_completion_provider_key_activates ()
gchar * | ide_completion_provider_get_comment ()

## Types and Values

#define | IDE_TYPE_COMPLETION_PROVIDER
struct | IdeCompletionProviderInterface
| IdeCompletionProvider

## Object Hierarchy

        GInterface
        ╰── IdeCompletionProvider

## Prerequisites

IdeCompletionProvider requires GObject.

## Known Implementations

IdeCompletionProvider is implemented by IdeLspCompletionProvider.

## Description

## Functions

### ide_completion_provider_get_icon ()

    GIcon *
    ide_completion_provider_get_icon (IdeCompletionProvider *self);

Gets the GIcon to represent this provider. This may be used in UI to allow the user to filter the results to only those of this completion provider.

#### Parameters

self | an IdeCompletionProvider |

#### Returns

a GIcon or `NULL`.

[transfer full][nullable]

Since: 3.32

### ide_completion_provider_get_priority ()

    gint
    ide_completion_provider_get_priority (IdeCompletionProvider *self,
                                          IdeCompletionContext *context);

Gets the priority for the completion provider.

This value is used to group all of the providers proposals together when displayed, with relation to other providers.

The `context` is provided as some providers may want to lower their priority based on the position of the completion.

#### Parameters

self | an IdeCompletionProvider |
context | an IdeCompletionContext |

#### Returns

an integer specific to the provider

Since: 3.32

### ide_completion_provider_get_title ()

    gchar *
    ide_completion_provider_get_title (IdeCompletionProvider *self);

Gets the title for the provider. This may be used in UI to give the user context about the type of results that are displayed.

#### Parameters

self | an IdeCompletionProvider |

#### Returns

a string or `NULL`.

[transfer full][nullable]

Since: 3.32

### ide_completion_provider_populate_async ()

    void
    ide_completion_provider_populate_async
                                   (IdeCompletionProvider *self,
                                    IdeCompletionContext *context,
                                    GCancellable *cancellable,
                                    GAsyncReadyCallback callback,
                                    gpointer user_data);

Asynchronously requests the provider populate the contents.

For completion providers that can provide intermediate results immediately, use `ide_completion_context_set_proposals_for_provider()` to notify of results while the async operation is in progress.

#### Parameters

self | an IdeCompletionProvider |
context | the completion context |
cancellable | a GCancellable, or `NULL`. | [nullable]
callback | a GAsyncReadyCallback or `NULL`. Called when the provider has completed loading proposals. | [nullable][scope async][closure user_data]
user_data | closure data for `callback` |

Since: 3.32

### ide_completion_provider_populate_finish ()

    GListModel *
    ide_completion_provider_populate_finish
                                   (IdeCompletionProvider *self,
                                    GAsyncResult *result,
                                    GError **error);

#### Parameters

self | an IdeCompletionProvider |
result | a GAsyncResult provided to callback |
error | a location for a GError, or `NULL` |

#### Returns

a GListModel of IdeCompletionProposal.

[transfer full]

Since: 3.32

### ide_completion_provider_display_proposal ()

    void
    ide_completion_provider_display_proposal
                                   (IdeCompletionProvider *self,
                                    IdeCompletionListBoxRow *row,
                                    IdeCompletionContext *context,
                                    const gchar *typed_text,
                                    IdeCompletionProposal *proposal);

Requests that the provider update `row` with values from `proposal` .

The design rational about having this operation part of the IdeCompletionProvider interface (as opposed to the IdeCompletionProposal interface) is that it allows for some optimizations and code simplification on behalf of completion providers.

#### Parameters

self | a IdeCompletionProvider |
row | an IdeCompletionListBoxRow |
context | an IdeCompletionContext |
typed_text | the typed text for the proposal. | [nullable]
proposal | an IdeCompletionProposal |

Since: 3.32

### ide_completion_provider_activate_poposal ()

    void
    ide_completion_provider_activate_poposal
                                   (IdeCompletionProvider *self,
                                    IdeCompletionContext *context,
                                    IdeCompletionProposal *proposal,
                                    const GdkEventKey *key);

### ide_completion_provider_refilter ()

    gboolean
    ide_completion_provider_refilter (IdeCompletionProvider *self,
                                      IdeCompletionContext *context,
                                      GListModel *proposals);

This requests that the completion provider refilter the results based on changes to the IdeCompletionContext, such as additional text typed by the user. If the provider can refine the results, then the provider should do so and return `TRUE`.

Otherwise, `FALSE` is returned and the context will request a new set of completion results.

#### Parameters

self | an IdeCompletionProvider |
context | an IdeCompletionContext |
proposals | a GListModel of results previously provided to the context |

#### Returns

`TRUE` if refiltered; otherwise `FALSE`

Since: 3.32

### ide_completion_provider_is_trigger ()

    gboolean
    ide_completion_provider_is_trigger (IdeCompletionProvider *self,
                                        const GtkTextIter *iter,
                                        gunichar ch);

Completion providers may want to trigger that the completion window is displayed upon insertion of a particular character. For example, a C indenter might want to trigger after -> or . is inserted.

`ch` is set to the character that was just inserted. If you need something more complex, copy `iter` and move it backwards twice to check the character previous to `ch` .

#### Parameters

self | an IdeCompletionProvider |
iter | the current insertion point |
ch | the character that was just inserted |

#### Returns

`TRUE` to request that the completion window is displayed.

Since: 3.32

### ide_completion_provider_key_activates ()

    gboolean
    ide_completion_provider_key_activates (IdeCompletionProvider *self,
                                           IdeCompletionProposal *proposal,
                                           const GdkEventKey *key);

This function is called to ask the provider if the key-press event should force activation of the proposal. This is useful for languages where you might want to activate the completion from a language-specific character.

For example, in C, you might want to use period (.) to activate the completion and insert either (.) or (->) based on the type.

#### Parameters

self | a IdeCompletionProvider |
proposal | an IdeCompletionProposal created by the provider |
key | the GdkEventKey for the current keyboard event |

#### Returns

`TRUE` if the proposal should be activated.

Since: 3.32

### ide_completion_provider_get_comment ()

    gchar *
    ide_completion_provider_get_comment (IdeCompletionProvider *self,
                                         IdeCompletionProposal *proposal);

If the completion proposal has a comment, the provider should return a newly allocated string containing it.

This is displayed at the bottom of the completion window.

#### Parameters

self | an IdeCompletionProvider |
proposal | an IdeCompletionProposal |

#### Returns

A new string or `NULL`.

[transfer full][nullable]

Since: 3.32

## Types and Values

### IDE_TYPE_COMPLETION_PROVIDER

    #define IDE_TYPE_COMPLETION_PROVIDER (ide_completion_provider_get_type ())

### struct IdeCompletionProviderInterface

    struct IdeCompletionProviderInterface {
      GTypeInterface parent;

      void        (*load)              (IdeCompletionProvider    *self,
                                        IdeContext               *context);
      GIcon      *(*get_icon)          (IdeCompletionProvider    *self);
      gint        (*get_priority)      (IdeCompletionProvider    *self,
                                        IdeCompletionContext     *context);
      gchar      *(*get_title)         (IdeCompletionProvider    *self);
      void        (*populate_async)    (IdeCompletionProvider    *self,
                                        IdeCompletionContext     *context,
                                        GCancellable             *cancellable,
                                        GAsyncReadyCallback       callback,
                                        gpointer                  user_data);
      GListModel *(*populate_finish)   (IdeCompletionProvider    *self,
                                        GAsyncResult             *result,
                                        GError                  **error);
      void        (*display_proposal)  (IdeCompletionProvider    *self,
                                        IdeCompletionListBoxRow  *row,
                                        IdeCompletionContext     *context,
                                        const gchar              *typed_text,
                                        IdeCompletionProposal    *proposal);
      void        (*activate_proposal) (IdeCompletionProvider    *self,
                                        IdeCompletionContext     *context,
                                        IdeCompletionProposal    *proposal,
                                        const GdkEventKey        *key);
      gboolean    (*refilter)          (IdeCompletionProvider    *self,
                                        IdeCompletionContext     *context,
                                        GListModel               *proposals);
      gboolean    (*is_trigger)        (IdeCompletionProvider    *self,
                                        const GtkTextIter        *iter,
                                        gunichar                  ch);
      gboolean    (*key_activates)     (IdeCompletionProvider    *self,
                                        IdeCompletionProposal    *proposal,
                                        const GdkEventKey        *key);
      gchar      *(*get_comment)       (IdeCompletionProvider    *self,
                                        IdeCompletionProposal    *proposal);
    };

### IdeCompletionProvider

    typedef struct _IdeCompletionProvider IdeCompletionProvider;