@@ -6,7 +6,6 @@ import * as fs from "fs";
66import * as path from "path" ;
77import * as readline from "readline" ;
88import * as vscode from "vscode" ;
9- import { getTasksJsonPaths } from "./utils" ;
109import { DeprecatedExportJarTaskProvider , ExportJarTaskProvider } from "../../exportJarSteps/ExportJarTaskProvider" ;
1110
1211export class DiagnosticProvider implements vscode . Disposable {
@@ -21,12 +20,21 @@ export class DiagnosticProvider implements vscode.Disposable {
2120 this . refreshDiagnosticsTrigger = _ . debounce ( this . refreshDiagnostics , 500 /** ms */ ) ;
2221 this . diagnosticCollection = vscode . languages . createDiagnosticCollection ( "migrateExportTask" ) ;
2322 this . disposables . push ( this . diagnosticCollection ) ;
24- this . disposables . push ( vscode . workspace . onDidChangeTextDocument ( async ( e ) => {
23+ this . disposables . push ( vscode . workspace . onDidChangeTextDocument ( async ( e : vscode . TextDocumentChangeEvent ) => {
2524 if ( path . basename ( e . document . fileName ) === "tasks.json" ) {
2625 this . refreshDiagnosticsTrigger ( e . document . uri ) ;
2726 }
2827 } ) ) ;
29- this . initializeDiagnostics ( ) ;
28+ this . disposables . push ( vscode . workspace . onDidOpenTextDocument ( async ( e : vscode . TextDocument ) => {
29+ if ( path . basename ( e . fileName ) === "tasks.json" ) {
30+ this . refreshDiagnosticsTrigger ( e . uri ) ;
31+ }
32+ } ) ) ;
33+ this . disposables . push ( vscode . workspace . onDidCloseTextDocument ( async ( e : vscode . TextDocument ) => {
34+ if ( path . basename ( e . fileName ) === "tasks.json" ) {
35+ this . diagnosticCollection . set ( e . uri , undefined ) ;
36+ }
37+ } ) ) ;
3038 }
3139
3240 public dispose ( ) {
@@ -35,14 +43,6 @@ export class DiagnosticProvider implements vscode.Disposable {
3543 }
3644 }
3745
38- private async initializeDiagnostics ( ) : Promise < void > {
39- const tasksJsonPaths = await getTasksJsonPaths ( ) ;
40- for ( const tasksJsonPath of tasksJsonPaths ) {
41- const diagnostics : vscode . Diagnostic [ ] = await DiagnosticProvider . getDiagnosticsFromTasksJsonPath ( tasksJsonPath ) ;
42- this . diagnosticCollection . set ( vscode . Uri . file ( tasksJsonPath ) , diagnostics ) ;
43- }
44- }
45-
4646 private async refreshDiagnostics ( uri : vscode . Uri ) : Promise < void > {
4747 const diagnostics : vscode . Diagnostic [ ] = await DiagnosticProvider . getDiagnosticsFromTasksJsonPath ( uri . fsPath ) ;
4848 this . diagnosticCollection . set ( uri , diagnostics ) ;
0 commit comments