@@ -6,7 +6,6 @@ import * as fs from "fs";
6
6
import * as path from "path" ;
7
7
import * as readline from "readline" ;
8
8
import * as vscode from "vscode" ;
9
- import { getTasksJsonPaths } from "./utils" ;
10
9
import { DeprecatedExportJarTaskProvider , ExportJarTaskProvider } from "../../exportJarSteps/ExportJarTaskProvider" ;
11
10
12
11
export class DiagnosticProvider implements vscode . Disposable {
@@ -21,12 +20,21 @@ export class DiagnosticProvider implements vscode.Disposable {
21
20
this . refreshDiagnosticsTrigger = _ . debounce ( this . refreshDiagnostics , 500 /** ms */ ) ;
22
21
this . diagnosticCollection = vscode . languages . createDiagnosticCollection ( "migrateExportTask" ) ;
23
22
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 ) => {
25
24
if ( path . basename ( e . document . fileName ) === "tasks.json" ) {
26
25
this . refreshDiagnosticsTrigger ( e . document . uri ) ;
27
26
}
28
27
} ) ) ;
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
+ } ) ) ;
30
38
}
31
39
32
40
public dispose ( ) {
@@ -35,14 +43,6 @@ export class DiagnosticProvider implements vscode.Disposable {
35
43
}
36
44
}
37
45
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
-
46
46
private async refreshDiagnostics ( uri : vscode . Uri ) : Promise < void > {
47
47
const diagnostics : vscode . Diagnostic [ ] = await DiagnosticProvider . getDiagnosticsFromTasksJsonPath ( uri . fsPath ) ;
48
48
this . diagnosticCollection . set ( uri , diagnostics ) ;
0 commit comments