@@ -53,6 +53,8 @@ public void Initialize()
5353 this . AddRequestHandler ( DocumentSymbolRequest . Type , this . HandleDocumentSymbolRequest ) ;
5454 this . AddRequestHandler ( WorkspaceSymbolRequest . Type , this . HandleWorkspaceSymbolRequest ) ;
5555
56+ this . AddRequestHandler ( ShowOnlineHelpRequest . Type , this . HandleShowOnlineHelpRequest ) ;
57+
5658 this . AddRequestHandler ( DebugAdapterMessages . EvaluateRequest . Type , this . HandleEvaluateRequest ) ;
5759 }
5860
@@ -66,22 +68,22 @@ public void AddRequestHandler<TParams, TResult, TError>(
6668 }
6769
6870 public void AddEventHandler < TParams > (
69- EventType < TParams > eventType ,
71+ EventType < TParams > eventType ,
7072 Func < TParams , EditorSession , EventContext , Task > eventHandler )
7173 {
7274 this . messageDispatcher . AddEventHandler (
7375 eventType ,
7476 eventHandler ) ;
7577 }
76-
78+
7779 public async Task ProcessMessage (
78- Message messageToProcess ,
79- EditorSession editorSession ,
80+ Message messageToProcess ,
81+ EditorSession editorSession ,
8082 MessageWriter messageWriter )
8183 {
8284 await this . messageDispatcher . DispatchMessage (
83- messageToProcess ,
84- editorSession ,
85+ messageToProcess ,
86+ editorSession ,
8587 messageWriter ) ;
8688 }
8789
@@ -127,6 +129,25 @@ protected Task HandleShutdownRequest(
127129 return Task . FromResult ( true ) ;
128130 }
129131
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+
130151 protected Task HandleExitNotification (
131152 object exitParams ,
132153 EditorSession editorSession ,
@@ -144,7 +165,7 @@ protected Task HandleDidOpenTextDocumentNotification(
144165 {
145166 ScriptFile openedFile =
146167 editorSession . Workspace . GetFileBuffer (
147- openParams . Uri ,
168+ openParams . Uri ,
148169 openParams . Text ) ;
149170
150171 // TODO: Get all recently edited files in the workspace
@@ -210,7 +231,7 @@ protected async Task HandleDefinitionRequest(
210231 EditorSession editorSession ,
211232 RequestContext < Location [ ] , object > requestContext )
212233 {
213- ScriptFile scriptFile =
234+ ScriptFile scriptFile =
214235 editorSession . Workspace . GetFile (
215236 textDocumentPosition . Uri ) ;
216237
@@ -250,7 +271,7 @@ protected async Task HandleReferencesRequest(
250271 EditorSession editorSession ,
251272 RequestContext < Location [ ] , object > requestContext )
252273 {
253- ScriptFile scriptFile =
274+ ScriptFile scriptFile =
254275 editorSession . Workspace . GetFile (
255276 referencesParams . Uri ) ;
256277
@@ -298,7 +319,7 @@ protected async Task HandleCompletionRequest(
298319 int cursorLine = textDocumentPosition . Position . Line + 1 ;
299320 int cursorColumn = textDocumentPosition . Position . Character + 1 ;
300321
301- ScriptFile scriptFile =
322+ ScriptFile scriptFile =
302323 editorSession . Workspace . GetFile (
303324 textDocumentPosition . Uri ) ;
304325
@@ -309,7 +330,7 @@ await editorSession.LanguageService.GetCompletionsInFile(
309330 cursorColumn ) ;
310331
311332 CompletionItem [ ] completionItems = null ;
312-
333+
313334 if ( completionResults != null )
314335 {
315336 // By default, insert the completion at the current location
@@ -344,8 +365,8 @@ await editorSession.LanguageService.GetCompletionsInFile(
344365 . Completions
345366 . Select (
346367 c => CreateCompletionItem (
347- c ,
348- textDocumentPosition . Position . Line ,
368+ c ,
369+ textDocumentPosition . Position . Line ,
349370 startEditColumn ,
350371 endEditColumn ) )
351372 . ToArray ( ) ;
@@ -369,9 +390,9 @@ protected async Task HandleCompletionResolveRequest(
369390 await editorSession . powerShellContext . GetRunspaceHandle ( ) ;
370391
371392 // Get the documentation for the function
372- CommandInfo commandInfo =
393+ CommandInfo commandInfo =
373394 CommandHelpers . GetCommandInfo (
374- completionItem . Label ,
395+ completionItem . Label ,
375396 runspaceHandle . Runspace ) ;
376397
377398 if ( commandInfo != null )
@@ -394,7 +415,7 @@ protected async Task HandleSignatureHelpRequest(
394415 EditorSession editorSession ,
395416 RequestContext < SignatureHelp , object > requestContext )
396417 {
397- ScriptFile scriptFile =
418+ ScriptFile scriptFile =
398419 editorSession . Workspace . GetFile (
399420 textDocumentPosition . Uri ) ;
400421
@@ -446,7 +467,7 @@ protected async Task HandleDocumentHighlightRequest(
446467 EditorSession editorSession ,
447468 RequestContext < DocumentHighlight [ ] , object > requestContext )
448469 {
449- ScriptFile scriptFile =
470+ ScriptFile scriptFile =
450471 editorSession . Workspace . GetFile (
451472 textDocumentPosition . Uri ) ;
452473
@@ -486,7 +507,7 @@ protected async Task HandleHoverRequest(
486507 EditorSession editorSession ,
487508 RequestContext < Hover , object > requestContext )
488509 {
489- ScriptFile scriptFile =
510+ ScriptFile scriptFile =
490511 editorSession . Workspace . GetFile (
491512 textDocumentPosition . Uri ) ;
492513
@@ -553,12 +574,14 @@ protected async Task HandleDocumentSymbolRequest(
553574 symbols =
554575 foundSymbols
555576 . FoundOccurrences
556- . Select ( r =>
577+ . Select ( r =>
557578 {
558- return new SymbolInformation {
579+ return new SymbolInformation
580+ {
559581 ContainerName = containerName ,
560582 Kind = GetSymbolKind ( r . SymbolType ) ,
561- Location = new Location {
583+ Location = new Location
584+ {
562585 Uri = new Uri ( r . FilePath ) . AbsolutePath ,
563586 Range = GetRangeFromScriptRegion ( r . ScriptRegion )
564587 } ,
@@ -625,13 +648,14 @@ protected async Task HandleWorkspaceSymbolRequest(
625648 foundSymbols
626649 . FoundOccurrences
627650 . Where ( r => IsQueryMatch ( workspaceSymbolParams . Query , r . SymbolName ) )
628- . Select ( r =>
651+ . Select ( r =>
629652 {
630- return new SymbolInformation
653+ return new SymbolInformation
631654 {
632655 ContainerName = containerName ,
633656 Kind = r . SymbolType == SymbolType . Variable ? SymbolKind . Variable : SymbolKind . Function ,
634- Location = new Location {
657+ Location = new Location
658+ {
635659 Uri = new Uri ( r . FilePath ) . AbsoluteUri ,
636660 Range = GetRangeFromScriptRegion ( r . ScriptRegion )
637661 } ,
@@ -717,7 +741,7 @@ private static FileChange GetFileChangeDetails(Range changeRange, string insertS
717741
718742 private Task RunScriptDiagnostics (
719743 ScriptFile [ ] filesToAnalyze ,
720- EditorSession editorSession ,
744+ EditorSession editorSession ,
721745 EventContext eventContext )
722746 {
723747 // If there's an existing task, attempt to cancel it
@@ -810,8 +834,8 @@ await eventContext.SendEvent(
810834 new PublishDiagnosticsNotification
811835 {
812836 Uri = scriptFile . ClientFilePath ,
813- Diagnostics =
814- allMarkers
837+ Diagnostics =
838+ allMarkers
815839 . Select ( GetDiagnosticFromMarker )
816840 . ToArray ( )
817841 } ) ;
@@ -867,9 +891,9 @@ private static CompletionItemKind MapCompletionKind(CompletionType completionTyp
867891 }
868892
869893 private static CompletionItem CreateCompletionItem (
870- CompletionDetails completionDetails ,
871- int lineNumber ,
872- int startColumn ,
894+ CompletionDetails completionDetails ,
895+ int lineNumber ,
896+ int startColumn ,
873897 int endColumn )
874898 {
875899 string detailString = null ;
0 commit comments