3
3
using System . Threading . Tasks ;
4
4
using Microsoft . Extensions . Logging ;
5
5
using OmniSharp . Extensions . LanguageServer ;
6
- using OmniSharp . Extensions . LanguageServer . Abstractions ;
7
- using OmniSharp . Extensions . LanguageServer . Capabilities . Client ;
8
- using OmniSharp . Extensions . LanguageServer . Capabilities . Server ;
9
- using OmniSharp . Extensions . LanguageServer . Models ;
10
- using OmniSharp . Extensions . LanguageServer . Protocol ;
11
- using OmniSharp . Extensions . LanguageServer . Protocol . Document ;
12
6
13
7
namespace SampleServer
14
8
{
@@ -34,100 +28,4 @@ static async Task MainAsync(string[] args)
34
28
await server . WasShutDown ;
35
29
}
36
30
}
37
-
38
- class TextDocumentHandler : ITextDocumentSyncHandler
39
- {
40
- private readonly ILanguageServer _router ;
41
-
42
- private readonly DocumentSelector _documentSelector = new DocumentSelector (
43
- new DocumentFilter ( )
44
- {
45
- Pattern = "**/*.csproj" ,
46
- Language = "xml"
47
- }
48
- ) ;
49
-
50
- private SynchronizationCapability _capability ;
51
-
52
- public TextDocumentHandler ( ILanguageServer router )
53
- {
54
- _router = router ;
55
- }
56
-
57
- public TextDocumentSyncOptions Options { get ; } = new TextDocumentSyncOptions ( )
58
- {
59
- WillSaveWaitUntil = false ,
60
- WillSave = true ,
61
- Change = TextDocumentSyncKind . Full ,
62
- Save = new SaveOptions ( )
63
- {
64
- IncludeText = true
65
- } ,
66
- OpenClose = true
67
- } ;
68
-
69
- public Task Handle ( DidChangeTextDocumentParams notification )
70
- {
71
- _router . LogMessage ( new LogMessageParams ( )
72
- {
73
- Type = MessageType . Log ,
74
- Message = "Hello World!!!!"
75
- } ) ;
76
- return Task . CompletedTask ;
77
- }
78
-
79
- TextDocumentChangeRegistrationOptions IRegistration < TextDocumentChangeRegistrationOptions > . GetRegistrationOptions ( )
80
- {
81
- return new TextDocumentChangeRegistrationOptions ( )
82
- {
83
- DocumentSelector = _documentSelector ,
84
- SyncKind = Options . Change
85
- } ;
86
- }
87
-
88
- public void SetCapability ( SynchronizationCapability capability )
89
- {
90
- _capability = capability ;
91
- }
92
-
93
- public async Task Handle ( DidOpenTextDocumentParams notification )
94
- {
95
- _router . LogMessage ( new LogMessageParams ( )
96
- {
97
- Type = MessageType . Log ,
98
- Message = "Hello World!!!!"
99
- } ) ;
100
- }
101
-
102
- TextDocumentRegistrationOptions IRegistration < TextDocumentRegistrationOptions > . GetRegistrationOptions ( )
103
- {
104
- return new TextDocumentRegistrationOptions ( )
105
- {
106
- DocumentSelector = _documentSelector ,
107
- } ;
108
- }
109
-
110
- public Task Handle ( DidCloseTextDocumentParams notification )
111
- {
112
- return Task . CompletedTask ;
113
- }
114
-
115
- public Task Handle ( DidSaveTextDocumentParams notification )
116
- {
117
- return Task . CompletedTask ;
118
- }
119
-
120
- TextDocumentSaveRegistrationOptions IRegistration < TextDocumentSaveRegistrationOptions > . GetRegistrationOptions ( )
121
- {
122
- return new TextDocumentSaveRegistrationOptions ( )
123
- {
124
- DocumentSelector = _documentSelector ,
125
- IncludeText = Options . Save . IncludeText
126
- } ;
127
- }
128
- public TextDocumentAttributes GetTextDocumentAttributes ( Uri uri )
129
- {
130
- return new TextDocumentAttributes ( uri , "csharp" ) ;
131
- }
132
- }
133
31
}
0 commit comments