Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1536,6 +1536,11 @@
"type": "boolean",
"default": true,
"description": "%configuration.razor.languageServer.useNewFormattingEngine%"
},
"razor.languageServer.cohostingEnabled": {
"type": "boolean",
"default": false,
"description": "%configuration.razor.languageServer.cohostingEnabled%"
}
}
},
Expand Down Expand Up @@ -5596,4 +5601,4 @@
}
}
}
}
}
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"configuration.razor.languageServer.forceRuntimeCodeGeneration": "(EXPERIMENTAL) Enable combined design time/runtime code generation for Razor files",
"configuration.razor.languageServer.suppressLspErrorToasts": "Suppresses error toasts from showing up if the server encounters a recoverable error.",
"configuration.razor.languageServer.useNewFormattingEngine": "Use the new Razor formatting engine.",
"configuration.razor.languageServer.cohostingEnabled": "(EXPERIMENTAL) Enable Razor cohosting.",
"debuggers.coreclr.configurationSnippets.label.console-local": ".NET: Launch Executable file (Console)",
"debuggers.coreclr.configurationSnippets.label.web-local": ".NET: Launch Executable file (Web)",
"debuggers.coreclr.configurationSnippets.label.attach-local": ".NET: Attach to a .NET process",
Expand Down
16 changes: 8 additions & 8 deletions src/lsptoolshost/options/optionNameConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import assert from 'node:assert';

export function convertServerOptionNameToClientConfigurationName(section: string): string | null {
// Server name would be in format {languageName}|{grouping}.{name} or
// {grouping}.{name} if this option can be applied to multiple languages.
// {grouping}.{name} if this option can be applied to multiple languages or
// just {name} if this option is not in a group.
const languageNameIndex = section.indexOf('|');
if (languageNameIndex == -1 || section.substring(0, languageNameIndex) == 'csharp') {
// 1. locate the last dot to find the {name} part.
const lastDotIndex = section.lastIndexOf('.');
assert(lastDotIndex !== -1, `There is no . in ${section}.`);
const optionName = section.substring(lastDotIndex + 1);

// 2. Get {grouping} part.
Expand All @@ -25,7 +23,7 @@ export function convertServerOptionNameToClientConfigurationName(section: string
// Example:
// Grouping: implement_type
// Name: dotnet_insertion_behavior
// Expect result is: dotnet.implmentType.insertionBehavior
// Expect result is: dotnet.implementType.insertionBehavior
const prefixes = ['dotnet', 'csharp'];
const optionNamePrefix = getPrefix(optionName, prefixes);

Expand All @@ -34,9 +32,11 @@ export function convertServerOptionNameToClientConfigurationName(section: string
// Finally, convert everything to camel case and put them together.
const camelCaseGroupName = convertToCamelCase(optionGroupName, '_');
const camelCaseFeatureName = convertToCamelCase(featureName, '_');
return optionNamePrefix == ''
? camelCaseGroupName.concat('.', camelCaseFeatureName)
: convertToCamelCase(optionNamePrefix, '_').concat('.', camelCaseGroupName, '.', camelCaseFeatureName);
const camelCasePrefixName = convertToCamelCase(optionNamePrefix, '_');

// Concatenate the three parts together, with dots as separators, but only if they are not empty.
const parts = [camelCasePrefixName, camelCaseGroupName, camelCaseFeatureName].filter((part) => part !== '');
return parts.join('.');
}

return null;
Expand Down
21 changes: 14 additions & 7 deletions src/razor/src/document/razorDocumentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class RazorDocumentManager implements IRazorDocumentManager {
public razorDocumentGenerationInitialized = false;

constructor(
private readonly serverClient: RazorLanguageServerClient,
private readonly serverClient: RazorLanguageServerClient | undefined,
private readonly logger: RazorLogger,
private readonly telemetryReporter: TelemetryReporter,
private readonly platformInfo: PlatformInformation
Expand Down Expand Up @@ -128,13 +128,16 @@ export class RazorDocumentManager implements IRazorDocumentManager {

this.closeDocument(document.uri);
});
this.serverClient.onNotification('razor/updateCSharpBuffer', async (updateBufferRequest) =>
this.updateCSharpBuffer(updateBufferRequest)
);

this.serverClient.onNotification('razor/updateHtmlBuffer', async (updateBufferRequest) =>
this.updateHtmlBuffer(updateBufferRequest)
);
if (this.serverClient !== undefined) {
this.serverClient.onNotification('razor/updateCSharpBuffer', async (updateBufferRequest) =>
this.updateCSharpBuffer(updateBufferRequest)
);

this.serverClient.onNotification('razor/updateHtmlBuffer', async (updateBufferRequest) =>
this.updateHtmlBuffer(updateBufferRequest)
);
}

return vscode.Disposable.from(watcher, didCreateRegistration, didOpenRegistration, didCloseRegistration);
}
Expand Down Expand Up @@ -163,6 +166,10 @@ export class RazorDocumentManager implements IRazorDocumentManager {
}

public async ensureRazorInitialized() {
if (this.serverClient === undefined) {
return;
}

// Kick off the generation of all Razor documents so that components are
// discovered correctly. We need to do this even if a Razor file isn't
// open yet to handle the scenario where the user opens a C# file before
Expand Down
7 changes: 7 additions & 0 deletions src/razor/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export async function activate(
logger
);

if (razorOptions.cohostingEnabled) {
// TODO: We still need a document manager for Html, so need to do _some_ of the below, just not sure what yet,
// and it needs to be able to take a roslynLanguageServerClient instead of a razorLanguageServerClient I guess.

return;
}

const hostExecutableResolver = new DotnetRuntimeExtensionResolver(
platformInfo,
() => razorOptions.serverPath,
Expand Down
1 change: 1 addition & 0 deletions src/razor/src/razorLanguageServerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface RazorLanguageServerOptions {
forceRuntimeCodeGeneration: boolean;
suppressErrorToasts: boolean;
useNewFormattingEngine: boolean;
cohostingEnabled: boolean;
}
2 changes: 2 additions & 0 deletions src/razor/src/razorLanguageServerOptionsResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function resolveRazorLanguageServerOptions(

const suppressErrorToasts = serverConfig.get<boolean>('suppressLspErrorToasts');
const useNewFormattingEngine = serverConfig.get<boolean>('useNewFormattingEngine');
const cohostingEnabled = serverConfig.get<boolean>('cohostingEnabled');

return {
serverPath: languageServerExecutablePath,
Expand All @@ -46,6 +47,7 @@ export function resolveRazorLanguageServerOptions(
forceRuntimeCodeGeneration,
suppressErrorToasts,
useNewFormattingEngine,
cohostingEnabled,
} as RazorLanguageServerOptions;
}

Expand Down
Loading