-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathInitializaionService.cs
59 lines (52 loc) · 1.93 KB
/
InitializaionService.cs
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Threading.Tasks;
using JsonRpc;
using JsonRpc.Contracts;
using JsonRpc.Messages;
using JsonRpc.Server;
using LanguageServer.VsCode.Contracts;
using Newtonsoft.Json.Linq;
namespace DemoLanguageServer.Services
{
public class InitializationService : DemoLanguageServiceBase
{
[JsonRpcMethod(AllowExtensionData = true)]
public InitializeResult Initialize(int processId, Uri rootUri, ClientCapabilities capabilities,
JToken initializationOptions = null, string trace = null)
{
return new InitializeResult(new ServerCapabilities
{
HoverProvider = new HoverOptions(),
SignatureHelpProvider = new SignatureHelpOptions("()"),
CompletionProvider = new CompletionOptions(true, "."),
TextDocumentSync = new TextDocumentSyncOptions
{
OpenClose = true,
WillSave = true,
Change = TextDocumentSyncKind.Incremental
},
});
}
[JsonRpcMethod(IsNotification = true)]
public async Task Initialized()
{
await Client.Window.ShowMessage(MessageType.Info, $"Hello from language server. Params: {Environment.CommandLine}");
var choice = await Client.Window.ShowMessage(MessageType.Warning, "Wanna drink?", "Yes", "No");
await Client.Window.ShowMessage(MessageType.Info, $"You chose {(string) choice ?? "Nothing"}.");
}
[JsonRpcMethod]
public void Shutdown()
{
}
[JsonRpcMethod(IsNotification = true)]
public void Exit()
{
Session.StopServer();
}
[JsonRpcMethod("$/cancelRequest", IsNotification = true)]
public void CancelRequest(MessageId id)
{
RequestContext.Features.Get<IRequestCancellationFeature>().TryCancel(id);
}
}
}