Skip to content

Commit 4335212

Browse files
author
Andrew Hall
committed
Update types. Add nuget package to tasks
1 parent 68b2129 commit 4335212

File tree

8 files changed

+50
-22
lines changed

8 files changed

+50
-22
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ out
1313
.razoromnisharp/
1414
.razortelemetry/
1515
.razorDevKit/
16+
.razorExtension/
1617
.vscode-test/
1718
msbuild/signing/signJs/*.log
1819
msbuild/signing/signVsix/*.log

.vscodeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
!.razor/**
88
!.razorDevKit/**
99
!.razoromnisharp/**
10+
!.razorExtension/** */
1011
.rpt2_cache/**
1112
.config/**
1213
.devcontainer/**

src/razor/src/dynamicFile/dynamicFileInfoHandler.ts

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import { UriConverter } from '../../../lsptoolshost/utils/uriConverter';
88
import { RazorDocumentManager } from '../document/razorDocumentManager';
99
import { RazorLogger } from '../razorLogger';
1010
import { ProvideDynamicFileParams } from './provideDynamicFileParams';
11-
import { ProvideDynamicFileResponse, DynamicFileUpdate } from './provideDynamicFileResponse';
11+
import { ProvideDynamicFileResponse } from './provideDynamicFileResponse';
1212
import { RemoveDynamicFileParams } from './removeDynamicFileParams';
1313
import { CSharpProjectedDocument } from '../csharp/csharpProjectedDocument';
1414
import { RazorDocumentChangeKind } from '../document/razorDocumentChangeKind';
1515
import { RazorDynamicFileChangedParams } from './dynamicFileUpdatedParams';
1616
import { TextDocumentIdentifier } from 'vscode-languageserver-protocol';
17-
import { ServerTextChange } from '../rpc/serverTextChange';
17+
import { razorTextChange } from './razorTextChange';
18+
import { razorTextSpan } from './razorTextSpan';
1819

1920
// Handles Razor generated doc communication between the Roslyn workspace and Razor.
2021
// didChange behavior for Razor generated docs is handled in the RazorDocumentManager.
@@ -75,19 +76,11 @@ export class DynamicFileInfoHandler {
7576
if (request.fullText) {
7677
// The server asked for a full replace so the newtext is the important
7778
// thing here, the span doesn't matter.
78-
const change: ServerTextChange = {
79-
newText: razorDocument.csharpDocument.getContent(),
80-
span: {
81-
start: 0,
82-
length: 0,
83-
},
84-
};
85-
86-
const update = new DynamicFileUpdate([change]);
79+
const change = new razorTextChange(razorDocument.csharpDocument.getContent(), new razorTextSpan(0, 0));
8780

8881
return new ProvideDynamicFileResponse(
8982
request.razorDocument,
90-
[update],
83+
[change],
9184
csharpDocument.checksum,
9285
csharpDocument.checksumAlgorithm,
9386
csharpDocument.encodingCodePage
@@ -99,22 +92,25 @@ export class DynamicFileInfoHandler {
9992
if (this.documentManager.isRazorDocumentOpenInCSharpWorkspace(vscodeUri)) {
10093
// Open documents have didOpen/didChange to update the csharp buffer. Razor
10194
// does not send edits and instead lets vscode handle them.
102-
return new ProvideDynamicFileResponse(
103-
{ uri: virtualCsharpUri },
104-
null,
105-
csharpDocument.checksum,
106-
csharpDocument.checksumAlgorithm,
107-
csharpDocument.encodingCodePage
108-
);
95+
// return new ProvideDynamicFileResponse(
96+
// { uri: virtualCsharpUri },
97+
// null,
98+
// csharpDocument.checksum,
99+
// csharpDocument.checksumAlgorithm,
100+
// csharpDocument.encodingCodePage
101+
// );
102+
return null;
109103
} else {
110104
// Closed documents provide edits since the last time they were requested since
111105
// there is no open buffer in vscode corresponding to the csharp content.
112106
const response = csharpDocument.applyEdits();
113-
const updates = response.edits?.map((e) => new DynamicFileUpdate(e.changes)) ?? null;
107+
const updates = response.edits?.flatMap((e) =>
108+
e.changes.map((c) => new razorTextChange(c.newText, new razorTextSpan(c.span.start, c.span.length)))
109+
);
114110

115111
return new ProvideDynamicFileResponse(
116112
{ uri: virtualCsharpUri },
117-
updates,
113+
updates ?? [],
118114
response.originalChecksum,
119115
response.originalChecksumAlgorithm,
120116
response.originalEncodingCodePage

src/razor/src/dynamicFile/provideDynamicFileResponse.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55

66
import { TextDocumentIdentifier } from 'vscode-languageserver-protocol';
77
import { ServerTextChange } from '../rpc/serverTextChange';
8+
import { razorTextChange } from './razorTextChange';
89

910
// matches https://github.com/dotnet/roslyn/blob/9e91ca6590450e66e0041ee3135bbf044ac0687a/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/RazorDynamicFileInfoProvider.cs#L28
1011
export class ProvideDynamicFileResponse {
1112
constructor(
1213
public readonly csharpDocument: TextDocumentIdentifier | null,
13-
public readonly updates: DynamicFileUpdate[] | null,
14+
public readonly edits: razorTextChange[],
1415
public readonly checksum: string,
1516
public readonly checksumAlgorithm: number,
1617
public readonly encodingCodePage: number | null
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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 { razorTextSpan } from './razorTextSpan';
7+
8+
export class razorTextChange {
9+
constructor(public readonly newText: string | null, public readonly span: razorTextSpan) {}
10+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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+
export class razorTextSpan {
7+
constructor(public readonly start: number, public readonly length: number) {}
8+
}

tasks/offlinePackagingTasks.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
xamlToolsDirectory,
2828
razorLanguageServerDirectory,
2929
razorDevKitDirectory,
30+
razorExtensionDirectory,
3031
} from '../tasks/projectPaths';
3132
import { getPackageJSON } from '../tasks/packageJson';
3233
import { createPackageAsync, generateVsixManifest } from '../tasks/vsceTasks';
@@ -98,6 +99,12 @@ export const allNugetPackages: { [key: string]: NugetPackageInfo } = {
9899
getPackageContentPath: (_platformInfo) => 'content',
99100
vsixOutputPath: razorDevKitDirectory,
100101
},
102+
razorExtension: {
103+
getPackageName: (_platformInfo) => 'Microsoft.VisualStudioCode.RazorExtension',
104+
packageJsonName: 'razor',
105+
getPackageContentPath: (_platformInfo) => 'content',
106+
vsixOutputPath: razorExtensionDirectory,
107+
},
101108
};
102109

103110
const vsixTasks: string[] = [];
@@ -185,6 +192,9 @@ gulp.task(
185192

186193
// Also pull in the Razor DevKit dependencies nuget package.
187194
await acquireNugetPackage(allNugetPackages.razorDevKit, undefined, getPackageJSON(), true);
195+
196+
// Pull in the .razorExtension code that gets loaded in the roslyn language server
197+
await acquireNugetPackage(allNugetPackages.razorExtension, undefined, getPackageJSON(), true);
188198
}, 'installDependencies')
189199
);
190200

tasks/projectPaths.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const devKitDependenciesDirectory = path.join(rootPath, componentInfo.ros
2020
export const xamlToolsDirectory = path.join(rootPath, componentInfo.xamlTools.defaultFolderName);
2121
export const razorLanguageServerDirectory = path.join(rootPath, '.razor');
2222
export const razorDevKitDirectory = path.join(rootPath, componentInfo.razorDevKit.defaultFolderName);
23+
export const razorExtensionDirectory = path.join(rootPath, '.razorExtension');
2324

2425
export const codeExtensionPath = commandLineOptions.codeExtensionPath || rootPath;
2526

0 commit comments

Comments
 (0)