@jupyterlab/lsp
Version:
107 lines (106 loc) • 3.18 kB
TypeScript
import { ISignal } from '@lumino/signaling';
import { WidgetLSPAdapter } from './adapter';
import { IShell, IWidgetLSPAdapterTracker } from '../tokens';
/**
* A class that keeps track of widget adapter instances.
*
* @typeparam T - The type of widget being tracked. Defaults to `WidgetLSPAdapter`.
*/
export declare class WidgetLSPAdapterTracker<T extends WidgetLSPAdapter = WidgetLSPAdapter> implements IWidgetLSPAdapterTracker<T> {
/**
* Create a new widget tracker.
*
* @param options - The instantiation options for a widget tracker.
*/
constructor(options: WidgetLSPAdapterTracker.IOptions);
/**
* A signal emitted when the current adapter changes.
*/
get currentChanged(): ISignal<this, T | null>;
/**
* The current adapter is the most recently focused or added adapter.
*
* #### Notes
* It is the most recently focused adapter, or the most recently added
* adapter if no adapter has taken focus.
*/
get currentAdapter(): T | null;
/**
* The number of adapter held by the tracker.
*/
get size(): number;
/**
* A signal emitted when an adapter is added.
*/
get adapterAdded(): ISignal<this, T>;
/**
* A signal emitted when an adapter is updated.
*/
get adapterUpdated(): ISignal<this, T>;
/**
* Add a new adapter to the tracker.
*
* @param adapter - The adapter being added.
*
* #### Notes.
* The newly added adapter becomes the current adapter unless the shell
* already had a DocumentWidget as the activeWidget.
*/
add(adapter: T): void;
/**
* Test whether the tracker is disposed.
*/
get isDisposed(): boolean;
/**
* Dispose of the resources held by the tracker.
*/
dispose(): void;
/**
* Find the first adapter in the tracker that satisfies a filter function.
*
* @param fn The filter function to call on each adapter.
*
* #### Notes
* If no adapter is found, the value returned is `undefined`.
*/
find(fn: (adapter: T) => boolean): T | undefined;
/**
* Iterate through each adapter in the tracker.
*
* @param fn - The function to call on each adapter.
*/
forEach(fn: (adapter: T) => void): void;
/**
* Filter the adapter in the tracker based on a predicate.
*
* @param fn - The function by which to filter.
*/
filter(fn: (adapter: T) => boolean): T[];
/**
* Check if this tracker has the specified adapter.
*
* @param adapter - The adapter whose existence is being checked.
*/
has(adapter: T): boolean;
private _isDisposed;
private _shell;
private _current;
private _adapters;
private _adapterAdded;
private _adapterUpdated;
private _currentChanged;
}
/**
* A namespace for `WidgetLSPAdapterTracker` statics.
*/
export declare namespace WidgetLSPAdapterTracker {
/**
* The instantiation options for the WidgetLSPAdapterTracker.
*/
interface IOptions {
/**
* The JupyterLab shell for tracking all widgets.
*/
shell: IShell;
}
}