@@ -13,7 +13,7 @@ export enum AnalysisSetting {
13
13
14
14
export class BuildDiagnosticsService {
15
15
/** All the build results sent by the DevKit extension. */
16
- private _allBuildDiagnostics : Array < [ vscode . Uri , vscode . Diagnostic [ ] ] > = [ ] ;
16
+ private _allBuildDiagnostics : { [ uri : string ] : vscode . Diagnostic [ ] } = { } ;
17
17
18
18
/** The diagnostic results from build displayed by VS Code. When live diagnostics are available for a file, these are errors that only build knows about.
19
19
* When live diagnostics aren't loaded for a file, then these are all of the diagnostics reported by the build.*/
@@ -27,19 +27,14 @@ export class BuildDiagnosticsService {
27
27
this . _diagnosticsReportedByBuild . clear ( ) ;
28
28
}
29
29
30
- public async setBuildDiagnostics (
31
- buildDiagnostics : Array < [ vscode . Uri , vscode . Diagnostic [ ] ] > ,
32
- buildOnlyIds : string [ ]
33
- ) {
30
+ public async setBuildDiagnostics ( buildDiagnostics : { [ uri : string ] : vscode . Diagnostic [ ] } , buildOnlyIds : string [ ] ) {
34
31
this . _allBuildDiagnostics = buildDiagnostics ;
35
32
const displayedBuildDiagnostics = new Array < [ vscode . Uri , vscode . Diagnostic [ ] ] > ( ) ;
36
33
const allDocuments = vscode . workspace . textDocuments ;
37
34
38
- this . _allBuildDiagnostics . forEach ( ( fileDiagnostics ) => {
39
- const uri = fileDiagnostics [ 0 ] ;
40
- const diagnosticList = fileDiagnostics [ 1 ] ;
41
-
35
+ for ( const [ uriPath , diagnosticList ] of Object . entries ( this . _allBuildDiagnostics ) ) {
42
36
// Check if the document is open
37
+ const uri = vscode . Uri . file ( uriPath ) ;
43
38
const document = allDocuments . find ( ( d ) => this . compareUri ( d . uri , uri ) ) ;
44
39
const isDocumentOpen = document !== undefined ? ! document . isClosed : false ;
45
40
@@ -48,7 +43,7 @@ export class BuildDiagnosticsService {
48
43
uri ,
49
44
BuildDiagnosticsService . filterDiagnosticsFromBuild ( diagnosticList , buildOnlyIds , isDocumentOpen ) ,
50
45
] ) ;
51
- } ) ;
46
+ }
52
47
53
48
this . _diagnosticsReportedByBuild . set ( displayedBuildDiagnostics ) ;
54
49
}
@@ -59,13 +54,13 @@ export class BuildDiagnosticsService {
59
54
60
55
public async _onFileOpened ( document : vscode . TextDocument , buildOnlyIds : string [ ] ) {
61
56
const uri = document . uri ;
62
- const currentFileBuildDiagnostics = this . _allBuildDiagnostics ?. find ( ( [ u ] ) => this . compareUri ( u , uri ) ) ;
57
+ const currentFileBuildDiagnostics = this . _allBuildDiagnostics [ uri . fsPath ] ;
63
58
64
59
// The document is now open in the editor and live diagnostics are being shown. Filter diagnostics
65
60
// reported by the build to show build-only problems.
66
61
if ( currentFileBuildDiagnostics ) {
67
62
const buildDiagnostics = BuildDiagnosticsService . filterDiagnosticsFromBuild (
68
- currentFileBuildDiagnostics [ 1 ] ,
63
+ currentFileBuildDiagnostics ,
69
64
buildOnlyIds ,
70
65
true
71
66
) ;
0 commit comments