import { Kernel, KernelMessage } from '@jupyterlab/services'; import { IDisposable } from '@phosphor/disposable'; import { Message } from '@phosphor/messaging'; import { CodeEditor } from '../codeeditor'; import { CompleterWidget } from './widget'; /** * A class added to editors that can host a completer. */ export declare const COMPLETABLE_CLASS: string; /** * A class added to editors that have an active completer. */ export declare const COMPLETER_ACTIVE_CLASS: string; /** * A completion handler for editors. */ export declare class CompletionHandler implements IDisposable { /** * Construct a new completion handler for a widget. */ constructor(options: CompletionHandler.IOptions); /** * The completer widget managed by the handler. */ readonly completer: CompleterWidget; /** * The editor used by the completion handler. */ editor: CodeEditor.IEditor; /** * Get whether the completion handler is disposed. */ readonly isDisposed: boolean; /** * The kernel used by the completion handler. */ kernel: Kernel.IKernel; /** * Dispose of the resources used by the handler. */ dispose(): void; /** * Invoke the handler and launch a completer. */ invoke(): void; /** * Process a message sent to the completion handler. */ processMessage(msg: Message): void; /** * Get the state of the text editor at the given position. */ protected getState(position: CodeEditor.IPosition): CompleterWidget.ITextState; /** * Make a complete request using the kernel. */ protected makeRequest(position: CodeEditor.IPosition): Promise; /** * Handle `invoke-request` messages. */ protected onInvokeRequest(msg: Message): void; /** * Receive a completion reply from the kernel. * * @param state - The state of the editor when completion request was made. * * @param reply - The API response returned for a completion request. */ protected onReply(state: CompleterWidget.ITextState, reply: KernelMessage.ICompleteReplyMsg): 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. */ protected onSelectionsChanged(): void; /** * Handle a text changed signal from an editor. */ protected onTextChanged(): void; /** * Handle a visiblity change signal from a completion widget. */ protected onVisibilityChanged(completion: CompleterWidget): void; /** * Handle a completion selected signal from the completion widget. */ protected onCompletionSelected(widget: CompleterWidget, value: string): void; private _editor; private _completer; private _kernel; private _pending; } /** * A namespace for cell completion handler statics. */ export declare namespace CompletionHandler { /** * The instantiation options for cell completion handlers. */ interface IOptions { /** * The completion widget the handler will connect to. */ completer: CompleterWidget; /** * The kernel for the completion handler. */ kernel?: Kernel.IKernel; } /** * A namespace for completion handler messages. */ namespace Msg { /** * A singleton `'invoke-request'` message. */ const InvokeRequest: Message; } }