@@ -53,6 +53,8 @@ public void Initialize()
53
53
this . AddRequestHandler ( DocumentSymbolRequest . Type , this . HandleDocumentSymbolRequest ) ;
54
54
this . AddRequestHandler ( WorkspaceSymbolRequest . Type , this . HandleWorkspaceSymbolRequest ) ;
55
55
56
+ this . AddRequestHandler ( ShowOnlineHelpRequest . Type , this . HandleShowOnlineHelpRequest ) ;
57
+
56
58
this . AddRequestHandler ( DebugAdapterMessages . EvaluateRequest . Type , this . HandleEvaluateRequest ) ;
57
59
}
58
60
@@ -66,22 +68,22 @@ public void AddRequestHandler<TParams, TResult, TError>(
66
68
}
67
69
68
70
public void AddEventHandler < TParams > (
69
- EventType < TParams > eventType ,
71
+ EventType < TParams > eventType ,
70
72
Func < TParams , EditorSession , EventContext , Task > eventHandler )
71
73
{
72
74
this . messageDispatcher . AddEventHandler (
73
75
eventType ,
74
76
eventHandler ) ;
75
77
}
76
-
78
+
77
79
public async Task ProcessMessage (
78
- Message messageToProcess ,
79
- EditorSession editorSession ,
80
+ Message messageToProcess ,
81
+ EditorSession editorSession ,
80
82
MessageWriter messageWriter )
81
83
{
82
84
await this . messageDispatcher . DispatchMessage (
83
- messageToProcess ,
84
- editorSession ,
85
+ messageToProcess ,
86
+ editorSession ,
85
87
messageWriter ) ;
86
88
}
87
89
@@ -127,6 +129,25 @@ protected Task HandleShutdownRequest(
127
129
return Task . FromResult ( true ) ;
128
130
}
129
131
132
+ protected async Task HandleShowOnlineHelpRequest (
133
+ object helpParams ,
134
+ EditorSession editorSession ,
135
+ RequestContext < object , object > requestContext )
136
+ {
137
+ var psCommand = new PSCommand ( ) ;
138
+
139
+ if ( helpParams == null ) { helpParams = "get-help" ; }
140
+
141
+ var script = string . Format ( "get-help {0} -Online" , helpParams ) ;
142
+
143
+ psCommand . AddScript ( script ) ;
144
+
145
+ var result = await editorSession . powerShellContext . ExecuteCommand < object > (
146
+ psCommand ) ;
147
+
148
+ await requestContext . SendResult ( null ) ;
149
+ }
150
+
130
151
protected Task HandleExitNotification (
131
152
object exitParams ,
132
153
EditorSession editorSession ,
@@ -144,7 +165,7 @@ protected Task HandleDidOpenTextDocumentNotification(
144
165
{
145
166
ScriptFile openedFile =
146
167
editorSession . Workspace . GetFileBuffer (
147
- openParams . Uri ,
168
+ openParams . Uri ,
148
169
openParams . Text ) ;
149
170
150
171
// TODO: Get all recently edited files in the workspace
@@ -210,7 +231,7 @@ protected async Task HandleDefinitionRequest(
210
231
EditorSession editorSession ,
211
232
RequestContext < Location [ ] , object > requestContext )
212
233
{
213
- ScriptFile scriptFile =
234
+ ScriptFile scriptFile =
214
235
editorSession . Workspace . GetFile (
215
236
textDocumentPosition . Uri ) ;
216
237
@@ -250,7 +271,7 @@ protected async Task HandleReferencesRequest(
250
271
EditorSession editorSession ,
251
272
RequestContext < Location [ ] , object > requestContext )
252
273
{
253
- ScriptFile scriptFile =
274
+ ScriptFile scriptFile =
254
275
editorSession . Workspace . GetFile (
255
276
referencesParams . Uri ) ;
256
277
@@ -298,7 +319,7 @@ protected async Task HandleCompletionRequest(
298
319
int cursorLine = textDocumentPosition . Position . Line + 1 ;
299
320
int cursorColumn = textDocumentPosition . Position . Character + 1 ;
300
321
301
- ScriptFile scriptFile =
322
+ ScriptFile scriptFile =
302
323
editorSession . Workspace . GetFile (
303
324
textDocumentPosition . Uri ) ;
304
325
@@ -309,7 +330,7 @@ await editorSession.LanguageService.GetCompletionsInFile(
309
330
cursorColumn ) ;
310
331
311
332
CompletionItem [ ] completionItems = null ;
312
-
333
+
313
334
if ( completionResults != null )
314
335
{
315
336
// By default, insert the completion at the current location
@@ -344,8 +365,8 @@ await editorSession.LanguageService.GetCompletionsInFile(
344
365
. Completions
345
366
. Select (
346
367
c => CreateCompletionItem (
347
- c ,
348
- textDocumentPosition . Position . Line ,
368
+ c ,
369
+ textDocumentPosition . Position . Line ,
349
370
startEditColumn ,
350
371
endEditColumn ) )
351
372
. ToArray ( ) ;
@@ -369,9 +390,9 @@ protected async Task HandleCompletionResolveRequest(
369
390
await editorSession . powerShellContext . GetRunspaceHandle ( ) ;
370
391
371
392
// Get the documentation for the function
372
- CommandInfo commandInfo =
393
+ CommandInfo commandInfo =
373
394
CommandHelpers . GetCommandInfo (
374
- completionItem . Label ,
395
+ completionItem . Label ,
375
396
runspaceHandle . Runspace ) ;
376
397
377
398
if ( commandInfo != null )
@@ -394,7 +415,7 @@ protected async Task HandleSignatureHelpRequest(
394
415
EditorSession editorSession ,
395
416
RequestContext < SignatureHelp , object > requestContext )
396
417
{
397
- ScriptFile scriptFile =
418
+ ScriptFile scriptFile =
398
419
editorSession . Workspace . GetFile (
399
420
textDocumentPosition . Uri ) ;
400
421
@@ -446,7 +467,7 @@ protected async Task HandleDocumentHighlightRequest(
446
467
EditorSession editorSession ,
447
468
RequestContext < DocumentHighlight [ ] , object > requestContext )
448
469
{
449
- ScriptFile scriptFile =
470
+ ScriptFile scriptFile =
450
471
editorSession . Workspace . GetFile (
451
472
textDocumentPosition . Uri ) ;
452
473
@@ -486,7 +507,7 @@ protected async Task HandleHoverRequest(
486
507
EditorSession editorSession ,
487
508
RequestContext < Hover , object > requestContext )
488
509
{
489
- ScriptFile scriptFile =
510
+ ScriptFile scriptFile =
490
511
editorSession . Workspace . GetFile (
491
512
textDocumentPosition . Uri ) ;
492
513
@@ -553,12 +574,14 @@ protected async Task HandleDocumentSymbolRequest(
553
574
symbols =
554
575
foundSymbols
555
576
. FoundOccurrences
556
- . Select ( r =>
577
+ . Select ( r =>
557
578
{
558
- return new SymbolInformation {
579
+ return new SymbolInformation
580
+ {
559
581
ContainerName = containerName ,
560
582
Kind = GetSymbolKind ( r . SymbolType ) ,
561
- Location = new Location {
583
+ Location = new Location
584
+ {
562
585
Uri = new Uri ( r . FilePath ) . AbsolutePath ,
563
586
Range = GetRangeFromScriptRegion ( r . ScriptRegion )
564
587
} ,
@@ -625,13 +648,14 @@ protected async Task HandleWorkspaceSymbolRequest(
625
648
foundSymbols
626
649
. FoundOccurrences
627
650
. Where ( r => IsQueryMatch ( workspaceSymbolParams . Query , r . SymbolName ) )
628
- . Select ( r =>
651
+ . Select ( r =>
629
652
{
630
- return new SymbolInformation
653
+ return new SymbolInformation
631
654
{
632
655
ContainerName = containerName ,
633
656
Kind = r . SymbolType == SymbolType . Variable ? SymbolKind . Variable : SymbolKind . Function ,
634
- Location = new Location {
657
+ Location = new Location
658
+ {
635
659
Uri = new Uri ( r . FilePath ) . AbsoluteUri ,
636
660
Range = GetRangeFromScriptRegion ( r . ScriptRegion )
637
661
} ,
@@ -717,7 +741,7 @@ private static FileChange GetFileChangeDetails(Range changeRange, string insertS
717
741
718
742
private Task RunScriptDiagnostics (
719
743
ScriptFile [ ] filesToAnalyze ,
720
- EditorSession editorSession ,
744
+ EditorSession editorSession ,
721
745
EventContext eventContext )
722
746
{
723
747
// If there's an existing task, attempt to cancel it
@@ -810,8 +834,8 @@ await eventContext.SendEvent(
810
834
new PublishDiagnosticsNotification
811
835
{
812
836
Uri = scriptFile . ClientFilePath ,
813
- Diagnostics =
814
- allMarkers
837
+ Diagnostics =
838
+ allMarkers
815
839
. Select ( GetDiagnosticFromMarker )
816
840
. ToArray ( )
817
841
} ) ;
@@ -867,9 +891,9 @@ private static CompletionItemKind MapCompletionKind(CompletionType completionTyp
867
891
}
868
892
869
893
private static CompletionItem CreateCompletionItem (
870
- CompletionDetails completionDetails ,
871
- int lineNumber ,
872
- int startColumn ,
894
+ CompletionDetails completionDetails ,
895
+ int lineNumber ,
896
+ int startColumn ,
873
897
int endColumn )
874
898
{
875
899
string detailString = null ;
0 commit comments