Skip to content

Commit 5e1c028

Browse files
committed
Manage information diagnostic severity on the client-side.
- A server-side change is being made to report diagnostics with their reported severity. - This adds client-side middleware to allow users who prefer to not see information diagnostics in their editor have those diagnostics be reproted as hint.
1 parent 3afe7b5 commit 5e1c028

39 files changed

+745
-212
lines changed

package-lock.json

Lines changed: 498 additions & 73 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,11 @@
116116
"tmp": "0.0.33",
117117
"uuid": "^9.0.0",
118118
"vscode-html-languageservice": "^5.0.1",
119-
"vscode-jsonrpc": "8.2.0-next.0",
120-
"vscode-languageclient": "8.2.0-next.1",
121-
"vscode-languageserver-protocol": "3.17.4-next.1",
122-
"vscode-languageserver-textdocument": "^1.0.5",
119+
"vscode-jsonrpc": "9.0.0-next.7",
120+
"vscode-languageclient": "10.0.0-next.14",
121+
"vscode-languageserver-protocol": "3.17.6-next.12",
122+
"vscode-languageserver-textdocument": "1.0.12",
123+
"vscode-languageserver-types": "3.17.6-next.6",
123124
"vscode-nls": "5.0.1",
124125
"yauzl": "2.10.0"
125126
},
@@ -169,7 +170,9 @@
169170
"ts-jest": "^29.1.1",
170171
"ts-loader": "9.0.0",
171172
"ts-node": "9.1.1",
173+
"tsconfig-paths-webpack-plugin": "^4.2.0",
172174
"typescript": "5.6.2",
175+
"umd-compat-loader": "2.1.2",
173176
"unzipper": "0.10.11",
174177
"vscode-oniguruma": "^1.6.1",
175178
"vscode-textmate": "^6.0.0",
@@ -839,6 +842,12 @@
839842
"description": "%configuration.dotnet.backgroundAnalysis.compilerDiagnosticsScope%",
840843
"order": 30
841844
},
845+
"dotnet.diagnostics.reportInformationAsHint": {
846+
"type": "boolean",
847+
"default": false,
848+
"description": "%configuration.dotnet.diagnostics.reportInformationAsHint%",
849+
"order": 30
850+
},
842851
"dotnet.highlighting.highlightRelatedRegexComponents": {
843852
"type": "boolean",
844853
"default": "true",

package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
"configuration.dotnet.backgroundAnalysis.compilerDiagnosticsScope.openFiles": "Open documents",
6262
"configuration.dotnet.backgroundAnalysis.compilerDiagnosticsScope.fullSolution": "Entire solution",
6363
"configuration.dotnet.backgroundAnalysis.compilerDiagnosticsScope.none": "None",
64+
"configuration.dotnet.diagnostics.reportInformationAsHint": "Enable this setting to reduce visual distractions in your editor. Information problems will be reported as hints and only be visible when the code actions popup is open.",
6465
"configuration.dotnet.highlighting.highlightRelatedRegexComponents": "Highlight related regular expression components under cursor.",
6566
"configuration.dotnet.highlighting.highlightRelatedJsonComponents": "Highlight related JSON components under cursor.",
6667
"configuration.csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": "Show hints for implicit object creation",

src/lsptoolshost/autoInsert/onAutoInsertFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export class OnAutoInsertFeature implements DynamicFeature<RoslynProtocol.OnAuto
5656
this._registrations.delete(id);
5757
}
5858
}
59-
dispose(): void {
59+
clear(): void {
6060
this._registrations.clear();
6161
}
6262

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
import * as vscode from 'vscode';
7+
import { ProvideDiagnosticSignature, ProvideWorkspaceDiagnosticSignature, vsdiag } from 'vscode-languageclient/node';
8+
import { languageServerOptions } from '../../shared/options';
9+
10+
export async function provideDiagnostics(
11+
document: vscode.TextDocument | vscode.Uri,
12+
previousResultId: string | undefined,
13+
token: vscode.CancellationToken,
14+
next: ProvideDiagnosticSignature
15+
) {
16+
const result = await next(document, previousResultId, token);
17+
tryUpdateInformationDiagnostics(result);
18+
return result;
19+
}
20+
21+
export async function provideWorkspaceDiagnostics(
22+
resultIds: vsdiag.PreviousResultId[],
23+
token: vscode.CancellationToken,
24+
resultReporter: vsdiag.ResultReporter,
25+
next: ProvideWorkspaceDiagnosticSignature
26+
) {
27+
const result = await next(resultIds, token, (chunk) => {
28+
chunk?.items.forEach(tryUpdateInformationDiagnostics);
29+
resultReporter(chunk);
30+
});
31+
return result;
32+
}
33+
34+
function tryUpdateInformationDiagnostics(report: vsdiag.DocumentDiagnosticReport | null | undefined) {
35+
if (report?.kind === vsdiag.DocumentDiagnosticReportKind.full && languageServerOptions.reportInformationAsHint) {
36+
report.items.forEach((item) => {
37+
if (item.severity === vscode.DiagnosticSeverity.Information) {
38+
item.severity = vscode.DiagnosticSeverity.Hint;
39+
}
40+
});
41+
}
42+
}

src/lsptoolshost/diagnostics/fixAllCodeAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function getFixAllResponse(
5858

5959
if (response.edit) {
6060
const uriConverter: URIConverter = (value: string): vscode.Uri => UriConverter.deserialize(value);
61-
const protocolConverter = createConverter(uriConverter, true, true);
61+
const protocolConverter = createConverter(uriConverter, true, true, true);
6262
const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit);
6363
if (!(await vscode.workspace.applyEdit(fixAllEdit))) {
6464
const componentName = '[roslyn.client.fixAllCodeAction]';

src/lsptoolshost/diagnostics/nestedCodeAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ async function registerNestedResolveCodeAction(
7575

7676
const uriConverter: URIConverter = (value: string): vscode.Uri =>
7777
UriConverter.deserialize(value);
78-
const protocolConverter = createConverter(uriConverter, true, true);
78+
const protocolConverter = createConverter(uriConverter, true, true, true);
7979
const fixAllEdit = await protocolConverter.asWorkspaceEdit(response.edit);
8080
if (!(await vscode.workspace.applyEdit(fixAllEdit))) {
8181
const componentName = '[roslyn.client.nestedCodeAction]';

src/lsptoolshost/extensions/roslynLanguageServerExportChannel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55
import * as vscode from 'vscode';
6-
import { RequestType } from 'vscode-languageclient/node';
6+
import { RequestType } from 'vscode-jsonrpc';
77
import { RoslynLanguageServer } from '../server/roslynLanguageServer';
88

99
export class RoslynLanguageServerExport {

src/lsptoolshost/razor/razorCommands.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
InlayHintResolveRequest,
2828
InlayHintParams,
2929
InlayHintRequest,
30-
} from 'vscode-languageclient/node';
30+
} from 'vscode-languageclient';
3131
import SerializableSimplifyMethodParams from '../../razor/src/simplify/serializableSimplifyMethodParams';
3232
import { TextEdit } from 'vscode-html-languageservice';
3333
import { SerializableFormatNewFileParams } from '../../razor/src/formatNewFile/serializableFormatNewFileParams';

src/lsptoolshost/server/roslynLanguageClient.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import {
7-
CancellationToken,
8-
LanguageClient,
9-
LanguageClientOptions,
10-
MessageSignature,
11-
ServerOptions,
12-
} from 'vscode-languageclient/node';
6+
import { CancellationToken, MessageSignature } from 'vscode-jsonrpc';
7+
import { LanguageClient } from 'vscode-languageclient/node';
8+
import { LanguageClientOptions, ServerOptions } from 'vscode-languageclient';
139
import CompositeDisposable from '../../compositeDisposable';
1410
import { IDisposable } from '../../disposable';
1511
import { languageServerOptions } from '../../shared/options';

0 commit comments

Comments
 (0)