@@ -32,10 +32,16 @@ internal class PsesLanguageServer
3232 /// <summary>
3333 /// Create a new language server instance.
3434 /// </summary>
35+ /// <remarks>
36+ /// This class is only ever instantiated via <see
37+ /// cref="EditorServicesServerFactory.CreateLanguageServer"/>. It is essentially a
38+ /// singleton. The factory hides the logger.
39+ /// </remarks>
3540 /// <param name="factory">Factory to create loggers with.</param>
3641 /// <param name="inputStream">Protocol transport input stream.</param>
3742 /// <param name="outputStream">Protocol transport output stream.</param>
38- /// <param name="hostStartupInfo">Host configuration to instantiate the server and services with.</param>
43+ /// <param name="hostStartupInfo">Host configuration to instantiate the server and services
44+ /// with.</param>
3945 public PsesLanguageServer (
4046 ILoggerFactory factory ,
4147 Stream inputStream ,
@@ -53,6 +59,11 @@ public PsesLanguageServer(
5359 /// <summary>
5460 /// Start the server listening for input.
5561 /// </summary>
62+ /// <remarks>
63+ /// For the services (including the <see cref="PowerShellContextService">
64+ /// context wrapper around PowerShell itself) see <see
65+ /// cref="PsesServiceCollectionExtensions.AddPsesLanguageServices"/>.
66+ /// </remarks>
5667 /// <returns>A task that completes when the server is ready and listening.</returns>
5768 public async Task StartAsync ( )
5869 {
@@ -62,11 +73,12 @@ public async Task StartAsync()
6273 . WithInput ( _inputStream )
6374 . WithOutput ( _outputStream )
6475 . WithServices ( serviceCollection => serviceCollection
65- . AddPsesLanguageServices ( _hostDetails ) )
76+ . AddPsesLanguageServices ( _hostDetails ) ) // NOTE: This adds a lot of services!
6677 . ConfigureLogging ( builder => builder
67- . AddSerilog ( Log . Logger )
78+ . AddSerilog ( Log . Logger ) // TODO: Set dispose to true?
6879 . AddLanguageProtocolLogging ( )
6980 . SetMinimumLevel ( _minimumLogLevel ) )
81+ // TODO: Consider replacing all WithHandler with AddSingleton
7082 . WithHandler < PsesWorkspaceSymbolsHandler > ( )
7183 . WithHandler < PsesTextDocumentHandler > ( )
7284 . WithHandler < GetVersionHandler > ( )
@@ -91,10 +103,15 @@ public async Task StartAsync()
91103 . WithHandler < ShowHelpHandler > ( )
92104 . WithHandler < ExpandAliasHandler > ( )
93105 . WithHandler < PsesSemanticTokensHandler > ( )
106+ // NOTE: The OnInitialize delegate gets run when we first receive the
107+ // _Initialize_ request:
108+ // https://microsoft.github.io/language-server-protocol/specifications/specification-current/#initialize
94109 . OnInitialize (
95110 // TODO: Either fix or ignore "method lacks 'await'" warning.
96111 async ( languageServer , request , cancellationToken ) =>
97112 {
113+ Log . Logger . Debug ( "Initializing OmniSharp Language Server" ) ;
114+
98115 var serviceProvider = languageServer . Services ;
99116 var workspaceService = serviceProvider . GetService < WorkspaceService > ( ) ;
100117
@@ -125,6 +142,7 @@ public async Task StartAsync()
125142 /// <returns>A task that completes when the server is shut down.</returns>
126143 public async Task WaitForShutdown ( )
127144 {
145+ Log . Logger . Debug ( "Shutting down OmniSharp Language Server" ) ;
128146 await _serverStart . Task . ConfigureAwait ( false ) ;
129147 await LanguageServer . WaitForExit . ConfigureAwait ( false ) ;
130148 }
0 commit comments