All files / services/document document-context-service.interface.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121                                                                                                                                                                                                                                                 
import * as vscode from 'vscode';
import { IToken } from '@faubulous/mentor-rdf-parsers';
import { IDocumentContext } from '@src/services/document/document-context.interface';
import { DocumentIndex } from '@src/services/document/document-context-service';
 
/**
 * Interface for the DocumentContextService.
 */
export interface IDocumentContextService {
	/**
	 * Maps document URIs to loaded document contexts.
	 */
	readonly contexts: DocumentIndex;
 
	/**
	 * The currently active document context or `undefined`.
	 */
	activeContext: IDocumentContext | undefined;
 
	/**
	 * An event that is fired after the active document context has changed.
	 */
	readonly onDidChangeDocumentContext: vscode.Event<IDocumentContext | undefined>;
 
	/**
	 * Dispose the manager and clean up resources.
	 */
	dispose(): void;
 
	/**
	 * Get the document context from a URI.
	 * @param uri A document or workspace URI.
	 * @returns A document context if the document is loaded, `undefined` otherwise.
	 */
	getDocumentContextFromUri(uri: string): IDocumentContext | undefined;
 
	/**
	 * Get the document context from a text document.
	 * @param document A text document.
	 * @param contextType The expected type of the document context.
	 * @returns A document context of the specified type if the document is loaded and matches the type, null otherwise.
	 */
	getDocumentContext<T extends IDocumentContext>(document: vscode.TextDocument, contextType: new (...args: any[]) => T): T | null;
 
	/**
	 * Wait for tokens to be delivered from the language server for a document.
	 * @param uri The document URI to wait for tokens.
	 * @param timeout Optional timeout in milliseconds.
	 * @returns A promise that resolves with the tokens or rejects on timeout.
	 */
	waitForTokens(uri: string, timeout?: number): Promise<IToken[]>;
 
	/**
	 * Resolve pending token requests for a document. Called by language clients when tokens arrive.
	 * @param uri The document URI.
	 * @param tokens The tokens from the language server.
	 */
	resolveTokens(uri: string, tokens: IToken[]): void;
 
	/**
	 * Returns a promise that resolves with the next token delivery from the language server for the given URI.
	 * Unlike waitForTokens, this does not interfere with document loading — it is a one-shot listener.
	 * @param uri The document URI.
	 * @param timeout Timeout in milliseconds.
	 * @returns A promise that resolves with the tokens or rejects on timeout.
	 */
	onNextTokenDelivery(uri: string, timeout: number): Promise<IToken[]>;
 
	/**
	 * Get the document context from a file or workspace URI.
	 * @param uri A document or workspace URI.
	 * @returns A document context if the document is loaded, `undefined` otherwise.
	 */
	getContextFromUri(uri: string): IDocumentContext | undefined;
 
	/**
	 * Get the document context from a text document.
	 * @param document A text document.
	 * @param contextType The expected type of the document context.
	 * @returns A document context of the specified type if the document is loaded and matches the type, null otherwise.
	 */
	getContext<T extends IDocumentContext>(document: vscode.TextDocument, contextType: new (...args: any[]) => T): T | null;
 
	/**
	 * Load a text document into a document context.
	 * @param document The text document to load.
	 * @param forceReload Indicates whether a new context should be created for existing contexts.
	 * @returns A promise that resolves to the document context or undefined if unsupported.
	 */
	loadDocument(document: vscode.TextDocument, forceReload?: boolean): Promise<IDocumentContext | undefined>;
 
	/**
	 * Activate the document associated with the active context in the editor.
	 * @returns A promise that resolves to the active text editor or `undefined`.
	 */
	activateDocument(): Promise<vscode.TextEditor | undefined>;
 
	/**
	 * Handle active editor changed event.
	 */
	handleActiveEditorChanged(): Promise<void>;
 
	/**
	 * Handle active notebook editor changed event.
	 * @param editor The notebook editor.
	 */
	handleActiveNotebookEditorChanged(editor: vscode.NotebookEditor | undefined): Promise<void>;
 
	/**
	 * Handle text document changed event.
	 * @param e The text document change event.
	 */
	handleTextDocumentChanged(e: vscode.TextDocumentChangeEvent): Promise<void>;
 
	/**
	 * Handle text document closed event.
	 * @param document The closed text document.
	 */
	handleDocumentClosed(document: vscode.TextDocument): void;
}