Skip to content

Commit cb57a1e

Browse files
committed
change to dictionary
1 parent bb764bc commit cb57a1e

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

src/lsptoolshost/buildDiagnosticsService.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export enum AnalysisSetting {
1313

1414
export class BuildDiagnosticsService {
1515
/** All the build results sent by the DevKit extension. */
16-
private _allBuildDiagnostics: Array<[vscode.Uri, vscode.Diagnostic[]]> = [];
16+
private _allBuildDiagnostics: { [uri: string]: vscode.Diagnostic[] } = {};
1717

1818
/** 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.
1919
* 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 {
2727
this._diagnosticsReportedByBuild.clear();
2828
}
2929

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[]) {
3431
this._allBuildDiagnostics = buildDiagnostics;
3532
const displayedBuildDiagnostics = new Array<[vscode.Uri, vscode.Diagnostic[]]>();
3633
const allDocuments = vscode.workspace.textDocuments;
3734

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)) {
4236
// Check if the document is open
37+
const uri = vscode.Uri.file(uriPath);
4338
const document = allDocuments.find((d) => this.compareUri(d.uri, uri));
4439
const isDocumentOpen = document !== undefined ? !document.isClosed : false;
4540

@@ -48,7 +43,7 @@ export class BuildDiagnosticsService {
4843
uri,
4944
BuildDiagnosticsService.filterDiagnosticsFromBuild(diagnosticList, buildOnlyIds, isDocumentOpen),
5045
]);
51-
});
46+
}
5247

5348
this._diagnosticsReportedByBuild.set(displayedBuildDiagnostics);
5449
}
@@ -59,13 +54,13 @@ export class BuildDiagnosticsService {
5954

6055
public async _onFileOpened(document: vscode.TextDocument, buildOnlyIds: string[]) {
6156
const uri = document.uri;
62-
const currentFileBuildDiagnostics = this._allBuildDiagnostics?.find(([u]) => this.compareUri(u, uri));
57+
const currentFileBuildDiagnostics = this._allBuildDiagnostics[uri.fsPath];
6358

6459
// The document is now open in the editor and live diagnostics are being shown. Filter diagnostics
6560
// reported by the build to show build-only problems.
6661
if (currentFileBuildDiagnostics) {
6762
const buildDiagnostics = BuildDiagnosticsService.filterDiagnosticsFromBuild(
68-
currentFileBuildDiagnostics[1],
63+
currentFileBuildDiagnostics,
6964
buildOnlyIds,
7065
true
7166
);

src/lsptoolshost/services/buildResultReporterService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
* Copyright (c) Microsoft Corporation. All rights reserved.
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
5-
import { Diagnostic, Uri } from 'vscode';
65
import { RoslynLanguageServer } from '../roslynLanguageServer';
76
import { CancellationToken } from 'vscode-jsonrpc';
7+
import * as vscode from 'vscode';
88

99
interface IBuildResultDiagnostics {
1010
buildStarted(cancellationToken?: CancellationToken): Promise<void>;
1111
reportBuildResult(
12-
buildDiagnostics: Array<[Uri, Diagnostic[]]>,
12+
buildDiagnostics: { [uri: string]: vscode.Diagnostic[] },
1313
cancellationToken?: CancellationToken
1414
): Promise<void>;
1515
}
@@ -22,7 +22,7 @@ export class BuildResultDiagnostics implements IBuildResultDiagnostics {
2222
langServer._buildDiagnosticService.clearDiagnostics();
2323
}
2424

25-
public async reportBuildResult(buildDiagnostics: Array<[Uri, Diagnostic[]]>): Promise<void> {
25+
public async reportBuildResult(buildDiagnostics: { [uri: string]: vscode.Diagnostic[] }): Promise<void> {
2626
const langServer: RoslynLanguageServer = await this._languageServerPromise;
2727
const buildOnlyIds: string[] = await langServer.getBuildOnlyDiagnosticIds(CancellationToken.None);
2828
langServer._buildDiagnosticService.setBuildDiagnostics(buildDiagnostics, buildOnlyIds);

0 commit comments

Comments
 (0)