Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CompletionHandler

A completion handler for editors. A namespace for cell completion handler statics.

Hierarchy

  • CompletionHandler

Implements

  • IDisposable

Index

Constructors

constructor

Properties

Private _connector

_connector: IDataConnector<IReply, void, IRequest>

Private _editor

_editor: IEditor | null = null

Private _enabled

_enabled: boolean = false

Private _isDisposed

_isDisposed: boolean = false

Private _pending

_pending: number = 0

completer

completer: Completer

The completer widget managed by the handler.

Accessors

connector

  • The data connector used to populate completion requests.

    Notes

    The only method of this connector that will ever be called is fetch, so it is acceptable for the other methods to be simple functions that return rejected promises.

    Returns IDataConnector<IReply, void, IRequest>

  • The data connector used to populate completion requests.

    Notes

    The only method of this connector that will ever be called is fetch, so it is acceptable for the other methods to be simple functions that return rejected promises.

    Parameters

    Returns void

editor

  • get editor(): IEditor | null
  • set editor(newValue: IEditor | null): void
  • The editor used by the completion handler.

    Returns IEditor | null

  • The editor used by the completion handler.

    Parameters

    • newValue: IEditor | null

    Returns void

isDisposed

  • get isDisposed(): boolean
  • Get whether the completion handler is disposed.

    Returns boolean

Methods

Private _makeRequest

  • _makeRequest(position: IPosition): Promise<void>
  • Make a completion request.

    Parameters

    • position: IPosition

    Returns Promise<void>

Private _onReply

  • Receive a completion reply from the connector.

    Parameters

    • state: ITextState

      The state of the editor when completion request was made.

    • reply: IReply

      The API response returned for a completion request.

    Returns void

dispose

  • dispose(): void
  • Dispose of the resources used by the handler.

    Returns void

Protected getState

  • getState(editor: IEditor, position: IPosition): ITextState
  • Get the state of the text editor at the given position.

    Parameters

    • editor: IEditor
    • position: IPosition

    Returns ITextState

invoke

  • invoke(): void
  • Invoke the handler and launch a completer.

    Returns void

Protected onCompletionSelected

  • onCompletionSelected(completer: Completer, val: string): void
  • Handle a completion selected signal from the completion widget.

    Parameters

    Returns void

Protected onInvokeRequest

  • onInvokeRequest(msg: Message): void
  • Handle invoke-request messages.

    Parameters

    • msg: Message

    Returns void

Protected onSelectionsChanged

  • onSelectionsChanged(): void
  • Handle selection changed signal from an editor.

    Notes

    If a sub-class reimplements this method, then that class must either call its super method or it must take responsibility for adding and removing the completer completable class to the editor host node.

    Despite the fact that the editor widget adds a class whenever there is a primary selection, this method checks independently for two reasons:

    1. The editor widget connects to the same signal to add that class, so there is no guarantee that the class will be added before this method is invoked so simply checking for the CSS class's existence is not an option. Secondarily, checking the editor state should be faster than querying the DOM in either case.
    2. Because this method adds a class that indicates whether completer functionality ought to be enabled, relying on the behavior of the jp-mod-has-primary-selection to filter out any editors that have a selection means the semantic meaning of jp-mod-completer-enabled is obscured because there may be cases where the enabled class is added even though the completer is not available.

    Returns void

Protected onTextChanged

  • onTextChanged(): void
  • Handle a text changed signal from an editor.

    Returns void

Protected onVisibilityChanged

  • onVisibilityChanged(completer: Completer): void
  • Handle a visibility change signal from a completer widget.

    Parameters

    Returns void

processMessage

  • processMessage(msg: Message): void
  • Process a message sent to the completion handler.

    Parameters

    • msg: Message

    Returns void

Generated using TypeDoc