6
6
using OmniSharp . Extensions . LanguageServer . Protocol ;
7
7
using OmniSharp . Extensions . LanguageServer . Protocol . Client . Capabilities ;
8
8
using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
9
+ using OmniSharp . Extensions . LanguageServer . Protocol . Shared ;
9
10
using OmniSharp . Extensions . LanguageServer . Shared ;
10
11
11
12
namespace OmniSharp . Extensions . LanguageServer . Server
@@ -15,28 +16,25 @@ internal class ClientCapabilityProvider
15
16
private readonly IHandlerCollection _collection ;
16
17
private readonly bool _supportsProgress ;
17
18
18
- public ClientCapabilityProvider ( IHandlerCollection collection , bool supportsProgress )
19
+ public ClientCapabilityProvider (
20
+ IHandlerCollection collection ,
21
+ bool supportsProgress )
19
22
{
20
23
_collection = collection ;
21
24
_supportsProgress = supportsProgress ;
22
25
}
23
26
24
27
public bool HasStaticHandler < T > ( Supports < T > capability )
25
- where T : ConnectedCapability < IJsonRpcHandler > ? , IDynamicCapability ?
28
+ where T : IDynamicCapability ?
26
29
{
27
30
// Dynamic registration will cause us to double register things if we report our capabilities statically.
28
31
// However if the client does not tell us it's capabilities we should just assume that they do not support
29
32
// dynamic registrations but we should report any capabilities statically
30
33
if ( capability . IsSupported && capability . Value != null && capability . Value . DynamicRegistration ) return false ;
31
-
32
- var handlerTypes = typeof ( T ) . GetTypeInfo ( ) . ImplementedInterfaces
33
- . Where ( x => x . GetTypeInfo ( ) . IsGenericType && x . GetTypeInfo ( ) . GetGenericTypeDefinition ( ) == typeof ( ConnectedCapability < > ) )
34
- . Select ( x => x . GetTypeInfo ( ) . GetGenericArguments ( ) [ 0 ] . GetTypeInfo ( ) ) ;
35
-
36
- return handlerTypes . Any ( _collection . ContainsHandler ) ;
34
+ return _collection . Any ( z => z . HasCapability && z . CapabilityType == typeof ( T ) ) ;
37
35
}
38
36
39
- public IOptionsGetter GetStaticOptions < T > ( Supports < T > capability ) where T : DynamicCapability ? , ConnectedCapability < IJsonRpcHandler > ?
37
+ public IOptionsGetter GetStaticOptions < T > ( Supports < T > capability ) where T : DynamicCapability
40
38
=> ! HasStaticHandler ( capability ) ? Null : new OptionsGetter ( _collection , _supportsProgress ) ;
41
39
42
40
private static readonly IOptionsGetter Null = new NullOptionsGetter ( ) ;
0 commit comments