21
21
22
22
namespace Microsoft . PowerShell . EditorServices . Handlers
23
23
{
24
+ // TODO: Use ABCs.
24
25
internal class PsesCompletionHandler : ICompletionHandler , ICompletionResolveHandler
25
26
{
26
27
const int DefaultWaitTimeoutMilliseconds = 5000 ;
27
28
private readonly SemaphoreSlim _completionLock = AsyncUtils . CreateSimpleLockingSemaphore ( ) ;
28
29
private readonly SemaphoreSlim _completionResolveLock = AsyncUtils . CreateSimpleLockingSemaphore ( ) ;
29
-
30
30
private readonly ILogger _logger ;
31
31
private readonly PowerShellContextService _powerShellContextService ;
32
32
private readonly WorkspaceService _workspaceService ;
33
-
34
33
private CompletionResults _mostRecentCompletions ;
35
-
36
34
private int _mostRecentRequestLine ;
37
-
38
35
private int _mostRecentRequestOffest ;
39
-
40
36
private string _mostRecentRequestFile ;
41
-
42
37
private CompletionCapability _capability ;
38
+ private readonly Guid _id = Guid . NewGuid ( ) ;
39
+ Guid ICanBeIdentifiedHandler . Id => _id ;
43
40
44
41
public PsesCompletionHandler (
45
42
ILoggerFactory factory ,
@@ -51,15 +48,12 @@ public PsesCompletionHandler(
51
48
_workspaceService = workspaceService ;
52
49
}
53
50
54
- public CompletionRegistrationOptions GetRegistrationOptions ( )
51
+ public CompletionRegistrationOptions GetRegistrationOptions ( CompletionCapability capability , ClientCapabilities clientCapabilities ) => new CompletionRegistrationOptions
55
52
{
56
- return new CompletionRegistrationOptions
57
- {
58
- DocumentSelector = LspUtils . PowerShellDocumentSelector ,
59
- ResolveProvider = true ,
60
- TriggerCharacters = new [ ] { "." , "-" , ":" , "\\ " , "$" }
61
- } ;
62
- }
53
+ DocumentSelector = LspUtils . PowerShellDocumentSelector ,
54
+ ResolveProvider = true ,
55
+ TriggerCharacters = new [ ] { "." , "-" , ":" , "\\ " , "$" }
56
+ } ;
63
57
64
58
public async Task < CompletionList > Handle ( CompletionParams request , CancellationToken cancellationToken )
65
59
{
@@ -145,10 +139,10 @@ await CommandHelpers.GetCommandInfoAsync(
145
139
146
140
if ( commandInfo != null )
147
141
{
148
- request . Documentation =
149
- await CommandHelpers . GetCommandSynopsisAsync (
150
- commandInfo ,
151
- _powerShellContextService ) . ConfigureAwait ( false ) ;
142
+ request = request with
143
+ {
144
+ Documentation = await CommandHelpers . GetCommandSynopsisAsync ( commandInfo , _powerShellContextService ) . ConfigureAwait ( false )
145
+ } ;
152
146
}
153
147
154
148
// Send back the updated CompletionItem
@@ -160,7 +154,7 @@ await CommandHelpers.GetCommandSynopsisAsync(
160
154
}
161
155
}
162
156
163
- public void SetCapability ( CompletionCapability capability )
157
+ public void SetCapability ( CompletionCapability capability , ClientCapabilities clientCapabilities )
164
158
{
165
159
_capability = capability ;
166
160
}
0 commit comments