@@ -67,6 +67,11 @@ import {
6767 toUpdateSnapshotRequest ,
6868} from "../proto.ts" ;
6969import { SourceFileCache } from "../sourceFileCache.ts" ;
70+ import type {
71+ RequestTiming ,
72+ TimingAccumulators ,
73+ TimingInfo ,
74+ } from "../timing.ts" ;
7075import {
7176 Client ,
7277 type ClientSocketOptions ,
@@ -109,10 +114,9 @@ import type {
109114 UnionType ,
110115} from "./types.ts" ;
111116
112- export { CompletionItemKind , DiagnosticCategory , ElementFlags , ModifierFlags , ModuleKind , NodeBuilderFlags , ObjectFlags , SignatureFlags , SignatureKind , SymbolFlags , TypeFlags , TypePredicateKind } ;
113- export type { APIOptions , ClientSocketOptions , ClientSpawnOptions , CompilerOptions , DocumentIdentifier , DocumentPosition , LSPConnectionOptions , SourceFileMetadata } ;
114- export type { AssertsIdentifierTypePredicate , AssertsThisTypePredicate , BigIntLiteralType , BooleanLiteralType , CompletionEntry , CompletionInfo , CompletionOptions , ConditionalType , Diagnostic , FreshableType , IdentifierTypePredicate , IndexedAccessType , IndexInfo , IndexType , InterfaceType , IntersectionType , IntrinsicType , JSDocTagInfo , LiteralType , NumberLiteralType , ObjectType , StringLiteralType , StringMappingType , SubstitutionType , TemplateLiteralType , ThisTypePredicate , TupleType , Type , TypeParameter , TypePredicate , TypePredicateBase , TypeReference , UnionOrIntersectionType , UnionType } ;
115117export { documentURIToFileName , fileNameToDocumentURI } from "../path.ts" ;
118+ export { CompletionItemKind , DiagnosticCategory , ElementFlags , ModifierFlags , ModuleKind , NodeBuilderFlags , ObjectFlags , SignatureFlags , SignatureKind , SymbolFlags , TypeFlags , TypePredicateKind } ;
119+ export type { APIOptions , AssertsIdentifierTypePredicate , AssertsThisTypePredicate , BigIntLiteralType , BooleanLiteralType , ClientSocketOptions , ClientSpawnOptions , CompilerOptions , CompletionEntry , CompletionInfo , CompletionOptions , ConditionalType , Diagnostic , DocumentIdentifier , DocumentPosition , FreshableType , IdentifierTypePredicate , IndexedAccessType , IndexInfo , IndexType , InterfaceType , IntersectionType , IntrinsicType , JSDocTagInfo , LiteralType , LSPConnectionOptions , NumberLiteralType , ObjectType , RequestTiming , SourceFileMetadata , StringLiteralType , StringMappingType , SubstitutionType , TemplateLiteralType , ThisTypePredicate , TimingAccumulators , TimingInfo , TupleType , Type , TypeParameter , TypePredicate , TypePredicateBase , TypeReference , UnionOrIntersectionType , UnionType } ;
116120
117121export class API < FromLSP extends boolean = false > {
118122 private client : Client ;
@@ -203,6 +207,26 @@ export class API<FromLSP extends boolean = false> {
203207 clearSourceFileCache ( ) : void {
204208 this . sourceFileCache . clear ( ) ;
205209 }
210+
211+ /**
212+ * Returns a snapshot of collected timing information for requests made
213+ * through this API instance: client-measured round-trip latency and bytes
214+ * transferred, folded together with the server's own per-request processing
215+ * time and an estimated transport overhead (round-trip minus server time).
216+ *
217+ * Fetching the snapshot issues a lightweight request to the server to
218+ * retrieve its timing collection. Collection must be enabled via the
219+ * `collectTiming` option; when it is not, the returned snapshot has
220+ * `enabled: false` and zeroed totals.
221+ */
222+ getTimingInfo ( ) : Promise < TimingInfo > {
223+ return this . client . getTimingInfo ( ) ;
224+ }
225+
226+ /** Clears all accumulated timing totals and recent-request history, on both the client and the server. */
227+ resetTimingInfo ( ) : Promise < void > {
228+ return this . client . resetTimingInfo ( ) ;
229+ }
206230}
207231
208232export class InternalAPI {
@@ -612,7 +636,7 @@ export class Program {
612636 const parseOptionsKey = readParseOptionsKey ( view ) ;
613637
614638 // Create a new RemoteSourceFile and cache it (set returns existing if hash matches)
615- const sourceFile = new RemoteSourceFile ( binaryData , this . decoder ) as unknown as SourceFile ;
639+ const sourceFile = new RemoteSourceFile ( binaryData , this . decoder , this . client . getTimingCollector ( ) ) as unknown as SourceFile ;
616640 return this . sourceFileCache . set ( path , sourceFile , parseOptionsKey , contentHash , this . snapshotId , this . project . id ) ;
617641 }
618642
0 commit comments