11using  System . Collections . Generic ; 
2+ using  Microsoft . Extensions . Logging ; 
23using  Newtonsoft . Json . Linq ; 
34using  OmniSharp . Extensions . JsonRpc ; 
4- using  OmniSharp . Extensions . JsonRpc . Client ; 
55using  OmniSharp . Extensions . JsonRpc . Server ; 
6- using  OmniSharp . Extensions . LanguageServer . Protocol . Models ; 
6+ using  OmniSharp . Extensions . LanguageServer . Protocol ; 
77using  OmniSharp . Extensions . LanguageServer . Protocol . Shared ; 
88using  OmniSharp . Extensions . LanguageServer . Protocol . Window ; 
99
1010namespace  OmniSharp . Extensions . LanguageServer . Client 
1111{ 
1212    public  class  LspClientReceiver  :  Receiver ,  ILspClientReceiver 
1313    { 
14-         private  readonly  ILspHandlerTypeDescriptorProvider  _handlerTypeDescriptorProvider ; 
15-         private  bool  _initialized ; 
14+         private  readonly  ILogger < LspClientReceiver >  _logger ; 
1615
17-         public  LspClientReceiver ( ILspHandlerTypeDescriptorProvider   handlerTypeDescriptorProvider ) 
16+         public  LspClientReceiver ( ILogger < LspClientReceiver >   logger ) 
1817        { 
19-             _handlerTypeDescriptorProvider  =  handlerTypeDescriptorProvider ; 
18+             _logger  =  logger ; 
2019        } 
2120
2221        public  override  ( IEnumerable < Renor >  results ,  bool  hasResponse )  GetRequests ( JToken  container ) 
@@ -29,36 +28,33 @@ public override (IEnumerable<Renor> results, bool hasResponse) GetRequests(JToke
2928            var  ( results ,  hasResponse )  =  base . GetRequests ( container ) ; 
3029            foreach  ( var  item  in  results ) 
3130            { 
32-                 if  ( item . IsRequest   &&   _handlerTypeDescriptorProvider . IsMethodName ( item . Request ! . Method ,   typeof ( IShowMessageRequestHandler ) ) ) 
31+                 switch  ( item ) 
3332                { 
34-                     newResults . Add ( item ) ; 
35-                 } 
36-                 else  if  ( item . IsResponse ) 
37-                 { 
38-                     newResults . Add ( item ) ; 
39-                 } 
40-                 else  if  ( item . IsNotification  && 
41-                          _handlerTypeDescriptorProvider . IsMethodName ( 
42-                              item . Notification ! . Method , 
43-                              typeof ( IShowMessageHandler ) , 
44-                              typeof ( ILogMessageHandler ) , 
45-                              typeof ( ITelemetryEventHandler ) 
46-                          ) 
47-                 ) 
48-                 { 
49-                     newResults . Add ( item ) ; 
33+                     case  {  IsResponse :  true  } : 
34+                     case  {  IsRequest :  true ,  Request :  {  Method :  WindowNames . ShowMessageRequest  }  } : 
35+                     case  {  IsNotification :  true ,  Notification :  {  Method :  WindowNames . ShowMessage  }  } : 
36+                     case  {  IsNotification :  true ,  Notification :  {  Method :  WindowNames . LogMessage  }  } : 
37+                     case  {  IsNotification :  true ,  Notification :  {  Method :  WindowNames . TelemetryEvent  }  } : 
38+                     case  {  IsNotification :  true ,  Notification :  {  Method :  WindowNames . WorkDoneProgressCancel  }  } : 
39+                     case  {  IsNotification :  true ,  Notification :  {  Method :  WindowNames . WorkDoneProgressCreate  }  } : 
40+                         newResults . Add ( item ) ; 
41+                         break ; 
42+                     case  {  IsRequest :  true ,  Request :  {  }  } : 
43+                         _logger . LogWarning ( "Unexpected request {Method} {@Request}" ,  item . Request . Method ,  item . Request ) ; 
44+                         break ; 
45+                     case  {  IsNotification :  true ,  Notification :  {  }  } : 
46+                         _logger . LogWarning ( "Unexpected notification {Method} {@Request}" ,  item . Notification . Method ,  item . Notification ) ; 
47+                         break ; 
48+                     case  {  IsError :  true ,  Error :  {  }  } : 
49+                         _logger . LogWarning ( "Unexpected error {Method} {@Request}" ,  item . Error . Method ,  item . Error ) ; 
50+                         break ; 
51+                     default : 
52+                         _logger . LogError ( "Unexpected Renor {@Renor}" ,  item ) ; 
53+                         break ; 
5054                } 
5155            } 
5256
5357            return  (  newResults ,  hasResponse  ) ; 
5458        } 
55- 
56-         public  void  Initialized ( )  =>  _initialized  =  true ; 
57- 
58-         public  override  bool  ShouldFilterOutput ( object  value ) 
59-         { 
60-             if  ( _initialized )  return  true ; 
61-             return  value  is  OutgoingResponse  ||  value  is  OutgoingRequest  v  &&  v . Params  is  InitializeParams ; 
62-         } 
6359    } 
6460} 
0 commit comments