forked from dotnet/interactive
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVSCodeClientKernelExtension.cs
More file actions
41 lines (35 loc) · 1.83 KB
/
Copy pathVSCodeClientKernelExtension.cs
File metadata and controls
41 lines (35 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Threading.Tasks;
using Microsoft.DotNet.Interactive.Commands;
namespace Microsoft.DotNet.Interactive.VSCode;
public class VSCodeClientKernelExtension
{
public static async Task LoadAsync(Kernel kernel)
{
if (kernel is CompositeKernel root)
{
var hostKernel = await root.Host.ConnectProxyKernelOnDefaultConnectorAsync(
"vscode",
new Uri("kernel://vscode"),
["frontend"]);
hostKernel.KernelSpecifierDirective.Hidden = true;
hostKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(RequestInput)));
root.SetDefaultTargetKernelNameForCommand(typeof(RequestInput), "vscode");
hostKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(RequestInputs)));
root.SetDefaultTargetKernelNameForCommand(typeof(RequestInputs), "vscode");
hostKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(SendEditableCode)));
root.SetDefaultTargetKernelNameForCommand(typeof(SendEditableCode), "vscode");
var jsKernel = await root.Host.ConnectProxyKernelOnDefaultConnectorAsync(
"javascript",
new Uri("kernel://webview/javascript"),
["js"]);
jsKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(SubmitCode)));
jsKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(RequestValue)));
jsKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(RequestValueInfos)));
jsKernel.KernelInfo.SupportedKernelCommands.Add(new(nameof(SendValue)));
jsKernel.UseValueSharing();
}
}
}