Skip to content

Commit 9fbdb24

Browse files
authored
Update razor and use pull diagnostics (#8058)
[View Complete Diff of Changes](https://github.com/dotnet/razor/compare/2798396c3481573aa49f9c792179ebbb5e183dca...c0bd75d99369adcd5a2f7e1f1ac42bee8a3bf619?w=1) * Move VS Code To Pull Diagnostics (#11602) (PR: [#11602](dotnet/razor#11602)) * Upgrade to net9 (#11535) (PR: [#11535](dotnet/razor#11535)) * Cleanup CompletionTriggerAndCommitCharacters (#11600) (PR: [#11600](dotnet/razor#11600)) * Add constraints to CaptureParameters method (#11530) (PR: [#11530](dotnet/razor#11530)) * [main] Update dependencies from dotnet/source-build-reference-packages (#11598) (PR: [#11598](dotnet/razor#11598)) * [FUSE] Layout mapping (#11567) (PR: [#11567](dotnet/razor#11567)) * Stop running cohosting tests with and without FUSE (#11592) (PR: [#11592](dotnet/razor#11592))
2 parents 63af2b3 + 844cb4c commit 9fbdb24

File tree

4 files changed

+43
-12
lines changed

4 files changed

+43
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
- Debug from .csproj and .sln [#5876](https://github.com/dotnet/vscode-csharp/issues/5876)
55

66
# 2.70.x
7+
* Bump razor to 9.0.0-preview.25161.2 (PR: [#8058](https://github.com/dotnet/vscode-csharp/pull/8058))
8+
* Move VS Code To Pull Diagnostics (#11602) (PR: [#11602](https://github.com/dotnet/razor/pull/11602))
9+
* Upgrade to net9 (#11535) (PR: [#11535](https://github.com/dotnet/razor/pull/11535))
10+
* Cleanup CompletionTriggerAndCommitCharacters (#11600) (PR: [#11600](https://github.com/dotnet/razor/pull/11600))
11+
* Add constraints to CaptureParameters method (#11530) (PR: [#11530](https://github.com/dotnet/razor/pull/11530))
12+
* [FUSE] Layout mapping (#11567) (PR: [#11567](https://github.com/dotnet/razor/pull/11567))
713

814
# 2.69.x
915
* Bump razor to 9.0.0-preview.25156.2 (PR: [#8047](https://github.com/dotnet/vscode-csharp/pull/8047))

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"defaults": {
4040
"roslyn": "4.14.0-3.25156.1",
4141
"omniSharp": "1.39.12",
42-
"razor": "9.0.0-preview.25156.2",
42+
"razor": "9.0.0-preview.25161.2",
4343
"razorOmnisharp": "7.0.0-preview.23363.1",
4444
"xamlTools": "17.14.35904.287"
4545
},

src/razor/src/diagnostics/razorDiagnosticHandler.ts

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as vscode from 'vscode';
7-
import { DocumentDiagnosticReport, DocumentDiagnosticParams, RequestType } from 'vscode-languageserver-protocol';
7+
import { DocumentDiagnosticParams, DocumentDiagnosticReport, RequestType } from 'vscode-languageserver-protocol';
88
import { RazorLanguageServerClient } from '../razorLanguageServerClient';
99
import { RazorDocumentManager } from '../document/razorDocumentManager';
1010
import { UriConverter } from '../../../lsptoolshost/utils/uriConverter';
@@ -13,14 +13,15 @@ import { RazorLanguageFeatureBase } from '../razorLanguageFeatureBase';
1313
import { RazorDocumentSynchronizer } from '../document/razorDocumentSynchronizer';
1414
import { RazorLogger } from '../razorLogger';
1515
import { roslynPullDiagnosticCommand } from '../../../lsptoolshost/razor/razorCommands';
16+
import { SerializableTextDocumentIdentifierAndVersion } from '../simplify/serializableTextDocumentIdentifierAndVersion';
1617

1718
export class RazorDiagnosticHandler extends RazorLanguageFeatureBase {
1819
private static readonly razorPullDiagnosticsCommand = 'razor/csharpPullDiagnostics';
19-
private diagnosticRequestType: RequestType<DocumentDiagnosticParams, DocumentDiagnosticReport, any> =
20+
private diagnosticRequestType: RequestType<DelegatedDiagnosticParams, DocumentDiagnosticReport, any> =
2021
new RequestType(RazorDiagnosticHandler.razorPullDiagnosticsCommand);
2122

2223
constructor(
23-
documentSynchronizer: RazorDocumentSynchronizer,
24+
protected readonly documentSynchronizer: RazorDocumentSynchronizer,
2425
protected readonly serverClient: RazorLanguageServerClient,
2526
protected readonly serviceClient: RazorLanguageServiceClient,
2627
protected readonly documentManager: RazorDocumentManager,
@@ -31,31 +32,55 @@ export class RazorDiagnosticHandler extends RazorLanguageFeatureBase {
3132

3233
public async register() {
3334
await this.serverClient.onRequestWithParams<
34-
DocumentDiagnosticParams,
35+
DelegatedDiagnosticParams,
3536
DocumentDiagnosticReport | undefined,
3637
any
37-
>(this.diagnosticRequestType, async (request: DocumentDiagnosticParams, token: vscode.CancellationToken) =>
38+
>(this.diagnosticRequestType, async (request: DelegatedDiagnosticParams, token: vscode.CancellationToken) =>
3839
this.getDiagnostic(request, token)
3940
);
4041
}
4142

4243
private async getDiagnostic(
43-
request: DocumentDiagnosticParams,
44-
_: vscode.CancellationToken
44+
request: DelegatedDiagnosticParams,
45+
token: vscode.CancellationToken
4546
): Promise<DocumentDiagnosticReport | undefined> {
4647
if (!this.documentManager.roslynActivated) {
4748
return undefined;
4849
}
4950

50-
const razorDocumentUri = vscode.Uri.parse(request.textDocument.uri, true);
51+
const razorDocumentUri = vscode.Uri.parse(request.identifier.textDocumentIdentifier.uri, true);
52+
const textDocument = await vscode.workspace.openTextDocument(razorDocumentUri);
5153
const razorDocument = await this.documentManager.getDocument(razorDocumentUri);
54+
55+
const synchronized = await this.documentSynchronizer.trySynchronizeProjectedDocument(
56+
textDocument,
57+
razorDocument.csharpDocument,
58+
request.identifier.version,
59+
token
60+
);
61+
62+
if (!synchronized) {
63+
return undefined;
64+
}
65+
5266
const virtualCSharpUri = razorDocument.csharpDocument.uri;
53-
request.textDocument.uri = UriConverter.serialize(virtualCSharpUri);
67+
68+
const roslynRequest: DocumentDiagnosticParams = {
69+
textDocument: {
70+
uri: UriConverter.serialize(virtualCSharpUri),
71+
},
72+
};
73+
5474
const response: DocumentDiagnosticReport = await vscode.commands.executeCommand(
5575
roslynPullDiagnosticCommand,
56-
request
76+
roslynRequest
5777
);
5878

5979
return response;
6080
}
6181
}
82+
83+
interface DelegatedDiagnosticParams {
84+
identifier: SerializableTextDocumentIdentifierAndVersion;
85+
correlationId: string;
86+
}

src/razor/src/razorLanguageFeatureBase.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { getUriPath } from './uriPaths';
1414

1515
export class RazorLanguageFeatureBase {
1616
constructor(
17-
private readonly documentSynchronizer: RazorDocumentSynchronizer,
17+
protected readonly documentSynchronizer: RazorDocumentSynchronizer,
1818
protected readonly documentManager: RazorDocumentManager,
1919
protected readonly serviceClient: RazorLanguageServiceClient,
2020
protected readonly logger: RazorLogger

0 commit comments

Comments
 (0)