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 | import * as vscode from 'vscode';
import { IToken } from '@faubulous/mentor-rdf-parsers';
/**
* A single token delivery for a document.
*/
export interface TokenDelivery {
/**
* The URI of the document the tokens belong to.
*/
uri: string;
/**
* The delivered tokens.
*/
tokens: IToken[];
/**
* `true` when a pending {@link IDocumentTokenSource.waitForTokens} request
* consumed this delivery, `false` when the delivery was unsolicited (e.g.
* triggered by a document edit).
*/
consumed: boolean;
}
/**
* Supplies documents with tokens and coordinates concurrent document loads.
*
* This is the seam between the document context lifecycle and the token
* producer. The current implementation ({@link DocumentTokenSyncService})
* receives tokens pushed asynchronously by the language servers; a future
* implementation may tokenize synchronously in the extension host instead.
* The contract is deliberately transport-agnostic: consumers only wait for
* tokens and track load generations, producers only deliver tokens.
*/
export interface IDocumentTokenSource extends vscode.Disposable {
/**
* An event that is fired for every token delivery, after any pending
* {@link waitForTokens} request has been resolved.
*/
readonly onDidDeliverTokens: vscode.Event<TokenDelivery>;
/**
* Starts a new load generation for a document. Any load started earlier for
* the same URI becomes stale and should abandon its work.
* @param uri The document URI.
* @returns The new load generation.
*/
beginLoad(uri: string): number;
/**
* Indicates whether the given generation is still the newest load for a document.
* @param uri The document URI.
* @param generation A load generation returned by {@link beginLoad}.
*/
isCurrentLoad(uri: string, generation: number): boolean;
/**
* Waits for the next token delivery for a document. If a previous wait exists
* for the same URI, it is cancelled (rejected) first so that only one load at
* a time can be waiting for tokens per URI.
* @param uri The document URI to wait for tokens.
* @param timeout Optional timeout in milliseconds.
* @param document The already-open document to parse, when the caller holds it.
* Passing it makes local parsing reliable and O(1) instead of searching
* `workspace.textDocuments` by URI (which can miss a just-opened document that
* VS Code has already dropped from the list, causing a needless timeout).
* @returns A promise that resolves with the tokens or rejects on timeout/cancellation.
*/
waitForTokens(uri: string, timeout?: number, document?: vscode.TextDocument): Promise<IToken[]>;
/**
* Delivers tokens for a document. Resolves a pending {@link waitForTokens}
* request if one exists and fires {@link onDidDeliverTokens}.
* @param uri The document URI.
* @param tokens The delivered tokens.
*/
deliverTokens(uri: string, tokens: IToken[]): void;
/**
* Requests fresh tokens for a document, e.g. during workspace re-indexing.
* @param uri The document URI.
* @returns `true` when this source produced fresh tokens itself; `false` when
* the caller must request them from the token producer (the language server).
*/
refreshTokens(uri: string): boolean;
}
|