Skip to content

Commit

Permalink
feat(lsp): add --pipe parameter (#76351)
Browse files Browse the repository at this point in the history
resolves #72871
  • Loading branch information
JoeRobich authored Dec 14, 2024
2 parents bd782d4 + 6428ff4 commit bf617ef
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public static Task<ExportProvider> CreateExportProviderAsync(
DevKitDependencyPath: devKitDependencyPath,
RazorSourceGenerator: null,
RazorDesignTimePath: null,
ExtensionLogDirectory: string.Empty);
ExtensionLogDirectory: string.Empty,
ServerPipeName: null);
var extensionManager = ExtensionAssemblyManager.Create(serverConfiguration, loggerFactory);
assemblyLoader = new CustomExportAssemblyLoader(extensionManager, loggerFactory);
return ExportProviderBuilder.CreateExportProviderAsync(extensionManager, assemblyLoader, devKitDependencyPath, cacheDirectory, loggerFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,10 @@ static async Task RunAsync(ServerConfiguration serverConfiguration, Cancellation

var languageServerLogger = loggerFactory.CreateLogger(nameof(LanguageServerHost));

var (clientPipeName, serverPipeName) = CreateNewPipeNames();
var (clientPipeName, serverPipeName) = serverConfiguration.ServerPipeName is null
? CreateNewPipeNames()
: (serverConfiguration.ServerPipeName, serverConfiguration.ServerPipeName);

var pipeServer = new NamedPipeServerStream(serverPipeName,
PipeDirection.InOut,
maxNumberOfServerInstances: 1,
Expand Down Expand Up @@ -224,6 +227,12 @@ static CliRootCommand CreateCommandLineParser()
Required = false
};

var serverPipeNameOption = new CliOption<string?>("--pipe")
{
Description = "The name of the pipe the server will connect to.",
Required = false,
};

var rootCommand = new CliRootCommand()
{
debugOption,
Expand All @@ -236,7 +245,8 @@ static CliRootCommand CreateCommandLineParser()
devKitDependencyPathOption,
razorSourceGeneratorOption,
razorDesignTimePathOption,
extensionLogDirectoryOption
extensionLogDirectoryOption,
serverPipeNameOption
};
rootCommand.SetAction((parseResult, cancellationToken) =>
{
Expand All @@ -250,6 +260,7 @@ static CliRootCommand CreateCommandLineParser()
var razorSourceGenerator = parseResult.GetValue(razorSourceGeneratorOption);
var razorDesignTimePath = parseResult.GetValue(razorDesignTimePathOption);
var extensionLogDirectory = parseResult.GetValue(extensionLogDirectoryOption)!;
var serverPipeName = parseResult.GetValue(serverPipeNameOption);

var serverConfiguration = new ServerConfiguration(
LaunchDebugger: launchDebugger,
Expand All @@ -261,6 +272,7 @@ static CliRootCommand CreateCommandLineParser()
DevKitDependencyPath: devKitDependencyPath,
RazorSourceGenerator: razorSourceGenerator,
RazorDesignTimePath: razorDesignTimePath,
ServerPipeName: serverPipeName,
ExtensionLogDirectory: extensionLogDirectory);

return RunAsync(serverConfiguration, cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ internal record class ServerConfiguration(
string? DevKitDependencyPath,
string? RazorSourceGenerator,
string? RazorDesignTimePath,
string? ServerPipeName,
string ExtensionLogDirectory);

internal class LogConfiguration
Expand Down

0 comments on commit bf617ef

Please sign in to comment.