@@ -51,8 +51,14 @@ export interface ContextProvider<T extends SupportedContextItem> {
5151 selector : DocumentSelector ;
5252 resolver : ContextResolver < T > ;
5353}
54+
55+ export type ResolveOnTimeoutResult < T > = T | readonly T [ ] ;
56+ export type ResolveResult < T > = Promise < T > | Promise < readonly T [ ] > | AsyncIterable < T > ;
57+
5458export interface ContextResolver < T extends SupportedContextItem > {
55- resolve ( request : ResolveRequest , token : CancellationToken ) : Promise < T > | Promise < T [ ] > | AsyncIterable < T > ;
59+ resolve ( request : ResolveRequest , token : CancellationToken ) : ResolveResult < T > ;
60+ // Optional method to be invoked if the request timed out. This requests additional context items.
61+ resolveOnTimeout ?( request : ResolveRequest ) : ResolveOnTimeoutResult < T > | undefined ;
5662}
5763
5864/**
@@ -86,20 +92,29 @@ export type ContextUsageStatistics = {
8692 usageDetails ?: ContextItemUsageDetails [ ] ;
8793} ;
8894
95+ export type ProposedTextEdit = TextEdit & {
96+ positionAfterEdit : Position ;
97+ // Indicates whether the edit is suggested by the IDE. Otherwise it's assumed to be speculative
98+ source ?: 'selectedCompletionInfo' ;
99+ } ;
100+
89101export interface DocumentContext {
90102 uri : DocumentUri ;
91103 languageId : string ;
92104 version : number ;
105+ // Position and offset are relative to the provided version of the document.
106+ // The position after an edit is applied is found in ProposedTextEdit.positionAfterEdit.
93107 /**
94108 * @deprecated Use `position` instead.
95109 */
96110 offset : number ;
97111 position : Position ;
98- proposedEdits ?: TextEdit [ ] ;
112+ proposedEdits ?: ProposedTextEdit [ ] ;
99113}
100114export interface ResolveRequest {
101115 // A unique ID to correlate the request with the completion request.
102116 completionId : string ;
117+ opportunityId : string ;
103118 documentContext : DocumentContext ;
104119
105120 activeExperiments : Map < string , string | number | boolean | string [ ] > ;
@@ -109,9 +124,16 @@ export interface ResolveRequest {
109124 * After the time budget runs out, the request will be cancelled via the CancellationToken.
110125 * Providers can use this value as a hint when computing context. Providers should expect the
111126 * request to be cancelled once the time budget runs out.
127+ *
128+ * @deprecated Use `timeoutEnd` instead.
112129 */
113130 timeBudget : number ;
114131
132+ /**
133+ * Unix timestamp representing the exact time the request will be cancelled via the CancellationToken.
134+ */
135+ timeoutEnd : number ;
136+
115137 /**
116138 * Various statistics about the last completion request. This can be used by the context provider
117139 * to make decisions about what context to provide for the current call.
0 commit comments