{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE BangPatterns         #-}
{-# LANGUAGE LambdaCase           #-}
{-# LANGUAGE GADTs                #-}
{-# LANGUAGE MultiWayIf           #-}
{-# LANGUAGE BinaryLiterals       #-}
{-# LANGUAGE OverloadedStrings    #-}
{-# LANGUAGE RankNTypes           #-}
{-# LANGUAGE ScopedTypeVariables  #-}
{-# LANGUAGE TypeFamilies         #-}
{-# LANGUAGE FlexibleContexts     #-}
{-# LANGUAGE ViewPatterns         #-}
{-# LANGUAGE TypeInType           #-}
{-# LANGUAGE TypeApplications     #-}
{-# LANGUAGE RecordWildCards      #-}
{-# LANGUAGE NamedFieldPuns       #-}
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE RoleAnnotations #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
{-# OPTIONS_GHC -fprint-explicit-kinds #-}


module Language.LSP.Server.Core where

import           Control.Concurrent.Async
import           Control.Concurrent.STM
import qualified Control.Exception as E
import           Control.Monad
import           Control.Monad.Fix
import           Control.Monad.IO.Class
import           Control.Monad.Trans.Reader
import           Control.Monad.Trans.Class
import           Control.Monad.IO.Unlift
import           Control.Lens ( (^.), (^?), _Just )
import qualified Data.Aeson as J
import           Data.Default
import           Data.Functor.Product
import           Data.IxMap
import qualified Data.Dependent.Map as DMap
import           Data.Dependent.Map (DMap)
import qualified Data.HashMap.Strict as HM
import           Data.Kind
import qualified Data.List as L
import           Data.List.NonEmpty (NonEmpty(..))
import qualified Data.Map.Strict as Map
import           Data.Maybe
import           Data.Ord (Down (Down))
import qualified Data.Text as T
import           Data.Text ( Text )
import qualified Data.UUID as UUID
import qualified Language.LSP.Types.Capabilities    as J
import Language.LSP.Types as J
import qualified Language.LSP.Types.Lens as J
import           Language.LSP.VFS
import           Language.LSP.Diagnostics
import           System.IO
import qualified System.Log.Formatter as L
import qualified System.Log.Handler as LH
import qualified System.Log.Handler.Simple as LHS
import           System.Log.Logger
import qualified System.Log.Logger as L
import           System.Random hiding (next)
import           Control.Monad.Trans.Identity

-- ---------------------------------------------------------------------
{-# ANN module ("HLint: ignore Eta reduce"         :: String) #-}
{-# ANN module ("HLint: ignore Redundant do"       :: String) #-}
{-# ANN module ("HLint: ignore Reduce duplication" :: String) #-}
-- ---------------------------------------------------------------------

newtype LspT config m a = LspT { LspT config m a -> ReaderT (LanguageContextEnv config) m a
unLspT :: ReaderT (LanguageContextEnv config) m a }
  deriving (a -> LspT config m b -> LspT config m a
(a -> b) -> LspT config m a -> LspT config m b
(forall a b. (a -> b) -> LspT config m a -> LspT config m b)
-> (forall a b. a -> LspT config m b -> LspT config m a)
-> Functor (LspT config m)
forall a b. a -> LspT config m b -> LspT config m a
forall a b. (a -> b) -> LspT config m a -> LspT config m b
forall config (m :: * -> *) a b.
Functor m =>
a -> LspT config m b -> LspT config m a
forall config (m :: * -> *) a b.
Functor m =>
(a -> b) -> LspT config m a -> LspT config m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> LspT config m b -> LspT config m a
$c<$ :: forall config (m :: * -> *) a b.
Functor m =>
a -> LspT config m b -> LspT config m a
fmap :: (a -> b) -> LspT config m a -> LspT config m b
$cfmap :: forall config (m :: * -> *) a b.
Functor m =>
(a -> b) -> LspT config m a -> LspT config m b
Functor, Functor (LspT config m)
a -> LspT config m a
Functor (LspT config m)
-> (forall a. a -> LspT config m a)
-> (forall a b.
    LspT config m (a -> b) -> LspT config m a -> LspT config m b)
-> (forall a b c.
    (a -> b -> c)
    -> LspT config m a -> LspT config m b -> LspT config m c)
-> (forall a b.
    LspT config m a -> LspT config m b -> LspT config m b)
-> (forall a b.
    LspT config m a -> LspT config m b -> LspT config m a)
-> Applicative (LspT config m)
LspT config m a -> LspT config m b -> LspT config m b
LspT config m a -> LspT config m b -> LspT config m a
LspT config m (a -> b) -> LspT config m a -> LspT config m b
(a -> b -> c)
-> LspT config m a -> LspT config m b -> LspT config m c
forall a. a -> LspT config m a
forall a b. LspT config m a -> LspT config m b -> LspT config m a
forall a b. LspT config m a -> LspT config m b -> LspT config m b
forall a b.
LspT config m (a -> b) -> LspT config m a -> LspT config m b
forall a b c.
(a -> b -> c)
-> LspT config m a -> LspT config m b -> LspT config m c
forall config (m :: * -> *).
Applicative m =>
Functor (LspT config m)
forall config (m :: * -> *) a.
Applicative m =>
a -> LspT config m a
forall config (m :: * -> *) a b.
Applicative m =>
LspT config m a -> LspT config m b -> LspT config m a
forall config (m :: * -> *) a b.
Applicative m =>
LspT config m a -> LspT config m b -> LspT config m b
forall config (m :: * -> *) a b.
Applicative m =>
LspT config m (a -> b) -> LspT config m a -> LspT config m b
forall config (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> LspT config m a -> LspT config m b -> LspT config m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
<* :: LspT config m a -> LspT config m b -> LspT config m a
$c<* :: forall config (m :: * -> *) a b.
Applicative m =>
LspT config m a -> LspT config m b -> LspT config m a
*> :: LspT config m a -> LspT config m b -> LspT config m b
$c*> :: forall config (m :: * -> *) a b.
Applicative m =>
LspT config m a -> LspT config m b -> LspT config m b
liftA2 :: (a -> b -> c)
-> LspT config m a -> LspT config m b -> LspT config m c
$cliftA2 :: forall config (m :: * -> *) a b c.
Applicative m =>
(a -> b -> c)
-> LspT config m a -> LspT config m b -> LspT config m c
<*> :: LspT config m (a -> b) -> LspT config m a -> LspT config m b
$c<*> :: forall config (m :: * -> *) a b.
Applicative m =>
LspT config m (a -> b) -> LspT config m a -> LspT config m b
pure :: a -> LspT config m a
$cpure :: forall config (m :: * -> *) a.
Applicative m =>
a -> LspT config m a
$cp1Applicative :: forall config (m :: * -> *).
Applicative m =>
Functor (LspT config m)
Applicative, Applicative (LspT config m)
a -> LspT config m a
Applicative (LspT config m)
-> (forall a b.
    LspT config m a -> (a -> LspT config m b) -> LspT config m b)
-> (forall a b.
    LspT config m a -> LspT config m b -> LspT config m b)
-> (forall a. a -> LspT config m a)
-> Monad (LspT config m)
LspT config m a -> (a -> LspT config m b) -> LspT config m b
LspT config m a -> LspT config m b -> LspT config m b
forall a. a -> LspT config m a
forall a b. LspT config m a -> LspT config m b -> LspT config m b
forall a b.
LspT config m a -> (a -> LspT config m b) -> LspT config m b
forall config (m :: * -> *). Monad m => Applicative (LspT config m)
forall config (m :: * -> *) a. Monad m => a -> LspT config m a
forall config (m :: * -> *) a b.
Monad m =>
LspT config m a -> LspT config m b -> LspT config m b
forall config (m :: * -> *) a b.
Monad m =>
LspT config m a -> (a -> LspT config m b) -> LspT config m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
return :: a -> LspT config m a
$creturn :: forall config (m :: * -> *) a. Monad m => a -> LspT config m a
>> :: LspT config m a -> LspT config m b -> LspT config m b
$c>> :: forall config (m :: * -> *) a b.
Monad m =>
LspT config m a -> LspT config m b -> LspT config m b
>>= :: LspT config m a -> (a -> LspT config m b) -> LspT config m b
$c>>= :: forall config (m :: * -> *) a b.
Monad m =>
LspT config m a -> (a -> LspT config m b) -> LspT config m b
$cp1Monad :: forall config (m :: * -> *). Monad m => Applicative (LspT config m)
Monad, Monad (LspT config m)
Monad (LspT config m)
-> (forall a. IO a -> LspT config m a) -> MonadIO (LspT config m)
IO a -> LspT config m a
forall a. IO a -> LspT config m a
forall config (m :: * -> *). MonadIO m => Monad (LspT config m)
forall config (m :: * -> *) a. MonadIO m => IO a -> LspT config m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> LspT config m a
$cliftIO :: forall config (m :: * -> *) a. MonadIO m => IO a -> LspT config m a
$cp1MonadIO :: forall config (m :: * -> *). MonadIO m => Monad (LspT config m)
MonadIO, m a -> LspT config m a
(forall (m :: * -> *) a. Monad m => m a -> LspT config m a)
-> MonadTrans (LspT config)
forall config (m :: * -> *) a. Monad m => m a -> LspT config m a
forall (m :: * -> *) a. Monad m => m a -> LspT config m a
forall (t :: (* -> *) -> * -> *).
(forall (m :: * -> *) a. Monad m => m a -> t m a) -> MonadTrans t
lift :: m a -> LspT config m a
$clift :: forall config (m :: * -> *) a. Monad m => m a -> LspT config m a
MonadTrans, MonadIO (LspT config m)
MonadIO (LspT config m)
-> (forall b.
    ((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b)
-> MonadUnliftIO (LspT config m)
((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b
forall b.
((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b
forall config (m :: * -> *).
MonadUnliftIO m =>
MonadIO (LspT config m)
forall config (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b
forall (m :: * -> *).
MonadIO m
-> (forall b. ((forall a. m a -> IO a) -> IO b) -> m b)
-> MonadUnliftIO m
withRunInIO :: ((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b
$cwithRunInIO :: forall config (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. LspT config m a -> IO a) -> IO b) -> LspT config m b
$cp1MonadUnliftIO :: forall config (m :: * -> *).
MonadUnliftIO m =>
MonadIO (LspT config m)
MonadUnliftIO, Monad (LspT config m)
Monad (LspT config m)
-> (forall a. (a -> LspT config m a) -> LspT config m a)
-> MonadFix (LspT config m)
(a -> LspT config m a) -> LspT config m a
forall a. (a -> LspT config m a) -> LspT config m a
forall config (m :: * -> *). MonadFix m => Monad (LspT config m)
forall config (m :: * -> *) a.
MonadFix m =>
(a -> LspT config m a) -> LspT config m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> LspT config m a) -> LspT config m a
$cmfix :: forall config (m :: * -> *) a.
MonadFix m =>
(a -> LspT config m a) -> LspT config m a
$cp1MonadFix :: forall config (m :: * -> *). MonadFix m => Monad (LspT config m)
MonadFix)

-- for deriving the instance of MonadUnliftIO
type role LspT representational representational nominal

runLspT :: LanguageContextEnv config -> LspT config m a -> m a
runLspT :: LanguageContextEnv config -> LspT config m a -> m a
runLspT LanguageContextEnv config
env = (ReaderT (LanguageContextEnv config) m a
 -> LanguageContextEnv config -> m a)
-> LanguageContextEnv config
-> ReaderT (LanguageContextEnv config) m a
-> m a
forall a b c. (a -> b -> c) -> b -> a -> c
flip ReaderT (LanguageContextEnv config) m a
-> LanguageContextEnv config -> m a
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT LanguageContextEnv config
env (ReaderT (LanguageContextEnv config) m a -> m a)
-> (LspT config m a -> ReaderT (LanguageContextEnv config) m a)
-> LspT config m a
-> m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LspT config m a -> ReaderT (LanguageContextEnv config) m a
forall config (m :: * -> *) a.
LspT config m a -> ReaderT (LanguageContextEnv config) m a
unLspT

{-# INLINE runLspT #-}

type LspM config = LspT config IO

class MonadUnliftIO m => MonadLsp config m | m -> config where
  getLspEnv :: m (LanguageContextEnv config)

instance MonadUnliftIO m => MonadLsp config (LspT config m) where
  {-# SPECIALIZE instance MonadLsp config (LspT config IO) #-}
  {-# INLINE getLspEnv #-}
  getLspEnv :: LspT config m (LanguageContextEnv config)
getLspEnv = ReaderT (LanguageContextEnv config) m (LanguageContextEnv config)
-> LspT config m (LanguageContextEnv config)
forall config (m :: * -> *) a.
ReaderT (LanguageContextEnv config) m a -> LspT config m a
LspT ReaderT (LanguageContextEnv config) m (LanguageContextEnv config)
forall (m :: * -> *) r. Monad m => ReaderT r m r
ask

instance MonadLsp c m => MonadLsp c (ReaderT r m) where
  {-# SPECIALIZE instance MonadLsp config (ReaderT r (LspT config IO)) #-}
  {-# INLINE getLspEnv #-}
  getLspEnv :: ReaderT r m (LanguageContextEnv c)
getLspEnv = m (LanguageContextEnv c) -> ReaderT r m (LanguageContextEnv c)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (LanguageContextEnv c)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv

instance MonadLsp c m => MonadLsp c (IdentityT m) where
  getLspEnv :: IdentityT @* m (LanguageContextEnv c)
getLspEnv = m (LanguageContextEnv c) -> IdentityT @* m (LanguageContextEnv c)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (LanguageContextEnv c)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv

data LanguageContextEnv config =
  LanguageContextEnv
  { LanguageContextEnv config -> Handlers IO
resHandlers            :: !(Handlers IO)
  , LanguageContextEnv config -> config -> Value -> Either Text config
resParseConfig         :: !(config -> J.Value -> (Either T.Text config))
  , LanguageContextEnv config -> FromServerMessage -> IO ()
resSendMessage         :: !(FromServerMessage -> IO ())
  -- We keep the state in a TVar to be thread safe
  , LanguageContextEnv config -> LanguageContextState config
resState               :: !(LanguageContextState config)
  , LanguageContextEnv config -> ClientCapabilities
resClientCapabilities  :: !J.ClientCapabilities
  , LanguageContextEnv config -> Maybe FilePath
resRootPath            :: !(Maybe FilePath)
  }

-- ---------------------------------------------------------------------
-- Handlers
-- ---------------------------------------------------------------------

-- | A mapping from methods to the static 'Handler's that should be used to
-- handle responses when they come in from the client. To build up a 'Handlers',
-- you should 'mconcat' a list of 'notificationHandler' and 'requestHandler's:
--
-- @
-- mconcat [
--   notificationHandler SInitialized $ \notif -> pure ()
-- , requestHandler STextDocumentHover $ \req responder -> pure ()
-- ]
-- @ 
data Handlers m
  = Handlers
  { Handlers m
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler m 'Request)
reqHandlers :: !(DMap SMethod (ClientMessageHandler m Request))
  , Handlers m
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
notHandlers :: !(DMap SMethod (ClientMessageHandler m Notification))
  }
instance Semigroup (Handlers config) where
  Handlers DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
r1 DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler config 'Notification)
n1 <> :: Handlers config -> Handlers config -> Handlers config
<> Handlers DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
r2 DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler config 'Notification)
n2 = DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler config 'Notification)
-> Handlers config
forall (m :: * -> *).
DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
-> Handlers m
Handlers (DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
r1 DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler config 'Request)
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler config 'Request)
forall a. Semigroup a => a -> a -> a
<> DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
r2) (DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler config 'Notification)
n1 DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler config 'Notification)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler config 'Notification)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler config 'Notification)
forall a. Semigroup a => a -> a -> a
<> DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler config 'Notification)
n2)
instance Monoid (Handlers config) where
  mempty :: Handlers config
mempty = DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler config 'Notification)
-> Handlers config
forall (m :: * -> *).
DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
-> Handlers m
Handlers DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler config 'Request)
forall a. Monoid a => a
mempty DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler config 'Notification)
forall a. Monoid a => a
mempty

notificationHandler :: forall (m :: Method FromClient Notification) f. SMethod m -> Handler f m -> Handlers f
notificationHandler :: SMethod @'FromClient @'Notification m
-> Handler @'FromClient @'Notification f m -> Handlers f
notificationHandler SMethod @'FromClient @'Notification m
m Handler @'FromClient @'Notification f m
h = DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler f 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler f 'Notification)
-> Handlers f
forall (m :: * -> *).
DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
-> Handlers m
Handlers DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler f 'Request)
forall a. Monoid a => a
mempty (SMethod @'FromClient @'Notification m
-> ClientMessageHandler f 'Notification m
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler f 'Notification)
forall k1 (k2 :: k1 -> *) (v :: k1) (f :: k1 -> *).
k2 v -> f v -> DMap @k1 k2 f
DMap.singleton SMethod @'FromClient @'Notification m
m (Handler @'FromClient @'Notification f m
-> ClientMessageHandler f 'Notification m
forall (f :: * -> *) (t :: MethodType) (m :: Method 'FromClient t).
Handler @'FromClient @t f m -> ClientMessageHandler f t m
ClientMessageHandler Handler @'FromClient @'Notification f m
h))

requestHandler :: forall (m :: Method FromClient Request) f. SMethod m -> Handler f m -> Handlers f
requestHandler :: SMethod @'FromClient @'Request m
-> Handler @'FromClient @'Request f m -> Handlers f
requestHandler SMethod @'FromClient @'Request m
m Handler @'FromClient @'Request f m
h = DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler f 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler f 'Notification)
-> Handlers f
forall (m :: * -> *).
DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
-> Handlers m
Handlers (SMethod @'FromClient @'Request m
-> ClientMessageHandler f 'Request m
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler f 'Request)
forall k1 (k2 :: k1 -> *) (v :: k1) (f :: k1 -> *).
k2 v -> f v -> DMap @k1 k2 f
DMap.singleton SMethod @'FromClient @'Request m
m (Handler @'FromClient @'Request f m
-> ClientMessageHandler f 'Request m
forall (f :: * -> *) (t :: MethodType) (m :: Method 'FromClient t).
Handler @'FromClient @t f m -> ClientMessageHandler f t m
ClientMessageHandler Handler @'FromClient @'Request f m
h)) DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler f 'Notification)
forall a. Monoid a => a
mempty

-- | Wrapper to restrict 'Handler's to 'FromClient' 'Method's
newtype ClientMessageHandler f (t :: MethodType) (m :: Method FromClient t) = ClientMessageHandler (Handler f m)

-- | The type of a handler that handles requests and notifications coming in
-- from the server or client
type family Handler (f :: Type -> Type) (m :: Method from t) = (result :: Type) | result -> f t m where
  Handler f (m :: Method _from Request)      = RequestMessage m -> (Either ResponseError (ResponseResult m) -> f ()) -> f ()
  Handler f (m :: Method _from Notification) = NotificationMessage m -> f ()

-- | How to convert two isomorphic data structures between each other.
data m <~> n
  = Iso
  { (<~>) @k m n -> forall (a :: k). m a -> n a
forward :: forall a. m a -> n a
  , (<~>) @k m n -> forall (a :: k). n a -> m a
backward :: forall a. n a -> m a
  }

transmuteHandlers :: (m <~> n) -> Handlers m -> Handlers n
transmuteHandlers :: (<~>) @* m n -> Handlers m -> Handlers n
transmuteHandlers (<~>) @* m n
nat = (forall (a :: Method 'FromClient 'Request).
 Handler @'FromClient @'Request m a
 -> Handler @'FromClient @'Request n a)
-> (forall (a :: Method 'FromClient 'Notification).
    Handler @'FromClient @'Notification m a
    -> Handler @'FromClient @'Notification n a)
-> Handlers m
-> Handlers n
forall (m :: * -> *) (n :: * -> *).
(forall (a :: Method 'FromClient 'Request).
 Handler @'FromClient @'Request m a
 -> Handler @'FromClient @'Request n a)
-> (forall (a :: Method 'FromClient 'Notification).
    Handler @'FromClient @'Notification m a
    -> Handler @'FromClient @'Notification n a)
-> Handlers m
-> Handlers n
mapHandlers (\Handler @'FromClient @'Request m a
i RequestMessage @'FromClient a
m Either ResponseError (ResponseResult @'FromClient a) -> n ()
k -> (<~>) @* m n -> m () -> n ()
forall k (m :: k -> *) (n :: k -> *).
(<~>) @k m n -> forall (a :: k). m a -> n a
forward (<~>) @* m n
nat (Handler @'FromClient @'Request m a
RequestMessage @'FromClient a
-> (Either ResponseError (ResponseResult @'FromClient a) -> m ())
-> m ()
i RequestMessage @'FromClient a
m ((<~>) @* m n -> forall a. n a -> m a
forall k (m :: k -> *) (n :: k -> *).
(<~>) @k m n -> forall (a :: k). n a -> m a
backward (<~>) @* m n
nat (n () -> m ())
-> (Either ResponseError (ResponseResult @'FromClient a) -> n ())
-> Either ResponseError (ResponseResult @'FromClient a)
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either ResponseError (ResponseResult @'FromClient a) -> n ()
k))) (\Handler @'FromClient @'Notification m a
i NotificationMessage @'FromClient a
m -> (<~>) @* m n -> m () -> n ()
forall k (m :: k -> *) (n :: k -> *).
(<~>) @k m n -> forall (a :: k). m a -> n a
forward (<~>) @* m n
nat (Handler @'FromClient @'Notification m a
NotificationMessage @'FromClient a -> m ()
i NotificationMessage @'FromClient a
m))

mapHandlers
  :: (forall (a :: Method FromClient Request). Handler m a -> Handler n a)
  -> (forall (a :: Method FromClient Notification). Handler m a -> Handler n a)
  -> Handlers m -> Handlers n
mapHandlers :: (forall (a :: Method 'FromClient 'Request).
 Handler @'FromClient @'Request m a
 -> Handler @'FromClient @'Request n a)
-> (forall (a :: Method 'FromClient 'Notification).
    Handler @'FromClient @'Notification m a
    -> Handler @'FromClient @'Notification n a)
-> Handlers m
-> Handlers n
mapHandlers forall (a :: Method 'FromClient 'Request).
Handler @'FromClient @'Request m a
-> Handler @'FromClient @'Request n a
mapReq forall (a :: Method 'FromClient 'Notification).
Handler @'FromClient @'Notification m a
-> Handler @'FromClient @'Notification n a
mapNot (Handlers DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
reqs DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler m 'Notification)
nots) = DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler n 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler n 'Notification)
-> Handlers n
forall (m :: * -> *).
DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
-> Handlers m
Handlers DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler n 'Request)
reqs' DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler n 'Notification)
nots'
  where
    reqs' :: DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler n 'Request)
reqs' = (forall (v :: Method 'FromClient 'Request).
 ClientMessageHandler m 'Request v
 -> ClientMessageHandler n 'Request v)
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler m 'Request)
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler n 'Request)
forall k1 (f :: k1 -> *) (g :: k1 -> *) (k2 :: k1 -> *).
(forall (v :: k1). f v -> g v) -> DMap @k1 k2 f -> DMap @k1 k2 g
DMap.map (\(ClientMessageHandler i) -> Handler @'FromClient @'Request n v
-> ClientMessageHandler n 'Request v
forall (f :: * -> *) (t :: MethodType) (m :: Method 'FromClient t).
Handler @'FromClient @t f m -> ClientMessageHandler f t m
ClientMessageHandler (Handler @'FromClient @'Request n v
 -> ClientMessageHandler n 'Request v)
-> Handler @'FromClient @'Request n v
-> ClientMessageHandler n 'Request v
forall a b. (a -> b) -> a -> b
$ Handler @'FromClient @'Request m v
-> Handler @'FromClient @'Request n v
forall (a :: Method 'FromClient 'Request).
Handler @'FromClient @'Request m a
-> Handler @'FromClient @'Request n a
mapReq Handler @'FromClient @'Request m v
i) DMap
  @(Method 'FromClient 'Request)
  (SMethod @'FromClient @'Request)
  (ClientMessageHandler m 'Request)
reqs
    nots' :: DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler n 'Notification)
nots' = (forall (v :: Method 'FromClient 'Notification).
 ClientMessageHandler m 'Notification v
 -> ClientMessageHandler n 'Notification v)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler n 'Notification)
forall k1 (f :: k1 -> *) (g :: k1 -> *) (k2 :: k1 -> *).
(forall (v :: k1). f v -> g v) -> DMap @k1 k2 f -> DMap @k1 k2 g
DMap.map (\(ClientMessageHandler i) -> Handler @'FromClient @'Notification n v
-> ClientMessageHandler n 'Notification v
forall (f :: * -> *) (t :: MethodType) (m :: Method 'FromClient t).
Handler @'FromClient @t f m -> ClientMessageHandler f t m
ClientMessageHandler (Handler @'FromClient @'Notification n v
 -> ClientMessageHandler n 'Notification v)
-> Handler @'FromClient @'Notification n v
-> ClientMessageHandler n 'Notification v
forall a b. (a -> b) -> a -> b
$ Handler @'FromClient @'Notification m v
-> Handler @'FromClient @'Notification n v
forall (a :: Method 'FromClient 'Notification).
Handler @'FromClient @'Notification m a
-> Handler @'FromClient @'Notification n a
mapNot Handler @'FromClient @'Notification m v
i) DMap
  @(Method 'FromClient 'Notification)
  (SMethod @'FromClient @'Notification)
  (ClientMessageHandler m 'Notification)
nots

-- | state used by the LSP dispatcher to manage the message loop
data LanguageContextState config =
  LanguageContextState
  { LanguageContextState config -> TVar VFSData
resVFS                 :: !(TVar VFSData)
  , LanguageContextState config -> TVar DiagnosticStore
resDiagnostics         :: !(TVar DiagnosticStore)
  , LanguageContextState config -> TVar config
resConfig              :: !(TVar config)
  , LanguageContextState config -> TVar [WorkspaceFolder]
resWorkspaceFolders    :: !(TVar [WorkspaceFolder])
  , LanguageContextState config -> ProgressData
resProgressData        :: !ProgressData
  , LanguageContextState config -> TVar ResponseMap
resPendingResponses    :: !(TVar ResponseMap)
  , LanguageContextState config -> TVar (RegistrationMap 'Notification)
resRegistrationsNot    :: !(TVar (RegistrationMap Notification))
  , LanguageContextState config -> TVar (RegistrationMap 'Request)
resRegistrationsReq    :: !(TVar (RegistrationMap Request))
  , LanguageContextState config -> TVar Int
resLspId               :: !(TVar Int)
  }

type ResponseMap = IxMap LspId (Product SMethod ServerResponseCallback)

type RegistrationMap (t :: MethodType) = DMap SMethod (Product RegistrationId (ClientMessageHandler IO t))

data RegistrationToken (m :: Method FromClient t) = RegistrationToken (SMethod m) (RegistrationId m)
newtype RegistrationId (m :: Method FromClient t) = RegistrationId Text
  deriving RegistrationId @t m -> RegistrationId @t m -> Bool
(RegistrationId @t m -> RegistrationId @t m -> Bool)
-> (RegistrationId @t m -> RegistrationId @t m -> Bool)
-> Eq (RegistrationId @t m)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (t :: MethodType) (m :: Method 'FromClient t).
RegistrationId @t m -> RegistrationId @t m -> Bool
/= :: RegistrationId @t m -> RegistrationId @t m -> Bool
$c/= :: forall (t :: MethodType) (m :: Method 'FromClient t).
RegistrationId @t m -> RegistrationId @t m -> Bool
== :: RegistrationId @t m -> RegistrationId @t m -> Bool
$c== :: forall (t :: MethodType) (m :: Method 'FromClient t).
RegistrationId @t m -> RegistrationId @t m -> Bool
Eq

data ProgressData = ProgressData { ProgressData -> TVar Int
progressNextId :: !(TVar Int)
                                 , ProgressData -> TVar (Map ProgressToken (IO ()))
progressCancel :: !(TVar (Map.Map ProgressToken (IO ()))) }

data VFSData =
  VFSData
    { VFSData -> VFS
vfsData :: !VFS
    , VFSData -> Map FilePath FilePath
reverseMap :: !(Map.Map FilePath FilePath)
    }

{-# INLINE modifyState #-}
modifyState :: MonadLsp config m => (LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState :: (LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState LanguageContextState config -> TVar a
sel a -> a
f = do
  TVar a
tvarDat <- LanguageContextState config -> TVar a
sel (LanguageContextState config -> TVar a)
-> (LanguageContextEnv config -> LanguageContextState config)
-> LanguageContextEnv config
-> TVar a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LanguageContextEnv config -> LanguageContextState config
forall config.
LanguageContextEnv config -> LanguageContextState config
resState (LanguageContextEnv config -> TVar a)
-> m (LanguageContextEnv config) -> m (TVar a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv
  IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ TVar a -> (a -> a) -> STM ()
forall a. TVar a -> (a -> a) -> STM ()
modifyTVar' TVar a
tvarDat a -> a
f

{-# INLINE stateState #-}
stateState :: MonadLsp config m => (LanguageContextState config -> TVar s) -> (s -> (a,s)) -> m a
stateState :: (LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState LanguageContextState config -> TVar s
sel s -> (a, s)
f = do
  TVar s
tvarDat <- LanguageContextState config -> TVar s
sel (LanguageContextState config -> TVar s)
-> (LanguageContextEnv config -> LanguageContextState config)
-> LanguageContextEnv config
-> TVar s
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LanguageContextEnv config -> LanguageContextState config
forall config.
LanguageContextEnv config -> LanguageContextState config
resState (LanguageContextEnv config -> TVar s)
-> m (LanguageContextEnv config) -> m (TVar s)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv
  IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> IO a -> m a
forall a b. (a -> b) -> a -> b
$ STM a -> IO a
forall a. STM a -> IO a
atomically (STM a -> IO a) -> STM a -> IO a
forall a b. (a -> b) -> a -> b
$ TVar s -> (s -> (a, s)) -> STM a
forall s a. TVar s -> (s -> (a, s)) -> STM a
stateTVar TVar s
tvarDat s -> (a, s)
f

{-# INLINE getsState #-}
getsState :: MonadLsp config m => (LanguageContextState config -> TVar a) -> m a
getsState :: (LanguageContextState config -> TVar a) -> m a
getsState LanguageContextState config -> TVar a
f = do
  TVar a
tvarDat <- LanguageContextState config -> TVar a
f (LanguageContextState config -> TVar a)
-> (LanguageContextEnv config -> LanguageContextState config)
-> LanguageContextEnv config
-> TVar a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LanguageContextEnv config -> LanguageContextState config
forall config.
LanguageContextEnv config -> LanguageContextState config
resState (LanguageContextEnv config -> TVar a)
-> m (LanguageContextEnv config) -> m (TVar a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv
  IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> IO a -> m a
forall a b. (a -> b) -> a -> b
$ TVar a -> IO a
forall a. TVar a -> IO a
readTVarIO TVar a
tvarDat

-- ---------------------------------------------------------------------

-- | Language Server Protocol options that the server may configure.
-- If you set handlers for some requests, you may need to set some of these options.
data Options =
  Options
    { Options -> Maybe TextDocumentSyncOptions
textDocumentSync                 :: Maybe J.TextDocumentSyncOptions
    -- |  The characters that trigger completion automatically.
    , Options -> Maybe FilePath
completionTriggerCharacters      :: Maybe [Char]
    -- | The list of all possible characters that commit a completion. This field can be used
    -- if clients don't support individual commmit characters per completion item. See
    -- `_commitCharactersSupport`.
    , Options -> Maybe FilePath
completionAllCommitCharacters    :: Maybe [Char]
    -- | The characters that trigger signature help automatically.
    , Options -> Maybe FilePath
signatureHelpTriggerCharacters   :: Maybe [Char]
    -- | List of characters that re-trigger signature help.
    -- These trigger characters are only active when signature help is already showing. All trigger characters
    -- are also counted as re-trigger characters.
    , Options -> Maybe FilePath
signatureHelpRetriggerCharacters :: Maybe [Char]
    -- | CodeActionKinds that this server may return.
    -- The list of kinds may be generic, such as `CodeActionKind.Refactor`, or the server
    -- may list out every specific kind they provide.
    , Options -> Maybe [CodeActionKind]
codeActionKinds                  :: Maybe [CodeActionKind]
    -- | The list of characters that triggers on type formatting.
    -- If you set `documentOnTypeFormattingHandler`, you **must** set this.
    -- The first character is mandatory, so a 'NonEmpty' should be passed.
    , Options -> Maybe (NonEmpty Char)
documentOnTypeFormattingTriggerCharacters :: Maybe (NonEmpty Char)
    -- | The commands to be executed on the server.
    -- If you set `executeCommandHandler`, you **must** set this.
    , Options -> Maybe [Text]
executeCommandCommands           :: Maybe [Text]
    -- | Information about the server that can be advertised to the client.
    , Options -> Maybe ServerInfo
serverInfo                       :: Maybe J.ServerInfo
    }

instance Default Options where
  def :: Options
def = Maybe TextDocumentSyncOptions
-> Maybe FilePath
-> Maybe FilePath
-> Maybe FilePath
-> Maybe FilePath
-> Maybe [CodeActionKind]
-> Maybe (NonEmpty Char)
-> Maybe [Text]
-> Maybe ServerInfo
-> Options
Options Maybe TextDocumentSyncOptions
forall a. Maybe a
Nothing Maybe FilePath
forall a. Maybe a
Nothing Maybe FilePath
forall a. Maybe a
Nothing Maybe FilePath
forall a. Maybe a
Nothing Maybe FilePath
forall a. Maybe a
Nothing
                Maybe [CodeActionKind]
forall a. Maybe a
Nothing Maybe (NonEmpty Char)
forall a. Maybe a
Nothing Maybe [Text]
forall a. Maybe a
Nothing Maybe ServerInfo
forall a. Maybe a
Nothing

defaultOptions :: Options
defaultOptions :: Options
defaultOptions = Options
forall a. Default a => a
def

-- | A package indicating the perecentage of progress complete and a
-- an optional message to go with it during a 'withProgress'
--
-- @since 0.10.0.0
data ProgressAmount = ProgressAmount (Maybe Double) (Maybe Text)

-- | Thrown if the user cancels a 'Cancellable' 'withProgress'/'withIndefiniteProgress'/ session
--
-- @since 0.11.0.0
data ProgressCancelledException = ProgressCancelledException
  deriving Int -> ProgressCancelledException -> ShowS
[ProgressCancelledException] -> ShowS
ProgressCancelledException -> FilePath
(Int -> ProgressCancelledException -> ShowS)
-> (ProgressCancelledException -> FilePath)
-> ([ProgressCancelledException] -> ShowS)
-> Show ProgressCancelledException
forall a.
(Int -> a -> ShowS) -> (a -> FilePath) -> ([a] -> ShowS) -> Show a
showList :: [ProgressCancelledException] -> ShowS
$cshowList :: [ProgressCancelledException] -> ShowS
show :: ProgressCancelledException -> FilePath
$cshow :: ProgressCancelledException -> FilePath
showsPrec :: Int -> ProgressCancelledException -> ShowS
$cshowsPrec :: Int -> ProgressCancelledException -> ShowS
Show
instance E.Exception ProgressCancelledException

-- | Whether or not the user should be able to cancel a 'withProgress'/'withIndefiniteProgress'
-- session
--
-- @since 0.11.0.0
data ProgressCancellable = Cancellable | NotCancellable

-- | Contains all the callbacks to use for initialized the language server.
-- it is parameterized over a config type variable representing the type for the
-- specific configuration data the language server needs to use.
data ServerDefinition config = forall m a.
  ServerDefinition
    { ServerDefinition config -> config
defaultConfig :: config
      -- ^ The default value we initialize the config variable to.
    , ServerDefinition config -> config -> Value -> Either Text config
onConfigurationChange :: config -> J.Value -> Either T.Text config
      -- ^ @onConfigurationChange oldConfig newConfig@ is called whenever the
      -- clients sends a message with a changed client configuration. This
      -- callback should return either the parsed configuration data or an error
      -- indicating what went wrong. The parsed configuration object will be
      -- stored internally and can be accessed via 'config'.
      -- It is also called on the `initializationOptions` field of the InitializeParams
    , ()
doInitialize :: LanguageContextEnv config -> Message Initialize -> IO (Either ResponseError a)
      -- ^ Called *after* receiving the @initialize@ request and *before*
      -- returning the response. This callback will be invoked to offer the
      -- language server implementation the chance to create any processes or
      -- start new threads that may be necesary for the server lifecycle. It can
      -- also return an error in the initialization if necessary.
    , ()
staticHandlers :: Handlers m
      -- ^ Handlers for any methods you want to statically support.
      -- The handlers here cannot be unregistered during the server's lifetime
      -- and will be regsitered statically in the initialize request.
    , ()
interpretHandler :: a -> (m <~> IO)
      -- ^ How to run the handlers in your own monad of choice, @m@. 
      -- It is passed the result of 'doInitialize', so typically you will want
      -- to thread along the 'LanguageContextEnv' as well as any other state you
      -- need to run your monad. @m@ should most likely be built on top of
      -- 'LspT'.
      --
      -- @
      --  ServerDefinition { ...
      --  , doInitialize = \env _req -> pure $ Right env
      --  , interpretHandler = \env -> Iso 
      --     (runLspT env) -- how to convert from IO ~> m
      --     liftIO        -- how to convert from m ~> IO
      --  }
      -- @
    , ServerDefinition config -> Options
options :: Options
      -- ^ Configurable options for the server's capabilities.
    }

-- | A function that a 'Handler' is passed that can be used to respond to a
-- request with either an error, or the response params.
newtype ServerResponseCallback (m :: Method FromServer Request)
  = ServerResponseCallback (Either ResponseError (ResponseResult m) -> IO ())

-- | Return value signals if response handler was inserted succesfully
-- Might fail if the id was already in the map
addResponseHandler :: MonadLsp config f => LspId m -> (Product SMethod ServerResponseCallback) m -> f Bool
addResponseHandler :: LspId @'FromServer m
-> Product
     @(Method 'FromServer 'Request)
     (SMethod @'FromServer @'Request)
     ServerResponseCallback
     m
-> f Bool
addResponseHandler LspId @'FromServer m
lid Product
  @(Method 'FromServer 'Request)
  (SMethod @'FromServer @'Request)
  ServerResponseCallback
  m
h = do
  (LanguageContextState config -> TVar ResponseMap)
-> (ResponseMap -> (Bool, ResponseMap)) -> f Bool
forall config (m :: * -> *) s a.
MonadLsp config m =>
(LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState LanguageContextState config -> TVar ResponseMap
forall config. LanguageContextState config -> TVar ResponseMap
resPendingResponses ((ResponseMap -> (Bool, ResponseMap)) -> f Bool)
-> (ResponseMap -> (Bool, ResponseMap)) -> f Bool
forall a b. (a -> b) -> a -> b
$ \ResponseMap
pending ->
    case LspId @'FromServer m
-> Product
     @(Method 'FromServer 'Request)
     (SMethod @'FromServer @'Request)
     ServerResponseCallback
     m
-> ResponseMap
-> Maybe ResponseMap
forall a (k :: a -> *) (m :: a) (f :: a -> *).
IxOrd @a k =>
k m -> f m -> IxMap @a k f -> Maybe (IxMap @a k f)
insertIxMap LspId @'FromServer m
lid Product
  @(Method 'FromServer 'Request)
  (SMethod @'FromServer @'Request)
  ServerResponseCallback
  m
h ResponseMap
pending of
      Just !ResponseMap
m -> (Bool
True, ResponseMap
m)
      Maybe ResponseMap
Nothing -> (Bool
False, ResponseMap
pending)

sendNotification
  :: forall (m :: Method FromServer Notification) f config. MonadLsp config f
  => SServerMethod m
  -> MessageParams m
  -> f ()
sendNotification :: SServerMethod @'Notification m
-> MessageParams @'FromServer @'Notification m -> f ()
sendNotification SServerMethod @'Notification m
m MessageParams @'FromServer @'Notification m
params =
  let msg :: NotificationMessage @'FromServer m
msg = Text
-> SServerMethod @'Notification m
-> MessageParams @'FromServer @'Notification m
-> NotificationMessage @'FromServer m
forall (f :: From) (m :: Method f 'Notification).
Text
-> SMethod @f @'Notification m
-> MessageParams @f @'Notification m
-> NotificationMessage @f m
NotificationMessage Text
"2.0" SServerMethod @'Notification m
m MessageParams @'FromServer @'Notification m
params
  in case SServerMethod @'Notification m -> ServerNotOrReq @'Notification m
forall (t :: MethodType) (m :: Method 'FromServer t).
SServerMethod @t m -> ServerNotOrReq @t m
splitServerMethod SServerMethod @'Notification m
m of
        ServerNotOrReq @'Notification m
IsServerNot -> FromServerMessage -> f ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> f ()) -> FromServerMessage -> f ()
forall a b. (a -> b) -> a -> b
$ NotificationMessage @'FromServer m -> FromServerMessage
forall (m :: Method 'FromServer 'Notification).
((Message @'FromServer @'Notification m :: *)
 ~ (NotificationMessage @'FromServer m :: *)) =>
NotificationMessage @'FromServer m -> FromServerMessage
fromServerNot NotificationMessage @'FromServer m
msg
        ServerNotOrReq @'Notification m
IsServerEither -> FromServerMessage -> f ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> f ()) -> FromServerMessage -> f ()
forall a b. (a -> b) -> a -> b
$ SServerMethod @'Notification m
-> Message @'FromServer @'Notification m -> FromServerMessage
forall (t :: MethodType) (m :: Method 'FromServer t)
       (a :: Method 'FromClient 'Request -> *).
SMethod @'FromServer @t m
-> Message @'FromServer @t m -> FromServerMessage' a
FromServerMess SServerMethod @'Notification m
m (Message @'FromServer @'Notification m -> FromServerMessage)
-> Message @'FromServer @'Notification m -> FromServerMessage
forall a b. (a -> b) -> a -> b
$ NotificationMessage
  @'FromServer ('CustomMethod @'FromServer @'Notification)
-> CustomMessage 'FromServer 'Notification
forall (f :: From).
NotificationMessage @f ('CustomMethod @f @'Notification)
-> CustomMessage f 'Notification
NotMess NotificationMessage @'FromServer m
NotificationMessage
  @'FromServer ('CustomMethod @'FromServer @'Notification)
msg

sendRequest :: forall (m :: Method FromServer Request) f config. MonadLsp config f
            => SServerMethod m
            -> MessageParams m
            -> (Either ResponseError (ResponseResult m) -> f ())
            -> f (LspId m)
sendRequest :: SServerMethod @'Request m
-> MessageParams @'FromServer @'Request m
-> (Either ResponseError (ResponseResult @'FromServer m) -> f ())
-> f (LspId @'FromServer m)
sendRequest SServerMethod @'Request m
m MessageParams @'FromServer @'Request m
params Either ResponseError (ResponseResult @'FromServer m) -> f ()
resHandler = do
  LspId @'FromServer m
reqId <- Int -> LspId @'FromServer m
forall (f :: From) (m :: Method f 'Request). Int -> LspId @f m
IdInt (Int -> LspId @'FromServer m) -> f Int -> f (LspId @'FromServer m)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f Int
forall config (m :: * -> *). MonadLsp config m => m Int
freshLspId
  f () -> IO ()
rio <- f (f () -> IO ())
forall (m :: * -> *) a. MonadUnliftIO m => m (m a -> IO a)
askRunInIO
  Bool
success <- LspId @'FromServer m
-> Product
     @(Method 'FromServer 'Request)
     (SMethod @'FromServer @'Request)
     ServerResponseCallback
     m
-> f Bool
forall config (f :: * -> *) (m :: Method 'FromServer 'Request).
MonadLsp config f =>
LspId @'FromServer m
-> Product
     @(Method 'FromServer 'Request)
     (SMethod @'FromServer @'Request)
     ServerResponseCallback
     m
-> f Bool
addResponseHandler LspId @'FromServer m
reqId (SServerMethod @'Request m
-> ServerResponseCallback m
-> Product
     @(Method 'FromServer 'Request)
     (SMethod @'FromServer @'Request)
     ServerResponseCallback
     m
forall k (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product @k f g a
Pair SServerMethod @'Request m
m ((Either ResponseError (ResponseResult @'FromServer m) -> IO ())
-> ServerResponseCallback m
forall (m :: Method 'FromServer 'Request).
(Either ResponseError (ResponseResult @'FromServer m) -> IO ())
-> ServerResponseCallback m
ServerResponseCallback (f () -> IO ()
rio (f () -> IO ())
-> (Either ResponseError (ResponseResult @'FromServer m) -> f ())
-> Either ResponseError (ResponseResult @'FromServer m)
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either ResponseError (ResponseResult @'FromServer m) -> f ()
resHandler)))
  Bool -> f () -> f ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless Bool
success (f () -> f ()) -> f () -> f ()
forall a b. (a -> b) -> a -> b
$ FilePath -> f ()
forall a. HasCallStack => FilePath -> a
error FilePath
"haskell-lsp: could not send FromServer request as id is reused"

  let msg :: RequestMessage @'FromServer m
msg = Text
-> LspId @'FromServer m
-> SServerMethod @'Request m
-> MessageParams @'FromServer @'Request m
-> RequestMessage @'FromServer m
forall (f :: From) (m :: Method f 'Request).
Text
-> LspId @f m
-> SMethod @f @'Request m
-> MessageParams @f @'Request m
-> RequestMessage @f m
RequestMessage Text
"2.0" LspId @'FromServer m
reqId SServerMethod @'Request m
m MessageParams @'FromServer @'Request m
params
  ~() <- case SServerMethod @'Request m -> ServerNotOrReq @'Request m
forall (t :: MethodType) (m :: Method 'FromServer t).
SServerMethod @t m -> ServerNotOrReq @t m
splitServerMethod SServerMethod @'Request m
m of
    ServerNotOrReq @'Request m
IsServerReq -> FromServerMessage -> f ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> f ()) -> FromServerMessage -> f ()
forall a b. (a -> b) -> a -> b
$ RequestMessage @'FromServer m -> FromServerMessage
forall (m :: Method 'FromServer 'Request).
((Message @'FromServer @'Request m :: *)
 ~ (RequestMessage @'FromServer m :: *)) =>
RequestMessage @'FromServer m -> FromServerMessage
fromServerReq RequestMessage @'FromServer m
msg
    ServerNotOrReq @'Request m
IsServerEither -> FromServerMessage -> f ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> f ()) -> FromServerMessage -> f ()
forall a b. (a -> b) -> a -> b
$ SServerMethod @'Request m
-> Message @'FromServer @'Request m -> FromServerMessage
forall (t :: MethodType) (m :: Method 'FromServer t)
       (a :: Method 'FromClient 'Request -> *).
SMethod @'FromServer @t m
-> Message @'FromServer @t m -> FromServerMessage' a
FromServerMess SServerMethod @'Request m
m (Message @'FromServer @'Request m -> FromServerMessage)
-> Message @'FromServer @'Request m -> FromServerMessage
forall a b. (a -> b) -> a -> b
$ RequestMessage @'FromServer ('CustomMethod @'FromServer @'Request)
-> CustomMessage 'FromServer 'Request
forall (f :: From).
RequestMessage @f ('CustomMethod @f @'Request)
-> CustomMessage f 'Request
ReqMess RequestMessage @'FromServer m
RequestMessage @'FromServer ('CustomMethod @'FromServer @'Request)
msg
  LspId @'FromServer m -> f (LspId @'FromServer m)
forall (m :: * -> *) a. Monad m => a -> m a
return LspId @'FromServer m
reqId

-- ---------------------------------------------------------------------

-- | Return the 'VirtualFile' associated with a given 'NormalizedUri', if there is one.
getVirtualFile :: MonadLsp config m => NormalizedUri -> m (Maybe VirtualFile)
getVirtualFile :: NormalizedUri -> m (Maybe VirtualFile)
getVirtualFile NormalizedUri
uri = NormalizedUri -> Map NormalizedUri VirtualFile -> Maybe VirtualFile
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup NormalizedUri
uri (Map NormalizedUri VirtualFile -> Maybe VirtualFile)
-> (VFSData -> Map NormalizedUri VirtualFile)
-> VFSData
-> Maybe VirtualFile
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VFS -> Map NormalizedUri VirtualFile
vfsMap (VFS -> Map NormalizedUri VirtualFile)
-> (VFSData -> VFS) -> VFSData -> Map NormalizedUri VirtualFile
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VFSData -> VFS
vfsData (VFSData -> Maybe VirtualFile)
-> m VFSData -> m (Maybe VirtualFile)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LanguageContextState config -> TVar VFSData) -> m VFSData
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> m a
getsState LanguageContextState config -> TVar VFSData
forall config. LanguageContextState config -> TVar VFSData
resVFS

{-# INLINE getVirtualFile #-}

getVirtualFiles :: MonadLsp config m => m VFS
getVirtualFiles :: m VFS
getVirtualFiles = VFSData -> VFS
vfsData (VFSData -> VFS) -> m VFSData -> m VFS
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LanguageContextState config -> TVar VFSData) -> m VFSData
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> m a
getsState LanguageContextState config -> TVar VFSData
forall config. LanguageContextState config -> TVar VFSData
resVFS

{-# INLINE getVirtualFiles #-}

-- | Dump the current text for a given VFS file to a temporary file,
-- and return the path to the file.
persistVirtualFile :: MonadLsp config m => NormalizedUri -> m (Maybe FilePath)
persistVirtualFile :: NormalizedUri -> m (Maybe FilePath)
persistVirtualFile NormalizedUri
uri = do
  m (m (Maybe FilePath)) -> m (Maybe FilePath)
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (m (m (Maybe FilePath)) -> m (Maybe FilePath))
-> m (m (Maybe FilePath)) -> m (Maybe FilePath)
forall a b. (a -> b) -> a -> b
$ (LanguageContextState config -> TVar VFSData)
-> (VFSData -> (m (Maybe FilePath), VFSData))
-> m (m (Maybe FilePath))
forall config (m :: * -> *) s a.
MonadLsp config m =>
(LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState LanguageContextState config -> TVar VFSData
forall config. LanguageContextState config -> TVar VFSData
resVFS ((VFSData -> (m (Maybe FilePath), VFSData))
 -> m (m (Maybe FilePath)))
-> (VFSData -> (m (Maybe FilePath), VFSData))
-> m (m (Maybe FilePath))
forall a b. (a -> b) -> a -> b
$ \VFSData
vfs ->
    case VFS -> NormalizedUri -> Maybe (FilePath, IO ())
persistFileVFS (VFSData -> VFS
vfsData VFSData
vfs) NormalizedUri
uri of
      Maybe (FilePath, IO ())
Nothing -> (Maybe FilePath -> m (Maybe FilePath)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe FilePath
forall a. Maybe a
Nothing, VFSData
vfs)
      Just (FilePath
fn, IO ()
write) ->
        let !revMap :: Map FilePath FilePath
revMap = case Uri -> Maybe FilePath
uriToFilePath (NormalizedUri -> Uri
fromNormalizedUri NormalizedUri
uri) of
              Just FilePath
uri_fp -> FilePath
-> FilePath -> Map FilePath FilePath -> Map FilePath FilePath
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert FilePath
fn FilePath
uri_fp (Map FilePath FilePath -> Map FilePath FilePath)
-> Map FilePath FilePath -> Map FilePath FilePath
forall a b. (a -> b) -> a -> b
$ VFSData -> Map FilePath FilePath
reverseMap VFSData
vfs
              -- TODO: Does the VFS make sense for URIs which are not files?
              -- The reverse map should perhaps be (FilePath -> URI)
              Maybe FilePath
Nothing -> VFSData -> Map FilePath FilePath
reverseMap VFSData
vfs
            !vfs' :: VFSData
vfs' = VFSData
vfs {reverseMap :: Map FilePath FilePath
reverseMap = Map FilePath FilePath
revMap}
            act :: m (Maybe FilePath)
act = do
              IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO IO ()
write
              Maybe FilePath -> m (Maybe FilePath)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (FilePath -> Maybe FilePath
forall a. a -> Maybe a
Just FilePath
fn)
        in (m (Maybe FilePath)
act, VFSData
vfs')

-- | Given a text document identifier, annotate it with the latest version.
getVersionedTextDoc :: MonadLsp config m => TextDocumentIdentifier -> m VersionedTextDocumentIdentifier
getVersionedTextDoc :: TextDocumentIdentifier -> m VersionedTextDocumentIdentifier
getVersionedTextDoc TextDocumentIdentifier
doc = do
  let uri :: Uri
uri = TextDocumentIdentifier
doc TextDocumentIdentifier
-> Getting Uri TextDocumentIdentifier Uri -> Uri
forall s a. s -> Getting a s a -> a
^. Getting Uri TextDocumentIdentifier Uri
forall s a. HasUri s a => Lens' s a
J.uri
  Maybe VirtualFile
mvf <- NormalizedUri -> m (Maybe VirtualFile)
forall config (m :: * -> *).
MonadLsp config m =>
NormalizedUri -> m (Maybe VirtualFile)
getVirtualFile (Uri -> NormalizedUri
toNormalizedUri Uri
uri)
  let ver :: Maybe Int
ver = case Maybe VirtualFile
mvf of
        Just (VirtualFile Int
lspver Int
_ Rope
_) -> Int -> Maybe Int
forall a. a -> Maybe a
Just Int
lspver
        Maybe VirtualFile
Nothing -> Maybe Int
forall a. Maybe a
Nothing
  VersionedTextDocumentIdentifier
-> m VersionedTextDocumentIdentifier
forall (m :: * -> *) a. Monad m => a -> m a
return (Uri -> Maybe Int -> VersionedTextDocumentIdentifier
VersionedTextDocumentIdentifier Uri
uri Maybe Int
ver)

{-# INLINE getVersionedTextDoc #-}

-- TODO: should this function return a URI?
-- | If the contents of a VFS has been dumped to a temporary file, map
-- the temporary file name back to the original one.
reverseFileMap :: MonadLsp config m => m (FilePath -> FilePath)
reverseFileMap :: m ShowS
reverseFileMap = do
  VFSData
vfs <- (LanguageContextState config -> TVar VFSData) -> m VFSData
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> m a
getsState LanguageContextState config -> TVar VFSData
forall config. LanguageContextState config -> TVar VFSData
resVFS
  let f :: ShowS
f FilePath
fp = FilePath -> Maybe FilePath -> FilePath
forall a. a -> Maybe a -> a
fromMaybe FilePath
fp (Maybe FilePath -> FilePath)
-> (VFSData -> Maybe FilePath) -> VFSData -> FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. FilePath -> Map FilePath FilePath -> Maybe FilePath
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup FilePath
fp (Map FilePath FilePath -> Maybe FilePath)
-> (VFSData -> Map FilePath FilePath) -> VFSData -> Maybe FilePath
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VFSData -> Map FilePath FilePath
reverseMap (VFSData -> FilePath) -> VFSData -> FilePath
forall a b. (a -> b) -> a -> b
$ VFSData
vfs
  ShowS -> m ShowS
forall (m :: * -> *) a. Monad m => a -> m a
return ShowS
f

{-# INLINE reverseFileMap #-}

-- ---------------------------------------------------------------------

sendToClient :: MonadLsp config m => FromServerMessage -> m ()
sendToClient :: FromServerMessage -> m ()
sendToClient FromServerMessage
msg = do
  FromServerMessage -> IO ()
f <- LanguageContextEnv config -> FromServerMessage -> IO ()
forall config.
LanguageContextEnv config -> FromServerMessage -> IO ()
resSendMessage (LanguageContextEnv config -> FromServerMessage -> IO ())
-> m (LanguageContextEnv config) -> m (FromServerMessage -> IO ())
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv
  IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ FromServerMessage -> IO ()
f FromServerMessage
msg

{-# INLINE sendToClient #-}

-- ---------------------------------------------------------------------

sendErrorLog :: MonadLsp config m => Text -> m ()
sendErrorLog :: Text -> m ()
sendErrorLog Text
msg =
  FromServerMessage -> m ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> m ()) -> FromServerMessage -> m ()
forall a b. (a -> b) -> a -> b
$ NotificationMessage @'FromServer 'WindowLogMessage
-> FromServerMessage
forall (m :: Method 'FromServer 'Notification).
((Message @'FromServer @'Notification m :: *)
 ~ (NotificationMessage @'FromServer m :: *)) =>
NotificationMessage @'FromServer m -> FromServerMessage
fromServerNot (NotificationMessage @'FromServer 'WindowLogMessage
 -> FromServerMessage)
-> NotificationMessage @'FromServer 'WindowLogMessage
-> FromServerMessage
forall a b. (a -> b) -> a -> b
$
    Text
-> SMethod @'FromServer @'Notification 'WindowLogMessage
-> MessageParams @'FromServer @'Notification 'WindowLogMessage
-> NotificationMessage @'FromServer 'WindowLogMessage
forall (f :: From) (m :: Method f 'Notification).
Text
-> SMethod @f @'Notification m
-> MessageParams @f @'Notification m
-> NotificationMessage @f m
NotificationMessage Text
"2.0" SMethod @'FromServer @'Notification 'WindowLogMessage
SWindowLogMessage (MessageType -> Text -> LogMessageParams
LogMessageParams MessageType
MtError Text
msg)

{-# INLINE sendErrorLog #-}

-- ---------------------------------------------------------------------

freshLspId :: MonadLsp config m => m Int
freshLspId :: m Int
freshLspId = do
  (LanguageContextState config -> TVar Int)
-> (Int -> (Int, Int)) -> m Int
forall config (m :: * -> *) s a.
MonadLsp config m =>
(LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState LanguageContextState config -> TVar Int
forall config. LanguageContextState config -> TVar Int
resLspId ((Int -> (Int, Int)) -> m Int) -> (Int -> (Int, Int)) -> m Int
forall a b. (a -> b) -> a -> b
$ \Int
cur ->
    let !next :: Int
next = Int
curInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1 in (Int
cur, Int
next)

{-# INLINE freshLspId #-}

-- ---------------------------------------------------------------------

-- | The current configuration from the client as set via the @initialize@ and
-- @workspace/didChangeConfiguration@ requests.
getConfig :: MonadLsp config m => m config
getConfig :: m config
getConfig = (LanguageContextState config -> TVar config) -> m config
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> m a
getsState LanguageContextState config -> TVar config
forall config. LanguageContextState config -> TVar config
resConfig

{-# INLINE getConfig #-}

getClientCapabilities :: MonadLsp config m => m J.ClientCapabilities
getClientCapabilities :: m ClientCapabilities
getClientCapabilities = LanguageContextEnv config -> ClientCapabilities
forall config. LanguageContextEnv config -> ClientCapabilities
resClientCapabilities (LanguageContextEnv config -> ClientCapabilities)
-> m (LanguageContextEnv config) -> m ClientCapabilities
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv

{-# INLINE getClientCapabilities #-}

getRootPath :: MonadLsp config m => m (Maybe FilePath)
getRootPath :: m (Maybe FilePath)
getRootPath = LanguageContextEnv config -> Maybe FilePath
forall config. LanguageContextEnv config -> Maybe FilePath
resRootPath (LanguageContextEnv config -> Maybe FilePath)
-> m (LanguageContextEnv config) -> m (Maybe FilePath)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv

{-# INLINE getRootPath #-}

-- | The current workspace folders, if the client supports workspace folders.
getWorkspaceFolders :: MonadLsp config m => m (Maybe [WorkspaceFolder])
getWorkspaceFolders :: m (Maybe [WorkspaceFolder])
getWorkspaceFolders = do
  ClientCapabilities
clientCaps <- m ClientCapabilities
forall config (m :: * -> *).
MonadLsp config m =>
m ClientCapabilities
getClientCapabilities
  let clientSupportsWfs :: Bool
clientSupportsWfs = Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe Bool
False (Maybe Bool -> Bool) -> Maybe Bool -> Bool
forall a b. (a -> b) -> a -> b
$ do
        let (J.ClientCapabilities Maybe WorkspaceClientCapabilities
mw Maybe TextDocumentClientCapabilities
_ Maybe WindowClientCapabilities
_ Maybe Object
_) = ClientCapabilities
clientCaps
        (J.WorkspaceClientCapabilities Maybe Bool
_ Maybe WorkspaceEditClientCapabilities
_ Maybe DidChangeConfigurationClientCapabilities
_ Maybe DidChangeWatchedFilesClientCapabilities
_ Maybe WorkspaceSymbolClientCapabilities
_ Maybe ExecuteCommandClientCapabilities
_ Maybe Bool
mwf Maybe Bool
_) <- Maybe WorkspaceClientCapabilities
mw
        Maybe Bool
mwf
  if Bool
clientSupportsWfs
    then [WorkspaceFolder] -> Maybe [WorkspaceFolder]
forall a. a -> Maybe a
Just ([WorkspaceFolder] -> Maybe [WorkspaceFolder])
-> m [WorkspaceFolder] -> m (Maybe [WorkspaceFolder])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (LanguageContextState config -> TVar [WorkspaceFolder])
-> m [WorkspaceFolder]
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> m a
getsState LanguageContextState config -> TVar [WorkspaceFolder]
forall config.
LanguageContextState config -> TVar [WorkspaceFolder]
resWorkspaceFolders
    else Maybe [WorkspaceFolder] -> m (Maybe [WorkspaceFolder])
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe [WorkspaceFolder]
forall a. Maybe a
Nothing

{-# INLINE getWorkspaceFolders #-}

-- | Sends a @client/registerCapability@ request and dynamically registers
-- a 'Method' with a 'Handler'. Returns 'Nothing' if the client does not
-- support dynamic registration for the specified method, otherwise a
-- 'RegistrationToken' which can be used to unregister it later.
registerCapability :: forall f t (m :: Method FromClient t) config.
                      MonadLsp config f
                   => SClientMethod m
                   -> RegistrationOptions m
                   -> Handler f m
                   -> f (Maybe (RegistrationToken m))
registerCapability :: SClientMethod @t m
-> RegistrationOptions @t m
-> Handler @'FromClient @t f m
-> f (Maybe (RegistrationToken @t m))
registerCapability SClientMethod @t m
method RegistrationOptions @t m
regOpts Handler @'FromClient @t f m
f = do
  ClientCapabilities
clientCaps <- LanguageContextEnv config -> ClientCapabilities
forall config. LanguageContextEnv config -> ClientCapabilities
resClientCapabilities (LanguageContextEnv config -> ClientCapabilities)
-> f (LanguageContextEnv config) -> f ClientCapabilities
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv
  Handlers IO
handlers <- LanguageContextEnv config -> Handlers IO
forall config. LanguageContextEnv config -> Handlers IO
resHandlers (LanguageContextEnv config -> Handlers IO)
-> f (LanguageContextEnv config) -> f (Handlers IO)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> f (LanguageContextEnv config)
forall config (m :: * -> *).
MonadLsp config m =>
m (LanguageContextEnv config)
getLspEnv
  let alreadyStaticallyRegistered :: Bool
alreadyStaticallyRegistered = case SClientMethod @t m -> ClientNotOrReq @t m
forall (t :: MethodType) (m :: Method 'FromClient t).
SClientMethod @t m -> ClientNotOrReq @t m
splitClientMethod SClientMethod @t m
method of
        ClientNotOrReq @t m
IsClientNot -> SClientMethod @t m
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (ClientMessageHandler IO 'Notification)
-> Bool
forall k1 (k2 :: k1 -> *) (a :: k1) (f :: k1 -> *).
GCompare @k1 k2 =>
k2 a -> DMap @k1 k2 f -> Bool
DMap.member SClientMethod @t m
method (DMap
   @(Method 'FromClient t)
   (SMethod @'FromClient @t)
   (ClientMessageHandler IO 'Notification)
 -> Bool)
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (ClientMessageHandler IO 'Notification)
-> Bool
forall a b. (a -> b) -> a -> b
$ Handlers IO
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler IO 'Notification)
forall (m :: * -> *).
Handlers m
-> DMap
     @(Method 'FromClient 'Notification)
     (SMethod @'FromClient @'Notification)
     (ClientMessageHandler m 'Notification)
notHandlers Handlers IO
handlers
        ClientNotOrReq @t m
IsClientReq -> SClientMethod @t m
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (ClientMessageHandler IO 'Request)
-> Bool
forall k1 (k2 :: k1 -> *) (a :: k1) (f :: k1 -> *).
GCompare @k1 k2 =>
k2 a -> DMap @k1 k2 f -> Bool
DMap.member SClientMethod @t m
method (DMap
   @(Method 'FromClient t)
   (SMethod @'FromClient @t)
   (ClientMessageHandler IO 'Request)
 -> Bool)
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (ClientMessageHandler IO 'Request)
-> Bool
forall a b. (a -> b) -> a -> b
$ Handlers IO
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler IO 'Request)
forall (m :: * -> *).
Handlers m
-> DMap
     @(Method 'FromClient 'Request)
     (SMethod @'FromClient @'Request)
     (ClientMessageHandler m 'Request)
reqHandlers Handlers IO
handlers
        ClientNotOrReq @t m
IsClientEither -> FilePath -> Bool
forall a. HasCallStack => FilePath -> a
error FilePath
"Cannot register capability for custom methods"
  ClientCapabilities -> Bool -> f (Maybe (RegistrationToken @t m))
go ClientCapabilities
clientCaps Bool
alreadyStaticallyRegistered
  where
    -- If the server has already registered statically, don't dynamically register
    -- as per the spec
    go :: ClientCapabilities -> Bool -> f (Maybe (RegistrationToken @t m))
go ClientCapabilities
_clientCaps Bool
True = Maybe (RegistrationToken @t m)
-> f (Maybe (RegistrationToken @t m))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (RegistrationToken @t m)
forall a. Maybe a
Nothing
    go ClientCapabilities
clientCaps  Bool
False
      -- First, check to see if the client supports dynamic registration on this method
      | ClientCapabilities -> Bool
dynamicSupported ClientCapabilities
clientCaps = do
          Text
uuid <- IO Text -> f Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> f Text) -> IO Text -> f Text
forall a b. (a -> b) -> a -> b
$ UUID -> Text
UUID.toText (UUID -> Text) -> IO UUID -> IO Text
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (StdGen -> (UUID, StdGen)) -> IO UUID
forall (m :: * -> *) a. MonadIO m => (StdGen -> (a, StdGen)) -> m a
getStdRandom StdGen -> (UUID, StdGen)
forall a g. (Random a, RandomGen g) => g -> (a, g)
random
          let registration :: Registration @t m
registration = Text
-> SClientMethod @t m
-> RegistrationOptions @t m
-> Registration @t m
forall (t :: MethodType) (m :: Method 'FromClient t).
Text
-> SClientMethod @t m
-> RegistrationOptions @t m
-> Registration @t m
J.Registration Text
uuid SClientMethod @t m
method RegistrationOptions @t m
regOpts
              params :: RegistrationParams
params = List SomeRegistration -> RegistrationParams
J.RegistrationParams ([SomeRegistration] -> List SomeRegistration
forall a. [a] -> List a
J.List [Registration @t m -> SomeRegistration
forall (t :: MethodType) (m :: Method 'FromClient t).
Registration @t m -> SomeRegistration
J.SomeRegistration Registration @t m
registration])
              regId :: RegistrationId @t m
regId = Text -> RegistrationId @t m
forall (t :: MethodType) (m :: Method 'FromClient t).
Text -> RegistrationId @t m
RegistrationId Text
uuid
          UnliftIO f
rio <- f (UnliftIO f)
forall (m :: * -> *). MonadUnliftIO m => m (UnliftIO m)
askUnliftIO
          ~() <- case SClientMethod @t m -> ClientNotOrReq @t m
forall (t :: MethodType) (m :: Method 'FromClient t).
SClientMethod @t m -> ClientNotOrReq @t m
splitClientMethod SClientMethod @t m
method of
            ClientNotOrReq @t m
IsClientNot -> (LanguageContextState config
 -> TVar (RegistrationMap 'Notification))
-> (RegistrationMap 'Notification -> RegistrationMap 'Notification)
-> f ()
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState LanguageContextState config -> TVar (RegistrationMap 'Notification)
forall config.
LanguageContextState config -> TVar (RegistrationMap 'Notification)
resRegistrationsNot ((RegistrationMap 'Notification -> RegistrationMap 'Notification)
 -> f ())
-> (RegistrationMap 'Notification -> RegistrationMap 'Notification)
-> f ()
forall a b. (a -> b) -> a -> b
$ \RegistrationMap 'Notification
oldRegs ->
              let pair :: Product
  @(Method 'FromClient t)
  (RegistrationId @t)
  (ClientMessageHandler IO t)
  m
pair = RegistrationId @t m
-> ClientMessageHandler IO t m
-> Product
     @(Method 'FromClient t)
     (RegistrationId @t)
     (ClientMessageHandler IO t)
     m
forall k (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product @k f g a
Pair RegistrationId @t m
regId (Handler @'FromClient @t IO m -> ClientMessageHandler IO t m
forall (f :: * -> *) (t :: MethodType) (m :: Method 'FromClient t).
Handler @'FromClient @t f m -> ClientMessageHandler f t m
ClientMessageHandler (UnliftIO f -> forall a. f a -> IO a
forall (m :: * -> *). UnliftIO m -> forall a. m a -> IO a
unliftIO UnliftIO f
rio (f () -> IO ())
-> (NotificationMessage @'FromClient m -> f ())
-> NotificationMessage @'FromClient m
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Handler @'FromClient @t f m
NotificationMessage @'FromClient m -> f ()
f))
                in SClientMethod @t m
-> Product
     @(Method 'FromClient 'Notification)
     (RegistrationId @'Notification)
     (ClientMessageHandler IO 'Notification)
     m
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Notification)
        (RegistrationId @'Notification)
        (ClientMessageHandler IO 'Notification))
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Notification)
        (RegistrationId @'Notification)
        (ClientMessageHandler IO 'Notification))
forall k1 (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare @k1 k2 =>
k2 v -> f v -> DMap @k1 k2 f -> DMap @k1 k2 f
DMap.insert SClientMethod @t m
method Product
  @(Method 'FromClient t)
  (RegistrationId @t)
  (ClientMessageHandler IO t)
  m
Product
  @(Method 'FromClient 'Notification)
  (RegistrationId @'Notification)
  (ClientMessageHandler IO 'Notification)
  m
pair DMap
  @(Method 'FromClient t)
  (SMethod @'FromClient @t)
  (Product
     @(Method 'FromClient 'Notification)
     (RegistrationId @'Notification)
     (ClientMessageHandler IO 'Notification))
RegistrationMap 'Notification
oldRegs
            ClientNotOrReq @t m
IsClientReq -> (LanguageContextState config -> TVar (RegistrationMap 'Request))
-> (RegistrationMap 'Request -> RegistrationMap 'Request) -> f ()
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState LanguageContextState config -> TVar (RegistrationMap 'Request)
forall config.
LanguageContextState config -> TVar (RegistrationMap 'Request)
resRegistrationsReq ((RegistrationMap 'Request -> RegistrationMap 'Request) -> f ())
-> (RegistrationMap 'Request -> RegistrationMap 'Request) -> f ()
forall a b. (a -> b) -> a -> b
$ \RegistrationMap 'Request
oldRegs ->
              let pair :: Product
  @(Method 'FromClient t)
  (RegistrationId @t)
  (ClientMessageHandler IO t)
  m
pair = RegistrationId @t m
-> ClientMessageHandler IO t m
-> Product
     @(Method 'FromClient t)
     (RegistrationId @t)
     (ClientMessageHandler IO t)
     m
forall k (f :: k -> *) (g :: k -> *) (a :: k).
f a -> g a -> Product @k f g a
Pair RegistrationId @t m
regId (Handler @'FromClient @t IO m -> ClientMessageHandler IO t m
forall (f :: * -> *) (t :: MethodType) (m :: Method 'FromClient t).
Handler @'FromClient @t f m -> ClientMessageHandler f t m
ClientMessageHandler (\RequestMessage @'FromClient m
msg Either ResponseError (ResponseResult @'FromClient m) -> IO ()
k -> UnliftIO f -> forall a. f a -> IO a
forall (m :: * -> *). UnliftIO m -> forall a. m a -> IO a
unliftIO UnliftIO f
rio (f () -> IO ()) -> f () -> IO ()
forall a b. (a -> b) -> a -> b
$ Handler @'FromClient @t f m
RequestMessage @'FromClient m
-> (Either ResponseError (ResponseResult @'FromClient m) -> f ())
-> f ()
f RequestMessage @'FromClient m
msg (IO () -> f ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> f ())
-> (Either ResponseError (ResponseResult @'FromClient m) -> IO ())
-> Either ResponseError (ResponseResult @'FromClient m)
-> f ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Either ResponseError (ResponseResult @'FromClient m) -> IO ()
k)))
                in SClientMethod @t m
-> Product
     @(Method 'FromClient 'Request)
     (RegistrationId @'Request)
     (ClientMessageHandler IO 'Request)
     m
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Request)
        (RegistrationId @'Request)
        (ClientMessageHandler IO 'Request))
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Request)
        (RegistrationId @'Request)
        (ClientMessageHandler IO 'Request))
forall k1 (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare @k1 k2 =>
k2 v -> f v -> DMap @k1 k2 f -> DMap @k1 k2 f
DMap.insert SClientMethod @t m
method Product
  @(Method 'FromClient t)
  (RegistrationId @t)
  (ClientMessageHandler IO t)
  m
Product
  @(Method 'FromClient 'Request)
  (RegistrationId @'Request)
  (ClientMessageHandler IO 'Request)
  m
pair DMap
  @(Method 'FromClient t)
  (SMethod @'FromClient @t)
  (Product
     @(Method 'FromClient 'Request)
     (RegistrationId @'Request)
     (ClientMessageHandler IO 'Request))
RegistrationMap 'Request
oldRegs
            ClientNotOrReq @t m
IsClientEither -> FilePath -> f ()
forall a. HasCallStack => FilePath -> a
error FilePath
"Cannot register capability for custom methods"

          -- TODO: handle the scenario where this returns an error
          LspId @'FromServer 'ClientRegisterCapability
_ <- SServerMethod @'Request 'ClientRegisterCapability
-> MessageParams @'FromServer @'Request 'ClientRegisterCapability
-> (Either
      ResponseError
      (ResponseResult @'FromServer 'ClientRegisterCapability)
    -> f ())
-> f (LspId @'FromServer 'ClientRegisterCapability)
forall (m :: Method 'FromServer 'Request) (f :: * -> *) config.
MonadLsp config f =>
SServerMethod @'Request m
-> MessageParams @'FromServer @'Request m
-> (Either ResponseError (ResponseResult @'FromServer m) -> f ())
-> f (LspId @'FromServer m)
sendRequest SServerMethod @'Request 'ClientRegisterCapability
SClientRegisterCapability MessageParams @'FromServer @'Request 'ClientRegisterCapability
RegistrationParams
params ((Either
    ResponseError
    (ResponseResult @'FromServer 'ClientRegisterCapability)
  -> f ())
 -> f (LspId @'FromServer 'ClientRegisterCapability))
-> (Either
      ResponseError
      (ResponseResult @'FromServer 'ClientRegisterCapability)
    -> f ())
-> f (LspId @'FromServer 'ClientRegisterCapability)
forall a b. (a -> b) -> a -> b
$ \Either
  ResponseError
  (ResponseResult @'FromServer 'ClientRegisterCapability)
_res -> () -> f ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

          Maybe (RegistrationToken @t m)
-> f (Maybe (RegistrationToken @t m))
forall (f :: * -> *) a. Applicative f => a -> f a
pure (RegistrationToken @t m -> Maybe (RegistrationToken @t m)
forall a. a -> Maybe a
Just (SClientMethod @t m -> RegistrationId @t m -> RegistrationToken @t m
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod @'FromClient @t m
-> RegistrationId @t m -> RegistrationToken @t m
RegistrationToken SClientMethod @t m
method RegistrationId @t m
regId))
      | Bool
otherwise        = Maybe (RegistrationToken @t m)
-> f (Maybe (RegistrationToken @t m))
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe (RegistrationToken @t m)
forall a. Maybe a
Nothing

    -- Also I'm thinking we should move this function to somewhere in messages.hs so
    -- we don't forget to update it when adding new methods...
    capDyn :: J.HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
    capDyn :: Maybe a -> Bool
capDyn (Just a
x) = Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe Bool
False (Maybe Bool -> Bool) -> Maybe Bool -> Bool
forall a b. (a -> b) -> a -> b
$ a
x a -> Getting (Maybe Bool) a (Maybe Bool) -> Maybe Bool
forall s a. s -> Getting a s a -> a
^. Getting (Maybe Bool) a (Maybe Bool)
forall s a. HasDynamicRegistration s a => Lens' s a
J.dynamicRegistration
    capDyn Maybe a
Nothing  = Bool
False

    -- | Checks if client capabilities declares that the method supports dynamic registration
    dynamicSupported :: ClientCapabilities -> Bool
dynamicSupported ClientCapabilities
clientCaps = case SClientMethod @t m
method of
      SClientMethod @t m
SWorkspaceDidChangeConfiguration -> Maybe DidChangeConfigurationClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DidChangeConfigurationClientCapabilities -> Bool)
-> Maybe DidChangeConfigurationClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DidChangeConfigurationClientCapabilities)
     ClientCapabilities
     DidChangeConfigurationClientCapabilities
-> Maybe DidChangeConfigurationClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ClientCapabilities
-> Const
     @*
     (First DidChangeConfigurationClientCapabilities)
     ClientCapabilities
forall s a. HasWorkspace s a => Lens' s a
J.workspace ((Maybe WorkspaceClientCapabilities
  -> Const
       @*
       (First DidChangeConfigurationClientCapabilities)
       (Maybe WorkspaceClientCapabilities))
 -> ClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      ClientCapabilities)
-> ((DidChangeConfigurationClientCapabilities
     -> Const
          @*
          (First DidChangeConfigurationClientCapabilities)
          DidChangeConfigurationClientCapabilities)
    -> Maybe WorkspaceClientCapabilities
    -> Const
         @*
         (First DidChangeConfigurationClientCapabilities)
         (Maybe WorkspaceClientCapabilities))
-> Getting
     (First DidChangeConfigurationClientCapabilities)
     ClientCapabilities
     DidChangeConfigurationClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      WorkspaceClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeConfigurationClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((WorkspaceClientCapabilities
  -> Const
       @*
       (First DidChangeConfigurationClientCapabilities)
       WorkspaceClientCapabilities)
 -> Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ((DidChangeConfigurationClientCapabilities
     -> Const
          @*
          (First DidChangeConfigurationClientCapabilities)
          DidChangeConfigurationClientCapabilities)
    -> WorkspaceClientCapabilities
    -> Const
         @*
         (First DidChangeConfigurationClientCapabilities)
         WorkspaceClientCapabilities)
-> (DidChangeConfigurationClientCapabilities
    -> Const
         @*
         (First DidChangeConfigurationClientCapabilities)
         DidChangeConfigurationClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeConfigurationClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DidChangeConfigurationClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      (Maybe DidChangeConfigurationClientCapabilities))
-> WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeConfigurationClientCapabilities)
     WorkspaceClientCapabilities
forall s a. HasDidChangeConfiguration s a => Lens' s a
J.didChangeConfiguration ((Maybe DidChangeConfigurationClientCapabilities
  -> Const
       @*
       (First DidChangeConfigurationClientCapabilities)
       (Maybe DidChangeConfigurationClientCapabilities))
 -> WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      WorkspaceClientCapabilities)
-> ((DidChangeConfigurationClientCapabilities
     -> Const
          @*
          (First DidChangeConfigurationClientCapabilities)
          DidChangeConfigurationClientCapabilities)
    -> Maybe DidChangeConfigurationClientCapabilities
    -> Const
         @*
         (First DidChangeConfigurationClientCapabilities)
         (Maybe DidChangeConfigurationClientCapabilities))
-> (DidChangeConfigurationClientCapabilities
    -> Const
         @*
         (First DidChangeConfigurationClientCapabilities)
         DidChangeConfigurationClientCapabilities)
-> WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeConfigurationClientCapabilities)
     WorkspaceClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DidChangeConfigurationClientCapabilities
 -> Const
      @*
      (First DidChangeConfigurationClientCapabilities)
      DidChangeConfigurationClientCapabilities)
-> Maybe DidChangeConfigurationClientCapabilities
-> Const
     @*
     (First DidChangeConfigurationClientCapabilities)
     (Maybe DidChangeConfigurationClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
SWorkspaceDidChangeWatchedFiles  -> Maybe DidChangeWatchedFilesClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DidChangeWatchedFilesClientCapabilities -> Bool)
-> Maybe DidChangeWatchedFilesClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DidChangeWatchedFilesClientCapabilities)
     ClientCapabilities
     DidChangeWatchedFilesClientCapabilities
-> Maybe DidChangeWatchedFilesClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ClientCapabilities
-> Const
     @*
     (First DidChangeWatchedFilesClientCapabilities)
     ClientCapabilities
forall s a. HasWorkspace s a => Lens' s a
J.workspace ((Maybe WorkspaceClientCapabilities
  -> Const
       @*
       (First DidChangeWatchedFilesClientCapabilities)
       (Maybe WorkspaceClientCapabilities))
 -> ClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      ClientCapabilities)
-> ((DidChangeWatchedFilesClientCapabilities
     -> Const
          @*
          (First DidChangeWatchedFilesClientCapabilities)
          DidChangeWatchedFilesClientCapabilities)
    -> Maybe WorkspaceClientCapabilities
    -> Const
         @*
         (First DidChangeWatchedFilesClientCapabilities)
         (Maybe WorkspaceClientCapabilities))
-> Getting
     (First DidChangeWatchedFilesClientCapabilities)
     ClientCapabilities
     DidChangeWatchedFilesClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      WorkspaceClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeWatchedFilesClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((WorkspaceClientCapabilities
  -> Const
       @*
       (First DidChangeWatchedFilesClientCapabilities)
       WorkspaceClientCapabilities)
 -> Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ((DidChangeWatchedFilesClientCapabilities
     -> Const
          @*
          (First DidChangeWatchedFilesClientCapabilities)
          DidChangeWatchedFilesClientCapabilities)
    -> WorkspaceClientCapabilities
    -> Const
         @*
         (First DidChangeWatchedFilesClientCapabilities)
         WorkspaceClientCapabilities)
-> (DidChangeWatchedFilesClientCapabilities
    -> Const
         @*
         (First DidChangeWatchedFilesClientCapabilities)
         DidChangeWatchedFilesClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeWatchedFilesClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DidChangeWatchedFilesClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      (Maybe DidChangeWatchedFilesClientCapabilities))
-> WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeWatchedFilesClientCapabilities)
     WorkspaceClientCapabilities
forall s a. HasDidChangeWatchedFiles s a => Lens' s a
J.didChangeWatchedFiles ((Maybe DidChangeWatchedFilesClientCapabilities
  -> Const
       @*
       (First DidChangeWatchedFilesClientCapabilities)
       (Maybe DidChangeWatchedFilesClientCapabilities))
 -> WorkspaceClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      WorkspaceClientCapabilities)
-> ((DidChangeWatchedFilesClientCapabilities
     -> Const
          @*
          (First DidChangeWatchedFilesClientCapabilities)
          DidChangeWatchedFilesClientCapabilities)
    -> Maybe DidChangeWatchedFilesClientCapabilities
    -> Const
         @*
         (First DidChangeWatchedFilesClientCapabilities)
         (Maybe DidChangeWatchedFilesClientCapabilities))
-> (DidChangeWatchedFilesClientCapabilities
    -> Const
         @*
         (First DidChangeWatchedFilesClientCapabilities)
         DidChangeWatchedFilesClientCapabilities)
-> WorkspaceClientCapabilities
-> Const
     @*
     (First DidChangeWatchedFilesClientCapabilities)
     WorkspaceClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DidChangeWatchedFilesClientCapabilities
 -> Const
      @*
      (First DidChangeWatchedFilesClientCapabilities)
      DidChangeWatchedFilesClientCapabilities)
-> Maybe DidChangeWatchedFilesClientCapabilities
-> Const
     @*
     (First DidChangeWatchedFilesClientCapabilities)
     (Maybe DidChangeWatchedFilesClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
SWorkspaceSymbol                 -> Maybe WorkspaceSymbolClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe WorkspaceSymbolClientCapabilities -> Bool)
-> Maybe WorkspaceSymbolClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First WorkspaceSymbolClientCapabilities)
     ClientCapabilities
     WorkspaceSymbolClientCapabilities
-> Maybe WorkspaceSymbolClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First WorkspaceSymbolClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First WorkspaceSymbolClientCapabilities) ClientCapabilities
forall s a. HasWorkspace s a => Lens' s a
J.workspace ((Maybe WorkspaceClientCapabilities
  -> Const
       @*
       (First WorkspaceSymbolClientCapabilities)
       (Maybe WorkspaceClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First WorkspaceSymbolClientCapabilities) ClientCapabilities)
-> ((WorkspaceSymbolClientCapabilities
     -> Const
          @*
          (First WorkspaceSymbolClientCapabilities)
          WorkspaceSymbolClientCapabilities)
    -> Maybe WorkspaceClientCapabilities
    -> Const
         @*
         (First WorkspaceSymbolClientCapabilities)
         (Maybe WorkspaceClientCapabilities))
-> Getting
     (First WorkspaceSymbolClientCapabilities)
     ClientCapabilities
     WorkspaceSymbolClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WorkspaceClientCapabilities
 -> Const
      @*
      (First WorkspaceSymbolClientCapabilities)
      WorkspaceClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First WorkspaceSymbolClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((WorkspaceClientCapabilities
  -> Const
       @*
       (First WorkspaceSymbolClientCapabilities)
       WorkspaceClientCapabilities)
 -> Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First WorkspaceSymbolClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ((WorkspaceSymbolClientCapabilities
     -> Const
          @*
          (First WorkspaceSymbolClientCapabilities)
          WorkspaceSymbolClientCapabilities)
    -> WorkspaceClientCapabilities
    -> Const
         @*
         (First WorkspaceSymbolClientCapabilities)
         WorkspaceClientCapabilities)
-> (WorkspaceSymbolClientCapabilities
    -> Const
         @*
         (First WorkspaceSymbolClientCapabilities)
         WorkspaceSymbolClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First WorkspaceSymbolClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe WorkspaceSymbolClientCapabilities
 -> Const
      @*
      (First WorkspaceSymbolClientCapabilities)
      (Maybe WorkspaceSymbolClientCapabilities))
-> WorkspaceClientCapabilities
-> Const
     @*
     (First WorkspaceSymbolClientCapabilities)
     WorkspaceClientCapabilities
forall s a. HasSymbol s a => Lens' s a
J.symbol ((Maybe WorkspaceSymbolClientCapabilities
  -> Const
       @*
       (First WorkspaceSymbolClientCapabilities)
       (Maybe WorkspaceSymbolClientCapabilities))
 -> WorkspaceClientCapabilities
 -> Const
      @*
      (First WorkspaceSymbolClientCapabilities)
      WorkspaceClientCapabilities)
-> ((WorkspaceSymbolClientCapabilities
     -> Const
          @*
          (First WorkspaceSymbolClientCapabilities)
          WorkspaceSymbolClientCapabilities)
    -> Maybe WorkspaceSymbolClientCapabilities
    -> Const
         @*
         (First WorkspaceSymbolClientCapabilities)
         (Maybe WorkspaceSymbolClientCapabilities))
-> (WorkspaceSymbolClientCapabilities
    -> Const
         @*
         (First WorkspaceSymbolClientCapabilities)
         WorkspaceSymbolClientCapabilities)
-> WorkspaceClientCapabilities
-> Const
     @*
     (First WorkspaceSymbolClientCapabilities)
     WorkspaceClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WorkspaceSymbolClientCapabilities
 -> Const
      @*
      (First WorkspaceSymbolClientCapabilities)
      WorkspaceSymbolClientCapabilities)
-> Maybe WorkspaceSymbolClientCapabilities
-> Const
     @*
     (First WorkspaceSymbolClientCapabilities)
     (Maybe WorkspaceSymbolClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
SWorkspaceExecuteCommand         -> Maybe ExecuteCommandClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe ExecuteCommandClientCapabilities -> Bool)
-> Maybe ExecuteCommandClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First ExecuteCommandClientCapabilities)
     ClientCapabilities
     ExecuteCommandClientCapabilities
-> Maybe ExecuteCommandClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First ExecuteCommandClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First ExecuteCommandClientCapabilities) ClientCapabilities
forall s a. HasWorkspace s a => Lens' s a
J.workspace ((Maybe WorkspaceClientCapabilities
  -> Const
       @*
       (First ExecuteCommandClientCapabilities)
       (Maybe WorkspaceClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First ExecuteCommandClientCapabilities) ClientCapabilities)
-> ((ExecuteCommandClientCapabilities
     -> Const
          @*
          (First ExecuteCommandClientCapabilities)
          ExecuteCommandClientCapabilities)
    -> Maybe WorkspaceClientCapabilities
    -> Const
         @*
         (First ExecuteCommandClientCapabilities)
         (Maybe WorkspaceClientCapabilities))
-> Getting
     (First ExecuteCommandClientCapabilities)
     ClientCapabilities
     ExecuteCommandClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (WorkspaceClientCapabilities
 -> Const
      @*
      (First ExecuteCommandClientCapabilities)
      WorkspaceClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First ExecuteCommandClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((WorkspaceClientCapabilities
  -> Const
       @*
       (First ExecuteCommandClientCapabilities)
       WorkspaceClientCapabilities)
 -> Maybe WorkspaceClientCapabilities
 -> Const
      @*
      (First ExecuteCommandClientCapabilities)
      (Maybe WorkspaceClientCapabilities))
-> ((ExecuteCommandClientCapabilities
     -> Const
          @*
          (First ExecuteCommandClientCapabilities)
          ExecuteCommandClientCapabilities)
    -> WorkspaceClientCapabilities
    -> Const
         @*
         (First ExecuteCommandClientCapabilities)
         WorkspaceClientCapabilities)
-> (ExecuteCommandClientCapabilities
    -> Const
         @*
         (First ExecuteCommandClientCapabilities)
         ExecuteCommandClientCapabilities)
-> Maybe WorkspaceClientCapabilities
-> Const
     @*
     (First ExecuteCommandClientCapabilities)
     (Maybe WorkspaceClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe ExecuteCommandClientCapabilities
 -> Const
      @*
      (First ExecuteCommandClientCapabilities)
      (Maybe ExecuteCommandClientCapabilities))
-> WorkspaceClientCapabilities
-> Const
     @*
     (First ExecuteCommandClientCapabilities)
     WorkspaceClientCapabilities
forall s a. HasExecuteCommand s a => Lens' s a
J.executeCommand ((Maybe ExecuteCommandClientCapabilities
  -> Const
       @*
       (First ExecuteCommandClientCapabilities)
       (Maybe ExecuteCommandClientCapabilities))
 -> WorkspaceClientCapabilities
 -> Const
      @*
      (First ExecuteCommandClientCapabilities)
      WorkspaceClientCapabilities)
-> ((ExecuteCommandClientCapabilities
     -> Const
          @*
          (First ExecuteCommandClientCapabilities)
          ExecuteCommandClientCapabilities)
    -> Maybe ExecuteCommandClientCapabilities
    -> Const
         @*
         (First ExecuteCommandClientCapabilities)
         (Maybe ExecuteCommandClientCapabilities))
-> (ExecuteCommandClientCapabilities
    -> Const
         @*
         (First ExecuteCommandClientCapabilities)
         ExecuteCommandClientCapabilities)
-> WorkspaceClientCapabilities
-> Const
     @*
     (First ExecuteCommandClientCapabilities)
     WorkspaceClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ExecuteCommandClientCapabilities
 -> Const
      @*
      (First ExecuteCommandClientCapabilities)
      ExecuteCommandClientCapabilities)
-> Maybe ExecuteCommandClientCapabilities
-> Const
     @*
     (First ExecuteCommandClientCapabilities)
     (Maybe ExecuteCommandClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDidOpen             -> Maybe TextDocumentSyncClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe TextDocumentSyncClientCapabilities -> Bool)
-> Maybe TextDocumentSyncClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First TextDocumentSyncClientCapabilities)
     ClientCapabilities
     TextDocumentSyncClientCapabilities
-> Maybe TextDocumentSyncClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First TextDocumentSyncClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First TextDocumentSyncClientCapabilities) ClientCapabilities)
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First TextDocumentSyncClientCapabilities)
     ClientCapabilities
     TextDocumentSyncClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentClientCapabilities)
-> (TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentSyncClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe TextDocumentSyncClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentSyncClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasSynchronization s a => Lens' s a
J.synchronization ((Maybe TextDocumentSyncClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       (Maybe TextDocumentSyncClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentClientCapabilities)
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> Maybe TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         (Maybe TextDocumentSyncClientCapabilities))
-> (TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentSyncClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentSyncClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentSyncClientCapabilities)
-> Maybe TextDocumentSyncClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentSyncClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDidChange           -> Maybe TextDocumentSyncClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe TextDocumentSyncClientCapabilities -> Bool)
-> Maybe TextDocumentSyncClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First TextDocumentSyncClientCapabilities)
     ClientCapabilities
     TextDocumentSyncClientCapabilities
-> Maybe TextDocumentSyncClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First TextDocumentSyncClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First TextDocumentSyncClientCapabilities) ClientCapabilities)
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First TextDocumentSyncClientCapabilities)
     ClientCapabilities
     TextDocumentSyncClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentClientCapabilities)
-> (TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentSyncClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe TextDocumentSyncClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentSyncClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasSynchronization s a => Lens' s a
J.synchronization ((Maybe TextDocumentSyncClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       (Maybe TextDocumentSyncClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentClientCapabilities)
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> Maybe TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         (Maybe TextDocumentSyncClientCapabilities))
-> (TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentSyncClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentSyncClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentSyncClientCapabilities)
-> Maybe TextDocumentSyncClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentSyncClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDidClose            -> Maybe TextDocumentSyncClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe TextDocumentSyncClientCapabilities -> Bool)
-> Maybe TextDocumentSyncClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First TextDocumentSyncClientCapabilities)
     ClientCapabilities
     TextDocumentSyncClientCapabilities
-> Maybe TextDocumentSyncClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First TextDocumentSyncClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First TextDocumentSyncClientCapabilities) ClientCapabilities)
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First TextDocumentSyncClientCapabilities)
     ClientCapabilities
     TextDocumentSyncClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentClientCapabilities)
-> (TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentSyncClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe TextDocumentSyncClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      (Maybe TextDocumentSyncClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasSynchronization s a => Lens' s a
J.synchronization ((Maybe TextDocumentSyncClientCapabilities
  -> Const
       @*
       (First TextDocumentSyncClientCapabilities)
       (Maybe TextDocumentSyncClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentClientCapabilities)
-> ((TextDocumentSyncClientCapabilities
     -> Const
          @*
          (First TextDocumentSyncClientCapabilities)
          TextDocumentSyncClientCapabilities)
    -> Maybe TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         (Maybe TextDocumentSyncClientCapabilities))
-> (TextDocumentSyncClientCapabilities
    -> Const
         @*
         (First TextDocumentSyncClientCapabilities)
         TextDocumentSyncClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentSyncClientCapabilities
 -> Const
      @*
      (First TextDocumentSyncClientCapabilities)
      TextDocumentSyncClientCapabilities)
-> Maybe TextDocumentSyncClientCapabilities
-> Const
     @*
     (First TextDocumentSyncClientCapabilities)
     (Maybe TextDocumentSyncClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentCompletion          -> Maybe CompletionClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe CompletionClientCapabilities -> Bool)
-> Maybe CompletionClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First CompletionClientCapabilities)
     ClientCapabilities
     CompletionClientCapabilities
-> Maybe CompletionClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First CompletionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First CompletionClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First CompletionClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First CompletionClientCapabilities) ClientCapabilities)
-> ((CompletionClientCapabilities
     -> Const
          @*
          (First CompletionClientCapabilities)
          CompletionClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First CompletionClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First CompletionClientCapabilities)
     ClientCapabilities
     CompletionClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First CompletionClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First CompletionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First CompletionClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First CompletionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((CompletionClientCapabilities
     -> Const
          @*
          (First CompletionClientCapabilities)
          CompletionClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First CompletionClientCapabilities)
         TextDocumentClientCapabilities)
-> (CompletionClientCapabilities
    -> Const
         @*
         (First CompletionClientCapabilities)
         CompletionClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First CompletionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe CompletionClientCapabilities
 -> Const
      @*
      (First CompletionClientCapabilities)
      (Maybe CompletionClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First CompletionClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasCompletion s a => Lens' s a
J.completion ((Maybe CompletionClientCapabilities
  -> Const
       @*
       (First CompletionClientCapabilities)
       (Maybe CompletionClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First CompletionClientCapabilities)
      TextDocumentClientCapabilities)
-> ((CompletionClientCapabilities
     -> Const
          @*
          (First CompletionClientCapabilities)
          CompletionClientCapabilities)
    -> Maybe CompletionClientCapabilities
    -> Const
         @*
         (First CompletionClientCapabilities)
         (Maybe CompletionClientCapabilities))
-> (CompletionClientCapabilities
    -> Const
         @*
         (First CompletionClientCapabilities)
         CompletionClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First CompletionClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CompletionClientCapabilities
 -> Const
      @*
      (First CompletionClientCapabilities)
      CompletionClientCapabilities)
-> Maybe CompletionClientCapabilities
-> Const
     @*
     (First CompletionClientCapabilities)
     (Maybe CompletionClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentHover               -> Maybe HoverClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe HoverClientCapabilities -> Bool)
-> Maybe HoverClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First HoverClientCapabilities)
     ClientCapabilities
     HoverClientCapabilities
-> Maybe HoverClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First HoverClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First HoverClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First HoverClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const @* (First HoverClientCapabilities) ClientCapabilities)
-> ((HoverClientCapabilities
     -> Const
          @* (First HoverClientCapabilities) HoverClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First HoverClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First HoverClientCapabilities)
     ClientCapabilities
     HoverClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @* (First HoverClientCapabilities) TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First HoverClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @* (First HoverClientCapabilities) TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First HoverClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((HoverClientCapabilities
     -> Const
          @* (First HoverClientCapabilities) HoverClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @* (First HoverClientCapabilities) TextDocumentClientCapabilities)
-> (HoverClientCapabilities
    -> Const
         @* (First HoverClientCapabilities) HoverClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First HoverClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe HoverClientCapabilities
 -> Const
      @* (First HoverClientCapabilities) (Maybe HoverClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @* (First HoverClientCapabilities) TextDocumentClientCapabilities
forall s a. HasHover s a => Lens' s a
J.hover ((Maybe HoverClientCapabilities
  -> Const
       @* (First HoverClientCapabilities) (Maybe HoverClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @* (First HoverClientCapabilities) TextDocumentClientCapabilities)
-> ((HoverClientCapabilities
     -> Const
          @* (First HoverClientCapabilities) HoverClientCapabilities)
    -> Maybe HoverClientCapabilities
    -> Const
         @* (First HoverClientCapabilities) (Maybe HoverClientCapabilities))
-> (HoverClientCapabilities
    -> Const
         @* (First HoverClientCapabilities) HoverClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @* (First HoverClientCapabilities) TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HoverClientCapabilities
 -> Const
      @* (First HoverClientCapabilities) HoverClientCapabilities)
-> Maybe HoverClientCapabilities
-> Const
     @* (First HoverClientCapabilities) (Maybe HoverClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentSignatureHelp       -> Maybe SignatureHelpClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe SignatureHelpClientCapabilities -> Bool)
-> Maybe SignatureHelpClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First SignatureHelpClientCapabilities)
     ClientCapabilities
     SignatureHelpClientCapabilities
-> Maybe SignatureHelpClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First SignatureHelpClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First SignatureHelpClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First SignatureHelpClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First SignatureHelpClientCapabilities) ClientCapabilities)
-> ((SignatureHelpClientCapabilities
     -> Const
          @*
          (First SignatureHelpClientCapabilities)
          SignatureHelpClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First SignatureHelpClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First SignatureHelpClientCapabilities)
     ClientCapabilities
     SignatureHelpClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First SignatureHelpClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First SignatureHelpClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First SignatureHelpClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First SignatureHelpClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((SignatureHelpClientCapabilities
     -> Const
          @*
          (First SignatureHelpClientCapabilities)
          SignatureHelpClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First SignatureHelpClientCapabilities)
         TextDocumentClientCapabilities)
-> (SignatureHelpClientCapabilities
    -> Const
         @*
         (First SignatureHelpClientCapabilities)
         SignatureHelpClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First SignatureHelpClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe SignatureHelpClientCapabilities
 -> Const
      @*
      (First SignatureHelpClientCapabilities)
      (Maybe SignatureHelpClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First SignatureHelpClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasSignatureHelp s a => Lens' s a
J.signatureHelp ((Maybe SignatureHelpClientCapabilities
  -> Const
       @*
       (First SignatureHelpClientCapabilities)
       (Maybe SignatureHelpClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First SignatureHelpClientCapabilities)
      TextDocumentClientCapabilities)
-> ((SignatureHelpClientCapabilities
     -> Const
          @*
          (First SignatureHelpClientCapabilities)
          SignatureHelpClientCapabilities)
    -> Maybe SignatureHelpClientCapabilities
    -> Const
         @*
         (First SignatureHelpClientCapabilities)
         (Maybe SignatureHelpClientCapabilities))
-> (SignatureHelpClientCapabilities
    -> Const
         @*
         (First SignatureHelpClientCapabilities)
         SignatureHelpClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First SignatureHelpClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SignatureHelpClientCapabilities
 -> Const
      @*
      (First SignatureHelpClientCapabilities)
      SignatureHelpClientCapabilities)
-> Maybe SignatureHelpClientCapabilities
-> Const
     @*
     (First SignatureHelpClientCapabilities)
     (Maybe SignatureHelpClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDeclaration         -> Maybe DeclarationClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DeclarationClientCapabilities -> Bool)
-> Maybe DeclarationClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DeclarationClientCapabilities)
     ClientCapabilities
     DeclarationClientCapabilities
-> Maybe DeclarationClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DeclarationClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DeclarationClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DeclarationClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DeclarationClientCapabilities) ClientCapabilities)
-> ((DeclarationClientCapabilities
     -> Const
          @*
          (First DeclarationClientCapabilities)
          DeclarationClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DeclarationClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DeclarationClientCapabilities)
     ClientCapabilities
     DeclarationClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DeclarationClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DeclarationClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DeclarationClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DeclarationClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DeclarationClientCapabilities
     -> Const
          @*
          (First DeclarationClientCapabilities)
          DeclarationClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DeclarationClientCapabilities)
         TextDocumentClientCapabilities)
-> (DeclarationClientCapabilities
    -> Const
         @*
         (First DeclarationClientCapabilities)
         DeclarationClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DeclarationClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DeclarationClientCapabilities
 -> Const
      @*
      (First DeclarationClientCapabilities)
      (Maybe DeclarationClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DeclarationClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasDeclaration s a => Lens' s a
J.declaration ((Maybe DeclarationClientCapabilities
  -> Const
       @*
       (First DeclarationClientCapabilities)
       (Maybe DeclarationClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DeclarationClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DeclarationClientCapabilities
     -> Const
          @*
          (First DeclarationClientCapabilities)
          DeclarationClientCapabilities)
    -> Maybe DeclarationClientCapabilities
    -> Const
         @*
         (First DeclarationClientCapabilities)
         (Maybe DeclarationClientCapabilities))
-> (DeclarationClientCapabilities
    -> Const
         @*
         (First DeclarationClientCapabilities)
         DeclarationClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DeclarationClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DeclarationClientCapabilities
 -> Const
      @*
      (First DeclarationClientCapabilities)
      DeclarationClientCapabilities)
-> Maybe DeclarationClientCapabilities
-> Const
     @*
     (First DeclarationClientCapabilities)
     (Maybe DeclarationClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDefinition          -> Maybe DefinitionClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DefinitionClientCapabilities -> Bool)
-> Maybe DefinitionClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DefinitionClientCapabilities)
     ClientCapabilities
     DefinitionClientCapabilities
-> Maybe DefinitionClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DefinitionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First DefinitionClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DefinitionClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DefinitionClientCapabilities) ClientCapabilities)
-> ((DefinitionClientCapabilities
     -> Const
          @*
          (First DefinitionClientCapabilities)
          DefinitionClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DefinitionClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DefinitionClientCapabilities)
     ClientCapabilities
     DefinitionClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DefinitionClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DefinitionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DefinitionClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DefinitionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DefinitionClientCapabilities
     -> Const
          @*
          (First DefinitionClientCapabilities)
          DefinitionClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DefinitionClientCapabilities)
         TextDocumentClientCapabilities)
-> (DefinitionClientCapabilities
    -> Const
         @*
         (First DefinitionClientCapabilities)
         DefinitionClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DefinitionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DefinitionClientCapabilities
 -> Const
      @*
      (First DefinitionClientCapabilities)
      (Maybe DefinitionClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DefinitionClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasDefinition s a => Lens' s a
J.definition ((Maybe DefinitionClientCapabilities
  -> Const
       @*
       (First DefinitionClientCapabilities)
       (Maybe DefinitionClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DefinitionClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DefinitionClientCapabilities
     -> Const
          @*
          (First DefinitionClientCapabilities)
          DefinitionClientCapabilities)
    -> Maybe DefinitionClientCapabilities
    -> Const
         @*
         (First DefinitionClientCapabilities)
         (Maybe DefinitionClientCapabilities))
-> (DefinitionClientCapabilities
    -> Const
         @*
         (First DefinitionClientCapabilities)
         DefinitionClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DefinitionClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DefinitionClientCapabilities
 -> Const
      @*
      (First DefinitionClientCapabilities)
      DefinitionClientCapabilities)
-> Maybe DefinitionClientCapabilities
-> Const
     @*
     (First DefinitionClientCapabilities)
     (Maybe DefinitionClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentTypeDefinition      -> Maybe TypeDefinitionClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe TypeDefinitionClientCapabilities -> Bool)
-> Maybe TypeDefinitionClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First TypeDefinitionClientCapabilities)
     ClientCapabilities
     TypeDefinitionClientCapabilities
-> Maybe TypeDefinitionClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TypeDefinitionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First TypeDefinitionClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First TypeDefinitionClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First TypeDefinitionClientCapabilities) ClientCapabilities)
-> ((TypeDefinitionClientCapabilities
     -> Const
          @*
          (First TypeDefinitionClientCapabilities)
          TypeDefinitionClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First TypeDefinitionClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First TypeDefinitionClientCapabilities)
     ClientCapabilities
     TypeDefinitionClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First TypeDefinitionClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TypeDefinitionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First TypeDefinitionClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First TypeDefinitionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((TypeDefinitionClientCapabilities
     -> Const
          @*
          (First TypeDefinitionClientCapabilities)
          TypeDefinitionClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First TypeDefinitionClientCapabilities)
         TextDocumentClientCapabilities)
-> (TypeDefinitionClientCapabilities
    -> Const
         @*
         (First TypeDefinitionClientCapabilities)
         TypeDefinitionClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First TypeDefinitionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe TypeDefinitionClientCapabilities
 -> Const
      @*
      (First TypeDefinitionClientCapabilities)
      (Maybe TypeDefinitionClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TypeDefinitionClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasTypeDefinition s a => Lens' s a
J.typeDefinition ((Maybe TypeDefinitionClientCapabilities
  -> Const
       @*
       (First TypeDefinitionClientCapabilities)
       (Maybe TypeDefinitionClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First TypeDefinitionClientCapabilities)
      TextDocumentClientCapabilities)
-> ((TypeDefinitionClientCapabilities
     -> Const
          @*
          (First TypeDefinitionClientCapabilities)
          TypeDefinitionClientCapabilities)
    -> Maybe TypeDefinitionClientCapabilities
    -> Const
         @*
         (First TypeDefinitionClientCapabilities)
         (Maybe TypeDefinitionClientCapabilities))
-> (TypeDefinitionClientCapabilities
    -> Const
         @*
         (First TypeDefinitionClientCapabilities)
         TypeDefinitionClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First TypeDefinitionClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TypeDefinitionClientCapabilities
 -> Const
      @*
      (First TypeDefinitionClientCapabilities)
      TypeDefinitionClientCapabilities)
-> Maybe TypeDefinitionClientCapabilities
-> Const
     @*
     (First TypeDefinitionClientCapabilities)
     (Maybe TypeDefinitionClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentImplementation      -> Maybe ImplementationClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe ImplementationClientCapabilities -> Bool)
-> Maybe ImplementationClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First ImplementationClientCapabilities)
     ClientCapabilities
     ImplementationClientCapabilities
-> Maybe ImplementationClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First ImplementationClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First ImplementationClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First ImplementationClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First ImplementationClientCapabilities) ClientCapabilities)
-> ((ImplementationClientCapabilities
     -> Const
          @*
          (First ImplementationClientCapabilities)
          ImplementationClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First ImplementationClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First ImplementationClientCapabilities)
     ClientCapabilities
     ImplementationClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First ImplementationClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First ImplementationClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First ImplementationClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First ImplementationClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((ImplementationClientCapabilities
     -> Const
          @*
          (First ImplementationClientCapabilities)
          ImplementationClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First ImplementationClientCapabilities)
         TextDocumentClientCapabilities)
-> (ImplementationClientCapabilities
    -> Const
         @*
         (First ImplementationClientCapabilities)
         ImplementationClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First ImplementationClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe ImplementationClientCapabilities
 -> Const
      @*
      (First ImplementationClientCapabilities)
      (Maybe ImplementationClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First ImplementationClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasImplementation s a => Lens' s a
J.implementation ((Maybe ImplementationClientCapabilities
  -> Const
       @*
       (First ImplementationClientCapabilities)
       (Maybe ImplementationClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First ImplementationClientCapabilities)
      TextDocumentClientCapabilities)
-> ((ImplementationClientCapabilities
     -> Const
          @*
          (First ImplementationClientCapabilities)
          ImplementationClientCapabilities)
    -> Maybe ImplementationClientCapabilities
    -> Const
         @*
         (First ImplementationClientCapabilities)
         (Maybe ImplementationClientCapabilities))
-> (ImplementationClientCapabilities
    -> Const
         @*
         (First ImplementationClientCapabilities)
         ImplementationClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First ImplementationClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ImplementationClientCapabilities
 -> Const
      @*
      (First ImplementationClientCapabilities)
      ImplementationClientCapabilities)
-> Maybe ImplementationClientCapabilities
-> Const
     @*
     (First ImplementationClientCapabilities)
     (Maybe ImplementationClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentReferences          -> Maybe ReferencesClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe ReferencesClientCapabilities -> Bool)
-> Maybe ReferencesClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First ReferencesClientCapabilities)
     ClientCapabilities
     ReferencesClientCapabilities
-> Maybe ReferencesClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First ReferencesClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First ReferencesClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First ReferencesClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First ReferencesClientCapabilities) ClientCapabilities)
-> ((ReferencesClientCapabilities
     -> Const
          @*
          (First ReferencesClientCapabilities)
          ReferencesClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First ReferencesClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First ReferencesClientCapabilities)
     ClientCapabilities
     ReferencesClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First ReferencesClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First ReferencesClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First ReferencesClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First ReferencesClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((ReferencesClientCapabilities
     -> Const
          @*
          (First ReferencesClientCapabilities)
          ReferencesClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First ReferencesClientCapabilities)
         TextDocumentClientCapabilities)
-> (ReferencesClientCapabilities
    -> Const
         @*
         (First ReferencesClientCapabilities)
         ReferencesClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First ReferencesClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe ReferencesClientCapabilities
 -> Const
      @*
      (First ReferencesClientCapabilities)
      (Maybe ReferencesClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First ReferencesClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasReferences s a => Lens' s a
J.references ((Maybe ReferencesClientCapabilities
  -> Const
       @*
       (First ReferencesClientCapabilities)
       (Maybe ReferencesClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First ReferencesClientCapabilities)
      TextDocumentClientCapabilities)
-> ((ReferencesClientCapabilities
     -> Const
          @*
          (First ReferencesClientCapabilities)
          ReferencesClientCapabilities)
    -> Maybe ReferencesClientCapabilities
    -> Const
         @*
         (First ReferencesClientCapabilities)
         (Maybe ReferencesClientCapabilities))
-> (ReferencesClientCapabilities
    -> Const
         @*
         (First ReferencesClientCapabilities)
         ReferencesClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First ReferencesClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ReferencesClientCapabilities
 -> Const
      @*
      (First ReferencesClientCapabilities)
      ReferencesClientCapabilities)
-> Maybe ReferencesClientCapabilities
-> Const
     @*
     (First ReferencesClientCapabilities)
     (Maybe ReferencesClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDocumentHighlight   -> Maybe DocumentHighlightClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentHighlightClientCapabilities -> Bool)
-> Maybe DocumentHighlightClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentHighlightClientCapabilities)
     ClientCapabilities
     DocumentHighlightClientCapabilities
-> Maybe DocumentHighlightClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentHighlightClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DocumentHighlightClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentHighlightClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DocumentHighlightClientCapabilities) ClientCapabilities)
-> ((DocumentHighlightClientCapabilities
     -> Const
          @*
          (First DocumentHighlightClientCapabilities)
          DocumentHighlightClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentHighlightClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentHighlightClientCapabilities)
     ClientCapabilities
     DocumentHighlightClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentHighlightClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentHighlightClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentHighlightClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentHighlightClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentHighlightClientCapabilities
     -> Const
          @*
          (First DocumentHighlightClientCapabilities)
          DocumentHighlightClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentHighlightClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentHighlightClientCapabilities
    -> Const
         @*
         (First DocumentHighlightClientCapabilities)
         DocumentHighlightClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentHighlightClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentHighlightClientCapabilities
 -> Const
      @*
      (First DocumentHighlightClientCapabilities)
      (Maybe DocumentHighlightClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentHighlightClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasDocumentHighlight s a => Lens' s a
J.documentHighlight ((Maybe DocumentHighlightClientCapabilities
  -> Const
       @*
       (First DocumentHighlightClientCapabilities)
       (Maybe DocumentHighlightClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentHighlightClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentHighlightClientCapabilities
     -> Const
          @*
          (First DocumentHighlightClientCapabilities)
          DocumentHighlightClientCapabilities)
    -> Maybe DocumentHighlightClientCapabilities
    -> Const
         @*
         (First DocumentHighlightClientCapabilities)
         (Maybe DocumentHighlightClientCapabilities))
-> (DocumentHighlightClientCapabilities
    -> Const
         @*
         (First DocumentHighlightClientCapabilities)
         DocumentHighlightClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentHighlightClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentHighlightClientCapabilities
 -> Const
      @*
      (First DocumentHighlightClientCapabilities)
      DocumentHighlightClientCapabilities)
-> Maybe DocumentHighlightClientCapabilities
-> Const
     @*
     (First DocumentHighlightClientCapabilities)
     (Maybe DocumentHighlightClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDocumentSymbol      -> Maybe DocumentSymbolClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentSymbolClientCapabilities -> Bool)
-> Maybe DocumentSymbolClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentSymbolClientCapabilities)
     ClientCapabilities
     DocumentSymbolClientCapabilities
-> Maybe DocumentSymbolClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentSymbolClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DocumentSymbolClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentSymbolClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DocumentSymbolClientCapabilities) ClientCapabilities)
-> ((DocumentSymbolClientCapabilities
     -> Const
          @*
          (First DocumentSymbolClientCapabilities)
          DocumentSymbolClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentSymbolClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentSymbolClientCapabilities)
     ClientCapabilities
     DocumentSymbolClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentSymbolClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentSymbolClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentSymbolClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentSymbolClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentSymbolClientCapabilities
     -> Const
          @*
          (First DocumentSymbolClientCapabilities)
          DocumentSymbolClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentSymbolClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentSymbolClientCapabilities
    -> Const
         @*
         (First DocumentSymbolClientCapabilities)
         DocumentSymbolClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentSymbolClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentSymbolClientCapabilities
 -> Const
      @*
      (First DocumentSymbolClientCapabilities)
      (Maybe DocumentSymbolClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentSymbolClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasDocumentSymbol s a => Lens' s a
J.documentSymbol ((Maybe DocumentSymbolClientCapabilities
  -> Const
       @*
       (First DocumentSymbolClientCapabilities)
       (Maybe DocumentSymbolClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentSymbolClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentSymbolClientCapabilities
     -> Const
          @*
          (First DocumentSymbolClientCapabilities)
          DocumentSymbolClientCapabilities)
    -> Maybe DocumentSymbolClientCapabilities
    -> Const
         @*
         (First DocumentSymbolClientCapabilities)
         (Maybe DocumentSymbolClientCapabilities))
-> (DocumentSymbolClientCapabilities
    -> Const
         @*
         (First DocumentSymbolClientCapabilities)
         DocumentSymbolClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentSymbolClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentSymbolClientCapabilities
 -> Const
      @*
      (First DocumentSymbolClientCapabilities)
      DocumentSymbolClientCapabilities)
-> Maybe DocumentSymbolClientCapabilities
-> Const
     @*
     (First DocumentSymbolClientCapabilities)
     (Maybe DocumentSymbolClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentCodeAction          -> Maybe CodeActionClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe CodeActionClientCapabilities -> Bool)
-> Maybe CodeActionClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First CodeActionClientCapabilities)
     ClientCapabilities
     CodeActionClientCapabilities
-> Maybe CodeActionClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeActionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First CodeActionClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First CodeActionClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First CodeActionClientCapabilities) ClientCapabilities)
-> ((CodeActionClientCapabilities
     -> Const
          @*
          (First CodeActionClientCapabilities)
          CodeActionClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First CodeActionClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First CodeActionClientCapabilities)
     ClientCapabilities
     CodeActionClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeActionClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First CodeActionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First CodeActionClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeActionClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((CodeActionClientCapabilities
     -> Const
          @*
          (First CodeActionClientCapabilities)
          CodeActionClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First CodeActionClientCapabilities)
         TextDocumentClientCapabilities)
-> (CodeActionClientCapabilities
    -> Const
         @*
         (First CodeActionClientCapabilities)
         CodeActionClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First CodeActionClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe CodeActionClientCapabilities
 -> Const
      @*
      (First CodeActionClientCapabilities)
      (Maybe CodeActionClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First CodeActionClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasCodeAction s a => Lens' s a
J.codeAction ((Maybe CodeActionClientCapabilities
  -> Const
       @*
       (First CodeActionClientCapabilities)
       (Maybe CodeActionClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeActionClientCapabilities)
      TextDocumentClientCapabilities)
-> ((CodeActionClientCapabilities
     -> Const
          @*
          (First CodeActionClientCapabilities)
          CodeActionClientCapabilities)
    -> Maybe CodeActionClientCapabilities
    -> Const
         @*
         (First CodeActionClientCapabilities)
         (Maybe CodeActionClientCapabilities))
-> (CodeActionClientCapabilities
    -> Const
         @*
         (First CodeActionClientCapabilities)
         CodeActionClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First CodeActionClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeActionClientCapabilities
 -> Const
      @*
      (First CodeActionClientCapabilities)
      CodeActionClientCapabilities)
-> Maybe CodeActionClientCapabilities
-> Const
     @*
     (First CodeActionClientCapabilities)
     (Maybe CodeActionClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentCodeLens            -> Maybe CodeLensClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe CodeLensClientCapabilities -> Bool)
-> Maybe CodeLensClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First CodeLensClientCapabilities)
     ClientCapabilities
     CodeLensClientCapabilities
-> Maybe CodeLensClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeLensClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First CodeLensClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First CodeLensClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const @* (First CodeLensClientCapabilities) ClientCapabilities)
-> ((CodeLensClientCapabilities
     -> Const
          @* (First CodeLensClientCapabilities) CodeLensClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First CodeLensClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First CodeLensClientCapabilities)
     ClientCapabilities
     CodeLensClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeLensClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First CodeLensClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First CodeLensClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeLensClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((CodeLensClientCapabilities
     -> Const
          @* (First CodeLensClientCapabilities) CodeLensClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First CodeLensClientCapabilities)
         TextDocumentClientCapabilities)
-> (CodeLensClientCapabilities
    -> Const
         @* (First CodeLensClientCapabilities) CodeLensClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First CodeLensClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe CodeLensClientCapabilities
 -> Const
      @*
      (First CodeLensClientCapabilities)
      (Maybe CodeLensClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First CodeLensClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasCodeLens s a => Lens' s a
J.codeLens ((Maybe CodeLensClientCapabilities
  -> Const
       @*
       (First CodeLensClientCapabilities)
       (Maybe CodeLensClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First CodeLensClientCapabilities)
      TextDocumentClientCapabilities)
-> ((CodeLensClientCapabilities
     -> Const
          @* (First CodeLensClientCapabilities) CodeLensClientCapabilities)
    -> Maybe CodeLensClientCapabilities
    -> Const
         @*
         (First CodeLensClientCapabilities)
         (Maybe CodeLensClientCapabilities))
-> (CodeLensClientCapabilities
    -> Const
         @* (First CodeLensClientCapabilities) CodeLensClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First CodeLensClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CodeLensClientCapabilities
 -> Const
      @* (First CodeLensClientCapabilities) CodeLensClientCapabilities)
-> Maybe CodeLensClientCapabilities
-> Const
     @*
     (First CodeLensClientCapabilities)
     (Maybe CodeLensClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDocumentLink        -> Maybe DocumentLinkClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentLinkClientCapabilities -> Bool)
-> Maybe DocumentLinkClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentLinkClientCapabilities)
     ClientCapabilities
     DocumentLinkClientCapabilities
-> Maybe DocumentLinkClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentLinkClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DocumentLinkClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentLinkClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DocumentLinkClientCapabilities) ClientCapabilities)
-> ((DocumentLinkClientCapabilities
     -> Const
          @*
          (First DocumentLinkClientCapabilities)
          DocumentLinkClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentLinkClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentLinkClientCapabilities)
     ClientCapabilities
     DocumentLinkClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentLinkClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentLinkClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentLinkClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentLinkClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentLinkClientCapabilities
     -> Const
          @*
          (First DocumentLinkClientCapabilities)
          DocumentLinkClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentLinkClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentLinkClientCapabilities
    -> Const
         @*
         (First DocumentLinkClientCapabilities)
         DocumentLinkClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentLinkClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentLinkClientCapabilities
 -> Const
      @*
      (First DocumentLinkClientCapabilities)
      (Maybe DocumentLinkClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentLinkClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasDocumentLink s a => Lens' s a
J.documentLink ((Maybe DocumentLinkClientCapabilities
  -> Const
       @*
       (First DocumentLinkClientCapabilities)
       (Maybe DocumentLinkClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentLinkClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentLinkClientCapabilities
     -> Const
          @*
          (First DocumentLinkClientCapabilities)
          DocumentLinkClientCapabilities)
    -> Maybe DocumentLinkClientCapabilities
    -> Const
         @*
         (First DocumentLinkClientCapabilities)
         (Maybe DocumentLinkClientCapabilities))
-> (DocumentLinkClientCapabilities
    -> Const
         @*
         (First DocumentLinkClientCapabilities)
         DocumentLinkClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentLinkClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentLinkClientCapabilities
 -> Const
      @*
      (First DocumentLinkClientCapabilities)
      DocumentLinkClientCapabilities)
-> Maybe DocumentLinkClientCapabilities
-> Const
     @*
     (First DocumentLinkClientCapabilities)
     (Maybe DocumentLinkClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentDocumentColor       -> Maybe DocumentColorClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentColorClientCapabilities -> Bool)
-> Maybe DocumentColorClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentColorClientCapabilities)
     ClientCapabilities
     DocumentColorClientCapabilities
-> Maybe DocumentColorClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DocumentColorClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentColorClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DocumentColorClientCapabilities) ClientCapabilities)
-> ((DocumentColorClientCapabilities
     -> Const
          @*
          (First DocumentColorClientCapabilities)
          DocumentColorClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentColorClientCapabilities)
     ClientCapabilities
     DocumentColorClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentColorClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentColorClientCapabilities
     -> Const
          @*
          (First DocumentColorClientCapabilities)
          DocumentColorClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentColorClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         DocumentColorClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentColorClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      (Maybe DocumentColorClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasColorProvider s a => Lens' s a
J.colorProvider ((Maybe DocumentColorClientCapabilities
  -> Const
       @*
       (First DocumentColorClientCapabilities)
       (Maybe DocumentColorClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentColorClientCapabilities
     -> Const
          @*
          (First DocumentColorClientCapabilities)
          DocumentColorClientCapabilities)
    -> Maybe DocumentColorClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         (Maybe DocumentColorClientCapabilities))
-> (DocumentColorClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         DocumentColorClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentColorClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      DocumentColorClientCapabilities)
-> Maybe DocumentColorClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     (Maybe DocumentColorClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentColorPresentation   -> Maybe DocumentColorClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentColorClientCapabilities -> Bool)
-> Maybe DocumentColorClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentColorClientCapabilities)
     ClientCapabilities
     DocumentColorClientCapabilities
-> Maybe DocumentColorClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DocumentColorClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentColorClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DocumentColorClientCapabilities) ClientCapabilities)
-> ((DocumentColorClientCapabilities
     -> Const
          @*
          (First DocumentColorClientCapabilities)
          DocumentColorClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentColorClientCapabilities)
     ClientCapabilities
     DocumentColorClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentColorClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentColorClientCapabilities
     -> Const
          @*
          (First DocumentColorClientCapabilities)
          DocumentColorClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentColorClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         DocumentColorClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentColorClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      (Maybe DocumentColorClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasColorProvider s a => Lens' s a
J.colorProvider ((Maybe DocumentColorClientCapabilities
  -> Const
       @*
       (First DocumentColorClientCapabilities)
       (Maybe DocumentColorClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentColorClientCapabilities
     -> Const
          @*
          (First DocumentColorClientCapabilities)
          DocumentColorClientCapabilities)
    -> Maybe DocumentColorClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         (Maybe DocumentColorClientCapabilities))
-> (DocumentColorClientCapabilities
    -> Const
         @*
         (First DocumentColorClientCapabilities)
         DocumentColorClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentColorClientCapabilities
 -> Const
      @*
      (First DocumentColorClientCapabilities)
      DocumentColorClientCapabilities)
-> Maybe DocumentColorClientCapabilities
-> Const
     @*
     (First DocumentColorClientCapabilities)
     (Maybe DocumentColorClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentFormatting          -> Maybe DocumentFormattingClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentFormattingClientCapabilities -> Bool)
-> Maybe DocumentFormattingClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentFormattingClientCapabilities)
     ClientCapabilities
     DocumentFormattingClientCapabilities
-> Maybe DocumentFormattingClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentFormattingClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First DocumentFormattingClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentFormattingClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First DocumentFormattingClientCapabilities) ClientCapabilities)
-> ((DocumentFormattingClientCapabilities
     -> Const
          @*
          (First DocumentFormattingClientCapabilities)
          DocumentFormattingClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentFormattingClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentFormattingClientCapabilities)
     ClientCapabilities
     DocumentFormattingClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentFormattingClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentFormattingClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentFormattingClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentFormattingClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentFormattingClientCapabilities
     -> Const
          @*
          (First DocumentFormattingClientCapabilities)
          DocumentFormattingClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentFormattingClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentFormattingClientCapabilities
    -> Const
         @*
         (First DocumentFormattingClientCapabilities)
         DocumentFormattingClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentFormattingClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentFormattingClientCapabilities
 -> Const
      @*
      (First DocumentFormattingClientCapabilities)
      (Maybe DocumentFormattingClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentFormattingClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasFormatting s a => Lens' s a
J.formatting ((Maybe DocumentFormattingClientCapabilities
  -> Const
       @*
       (First DocumentFormattingClientCapabilities)
       (Maybe DocumentFormattingClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentFormattingClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentFormattingClientCapabilities
     -> Const
          @*
          (First DocumentFormattingClientCapabilities)
          DocumentFormattingClientCapabilities)
    -> Maybe DocumentFormattingClientCapabilities
    -> Const
         @*
         (First DocumentFormattingClientCapabilities)
         (Maybe DocumentFormattingClientCapabilities))
-> (DocumentFormattingClientCapabilities
    -> Const
         @*
         (First DocumentFormattingClientCapabilities)
         DocumentFormattingClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentFormattingClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentFormattingClientCapabilities
 -> Const
      @*
      (First DocumentFormattingClientCapabilities)
      DocumentFormattingClientCapabilities)
-> Maybe DocumentFormattingClientCapabilities
-> Const
     @*
     (First DocumentFormattingClientCapabilities)
     (Maybe DocumentFormattingClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentRangeFormatting     -> Maybe DocumentRangeFormattingClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentRangeFormattingClientCapabilities -> Bool)
-> Maybe DocumentRangeFormattingClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentRangeFormattingClientCapabilities)
     ClientCapabilities
     DocumentRangeFormattingClientCapabilities
-> Maybe DocumentRangeFormattingClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @*
     (First DocumentRangeFormattingClientCapabilities)
     ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentRangeFormattingClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      ClientCapabilities)
-> ((DocumentRangeFormattingClientCapabilities
     -> Const
          @*
          (First DocumentRangeFormattingClientCapabilities)
          DocumentRangeFormattingClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentRangeFormattingClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentRangeFormattingClientCapabilities)
     ClientCapabilities
     DocumentRangeFormattingClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentRangeFormattingClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentRangeFormattingClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentRangeFormattingClientCapabilities
     -> Const
          @*
          (First DocumentRangeFormattingClientCapabilities)
          DocumentRangeFormattingClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentRangeFormattingClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentRangeFormattingClientCapabilities
    -> Const
         @*
         (First DocumentRangeFormattingClientCapabilities)
         DocumentRangeFormattingClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentRangeFormattingClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentRangeFormattingClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      (Maybe DocumentRangeFormattingClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentRangeFormattingClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasRangeFormatting s a => Lens' s a
J.rangeFormatting ((Maybe DocumentRangeFormattingClientCapabilities
  -> Const
       @*
       (First DocumentRangeFormattingClientCapabilities)
       (Maybe DocumentRangeFormattingClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentRangeFormattingClientCapabilities
     -> Const
          @*
          (First DocumentRangeFormattingClientCapabilities)
          DocumentRangeFormattingClientCapabilities)
    -> Maybe DocumentRangeFormattingClientCapabilities
    -> Const
         @*
         (First DocumentRangeFormattingClientCapabilities)
         (Maybe DocumentRangeFormattingClientCapabilities))
-> (DocumentRangeFormattingClientCapabilities
    -> Const
         @*
         (First DocumentRangeFormattingClientCapabilities)
         DocumentRangeFormattingClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentRangeFormattingClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentRangeFormattingClientCapabilities
 -> Const
      @*
      (First DocumentRangeFormattingClientCapabilities)
      DocumentRangeFormattingClientCapabilities)
-> Maybe DocumentRangeFormattingClientCapabilities
-> Const
     @*
     (First DocumentRangeFormattingClientCapabilities)
     (Maybe DocumentRangeFormattingClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentOnTypeFormatting    -> Maybe DocumentOnTypeFormattingClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe DocumentOnTypeFormattingClientCapabilities -> Bool)
-> Maybe DocumentOnTypeFormattingClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First DocumentOnTypeFormattingClientCapabilities)
     ClientCapabilities
     DocumentOnTypeFormattingClientCapabilities
-> Maybe DocumentOnTypeFormattingClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @*
     (First DocumentOnTypeFormattingClientCapabilities)
     ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentOnTypeFormattingClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      ClientCapabilities)
-> ((DocumentOnTypeFormattingClientCapabilities
     -> Const
          @*
          (First DocumentOnTypeFormattingClientCapabilities)
          DocumentOnTypeFormattingClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentOnTypeFormattingClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First DocumentOnTypeFormattingClientCapabilities)
     ClientCapabilities
     DocumentOnTypeFormattingClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentOnTypeFormattingClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First DocumentOnTypeFormattingClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((DocumentOnTypeFormattingClientCapabilities
     -> Const
          @*
          (First DocumentOnTypeFormattingClientCapabilities)
          DocumentOnTypeFormattingClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First DocumentOnTypeFormattingClientCapabilities)
         TextDocumentClientCapabilities)
-> (DocumentOnTypeFormattingClientCapabilities
    -> Const
         @*
         (First DocumentOnTypeFormattingClientCapabilities)
         DocumentOnTypeFormattingClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentOnTypeFormattingClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe DocumentOnTypeFormattingClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      (Maybe DocumentOnTypeFormattingClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentOnTypeFormattingClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasOnTypeFormatting s a => Lens' s a
J.onTypeFormatting ((Maybe DocumentOnTypeFormattingClientCapabilities
  -> Const
       @*
       (First DocumentOnTypeFormattingClientCapabilities)
       (Maybe DocumentOnTypeFormattingClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      TextDocumentClientCapabilities)
-> ((DocumentOnTypeFormattingClientCapabilities
     -> Const
          @*
          (First DocumentOnTypeFormattingClientCapabilities)
          DocumentOnTypeFormattingClientCapabilities)
    -> Maybe DocumentOnTypeFormattingClientCapabilities
    -> Const
         @*
         (First DocumentOnTypeFormattingClientCapabilities)
         (Maybe DocumentOnTypeFormattingClientCapabilities))
-> (DocumentOnTypeFormattingClientCapabilities
    -> Const
         @*
         (First DocumentOnTypeFormattingClientCapabilities)
         DocumentOnTypeFormattingClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First DocumentOnTypeFormattingClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentOnTypeFormattingClientCapabilities
 -> Const
      @*
      (First DocumentOnTypeFormattingClientCapabilities)
      DocumentOnTypeFormattingClientCapabilities)
-> Maybe DocumentOnTypeFormattingClientCapabilities
-> Const
     @*
     (First DocumentOnTypeFormattingClientCapabilities)
     (Maybe DocumentOnTypeFormattingClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentRename              -> Maybe RenameClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe RenameClientCapabilities -> Bool)
-> Maybe RenameClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First RenameClientCapabilities)
     ClientCapabilities
     RenameClientCapabilities
-> Maybe RenameClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First RenameClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const @* (First RenameClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First RenameClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const @* (First RenameClientCapabilities) ClientCapabilities)
-> ((RenameClientCapabilities
     -> Const
          @* (First RenameClientCapabilities) RenameClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First RenameClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First RenameClientCapabilities)
     ClientCapabilities
     RenameClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @* (First RenameClientCapabilities) TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First RenameClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @* (First RenameClientCapabilities) TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First RenameClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((RenameClientCapabilities
     -> Const
          @* (First RenameClientCapabilities) RenameClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @* (First RenameClientCapabilities) TextDocumentClientCapabilities)
-> (RenameClientCapabilities
    -> Const
         @* (First RenameClientCapabilities) RenameClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First RenameClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe RenameClientCapabilities
 -> Const
      @*
      (First RenameClientCapabilities)
      (Maybe RenameClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @* (First RenameClientCapabilities) TextDocumentClientCapabilities
forall s a. HasRename s a => Lens' s a
J.rename ((Maybe RenameClientCapabilities
  -> Const
       @*
       (First RenameClientCapabilities)
       (Maybe RenameClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @* (First RenameClientCapabilities) TextDocumentClientCapabilities)
-> ((RenameClientCapabilities
     -> Const
          @* (First RenameClientCapabilities) RenameClientCapabilities)
    -> Maybe RenameClientCapabilities
    -> Const
         @*
         (First RenameClientCapabilities)
         (Maybe RenameClientCapabilities))
-> (RenameClientCapabilities
    -> Const
         @* (First RenameClientCapabilities) RenameClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @* (First RenameClientCapabilities) TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (RenameClientCapabilities
 -> Const
      @* (First RenameClientCapabilities) RenameClientCapabilities)
-> Maybe RenameClientCapabilities
-> Const
     @*
     (First RenameClientCapabilities)
     (Maybe RenameClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentFoldingRange        -> Maybe FoldingRangeClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe FoldingRangeClientCapabilities -> Bool)
-> Maybe FoldingRangeClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First FoldingRangeClientCapabilities)
     ClientCapabilities
     FoldingRangeClientCapabilities
-> Maybe FoldingRangeClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First FoldingRangeClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First FoldingRangeClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First FoldingRangeClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First FoldingRangeClientCapabilities) ClientCapabilities)
-> ((FoldingRangeClientCapabilities
     -> Const
          @*
          (First FoldingRangeClientCapabilities)
          FoldingRangeClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First FoldingRangeClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First FoldingRangeClientCapabilities)
     ClientCapabilities
     FoldingRangeClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First FoldingRangeClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First FoldingRangeClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First FoldingRangeClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First FoldingRangeClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((FoldingRangeClientCapabilities
     -> Const
          @*
          (First FoldingRangeClientCapabilities)
          FoldingRangeClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First FoldingRangeClientCapabilities)
         TextDocumentClientCapabilities)
-> (FoldingRangeClientCapabilities
    -> Const
         @*
         (First FoldingRangeClientCapabilities)
         FoldingRangeClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First FoldingRangeClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe FoldingRangeClientCapabilities
 -> Const
      @*
      (First FoldingRangeClientCapabilities)
      (Maybe FoldingRangeClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First FoldingRangeClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasFoldingRange s a => Lens' s a
J.foldingRange ((Maybe FoldingRangeClientCapabilities
  -> Const
       @*
       (First FoldingRangeClientCapabilities)
       (Maybe FoldingRangeClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First FoldingRangeClientCapabilities)
      TextDocumentClientCapabilities)
-> ((FoldingRangeClientCapabilities
     -> Const
          @*
          (First FoldingRangeClientCapabilities)
          FoldingRangeClientCapabilities)
    -> Maybe FoldingRangeClientCapabilities
    -> Const
         @*
         (First FoldingRangeClientCapabilities)
         (Maybe FoldingRangeClientCapabilities))
-> (FoldingRangeClientCapabilities
    -> Const
         @*
         (First FoldingRangeClientCapabilities)
         FoldingRangeClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First FoldingRangeClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FoldingRangeClientCapabilities
 -> Const
      @*
      (First FoldingRangeClientCapabilities)
      FoldingRangeClientCapabilities)
-> Maybe FoldingRangeClientCapabilities
-> Const
     @*
     (First FoldingRangeClientCapabilities)
     (Maybe FoldingRangeClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
STextDocumentSelectionRange      -> Maybe SelectionRangeClientCapabilities -> Bool
forall a. HasDynamicRegistration a (Maybe Bool) => Maybe a -> Bool
capDyn (Maybe SelectionRangeClientCapabilities -> Bool)
-> Maybe SelectionRangeClientCapabilities -> Bool
forall a b. (a -> b) -> a -> b
$ ClientCapabilities
clientCaps ClientCapabilities
-> Getting
     (First SelectionRangeClientCapabilities)
     ClientCapabilities
     SelectionRangeClientCapabilities
-> Maybe SelectionRangeClientCapabilities
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First SelectionRangeClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ClientCapabilities
-> Const
     @* (First SelectionRangeClientCapabilities) ClientCapabilities
forall s a. HasTextDocument s a => Lens' s a
J.textDocument ((Maybe TextDocumentClientCapabilities
  -> Const
       @*
       (First SelectionRangeClientCapabilities)
       (Maybe TextDocumentClientCapabilities))
 -> ClientCapabilities
 -> Const
      @* (First SelectionRangeClientCapabilities) ClientCapabilities)
-> ((SelectionRangeClientCapabilities
     -> Const
          @*
          (First SelectionRangeClientCapabilities)
          SelectionRangeClientCapabilities)
    -> Maybe TextDocumentClientCapabilities
    -> Const
         @*
         (First SelectionRangeClientCapabilities)
         (Maybe TextDocumentClientCapabilities))
-> Getting
     (First SelectionRangeClientCapabilities)
     ClientCapabilities
     SelectionRangeClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextDocumentClientCapabilities
 -> Const
      @*
      (First SelectionRangeClientCapabilities)
      TextDocumentClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First SelectionRangeClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just ((TextDocumentClientCapabilities
  -> Const
       @*
       (First SelectionRangeClientCapabilities)
       TextDocumentClientCapabilities)
 -> Maybe TextDocumentClientCapabilities
 -> Const
      @*
      (First SelectionRangeClientCapabilities)
      (Maybe TextDocumentClientCapabilities))
-> ((SelectionRangeClientCapabilities
     -> Const
          @*
          (First SelectionRangeClientCapabilities)
          SelectionRangeClientCapabilities)
    -> TextDocumentClientCapabilities
    -> Const
         @*
         (First SelectionRangeClientCapabilities)
         TextDocumentClientCapabilities)
-> (SelectionRangeClientCapabilities
    -> Const
         @*
         (First SelectionRangeClientCapabilities)
         SelectionRangeClientCapabilities)
-> Maybe TextDocumentClientCapabilities
-> Const
     @*
     (First SelectionRangeClientCapabilities)
     (Maybe TextDocumentClientCapabilities)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Maybe SelectionRangeClientCapabilities
 -> Const
      @*
      (First SelectionRangeClientCapabilities)
      (Maybe SelectionRangeClientCapabilities))
-> TextDocumentClientCapabilities
-> Const
     @*
     (First SelectionRangeClientCapabilities)
     TextDocumentClientCapabilities
forall s a. HasSelectionRange s a => Lens' s a
J.selectionRange ((Maybe SelectionRangeClientCapabilities
  -> Const
       @*
       (First SelectionRangeClientCapabilities)
       (Maybe SelectionRangeClientCapabilities))
 -> TextDocumentClientCapabilities
 -> Const
      @*
      (First SelectionRangeClientCapabilities)
      TextDocumentClientCapabilities)
-> ((SelectionRangeClientCapabilities
     -> Const
          @*
          (First SelectionRangeClientCapabilities)
          SelectionRangeClientCapabilities)
    -> Maybe SelectionRangeClientCapabilities
    -> Const
         @*
         (First SelectionRangeClientCapabilities)
         (Maybe SelectionRangeClientCapabilities))
-> (SelectionRangeClientCapabilities
    -> Const
         @*
         (First SelectionRangeClientCapabilities)
         SelectionRangeClientCapabilities)
-> TextDocumentClientCapabilities
-> Const
     @*
     (First SelectionRangeClientCapabilities)
     TextDocumentClientCapabilities
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (SelectionRangeClientCapabilities
 -> Const
      @*
      (First SelectionRangeClientCapabilities)
      SelectionRangeClientCapabilities)
-> Maybe SelectionRangeClientCapabilities
-> Const
     @*
     (First SelectionRangeClientCapabilities)
     (Maybe SelectionRangeClientCapabilities)
forall a b. Prism (Maybe a) (Maybe b) a b
_Just
      SClientMethod @t m
_                                -> Bool
False

-- | Sends a @client/unregisterCapability@ request and removes the handler
-- for that associated registration.
unregisterCapability :: MonadLsp config f => RegistrationToken m -> f ()
unregisterCapability :: RegistrationToken @t m -> f ()
unregisterCapability (RegistrationToken SMethod @'FromClient @t m
m (RegistrationId Text
uuid)) = do
  ~() <- case SMethod @'FromClient @t m -> ClientNotOrReq @t m
forall (t :: MethodType) (m :: Method 'FromClient t).
SClientMethod @t m -> ClientNotOrReq @t m
splitClientMethod SMethod @'FromClient @t m
m of
    ClientNotOrReq @t m
IsClientReq -> (LanguageContextState config -> TVar (RegistrationMap 'Request))
-> (RegistrationMap 'Request -> RegistrationMap 'Request) -> f ()
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState LanguageContextState config -> TVar (RegistrationMap 'Request)
forall config.
LanguageContextState config -> TVar (RegistrationMap 'Request)
resRegistrationsReq ((RegistrationMap 'Request -> RegistrationMap 'Request) -> f ())
-> (RegistrationMap 'Request -> RegistrationMap 'Request) -> f ()
forall a b. (a -> b) -> a -> b
$ SMethod @'FromClient @t m
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Request)
        (RegistrationId @'Request)
        (ClientMessageHandler IO 'Request))
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Request)
        (RegistrationId @'Request)
        (ClientMessageHandler IO 'Request))
forall k1 (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare @k1 k2 =>
k2 v -> DMap @k1 k2 f -> DMap @k1 k2 f
DMap.delete SMethod @'FromClient @t m
m
    ClientNotOrReq @t m
IsClientNot -> (LanguageContextState config
 -> TVar (RegistrationMap 'Notification))
-> (RegistrationMap 'Notification -> RegistrationMap 'Notification)
-> f ()
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState LanguageContextState config -> TVar (RegistrationMap 'Notification)
forall config.
LanguageContextState config -> TVar (RegistrationMap 'Notification)
resRegistrationsNot ((RegistrationMap 'Notification -> RegistrationMap 'Notification)
 -> f ())
-> (RegistrationMap 'Notification -> RegistrationMap 'Notification)
-> f ()
forall a b. (a -> b) -> a -> b
$ SMethod @'FromClient @t m
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Notification)
        (RegistrationId @'Notification)
        (ClientMessageHandler IO 'Notification))
-> DMap
     @(Method 'FromClient t)
     (SMethod @'FromClient @t)
     (Product
        @(Method 'FromClient 'Notification)
        (RegistrationId @'Notification)
        (ClientMessageHandler IO 'Notification))
forall k1 (k2 :: k1 -> *) (f :: k1 -> *) (v :: k1).
GCompare @k1 k2 =>
k2 v -> DMap @k1 k2 f -> DMap @k1 k2 f
DMap.delete SMethod @'FromClient @t m
m
    ClientNotOrReq @t m
IsClientEither -> FilePath -> f ()
forall a. HasCallStack => FilePath -> a
error FilePath
"Cannot unregister capability for custom methods"

  let unregistration :: Unregistration
unregistration = Text -> SomeClientMethod -> Unregistration
J.Unregistration Text
uuid (SMethod @'FromClient @t m -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod @'FromClient @t m -> SomeClientMethod
J.SomeClientMethod SMethod @'FromClient @t m
m)
      params :: UnregistrationParams
params = List Unregistration -> UnregistrationParams
J.UnregistrationParams ([Unregistration] -> List Unregistration
forall a. [a] -> List a
J.List [Unregistration
unregistration])
  f (LspId @'FromServer 'ClientUnregisterCapability) -> f ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (f (LspId @'FromServer 'ClientUnregisterCapability) -> f ())
-> f (LspId @'FromServer 'ClientUnregisterCapability) -> f ()
forall a b. (a -> b) -> a -> b
$ SServerMethod @'Request 'ClientUnregisterCapability
-> MessageParams @'FromServer @'Request 'ClientUnregisterCapability
-> (Either
      ResponseError
      (ResponseResult @'FromServer 'ClientUnregisterCapability)
    -> f ())
-> f (LspId @'FromServer 'ClientUnregisterCapability)
forall (m :: Method 'FromServer 'Request) (f :: * -> *) config.
MonadLsp config f =>
SServerMethod @'Request m
-> MessageParams @'FromServer @'Request m
-> (Either ResponseError (ResponseResult @'FromServer m) -> f ())
-> f (LspId @'FromServer m)
sendRequest SServerMethod @'Request 'ClientUnregisterCapability
SClientUnregisterCapability MessageParams @'FromServer @'Request 'ClientUnregisterCapability
UnregistrationParams
params ((Either
    ResponseError
    (ResponseResult @'FromServer 'ClientUnregisterCapability)
  -> f ())
 -> f (LspId @'FromServer 'ClientUnregisterCapability))
-> (Either
      ResponseError
      (ResponseResult @'FromServer 'ClientUnregisterCapability)
    -> f ())
-> f (LspId @'FromServer 'ClientUnregisterCapability)
forall a b. (a -> b) -> a -> b
$ \Either
  ResponseError
  (ResponseResult @'FromServer 'ClientUnregisterCapability)
_res -> () -> f ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

--------------------------------------------------------------------------------
-- PROGRESS
--------------------------------------------------------------------------------

storeProgress :: MonadLsp config m => ProgressToken -> Async a -> m ()
storeProgress :: ProgressToken -> Async a -> m ()
storeProgress ProgressToken
n Async a
a = (LanguageContextState config -> TVar (Map ProgressToken (IO ())))
-> (Map ProgressToken (IO ()) -> Map ProgressToken (IO ())) -> m ()
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState (ProgressData -> TVar (Map ProgressToken (IO ()))
progressCancel (ProgressData -> TVar (Map ProgressToken (IO ())))
-> (LanguageContextState config -> ProgressData)
-> LanguageContextState config
-> TVar (Map ProgressToken (IO ()))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LanguageContextState config -> ProgressData
forall config. LanguageContextState config -> ProgressData
resProgressData) ((Map ProgressToken (IO ()) -> Map ProgressToken (IO ())) -> m ())
-> (Map ProgressToken (IO ()) -> Map ProgressToken (IO ())) -> m ()
forall a b. (a -> b) -> a -> b
$ ProgressToken
-> IO () -> Map ProgressToken (IO ()) -> Map ProgressToken (IO ())
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert ProgressToken
n (Async a -> ProgressCancelledException -> IO ()
forall e a. Exception e => Async a -> e -> IO ()
cancelWith Async a
a ProgressCancelledException
ProgressCancelledException)

{-# INLINE storeProgress #-}

deleteProgress :: MonadLsp config m => ProgressToken -> m ()
deleteProgress :: ProgressToken -> m ()
deleteProgress ProgressToken
n = (LanguageContextState config -> TVar (Map ProgressToken (IO ())))
-> (Map ProgressToken (IO ()) -> Map ProgressToken (IO ())) -> m ()
forall config (m :: * -> *) a.
MonadLsp config m =>
(LanguageContextState config -> TVar a) -> (a -> a) -> m ()
modifyState (ProgressData -> TVar (Map ProgressToken (IO ()))
progressCancel (ProgressData -> TVar (Map ProgressToken (IO ())))
-> (LanguageContextState config -> ProgressData)
-> LanguageContextState config
-> TVar (Map ProgressToken (IO ()))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LanguageContextState config -> ProgressData
forall config. LanguageContextState config -> ProgressData
resProgressData) ((Map ProgressToken (IO ()) -> Map ProgressToken (IO ())) -> m ())
-> (Map ProgressToken (IO ()) -> Map ProgressToken (IO ())) -> m ()
forall a b. (a -> b) -> a -> b
$ ProgressToken
-> Map ProgressToken (IO ()) -> Map ProgressToken (IO ())
forall k a. Ord k => k -> Map k a -> Map k a
Map.delete ProgressToken
n

{-# INLINE deleteProgress #-}

-- Get a new id for the progress session and make a new one
getNewProgressId :: MonadLsp config m => m ProgressToken
getNewProgressId :: m ProgressToken
getNewProgressId = do
  (LanguageContextState config -> TVar Int)
-> (Int -> (ProgressToken, Int)) -> m ProgressToken
forall config (m :: * -> *) s a.
MonadLsp config m =>
(LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState (ProgressData -> TVar Int
progressNextId (ProgressData -> TVar Int)
-> (LanguageContextState config -> ProgressData)
-> LanguageContextState config
-> TVar Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LanguageContextState config -> ProgressData
forall config. LanguageContextState config -> ProgressData
resProgressData) ((Int -> (ProgressToken, Int)) -> m ProgressToken)
-> (Int -> (ProgressToken, Int)) -> m ProgressToken
forall a b. (a -> b) -> a -> b
$ \Int
cur ->
    let !next :: Int
next = Int
curInt -> Int -> Int
forall a. Num a => a -> a -> a
+Int
1
    in (Int -> ProgressToken
ProgressNumericToken Int
cur, Int
next)

{-# INLINE getNewProgressId #-}

withProgressBase :: MonadLsp c m => Bool -> Text -> ProgressCancellable -> ((ProgressAmount -> m ()) -> m a) -> m a
withProgressBase :: Bool
-> Text
-> ProgressCancellable
-> ((ProgressAmount -> m ()) -> m a)
-> m a
withProgressBase Bool
indefinite Text
title ProgressCancellable
cancellable (ProgressAmount -> m ()) -> m a
f = do

  ProgressToken
progId <- m ProgressToken
forall config (m :: * -> *). MonadLsp config m => m ProgressToken
getNewProgressId

  let initialPercentage :: Maybe Double
initialPercentage
        | Bool
indefinite = Maybe Double
forall a. Maybe a
Nothing
        | Bool
otherwise = Double -> Maybe Double
forall a. a -> Maybe a
Just Double
0
      cancellable' :: Bool
cancellable' = case ProgressCancellable
cancellable of
                      ProgressCancellable
Cancellable -> Bool
True
                      ProgressCancellable
NotCancellable -> Bool
False

  -- Create progress token
  -- FIXME  : This needs to wait until the request returns before
  -- continuing!!!
  LspId @'FromServer 'WindowWorkDoneProgressCreate
_ <- SServerMethod @'Request 'WindowWorkDoneProgressCreate
-> MessageParams
     @'FromServer @'Request 'WindowWorkDoneProgressCreate
-> (Either
      ResponseError
      (ResponseResult @'FromServer 'WindowWorkDoneProgressCreate)
    -> m ())
-> m (LspId @'FromServer 'WindowWorkDoneProgressCreate)
forall (m :: Method 'FromServer 'Request) (f :: * -> *) config.
MonadLsp config f =>
SServerMethod @'Request m
-> MessageParams @'FromServer @'Request m
-> (Either ResponseError (ResponseResult @'FromServer m) -> f ())
-> f (LspId @'FromServer m)
sendRequest SServerMethod @'Request 'WindowWorkDoneProgressCreate
SWindowWorkDoneProgressCreate
        (ProgressToken -> WorkDoneProgressCreateParams
WorkDoneProgressCreateParams ProgressToken
progId) ((Either
    ResponseError
    (ResponseResult @'FromServer 'WindowWorkDoneProgressCreate)
  -> m ())
 -> m (LspId @'FromServer 'WindowWorkDoneProgressCreate))
-> (Either
      ResponseError
      (ResponseResult @'FromServer 'WindowWorkDoneProgressCreate)
    -> m ())
-> m (LspId @'FromServer 'WindowWorkDoneProgressCreate)
forall a b. (a -> b) -> a -> b
$ \Either
  ResponseError
  (ResponseResult @'FromServer 'WindowWorkDoneProgressCreate)
res -> do
          case Either
  ResponseError
  (ResponseResult @'FromServer 'WindowWorkDoneProgressCreate)
res of
            -- An error ocurred when the client was setting it up
            -- No need to do anything then, as per the spec
            Left ResponseError
_err -> () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
            Right ResponseResult @'FromServer 'WindowWorkDoneProgressCreate
Empty -> () -> m ()
forall (f :: * -> *) a. Applicative f => a -> f a
pure ()

  -- Send the begin and done notifications via 'bracket_' so that they are always fired
  a
res <- ((forall a. m a -> IO a) -> IO a) -> m a
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO (((forall a. m a -> IO a) -> IO a) -> m a)
-> ((forall a. m a -> IO a) -> IO a) -> m a
forall a b. (a -> b) -> a -> b
$ \forall a. m a -> IO a
runInBase ->
    IO () -> IO () -> IO a -> IO a
forall a b c. IO a -> IO b -> IO c -> IO c
E.bracket_
      -- Send begin notification
      (m () -> IO ()
forall a. m a -> IO a
runInBase (m () -> IO ()) -> m () -> IO ()
forall a b. (a -> b) -> a -> b
$ SServerMethod @'Notification 'Progress
-> MessageParams @'FromServer @'Notification 'Progress -> m ()
forall (m :: Method 'FromServer 'Notification) (f :: * -> *)
       config.
MonadLsp config f =>
SServerMethod @'Notification m
-> MessageParams @'FromServer @'Notification m -> f ()
sendNotification SServerMethod @'Notification 'Progress
SProgress (MessageParams @'FromServer @'Notification 'Progress -> m ())
-> MessageParams @'FromServer @'Notification 'Progress -> m ()
forall a b. (a -> b) -> a -> b
$
        (WorkDoneProgressBeginParams -> SomeProgressParams)
-> ProgressParams WorkDoneProgressBeginParams
-> ProgressParams SomeProgressParams
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap WorkDoneProgressBeginParams -> SomeProgressParams
Begin (ProgressParams WorkDoneProgressBeginParams
 -> ProgressParams SomeProgressParams)
-> ProgressParams WorkDoneProgressBeginParams
-> ProgressParams SomeProgressParams
forall a b. (a -> b) -> a -> b
$ ProgressToken
-> WorkDoneProgressBeginParams
-> ProgressParams WorkDoneProgressBeginParams
forall t. ProgressToken -> t -> ProgressParams t
ProgressParams ProgressToken
progId (WorkDoneProgressBeginParams
 -> ProgressParams WorkDoneProgressBeginParams)
-> WorkDoneProgressBeginParams
-> ProgressParams WorkDoneProgressBeginParams
forall a b. (a -> b) -> a -> b
$
          Text
-> Maybe Bool
-> Maybe Text
-> Maybe Double
-> WorkDoneProgressBeginParams
WorkDoneProgressBeginParams Text
title (Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
cancellable') Maybe Text
forall a. Maybe a
Nothing Maybe Double
initialPercentage)

      -- Send end notification
      (m () -> IO ()
forall a. m a -> IO a
runInBase (m () -> IO ()) -> m () -> IO ()
forall a b. (a -> b) -> a -> b
$ SServerMethod @'Notification 'Progress
-> MessageParams @'FromServer @'Notification 'Progress -> m ()
forall (m :: Method 'FromServer 'Notification) (f :: * -> *)
       config.
MonadLsp config f =>
SServerMethod @'Notification m
-> MessageParams @'FromServer @'Notification m -> f ()
sendNotification SServerMethod @'Notification 'Progress
SProgress (MessageParams @'FromServer @'Notification 'Progress -> m ())
-> MessageParams @'FromServer @'Notification 'Progress -> m ()
forall a b. (a -> b) -> a -> b
$
        WorkDoneProgressEndParams -> SomeProgressParams
End (WorkDoneProgressEndParams -> SomeProgressParams)
-> ProgressParams WorkDoneProgressEndParams
-> ProgressParams SomeProgressParams
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ProgressToken
-> WorkDoneProgressEndParams
-> ProgressParams WorkDoneProgressEndParams
forall t. ProgressToken -> t -> ProgressParams t
ProgressParams ProgressToken
progId (Maybe Text -> WorkDoneProgressEndParams
WorkDoneProgressEndParams Maybe Text
forall a. Maybe a
Nothing)) (IO a -> IO a) -> IO a -> IO a
forall a b. (a -> b) -> a -> b
$ do

      -- Run f asynchronously
      Async a
aid <- IO a -> IO (Async a)
forall a. IO a -> IO (Async a)
async (IO a -> IO (Async a)) -> IO a -> IO (Async a)
forall a b. (a -> b) -> a -> b
$ m a -> IO a
forall a. m a -> IO a
runInBase (m a -> IO a) -> m a -> IO a
forall a b. (a -> b) -> a -> b
$ (ProgressAmount -> m ()) -> m a
f (ProgressToken -> ProgressAmount -> m ()
forall (m :: * -> *) config.
MonadLsp config m =>
ProgressToken -> ProgressAmount -> m ()
updater ProgressToken
progId)
      m () -> IO ()
forall a. m a -> IO a
runInBase (m () -> IO ()) -> m () -> IO ()
forall a b. (a -> b) -> a -> b
$ ProgressToken -> Async a -> m ()
forall config (m :: * -> *) a.
MonadLsp config m =>
ProgressToken -> Async a -> m ()
storeProgress ProgressToken
progId Async a
aid
      Async a -> IO a
forall a. Async a -> IO a
wait Async a
aid

  -- Delete the progress cancellation from the map
  -- If we don't do this then it's easy to leak things as the map contains any IO action.
  ProgressToken -> m ()
forall config (m :: * -> *).
MonadLsp config m =>
ProgressToken -> m ()
deleteProgress ProgressToken
progId

  a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
res
  where updater :: ProgressToken -> ProgressAmount -> m ()
updater ProgressToken
progId (ProgressAmount Maybe Double
percentage Maybe Text
msg) = do
          IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ FilePath -> IO ()
putStrLn FilePath
"asdf"
          SServerMethod @'Notification 'Progress
-> MessageParams @'FromServer @'Notification 'Progress -> m ()
forall (m :: Method 'FromServer 'Notification) (f :: * -> *)
       config.
MonadLsp config f =>
SServerMethod @'Notification m
-> MessageParams @'FromServer @'Notification m -> f ()
sendNotification SServerMethod @'Notification 'Progress
SProgress (MessageParams @'FromServer @'Notification 'Progress -> m ())
-> MessageParams @'FromServer @'Notification 'Progress -> m ()
forall a b. (a -> b) -> a -> b
$ (WorkDoneProgressReportParams -> SomeProgressParams)
-> ProgressParams WorkDoneProgressReportParams
-> ProgressParams SomeProgressParams
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap WorkDoneProgressReportParams -> SomeProgressParams
Report (ProgressParams WorkDoneProgressReportParams
 -> ProgressParams SomeProgressParams)
-> ProgressParams WorkDoneProgressReportParams
-> ProgressParams SomeProgressParams
forall a b. (a -> b) -> a -> b
$ ProgressToken
-> WorkDoneProgressReportParams
-> ProgressParams WorkDoneProgressReportParams
forall t. ProgressToken -> t -> ProgressParams t
ProgressParams ProgressToken
progId (WorkDoneProgressReportParams
 -> ProgressParams WorkDoneProgressReportParams)
-> WorkDoneProgressReportParams
-> ProgressParams WorkDoneProgressReportParams
forall a b. (a -> b) -> a -> b
$
              Maybe Bool
-> Maybe Text -> Maybe Double -> WorkDoneProgressReportParams
WorkDoneProgressReportParams Maybe Bool
forall a. Maybe a
Nothing Maybe Text
msg Maybe Double
percentage

clientSupportsProgress :: J.ClientCapabilities -> Bool
clientSupportsProgress :: ClientCapabilities -> Bool
clientSupportsProgress (J.ClientCapabilities Maybe WorkspaceClientCapabilities
_ Maybe TextDocumentClientCapabilities
_ Maybe WindowClientCapabilities
wc Maybe Object
_) = Bool -> Maybe Bool -> Bool
forall a. a -> Maybe a -> a
fromMaybe Bool
False (Maybe Bool -> Bool) -> Maybe Bool -> Bool
forall a b. (a -> b) -> a -> b
$ do
  (J.WindowClientCapabilities Maybe Bool
mProgress) <- Maybe WindowClientCapabilities
wc
  Maybe Bool
mProgress

{-# INLINE clientSupportsProgress #-}

-- | Wrapper for reporting progress to the client during a long running
-- task.
-- 'withProgress' @title cancellable f@ starts a new progress reporting
-- session, and finishes it once f is completed.
-- f is provided with an update function that allows it to report on
-- the progress during the session.
-- If @cancellable@ is 'Cancellable', @f@ will be thrown a
-- 'ProgressCancelledException' if the user cancels the action in
-- progress.
withProgress :: MonadLsp c m => Text -> ProgressCancellable -> ((ProgressAmount -> m ()) -> m a) -> m a
withProgress :: Text
-> ProgressCancellable -> ((ProgressAmount -> m ()) -> m a) -> m a
withProgress Text
title ProgressCancellable
cancellable (ProgressAmount -> m ()) -> m a
f = do
  ClientCapabilities
clientCaps <- m ClientCapabilities
forall config (m :: * -> *).
MonadLsp config m =>
m ClientCapabilities
getClientCapabilities
  if ClientCapabilities -> Bool
clientSupportsProgress ClientCapabilities
clientCaps
    then Bool
-> Text
-> ProgressCancellable
-> ((ProgressAmount -> m ()) -> m a)
-> m a
forall c (m :: * -> *) a.
MonadLsp c m =>
Bool
-> Text
-> ProgressCancellable
-> ((ProgressAmount -> m ()) -> m a)
-> m a
withProgressBase Bool
False Text
title ProgressCancellable
cancellable (ProgressAmount -> m ()) -> m a
f
    else (ProgressAmount -> m ()) -> m a
f (m () -> ProgressAmount -> m ()
forall a b. a -> b -> a
const (m () -> ProgressAmount -> m ()) -> m () -> ProgressAmount -> m ()
forall a b. (a -> b) -> a -> b
$ () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ())

-- | Same as 'withProgress', but for processes that do not report the
-- precentage complete.
--
-- @since 0.10.0.0
withIndefiniteProgress :: MonadLsp c m => Text -> ProgressCancellable -> m a -> m a
withIndefiniteProgress :: Text -> ProgressCancellable -> m a -> m a
withIndefiniteProgress Text
title ProgressCancellable
cancellable m a
f = do
  ClientCapabilities
clientCaps <- m ClientCapabilities
forall config (m :: * -> *).
MonadLsp config m =>
m ClientCapabilities
getClientCapabilities
  if ClientCapabilities -> Bool
clientSupportsProgress ClientCapabilities
clientCaps
    then Bool
-> Text
-> ProgressCancellable
-> ((ProgressAmount -> m ()) -> m a)
-> m a
forall c (m :: * -> *) a.
MonadLsp c m =>
Bool
-> Text
-> ProgressCancellable
-> ((ProgressAmount -> m ()) -> m a)
-> m a
withProgressBase Bool
True Text
title ProgressCancellable
cancellable (m a -> (ProgressAmount -> m ()) -> m a
forall a b. a -> b -> a
const m a
f)
    else m a
f
    
-- ---------------------------------------------------------------------

-- | Aggregate all diagnostics pertaining to a particular version of a document,
-- by source, and sends a @textDocument/publishDiagnostics@ notification with
-- the total (limited by the first parameter) whenever it is updated.
publishDiagnostics :: MonadLsp config m => Int -> NormalizedUri -> TextDocumentVersion -> DiagnosticsBySource -> m ()
publishDiagnostics :: Int -> NormalizedUri -> Maybe Int -> DiagnosticsBySource -> m ()
publishDiagnostics Int
maxDiagnosticCount NormalizedUri
uri Maybe Int
version DiagnosticsBySource
diags = m (m ()) -> m ()
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (m (m ()) -> m ()) -> m (m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ (LanguageContextState config -> TVar DiagnosticStore)
-> (DiagnosticStore -> (m (), DiagnosticStore)) -> m (m ())
forall config (m :: * -> *) s a.
MonadLsp config m =>
(LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState LanguageContextState config -> TVar DiagnosticStore
forall config. LanguageContextState config -> TVar DiagnosticStore
resDiagnostics ((DiagnosticStore -> (m (), DiagnosticStore)) -> m (m ()))
-> (DiagnosticStore -> (m (), DiagnosticStore)) -> m (m ())
forall a b. (a -> b) -> a -> b
$ \DiagnosticStore
oldDiags->
  let !newDiags :: DiagnosticStore
newDiags = DiagnosticStore
-> NormalizedUri
-> Maybe Int
-> DiagnosticsBySource
-> DiagnosticStore
updateDiagnostics DiagnosticStore
oldDiags NormalizedUri
uri Maybe Int
version DiagnosticsBySource
diags
      mdp :: Maybe PublishDiagnosticsParams
mdp = Int
-> DiagnosticStore
-> NormalizedUri
-> Maybe PublishDiagnosticsParams
getDiagnosticParamsFor Int
maxDiagnosticCount DiagnosticStore
newDiags NormalizedUri
uri
      act :: m ()
act = case Maybe PublishDiagnosticsParams
mdp of
        Maybe PublishDiagnosticsParams
Nothing -> () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
        Just PublishDiagnosticsParams
params ->
          FromServerMessage -> m ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> m ()) -> FromServerMessage -> m ()
forall a b. (a -> b) -> a -> b
$ NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
-> FromServerMessage
forall (m :: Method 'FromServer 'Notification).
((Message @'FromServer @'Notification m :: *)
 ~ (NotificationMessage @'FromServer m :: *)) =>
NotificationMessage @'FromServer m -> FromServerMessage
J.fromServerNot (NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
 -> FromServerMessage)
-> NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
-> FromServerMessage
forall a b. (a -> b) -> a -> b
$ Text
-> SMethod
     @'FromServer @'Notification 'TextDocumentPublishDiagnostics
-> MessageParams
     @'FromServer @'Notification 'TextDocumentPublishDiagnostics
-> NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
forall (f :: From) (m :: Method f 'Notification).
Text
-> SMethod @f @'Notification m
-> MessageParams @f @'Notification m
-> NotificationMessage @f m
J.NotificationMessage Text
"2.0" SMethod @'FromServer @'Notification 'TextDocumentPublishDiagnostics
J.STextDocumentPublishDiagnostics MessageParams
  @'FromServer @'Notification 'TextDocumentPublishDiagnostics
PublishDiagnosticsParams
params
      in (m ()
act,DiagnosticStore
newDiags)

-- ---------------------------------------------------------------------

-- | Remove all diagnostics from a particular source, and send the updates to
-- the client.
flushDiagnosticsBySource :: MonadLsp config m => Int -- ^ Max number of diagnostics to send
                         -> Maybe DiagnosticSource -> m ()
flushDiagnosticsBySource :: Int -> Maybe Text -> m ()
flushDiagnosticsBySource Int
maxDiagnosticCount Maybe Text
msource = m (m ()) -> m ()
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (m (m ()) -> m ()) -> m (m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ (LanguageContextState config -> TVar DiagnosticStore)
-> (DiagnosticStore -> (m (), DiagnosticStore)) -> m (m ())
forall config (m :: * -> *) s a.
MonadLsp config m =>
(LanguageContextState config -> TVar s) -> (s -> (a, s)) -> m a
stateState LanguageContextState config -> TVar DiagnosticStore
forall config. LanguageContextState config -> TVar DiagnosticStore
resDiagnostics ((DiagnosticStore -> (m (), DiagnosticStore)) -> m (m ()))
-> (DiagnosticStore -> (m (), DiagnosticStore)) -> m (m ())
forall a b. (a -> b) -> a -> b
$ \DiagnosticStore
oldDiags ->
  let !newDiags :: DiagnosticStore
newDiags = DiagnosticStore -> Maybe Text -> DiagnosticStore
flushBySource DiagnosticStore
oldDiags Maybe Text
msource
      -- Send the updated diagnostics to the client
      act :: m ()
act = [NormalizedUri] -> (NormalizedUri -> m ()) -> m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ (DiagnosticStore -> [NormalizedUri]
forall k v. HashMap k v -> [k]
HM.keys DiagnosticStore
newDiags) ((NormalizedUri -> m ()) -> m ())
-> (NormalizedUri -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \NormalizedUri
uri -> do
        let mdp :: Maybe PublishDiagnosticsParams
mdp = Int
-> DiagnosticStore
-> NormalizedUri
-> Maybe PublishDiagnosticsParams
getDiagnosticParamsFor Int
maxDiagnosticCount DiagnosticStore
newDiags NormalizedUri
uri
        case Maybe PublishDiagnosticsParams
mdp of
          Maybe PublishDiagnosticsParams
Nothing -> () -> m ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
          Just PublishDiagnosticsParams
params -> do
            FromServerMessage -> m ()
forall config (m :: * -> *).
MonadLsp config m =>
FromServerMessage -> m ()
sendToClient (FromServerMessage -> m ()) -> FromServerMessage -> m ()
forall a b. (a -> b) -> a -> b
$ NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
-> FromServerMessage
forall (m :: Method 'FromServer 'Notification).
((Message @'FromServer @'Notification m :: *)
 ~ (NotificationMessage @'FromServer m :: *)) =>
NotificationMessage @'FromServer m -> FromServerMessage
J.fromServerNot (NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
 -> FromServerMessage)
-> NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
-> FromServerMessage
forall a b. (a -> b) -> a -> b
$ Text
-> SMethod
     @'FromServer @'Notification 'TextDocumentPublishDiagnostics
-> MessageParams
     @'FromServer @'Notification 'TextDocumentPublishDiagnostics
-> NotificationMessage @'FromServer 'TextDocumentPublishDiagnostics
forall (f :: From) (m :: Method f 'Notification).
Text
-> SMethod @f @'Notification m
-> MessageParams @f @'Notification m
-> NotificationMessage @f m
J.NotificationMessage Text
"2.0" SMethod @'FromServer @'Notification 'TextDocumentPublishDiagnostics
J.STextDocumentPublishDiagnostics MessageParams
  @'FromServer @'Notification 'TextDocumentPublishDiagnostics
PublishDiagnosticsParams
params
      in (m ()
act,DiagnosticStore
newDiags)

-- =====================================================================
--
--  utility


--
--  Logger
--
setupLogger :: Maybe FilePath -> [String] -> Priority -> IO ()
setupLogger :: Maybe FilePath -> [FilePath] -> Priority -> IO ()
setupLogger Maybe FilePath
mLogFile [FilePath]
extraLogNames Priority
level = do

  Handle
logStream <- case Maybe FilePath
mLogFile of
    Just FilePath
logFile -> FilePath -> IOMode -> IO Handle
openFile FilePath
logFile IOMode
AppendMode IO Handle -> (IOException -> IO Handle) -> IO Handle
forall e a. Exception e => IO a -> (e -> IO a) -> IO a
`E.catch` FilePath -> IOException -> IO Handle
handleIOException FilePath
logFile
    Maybe FilePath
Nothing      -> Handle -> IO Handle
forall (m :: * -> *) a. Monad m => a -> m a
return Handle
stderr
  Handle -> TextEncoding -> IO ()
hSetEncoding Handle
logStream TextEncoding
utf8

  GenericHandler Handle
logH <- Handle -> Priority -> IO (GenericHandler Handle)
LHS.streamHandler Handle
logStream Priority
level

  let logHandle :: GenericHandler Handle
logHandle  = GenericHandler Handle
logH {closeFunc :: Handle -> IO ()
LHS.closeFunc = Handle -> IO ()
hClose}
      logFormatter :: LogFormatter (GenericHandler Handle)
logFormatter  = FilePath -> FilePath -> LogFormatter (GenericHandler Handle)
forall a. FilePath -> FilePath -> LogFormatter a
L.tfLogFormatter FilePath
logDateFormat FilePath
logFormat
      logHandler :: GenericHandler Handle
logHandler = GenericHandler Handle
-> LogFormatter (GenericHandler Handle) -> GenericHandler Handle
forall a. LogHandler a => a -> LogFormatter a -> a
LH.setFormatter GenericHandler Handle
logHandle LogFormatter (GenericHandler Handle)
logFormatter

  FilePath -> (Logger -> Logger) -> IO ()
L.updateGlobalLogger FilePath
L.rootLoggerName ((Logger -> Logger) -> IO ()) -> (Logger -> Logger) -> IO ()
forall a b. (a -> b) -> a -> b
$ [GenericHandler Handle] -> Logger -> Logger
forall a. LogHandler a => [a] -> Logger -> Logger
L.setHandlers ([] :: [LHS.GenericHandler Handle])
  FilePath -> (Logger -> Logger) -> IO ()
L.updateGlobalLogger FilePath
"haskell-lsp" ((Logger -> Logger) -> IO ()) -> (Logger -> Logger) -> IO ()
forall a b. (a -> b) -> a -> b
$ [GenericHandler Handle] -> Logger -> Logger
forall a. LogHandler a => [a] -> Logger -> Logger
L.setHandlers [GenericHandler Handle
logHandler]
  FilePath -> (Logger -> Logger) -> IO ()
L.updateGlobalLogger FilePath
"haskell-lsp" ((Logger -> Logger) -> IO ()) -> (Logger -> Logger) -> IO ()
forall a b. (a -> b) -> a -> b
$ Priority -> Logger -> Logger
L.setLevel Priority
level

  -- Also route the additional log names to the same log
  [FilePath] -> (FilePath -> IO ()) -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
t a -> (a -> m b) -> m ()
forM_ [FilePath]
extraLogNames ((FilePath -> IO ()) -> IO ()) -> (FilePath -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \FilePath
logName -> do
    FilePath -> (Logger -> Logger) -> IO ()
L.updateGlobalLogger FilePath
logName ((Logger -> Logger) -> IO ()) -> (Logger -> Logger) -> IO ()
forall a b. (a -> b) -> a -> b
$ [GenericHandler Handle] -> Logger -> Logger
forall a. LogHandler a => [a] -> Logger -> Logger
L.setHandlers [GenericHandler Handle
logHandler]
    FilePath -> (Logger -> Logger) -> IO ()
L.updateGlobalLogger FilePath
logName ((Logger -> Logger) -> IO ()) -> (Logger -> Logger) -> IO ()
forall a b. (a -> b) -> a -> b
$ Priority -> Logger -> Logger
L.setLevel Priority
level
  where
    logFormat :: FilePath
logFormat = FilePath
"$time [$tid] $prio $loggername:\t$msg"
    logDateFormat :: FilePath
logDateFormat = FilePath
"%Y-%m-%d %H:%M:%S%Q"

handleIOException :: FilePath -> E.IOException ->  IO Handle
handleIOException :: FilePath -> IOException -> IO Handle
handleIOException FilePath
logFile IOException
_ = do
  Handle -> FilePath -> IO ()
hPutStr Handle
stderr (FilePath -> IO ()) -> FilePath -> IO ()
forall a b. (a -> b) -> a -> b
$ FilePath
"Couldn't open log file " FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ FilePath
logFile FilePath -> ShowS
forall a. [a] -> [a] -> [a]
++ FilePath
"; falling back to stderr logging"
  Handle -> IO Handle
forall (m :: * -> *) a. Monad m => a -> m a
return Handle
stderr

-- ---------------------------------------------------------------------

-- | The changes in a workspace edit should be applied from the end of the file
-- toward the start. Sort them into this order.
reverseSortEdit :: J.WorkspaceEdit -> J.WorkspaceEdit
reverseSortEdit :: WorkspaceEdit -> WorkspaceEdit
reverseSortEdit (J.WorkspaceEdit Maybe WorkspaceEditMap
cs Maybe (List DocumentChange)
dcs Maybe ChangeAnnotationMap
anns) = Maybe WorkspaceEditMap
-> Maybe (List DocumentChange)
-> Maybe ChangeAnnotationMap
-> WorkspaceEdit
J.WorkspaceEdit Maybe WorkspaceEditMap
cs' Maybe (List DocumentChange)
dcs' Maybe ChangeAnnotationMap
anns
  where
    cs' :: Maybe J.WorkspaceEditMap
    cs' :: Maybe WorkspaceEditMap
cs' = ((WorkspaceEditMap -> WorkspaceEditMap)
-> Maybe WorkspaceEditMap -> Maybe WorkspaceEditMap
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((WorkspaceEditMap -> WorkspaceEditMap)
 -> Maybe WorkspaceEditMap -> Maybe WorkspaceEditMap)
-> ((List TextEdit -> List TextEdit)
    -> WorkspaceEditMap -> WorkspaceEditMap)
-> (List TextEdit -> List TextEdit)
-> Maybe WorkspaceEditMap
-> Maybe WorkspaceEditMap
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (List TextEdit -> List TextEdit)
-> WorkspaceEditMap -> WorkspaceEditMap
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ) List TextEdit -> List TextEdit
sortTextEdits Maybe WorkspaceEditMap
cs

    dcs' :: Maybe (J.List J.DocumentChange)
    dcs' :: Maybe (List DocumentChange)
dcs' = ((List DocumentChange -> List DocumentChange)
-> Maybe (List DocumentChange) -> Maybe (List DocumentChange)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((List DocumentChange -> List DocumentChange)
 -> Maybe (List DocumentChange) -> Maybe (List DocumentChange))
-> ((DocumentChange -> DocumentChange)
    -> List DocumentChange -> List DocumentChange)
-> (DocumentChange -> DocumentChange)
-> Maybe (List DocumentChange)
-> Maybe (List DocumentChange)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DocumentChange -> DocumentChange)
-> List DocumentChange -> List DocumentChange
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap) DocumentChange -> DocumentChange
sortOnlyTextDocumentEdits Maybe (List DocumentChange)
dcs

    sortTextEdits :: J.List J.TextEdit -> J.List J.TextEdit
    sortTextEdits :: List TextEdit -> List TextEdit
sortTextEdits (J.List [TextEdit]
edits) = [TextEdit] -> List TextEdit
forall a. [a] -> List a
J.List ((TextEdit -> Down Range) -> [TextEdit] -> [TextEdit]
forall b a. Ord b => (a -> b) -> [a] -> [a]
L.sortOn (Range -> Down Range
forall a. a -> Down a
Down (Range -> Down Range)
-> (TextEdit -> Range) -> TextEdit -> Down Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextEdit -> Getting Range TextEdit Range -> Range
forall s a. s -> Getting a s a -> a
^. Getting Range TextEdit Range
forall s a. HasRange s a => Lens' s a
J.range)) [TextEdit]
edits)

    sortOnlyTextDocumentEdits :: J.DocumentChange -> J.DocumentChange
    sortOnlyTextDocumentEdits :: DocumentChange -> DocumentChange
sortOnlyTextDocumentEdits (J.InL (J.TextDocumentEdit VersionedTextDocumentIdentifier
td (J.List [TextEdit |? AnnotatedTextEdit]
edits))) = TextDocumentEdit -> DocumentChange
forall a b. a -> a |? b
J.InL (TextDocumentEdit -> DocumentChange)
-> TextDocumentEdit -> DocumentChange
forall a b. (a -> b) -> a -> b
$ VersionedTextDocumentIdentifier
-> List (TextEdit |? AnnotatedTextEdit) -> TextDocumentEdit
J.TextDocumentEdit VersionedTextDocumentIdentifier
td ([TextEdit |? AnnotatedTextEdit]
-> List (TextEdit |? AnnotatedTextEdit)
forall a. [a] -> List a
J.List [TextEdit |? AnnotatedTextEdit]
edits')
      where
        edits' :: [TextEdit |? AnnotatedTextEdit]
edits' = ((TextEdit |? AnnotatedTextEdit) -> Down Range)
-> [TextEdit |? AnnotatedTextEdit]
-> [TextEdit |? AnnotatedTextEdit]
forall b a. Ord b => (a -> b) -> [a] -> [a]
L.sortOn (Range -> Down Range
forall a. a -> Down a
Down (Range -> Down Range)
-> ((TextEdit |? AnnotatedTextEdit) -> Range)
-> (TextEdit |? AnnotatedTextEdit)
-> Down Range
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TextEdit |? AnnotatedTextEdit) -> Range
editRange) [TextEdit |? AnnotatedTextEdit]
edits
    sortOnlyTextDocumentEdits (J.InR CreateFile |? (RenameFile |? DeleteFile)
others) = (CreateFile |? (RenameFile |? DeleteFile)) -> DocumentChange
forall a b. b -> a |? b
J.InR CreateFile |? (RenameFile |? DeleteFile)
others

    editRange :: J.TextEdit J.|? J.AnnotatedTextEdit -> J.Range
    editRange :: (TextEdit |? AnnotatedTextEdit) -> Range
editRange (J.InR AnnotatedTextEdit
e) = AnnotatedTextEdit
e AnnotatedTextEdit -> Getting Range AnnotatedTextEdit Range -> Range
forall s a. s -> Getting a s a -> a
^. Getting Range AnnotatedTextEdit Range
forall s a. HasRange s a => Lens' s a
J.range
    editRange (J.InL TextEdit
e) = TextEdit
e TextEdit -> Getting Range TextEdit Range -> Range
forall s a. s -> Getting a s a -> a
^. Getting Range TextEdit Range
forall s a. HasRange s a => Lens' s a
J.range