1- import { Diagnostic , DiagnosticSeverity , Disposable , languages , Range , Uri } from 'vscode' ;
1+ import { Diagnostic , DiagnosticSeverity , languages , Range , Uri } from 'vscode' ;
22import { DisposableObject } from '../pure/disposable-object' ;
33import { QueryHistoryManager } from '../query-history' ;
44import { QueryHistoryInfo } from '../query-results' ;
5- import { EvaluationLogProblemReporter , EvaluationLogScannerProvider } from './log-scanner' ;
5+ import { EvaluationLogProblemReporter , EvaluationLogScannerSet } from './log-scanner' ;
66import { PipelineInfo , SummarySymbols } from './summary-parser' ;
77import * as fs from 'fs-extra' ;
8- import { readJsonlFile } from './jsonl-reader' ;
98
109/**
1110 * Compute the key used to find a predicate in the summary symbols.
@@ -43,8 +42,7 @@ class ProblemReporter implements EvaluationLogProblemReporter {
4342}
4443
4544export class LogScannerService extends DisposableObject {
46- private readonly scannerProviders = new Map < number , EvaluationLogScannerProvider > ( ) ;
47- private nextScannerProviderId = 0 ;
45+ public readonly scanners = new EvaluationLogScannerSet ( ) ;
4846 private readonly diagnosticCollection = this . push ( languages . createDiagnosticCollection ( 'ql-eval-log' ) ) ;
4947 private currentItem : QueryHistoryInfo | undefined = undefined ;
5048
@@ -84,24 +82,6 @@ export class LogScannerService extends DisposableObject {
8482 this . diagnosticCollection . set ( uri , diagnostics ) ;
8583 }
8684
87- /**
88- * Register a provider that can create instances of `EvaluationLogScanner` to scan evaluation logs
89- * for problems.
90- * @param provider The provider.
91- * @returns A `Disposable` that, when disposed, will unregister the provider.
92- */
93- public registerLogScannerProvider ( provider : EvaluationLogScannerProvider ) : Disposable {
94- const id = this . nextScannerProviderId ;
95- this . nextScannerProviderId ++ ;
96-
97- this . scannerProviders . set ( id , provider ) ;
98- return {
99- dispose : ( ) => {
100- this . scannerProviders . delete ( id ) ;
101- }
102- } ;
103- }
104-
10585 /**
10686 * Scan the evaluator summary log for problems, using the scanners for all registered providers.
10787 * @param jsonSummaryLocation The file path of the JSON summary log.
@@ -113,18 +93,9 @@ export class LogScannerService extends DisposableObject {
11393 if ( symbolsLocation !== undefined ) {
11494 symbols = JSON . parse ( await fs . readFile ( symbolsLocation , { encoding : 'utf-8' } ) ) ;
11595 }
116-
11796 const problemReporter = new ProblemReporter ( symbols ) ;
11897
119- const scanners = [ ...this . scannerProviders . values ( ) ] . map ( p => p . createScanner ( problemReporter ) ) ;
120-
121- await readJsonlFile ( jsonSummaryLocation , async obj => {
122- scanners . forEach ( scanner => {
123- scanner . onEvent ( obj ) ;
124- } ) ;
125- } ) ;
126-
127- scanners . forEach ( scanner => scanner . onDone ( ) ) ;
98+ await this . scanners . scanLog ( jsonSummaryLocation , problemReporter ) ;
12899
129100 return problemReporter . diagnostics ;
130101 }
0 commit comments