@jupyter-lsp/jupyterlab-lsp
Version:
Language Server Protocol integration for JupyterLab
97 lines (96 loc) • 4.34 kB
TypeScript
import { JupyterFrontEndPlugin } from '@jupyterlab/application';
import { CodeEditor } from '@jupyterlab/codeeditor';
import { IRootPosition, IVirtualPosition, WidgetLSPAdapter, Document } from '@jupyterlab/lsp';
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
import { LabIcon } from '@jupyterlab/ui-components';
import { Throttler } from '@lumino/polling';
import type * as lsProtocol from 'vscode-languageserver-protocol';
import { CodeHover as LSPHoverSettings, ModifierKey } from '../_hover';
import { EditorTooltipManager } from '../components/free_tooltip';
import { ContextAssembler } from '../context';
import { IEditorRange } from '../converter';
import { FeatureSettings, Feature } from '../feature';
import { ISimpleMarkManager } from '../marks';
import { BrowserConsole } from '../virtual/console';
import { VirtualDocument } from '../virtual/document';
export declare const hoverIcon: LabIcon;
interface IResponseData {
response: lsProtocol.Hover;
document: VirtualDocument;
editorRange: IEditorRange;
ceEditor: CodeEditor.IEditor;
}
declare class ResponseCache {
maxSize: number;
protected _data: Array<IResponseData>;
get data(): IResponseData[];
constructor(maxSize: number);
store(item: IResponseData): void;
clean(): void;
}
interface IContext {
adapter: WidgetLSPAdapter<any>;
token: CodeEditor.IToken;
editor: CodeEditor.IEditor;
editorAccessor: Document.IEditor;
}
export declare class HoverFeature extends Feature {
readonly capabilities: lsProtocol.ClientCapabilities;
readonly id: string;
tooltipManager: EditorTooltipManager;
protected console: BrowserConsole;
protected settings: FeatureSettings<LSPHoverSettings>;
protected lastHoverCharacter: IRootPosition | null;
private lastHoverResponse;
protected hasMarker: boolean;
protected markManager: ISimpleMarkManager<'hover'>;
private virtualPosition;
protected cache: ResponseCache;
protected contextAssembler: ContextAssembler;
private debouncedGetHover;
private tooltip;
private _previousHoverRequest;
constructor(options: HoverFeature.IOptions);
protected createThrottler(): Throttler<Promise<lsProtocol.Hover | null>, void, [VirtualDocument, IVirtualPosition, IContext]>;
protected get modifierKey(): ModifierKey;
protected get isHoverAutomatic(): boolean;
protected restoreFromCache(document: VirtualDocument, virtualPosition: IVirtualPosition): IResponseData | null;
protected onKeyDown: (event: KeyboardEvent, adapter: WidgetLSPAdapter<any>) => void;
protected onMouseLeave: (event: MouseEvent) => void;
protected maybeHideTooltip(mouseEvent: MouseEvent): void;
afterChange(): void;
protected getHover: (virtualDocument: VirtualDocument, virtualPosition: IVirtualPosition, context: IContext) => Promise<lsProtocol.Hover | null>;
protected static getMarkupForHover(response: lsProtocol.Hover): lsProtocol.MarkupContent;
/**
* marks the word if a tooltip is available.
* Displays tooltip if asked to do so.
*
* Returns true is the tooltip was shown.
*/
handleResponse: (adapter: WidgetLSPAdapter<any>, responseData: IResponseData, rootPosition: IRootPosition, showTooltip: boolean) => boolean;
protected isTokenEmpty(token: CodeEditor.IToken): boolean;
protected isEventInsideVisible(event: MouseEvent): boolean;
protected isResponseUseful(response: lsProtocol.Hover): boolean | "";
/**
* Returns true if the tooltip should stay.
*/
protected _updateUnderlineAndTooltip(event: MouseEvent, adapter: WidgetLSPAdapter<any>): Promise<boolean>;
protected updateUnderlineAndTooltip: (event: MouseEvent, adapter: WidgetLSPAdapter<any>) => Promise<boolean> | undefined;
protected removeRangeHighlight: () => void;
remove(): void;
/**
* Construct the range to underline manually using the token information.
*/
private _getEditorRange;
private _addRange;
}
export declare namespace HoverFeature {
interface IOptions extends Feature.IOptions {
settings: FeatureSettings<LSPHoverSettings>;
renderMimeRegistry: IRenderMimeRegistry;
contextAssembler: ContextAssembler;
}
const id: string;
}
export declare const HOVER_PLUGIN: JupyterFrontEndPlugin<void>;
export {};