import * as rpc from "vscode-jsonrpc/node"; import { Markers } from "../markers"; import { ReferenceMap } from "../reference"; /** * Interface representing an RPC codec that defines methods * for sending and receiving objects in an RPC communication. */ export interface RpcCodec { /** * Creates a new instance of the object type with proper constructor defaults. * If not provided, a plain object `{kind: type}` will be created. * * @returns A new instance of the object type. */ rpcNew?(): T; /** * Serializes and sends an object over an RPC send queue. * * @param after - The object to be sent. * @param q - The RPC send queue where the object will be enqueued. */ rpcSend(after: T, q: RpcSendQueue): Promise; /** * Receives and deserializes an object from an RPC receive queue. * * @param before - The initial object state before deserialization. * @param q - The RPC receive queue where the object data is retrieved. * @returns A Promise resolving to the deserialized object. */ rpcReceive(before: T, q: RpcReceiveQueue): Promise; } /** * A registry for managing RPC codecs based on object types. */ export declare class RpcCodecs { private static nonTreeCodecs; /** * The first key is on sourceFileType and the second on object type */ private static treeCodecs; /** * Registers an RPC codec for a given type. * * @param type - The string identifier of the object type. * @param codec - The codec implementation to be registered. * @param sourceFileType The source file type of the source file containing (or will contain) this element. */ static registerCodec(type: string, codec: RpcCodec, sourceFileType?: string): void; /** * Retrieves the registered codec for a given type. * * @param type - The string identifier of the object type. * @param sourceFileType The source file type of the source file containing (or will contain) this element. * @returns The corresponding `RpcCodec`, or `undefined` if not found. */ static forType(type: string, sourceFileType?: string): RpcCodec | undefined; /** * Determines the appropriate codec for an instance based on its `kind` property. * * @param before - The object instance to find a codec for. * @param sourceFileType The source file type of the source file containing (or will contain) this element. * @returns The corresponding `RpcCodec`, or `undefined` if no matching codec is found. */ static forInstance(before: any, sourceFileType?: string): RpcCodec | undefined; } export declare class RpcSendQueue { private readonly refs; private readonly sourceFileType; private readonly trace; private q; private before?; constructor(refs: ReferenceMap, sourceFileType: string | undefined, trace: boolean); generate(after: any, before: any): Promise; /** * Send a bare list (no enclosing object) and return the complete batch terminated by * END_OF_OBJECT. Used by self-contained responses like DependencyTypes, where the peer * drains one list of ref-deduplicated elements rather than a tree. */ generateList(after: T[] | undefined, id: (value: T) => any, onChange: (value: T) => Promise): Promise; /** * Terminate a hand-composed batch: append END_OF_OBJECT and return the accumulated data, * resetting the queue. Lets a caller emit several {@link sendList}s into one stream that the * peer drains as consecutive lists (e.g. DependencyTypes sends its FQN list then its type list). */ finish(): RpcObjectData[]; private put; getAndSend(parent: T, value: (parent: T) => U | undefined, onChange?: (value: U) => Promise): Promise; getAndSendList(parent: T, values: (parent: T) => U[] | undefined, id: (value: U) => any, onChange?: (value: U) => Promise): Promise; send(after: T | undefined, before: T | undefined, onChange?: (() => Promise)): Promise; sendList(after: T[] | undefined, before: T[] | undefined, id: (value: T) => any, onChange?: (value: T) => Promise): Promise; private putListPositions; private add; private doChange; private typesAreDifferent; private getValueType; } export declare class RpcReceiveQueue { private readonly refs; private readonly sourceFileType; private readonly pull; private readonly logger; private readonly trace; private batch; constructor(refs: Map, sourceFileType: string | undefined, pull: () => Promise, logger: rpc.Logger | undefined, trace: boolean); take(): Promise; receiveMarkers(markers?: Markers): Promise; receive(before: T | undefined, onChange?: (before: T) => T | Promise | undefined): Promise; receiveListDefined(before: T[] | undefined, onChange?: (before: T) => T | Promise | undefined): Promise; receiveList(before: T[] | undefined, onChange?: (before: T) => T | Promise | undefined): Promise; private newObj; } /** * Refer to RpcObjectData.java for a description of these fields. */ export interface RpcObjectData { state: RpcObjectState; valueType?: string; value?: any; ref?: number; trace?: string; } export declare namespace RpcObjectData { function logTrace(message: RpcObjectData, enabled: boolean, logger: rpc.Logger | undefined): void; } export declare enum RpcObjectState { NO_CHANGE = "NO_CHANGE", ADD = "ADD", DELETE = "DELETE", CHANGE = "CHANGE", END_OF_OBJECT = "END_OF_OBJECT" } //# sourceMappingURL=queue.d.ts.map