Skip to content

Commit ad9f0c5

Browse files
committed
Lookup Razor file context using its document uri.
1 parent af51128 commit ad9f0c5

File tree

1 file changed

+1
-28
lines changed

1 file changed

+1
-28
lines changed

src/lsptoolshost/services/projectContextService.ts

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ import { TextDocumentIdentifier } from 'vscode-languageserver-protocol';
1010
import { UriConverter } from '../uriConverter';
1111
import { LanguageServerEvents } from '../languageServerEvents';
1212
import { ServerState } from '../serverStateChange';
13-
import { DynamicFileInfoHandler } from '../../razor/src/dynamicFile/dynamicFileInfoHandler';
14-
import { ProvideDynamicFileResponse } from '../../razor/src/dynamicFile/provideDynamicFileResponse';
15-
import { ProvideDynamicFileParams } from '../../razor/src/dynamicFile/provideDynamicFileParams';
1613

1714
export interface ProjectContextChangeEvent {
1815
uri: vscode.Uri;
@@ -57,23 +54,13 @@ export class ProjectContextService {
5754
this._source.cancel();
5855
this._source = new vscode.CancellationTokenSource();
5956

60-
let uri = textEditor!.document.uri;
57+
const uri = textEditor!.document.uri;
6158

6259
if (!this._languageServer.isRunning()) {
6360
this._contextChangeEmitter.fire({ uri, context: this._emptyProjectContext });
6461
return;
6562
}
6663

67-
// If the active document is a Razor file, we need to map it back to a C# file.
68-
if (languageId === 'aspnetcorerazor') {
69-
const virtualUri = await this.getVirtualCSharpUri(uri);
70-
if (!virtualUri) {
71-
return;
72-
}
73-
74-
uri = virtualUri;
75-
}
76-
7764
const contextList = await this.getProjectContexts(uri, this._source.token);
7865
if (!contextList) {
7966
return;
@@ -83,20 +70,6 @@ export class ProjectContextService {
8370
this._contextChangeEmitter.fire({ uri, context });
8471
}
8572

86-
private async getVirtualCSharpUri(uri: vscode.Uri): Promise<vscode.Uri | undefined> {
87-
const response = await vscode.commands.executeCommand<ProvideDynamicFileResponse>(
88-
DynamicFileInfoHandler.provideDynamicFileInfoCommand,
89-
new ProvideDynamicFileParams({ uri: UriConverter.serialize(uri) })
90-
);
91-
92-
const responseUri = response.csharpDocument?.uri;
93-
if (!responseUri) {
94-
return undefined;
95-
}
96-
97-
return UriConverter.deserialize(responseUri);
98-
}
99-
10073
private async getProjectContexts(
10174
uri: vscode.Uri,
10275
token: vscode.CancellationToken

0 commit comments

Comments
 (0)