{-# LANGUAGE OverloadedStrings          #-}
{-# LANGUAGE TemplateHaskell            #-}
{-# LANGUAGE DataKinds                  #-}
{-# LANGUAGE GADTs                      #-}
{-# LANGUAGE TypeFamilies               #-}
{-# LANGUAGE TypeInType                 #-}
{-# LANGUAGE FlexibleInstances          #-}
{-# LANGUAGE StandaloneDeriving         #-}
{-# LANGUAGE ScopedTypeVariables        #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
module Language.LSP.Types.Method where

import qualified Data.Aeson                                 as A
import           Data.Aeson.Types
import           Data.Text                                  (Text)
import           Language.LSP.Types.Utils
import           Data.Function (on)
import Control.Applicative
import  Data.GADT.Compare.TH

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

data From       = FromServer   | FromClient
data MethodType = Notification | Request

data Method (f :: From) (t :: MethodType) where
-- Client Methods
  -- General
  Initialize                         :: Method FromClient Request
  Initialized                        :: Method FromClient Notification
  Shutdown                           :: Method FromClient Request
  Exit                               :: Method FromClient Notification
  -- Workspace
  WorkspaceDidChangeWorkspaceFolders :: Method FromClient Notification
  WorkspaceDidChangeConfiguration    :: Method FromClient Notification
  WorkspaceDidChangeWatchedFiles     :: Method FromClient Notification
  WorkspaceSymbol                    :: Method FromClient Request
  WorkspaceExecuteCommand            :: Method FromClient Request
  -- Document
  TextDocumentDidOpen                :: Method FromClient Notification
  TextDocumentDidChange              :: Method FromClient Notification
  TextDocumentWillSave               :: Method FromClient Notification
  TextDocumentWillSaveWaitUntil      :: Method FromClient Request
  TextDocumentDidSave                :: Method FromClient Notification
  TextDocumentDidClose               :: Method FromClient Notification
  -- Completion
  TextDocumentCompletion             :: Method FromClient Request
  CompletionItemResolve              :: Method FromClient Request
  -- LanguageQueries
  TextDocumentHover                  :: Method FromClient Request
  TextDocumentSignatureHelp          :: Method FromClient Request
  TextDocumentDeclaration            :: Method FromClient Request
  TextDocumentDefinition             :: Method FromClient Request
  TextDocumentTypeDefinition         :: Method FromClient Request
  TextDocumentImplementation         :: Method FromClient Request
  TextDocumentReferences             :: Method FromClient Request
  TextDocumentDocumentHighlight      :: Method FromClient Request
  TextDocumentDocumentSymbol         :: Method FromClient Request
  -- Code Action/Lens/Link
  TextDocumentCodeAction             :: Method FromClient Request
  TextDocumentCodeLens               :: Method FromClient Request
  CodeLensResolve                    :: Method FromClient Request
  TextDocumentDocumentLink           :: Method FromClient Request
  DocumentLinkResolve                :: Method FromClient Request
  -- Syntax highlighting/Coloring
  TextDocumentDocumentColor          :: Method FromClient Request
  TextDocumentColorPresentation      :: Method FromClient Request
  -- Formatting
  TextDocumentFormatting             :: Method FromClient Request
  TextDocumentRangeFormatting        :: Method FromClient Request
  TextDocumentOnTypeFormatting       :: Method FromClient Request
  -- Rename
  TextDocumentRename                 :: Method FromClient Request
  TextDocumentPrepareRename          :: Method FromClient Request
  -- FoldingRange
  TextDocumentFoldingRange           :: Method FromClient Request
  TextDocumentSelectionRange         :: Method FromClient Request

-- ServerMethods
  -- Window
  WindowShowMessage                  :: Method FromServer Notification
  WindowShowMessageRequest           :: Method FromServer Request
  WindowLogMessage                   :: Method FromServer Notification
  WindowWorkDoneProgressCancel       :: Method FromClient Notification
  WindowWorkDoneProgressCreate       :: Method FromServer Request
  -- Progress
  Progress                           :: Method FromServer Notification
  -- Telemetry
  TelemetryEvent                     :: Method FromServer Notification
  -- Client
  ClientRegisterCapability           :: Method FromServer Request
  ClientUnregisterCapability         :: Method FromServer Request
  -- Workspace
  WorkspaceWorkspaceFolders          :: Method FromServer Request
  WorkspaceConfiguration             :: Method FromServer Request
  WorkspaceApplyEdit                 :: Method FromServer Request
  -- Document
  TextDocumentPublishDiagnostics     :: Method FromServer Notification

-- Cancelling
  CancelRequest                      :: Method f Notification

-- Custom
  -- A custom message type. It is not enforced that this starts with $/.
  CustomMethod                       :: Method f t

data SMethod (m :: Method f t) where
  SInitialize                         :: SMethod Initialize
  SInitialized                        :: SMethod Initialized
  SShutdown                           :: SMethod Shutdown
  SExit                               :: SMethod Exit
  SWorkspaceDidChangeWorkspaceFolders :: SMethod WorkspaceDidChangeWorkspaceFolders
  SWorkspaceDidChangeConfiguration    :: SMethod WorkspaceDidChangeConfiguration
  SWorkspaceDidChangeWatchedFiles     :: SMethod WorkspaceDidChangeWatchedFiles
  SWorkspaceSymbol                    :: SMethod WorkspaceSymbol
  SWorkspaceExecuteCommand            :: SMethod WorkspaceExecuteCommand
  STextDocumentDidOpen                :: SMethod TextDocumentDidOpen
  STextDocumentDidChange              :: SMethod TextDocumentDidChange
  STextDocumentWillSave               :: SMethod TextDocumentWillSave
  STextDocumentWillSaveWaitUntil      :: SMethod TextDocumentWillSaveWaitUntil
  STextDocumentDidSave                :: SMethod TextDocumentDidSave
  STextDocumentDidClose               :: SMethod TextDocumentDidClose
  STextDocumentCompletion             :: SMethod TextDocumentCompletion
  SCompletionItemResolve              :: SMethod CompletionItemResolve
  STextDocumentHover                  :: SMethod TextDocumentHover
  STextDocumentSignatureHelp          :: SMethod TextDocumentSignatureHelp
  STextDocumentDeclaration            :: SMethod TextDocumentDeclaration
  STextDocumentDefinition             :: SMethod TextDocumentDefinition
  STextDocumentTypeDefinition         :: SMethod TextDocumentTypeDefinition
  STextDocumentImplementation         :: SMethod TextDocumentImplementation
  STextDocumentReferences             :: SMethod TextDocumentReferences
  STextDocumentDocumentHighlight      :: SMethod TextDocumentDocumentHighlight
  STextDocumentDocumentSymbol         :: SMethod TextDocumentDocumentSymbol
  STextDocumentCodeAction             :: SMethod TextDocumentCodeAction
  STextDocumentCodeLens               :: SMethod TextDocumentCodeLens
  SCodeLensResolve                    :: SMethod CodeLensResolve
  STextDocumentDocumentLink           :: SMethod TextDocumentDocumentLink
  SDocumentLinkResolve                :: SMethod DocumentLinkResolve
  STextDocumentDocumentColor          :: SMethod TextDocumentDocumentColor
  STextDocumentColorPresentation      :: SMethod TextDocumentColorPresentation
  STextDocumentFormatting             :: SMethod TextDocumentFormatting
  STextDocumentRangeFormatting        :: SMethod TextDocumentRangeFormatting
  STextDocumentOnTypeFormatting       :: SMethod TextDocumentOnTypeFormatting
  STextDocumentRename                 :: SMethod TextDocumentRename
  STextDocumentPrepareRename          :: SMethod TextDocumentPrepareRename
  STextDocumentFoldingRange           :: SMethod TextDocumentFoldingRange
  STextDocumentSelectionRange         :: SMethod TextDocumentSelectionRange

  SWindowShowMessage                  :: SMethod WindowShowMessage
  SWindowShowMessageRequest           :: SMethod WindowShowMessageRequest
  SWindowLogMessage                   :: SMethod WindowLogMessage
  SWindowWorkDoneProgressCreate       :: SMethod WindowWorkDoneProgressCreate
  SWindowWorkDoneProgressCancel       :: SMethod WindowWorkDoneProgressCancel
  SProgress                           :: SMethod Progress
  STelemetryEvent                     :: SMethod TelemetryEvent
  SClientRegisterCapability           :: SMethod ClientRegisterCapability
  SClientUnregisterCapability         :: SMethod ClientUnregisterCapability
  SWorkspaceWorkspaceFolders          :: SMethod WorkspaceWorkspaceFolders
  SWorkspaceConfiguration             :: SMethod WorkspaceConfiguration
  SWorkspaceApplyEdit                 :: SMethod WorkspaceApplyEdit
  STextDocumentPublishDiagnostics     :: SMethod TextDocumentPublishDiagnostics

  SCancelRequest                      :: SMethod CancelRequest
  SCustomMethod                       :: Text -> SMethod CustomMethod

deriveGEq ''SMethod
deriveGCompare ''SMethod

deriving instance Eq   (SMethod m)
deriving instance Ord  (SMethod m)
deriving instance Show (SMethod m)

-- Some useful type synonyms
type SClientMethod (m :: Method FromClient t) = SMethod m
type SServerMethod (m :: Method FromServer t) = SMethod m

data SomeClientMethod = forall t (m :: Method FromClient t). SomeClientMethod (SMethod m)
data SomeServerMethod = forall t (m :: Method FromServer t). SomeServerMethod (SMethod m)

data SomeMethod where
  SomeMethod :: forall m. SMethod m -> SomeMethod

deriving instance Show SomeMethod
instance Eq SomeMethod where
  == :: SomeMethod -> SomeMethod -> Bool
(==) = Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Value -> Value -> Bool)
-> (SomeMethod -> Value) -> SomeMethod -> SomeMethod -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` SomeMethod -> Value
forall a. ToJSON a => a -> Value
toJSON
instance Ord SomeMethod where
  compare :: SomeMethod -> SomeMethod -> Ordering
compare = Text -> Text -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Text -> Text -> Ordering)
-> (SomeMethod -> Text) -> SomeMethod -> SomeMethod -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (Value -> Text
getString (Value -> Text) -> (SomeMethod -> Value) -> SomeMethod -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeMethod -> Value
forall a. ToJSON a => a -> Value
toJSON)
    where
      getString :: Value -> Text
getString (A.String Text
t) = Text
t
      getString Value
_ = String -> Text
forall a. HasCallStack => String -> a
error String
"ToJSON instance for some method isn't string"
deriving instance Show SomeClientMethod
instance Eq SomeClientMethod where
  == :: SomeClientMethod -> SomeClientMethod -> Bool
(==) = Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Value -> Value -> Bool)
-> (SomeClientMethod -> Value)
-> SomeClientMethod
-> SomeClientMethod
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` SomeClientMethod -> Value
forall a. ToJSON a => a -> Value
toJSON
instance Ord SomeClientMethod where
  compare :: SomeClientMethod -> SomeClientMethod -> Ordering
compare = Text -> Text -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Text -> Text -> Ordering)
-> (SomeClientMethod -> Text)
-> SomeClientMethod
-> SomeClientMethod
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (Value -> Text
getString (Value -> Text)
-> (SomeClientMethod -> Value) -> SomeClientMethod -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeClientMethod -> Value
forall a. ToJSON a => a -> Value
toJSON)
    where
      getString :: Value -> Text
getString (A.String Text
t) = Text
t
      getString Value
_ = String -> Text
forall a. HasCallStack => String -> a
error String
"ToJSON instance for some method isn't string"
deriving instance Show SomeServerMethod
instance Eq SomeServerMethod where
  == :: SomeServerMethod -> SomeServerMethod -> Bool
(==) = Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Value -> Value -> Bool)
-> (SomeServerMethod -> Value)
-> SomeServerMethod
-> SomeServerMethod
-> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` SomeServerMethod -> Value
forall a. ToJSON a => a -> Value
toJSON
instance Ord SomeServerMethod where
  compare :: SomeServerMethod -> SomeServerMethod -> Ordering
compare = Text -> Text -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (Text -> Text -> Ordering)
-> (SomeServerMethod -> Text)
-> SomeServerMethod
-> SomeServerMethod
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (Value -> Text
getString (Value -> Text)
-> (SomeServerMethod -> Value) -> SomeServerMethod -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SomeServerMethod -> Value
forall a. ToJSON a => a -> Value
toJSON)
    where
      getString :: Value -> Text
getString (A.String Text
t) = Text
t
      getString Value
_ = String -> Text
forall a. HasCallStack => String -> a
error String
"ToJSON instance for some method isn't string"

-- ---------------------------------------------------------------------
-- From JSON
-- ---------------------------------------------------------------------

instance FromJSON SomeMethod where
  parseJSON :: Value -> Parser SomeMethod
parseJSON Value
v = Parser SomeMethod
client Parser SomeMethod -> Parser SomeMethod -> Parser SomeMethod
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser SomeMethod
server
    where
      client :: Parser SomeMethod
client = do
        SomeClientMethod
c <- Value -> Parser SomeClientMethod
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
        case SomeClientMethod
c of
          -- Don't parse the client custom method so that we can still
          -- parse the server methods
          SomeClientMethod (SCustomMethod Text
_) -> Parser SomeMethod
forall a. Monoid a => a
mempty
          SomeClientMethod SMethod m
m -> SomeMethod -> Parser SomeMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeMethod -> Parser SomeMethod)
-> SomeMethod -> Parser SomeMethod
forall a b. (a -> b) -> a -> b
$ SMethod m -> SomeMethod
forall (f :: From) (t :: MethodType) (m :: Method f t).
SMethod m -> SomeMethod
SomeMethod SMethod m
m
      server :: Parser SomeMethod
server = do
        SomeServerMethod
c <- Value -> Parser SomeServerMethod
forall a. FromJSON a => Value -> Parser a
parseJSON Value
v
        case SomeServerMethod
c of
          SomeServerMethod SMethod m
m -> SomeMethod -> Parser SomeMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeMethod -> Parser SomeMethod)
-> SomeMethod -> Parser SomeMethod
forall a b. (a -> b) -> a -> b
$ SMethod m -> SomeMethod
forall (f :: From) (t :: MethodType) (m :: Method f t).
SMethod m -> SomeMethod
SomeMethod SMethod m
m

instance FromJSON SomeClientMethod where
    -- General
  parseJSON :: Value -> Parser SomeClientMethod
parseJSON (A.String Text
"initialize")                          = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'Initialize -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'Initialize
SInitialize
  parseJSON (A.String Text
"initialized")                         = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'Initialized -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'Initialized
SInitialized
  parseJSON (A.String Text
"shutdown")                            = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'Shutdown -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'Shutdown
SShutdown
  parseJSON (A.String Text
"exit")                                = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'Exit -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'Exit
SExit
 -- Workspace
  parseJSON (A.String Text
"workspace/didChangeWorkspaceFolders") = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceDidChangeWorkspaceFolders -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'WorkspaceDidChangeWorkspaceFolders
SWorkspaceDidChangeWorkspaceFolders
  parseJSON (A.String Text
"workspace/didChangeConfiguration")    = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceDidChangeConfiguration -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'WorkspaceDidChangeConfiguration
SWorkspaceDidChangeConfiguration
  parseJSON (A.String Text
"workspace/didChangeWatchedFiles")     = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceDidChangeWatchedFiles -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'WorkspaceDidChangeWatchedFiles
SWorkspaceDidChangeWatchedFiles
  parseJSON (A.String Text
"workspace/symbol")                    = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceSymbol -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'WorkspaceSymbol
SWorkspaceSymbol
  parseJSON (A.String Text
"workspace/executeCommand")            = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceExecuteCommand -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'WorkspaceExecuteCommand
SWorkspaceExecuteCommand
 -- Document
  parseJSON (A.String Text
"textDocument/didOpen")                = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDidOpen -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDidOpen
STextDocumentDidOpen
  parseJSON (A.String Text
"textDocument/didChange")              = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDidChange -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDidChange
STextDocumentDidChange
  parseJSON (A.String Text
"textDocument/willSave")               = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentWillSave -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentWillSave
STextDocumentWillSave
  parseJSON (A.String Text
"textDocument/willSaveWaitUntil")      = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentWillSaveWaitUntil -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentWillSaveWaitUntil
STextDocumentWillSaveWaitUntil
  parseJSON (A.String Text
"textDocument/didSave")                = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDidSave -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDidSave
STextDocumentDidSave
  parseJSON (A.String Text
"textDocument/didClose")               = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDidClose -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDidClose
STextDocumentDidClose
  parseJSON (A.String Text
"textDocument/completion")             = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentCompletion -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentCompletion
STextDocumentCompletion
  parseJSON (A.String Text
"completionItem/resolve")              = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'CompletionItemResolve -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'CompletionItemResolve
SCompletionItemResolve
  parseJSON (A.String Text
"textDocument/hover")                  = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentHover -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentHover
STextDocumentHover
  parseJSON (A.String Text
"textDocument/signatureHelp")          = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentSignatureHelp -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentSignatureHelp
STextDocumentSignatureHelp
  parseJSON (A.String Text
"textDocument/declaration")            = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDeclaration -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDeclaration
STextDocumentDeclaration
  parseJSON (A.String Text
"textDocument/definition")             = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDefinition -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDefinition
STextDocumentDefinition
  parseJSON (A.String Text
"textDocument/typeDefinition")         = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentTypeDefinition -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentTypeDefinition
STextDocumentTypeDefinition
  parseJSON (A.String Text
"textDocument/implementation")         = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentImplementation -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentImplementation
STextDocumentImplementation
  parseJSON (A.String Text
"textDocument/references")             = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentReferences -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentReferences
STextDocumentReferences
  parseJSON (A.String Text
"textDocument/documentHighlight")      = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDocumentHighlight -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDocumentHighlight
STextDocumentDocumentHighlight
  parseJSON (A.String Text
"textDocument/documentSymbol")         = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDocumentSymbol -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDocumentSymbol
STextDocumentDocumentSymbol
  parseJSON (A.String Text
"textDocument/codeAction")             = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentCodeAction -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentCodeAction
STextDocumentCodeAction
  parseJSON (A.String Text
"textDocument/codeLens")               = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentCodeLens -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentCodeLens
STextDocumentCodeLens
  parseJSON (A.String Text
"codeLens/resolve")                    = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'CodeLensResolve -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'CodeLensResolve
SCodeLensResolve
  parseJSON (A.String Text
"textDocument/documentLink")           = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDocumentLink -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDocumentLink
STextDocumentDocumentLink
  parseJSON (A.String Text
"documentLink/resolve")                = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'DocumentLinkResolve -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'DocumentLinkResolve
SDocumentLinkResolve
  parseJSON (A.String Text
"textDocument/documentColor")          = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentDocumentColor -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentDocumentColor
STextDocumentDocumentColor
  parseJSON (A.String Text
"textDocument/colorPresentation")      = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentColorPresentation -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentColorPresentation
STextDocumentColorPresentation
  parseJSON (A.String Text
"textDocument/formatting")             = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentFormatting -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentFormatting
STextDocumentFormatting
  parseJSON (A.String Text
"textDocument/rangeFormatting")        = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentRangeFormatting -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentRangeFormatting
STextDocumentRangeFormatting
  parseJSON (A.String Text
"textDocument/onTypeFormatting")       = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentOnTypeFormatting -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentOnTypeFormatting
STextDocumentOnTypeFormatting
  parseJSON (A.String Text
"textDocument/rename")                 = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentRename -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentRename
STextDocumentRename
  parseJSON (A.String Text
"textDocument/prepareRename")          = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentPrepareRename -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentPrepareRename
STextDocumentPrepareRename
  parseJSON (A.String Text
"textDocument/foldingRange")           = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentFoldingRange -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentFoldingRange
STextDocumentFoldingRange
  parseJSON (A.String Text
"textDocument/selectionRange")         = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentFoldingRange -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'TextDocumentFoldingRange
STextDocumentFoldingRange
  parseJSON (A.String Text
"window/workDoneProgress/cancel")      = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WindowWorkDoneProgressCancel -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'WindowWorkDoneProgressCancel
SWindowWorkDoneProgressCancel
-- Cancelling
  parseJSON (A.String Text
"$/cancelRequest")                     = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'CancelRequest -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod SMethod 'CancelRequest
forall (f :: From). SMethod 'CancelRequest
SCancelRequest
-- Custom
  parseJSON (A.String Text
m)                                     = SomeClientMethod -> Parser SomeClientMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeClientMethod -> Parser SomeClientMethod)
-> SomeClientMethod -> Parser SomeClientMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'CustomMethod -> SomeClientMethod
forall (t :: MethodType) (m :: Method 'FromClient t).
SMethod m -> SomeClientMethod
SomeClientMethod (Text -> SMethod 'CustomMethod
forall (f :: From) (t :: MethodType). Text -> SMethod 'CustomMethod
SCustomMethod Text
m)
  parseJSON Value
_                                                = Parser SomeClientMethod
forall a. Monoid a => a
mempty

instance A.FromJSON SomeServerMethod where
-- Server
  -- Window
  parseJSON :: Value -> Parser SomeServerMethod
parseJSON (A.String Text
"window/showMessage")                  = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WindowShowMessage -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WindowShowMessage
SWindowShowMessage
  parseJSON (A.String Text
"window/showMessageRequest")           = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WindowShowMessageRequest -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WindowShowMessageRequest
SWindowShowMessageRequest
  parseJSON (A.String Text
"window/logMessage")                   = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WindowLogMessage -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WindowLogMessage
SWindowLogMessage
  parseJSON (A.String Text
"window/workDoneProgress/create")      = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WindowWorkDoneProgressCreate -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WindowWorkDoneProgressCreate
SWindowWorkDoneProgressCreate
  parseJSON (A.String Text
"$/progress")                          = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'Progress -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'Progress
SProgress
  parseJSON (A.String Text
"telemetry/event")                     = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TelemetryEvent -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'TelemetryEvent
STelemetryEvent
  -- Client
  parseJSON (A.String Text
"client/registerCapability")           = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'ClientRegisterCapability -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'ClientRegisterCapability
SClientRegisterCapability
  parseJSON (A.String Text
"client/unregisterCapability")         = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'ClientUnregisterCapability -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'ClientUnregisterCapability
SClientUnregisterCapability
  -- Workspace
  parseJSON (A.String Text
"workspace/workspaceFolders")          = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceWorkspaceFolders -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WorkspaceWorkspaceFolders
SWorkspaceWorkspaceFolders
  parseJSON (A.String Text
"workspace/configuration")             = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceConfiguration -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WorkspaceConfiguration
SWorkspaceConfiguration
  parseJSON (A.String Text
"workspace/applyEdit")                 = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'WorkspaceApplyEdit -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'WorkspaceApplyEdit
SWorkspaceApplyEdit
  -- Document
  parseJSON (A.String Text
"textDocument/publishDiagnostics")     = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'TextDocumentPublishDiagnostics -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'TextDocumentPublishDiagnostics
STextDocumentPublishDiagnostics

-- Cancelling
  parseJSON (A.String Text
"$/cancelRequest")                     = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'CancelRequest -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod SMethod 'CancelRequest
forall (f :: From). SMethod 'CancelRequest
SCancelRequest

-- Custom
  parseJSON (A.String Text
m)                                     = SomeServerMethod -> Parser SomeServerMethod
forall (f :: * -> *) a. Applicative f => a -> f a
pure (SomeServerMethod -> Parser SomeServerMethod)
-> SomeServerMethod -> Parser SomeServerMethod
forall a b. (a -> b) -> a -> b
$ SMethod 'CustomMethod -> SomeServerMethod
forall (t :: MethodType) (m :: Method 'FromServer t).
SMethod m -> SomeServerMethod
SomeServerMethod (Text -> SMethod 'CustomMethod
forall (f :: From) (t :: MethodType). Text -> SMethod 'CustomMethod
SCustomMethod Text
m)
  parseJSON Value
_                                                = Parser SomeServerMethod
forall a. Monoid a => a
mempty

-- instance FromJSON (SMethod m)
makeSingletonFromJSON 'SomeMethod ''SMethod

-- ---------------------------------------------------------------------
-- TO JSON
-- ---------------------------------------------------------------------

instance ToJSON SomeMethod where
  toJSON :: SomeMethod -> Value
toJSON (SomeMethod SMethod m
m) = SMethod m -> Value
forall a. ToJSON a => a -> Value
toJSON SMethod m
m

instance ToJSON SomeClientMethod where
    toJSON :: SomeClientMethod -> Value
toJSON (SomeClientMethod SMethod m
m) = SMethod m -> Value
forall a. ToJSON a => a -> Value
toJSON SMethod m
m
instance ToJSON SomeServerMethod where
    toJSON :: SomeServerMethod -> Value
toJSON (SomeServerMethod SMethod m
m) = SMethod m -> Value
forall a. ToJSON a => a -> Value
toJSON SMethod m
m

instance A.ToJSON (SMethod m) where
-- Client
  -- General
  toJSON :: SMethod m -> Value
toJSON SMethod m
SInitialize                         = Text -> Value
A.String Text
"initialize"
  toJSON SMethod m
SInitialized                        = Text -> Value
A.String Text
"initialized"
  toJSON SMethod m
SShutdown                           = Text -> Value
A.String Text
"shutdown"
  toJSON SMethod m
SExit                               = Text -> Value
A.String Text
"exit"
  -- Workspace
  toJSON SMethod m
SWorkspaceDidChangeWorkspaceFolders = Text -> Value
A.String Text
"workspace/didChangeWorkspaceFolders"
  toJSON SMethod m
SWorkspaceDidChangeConfiguration    = Text -> Value
A.String Text
"workspace/didChangeConfiguration"
  toJSON SMethod m
SWorkspaceDidChangeWatchedFiles     = Text -> Value
A.String Text
"workspace/didChangeWatchedFiles"
  toJSON SMethod m
SWorkspaceSymbol                    = Text -> Value
A.String Text
"workspace/symbol"
  toJSON SMethod m
SWorkspaceExecuteCommand            = Text -> Value
A.String Text
"workspace/executeCommand"
  -- Document
  toJSON SMethod m
STextDocumentDidOpen                = Text -> Value
A.String Text
"textDocument/didOpen"
  toJSON SMethod m
STextDocumentDidChange              = Text -> Value
A.String Text
"textDocument/didChange"
  toJSON SMethod m
STextDocumentWillSave               = Text -> Value
A.String Text
"textDocument/willSave"
  toJSON SMethod m
STextDocumentWillSaveWaitUntil      = Text -> Value
A.String Text
"textDocument/willSaveWaitUntil"
  toJSON SMethod m
STextDocumentDidSave                = Text -> Value
A.String Text
"textDocument/didSave"
  toJSON SMethod m
STextDocumentDidClose               = Text -> Value
A.String Text
"textDocument/didClose"
  toJSON SMethod m
STextDocumentCompletion             = Text -> Value
A.String Text
"textDocument/completion"
  toJSON SMethod m
SCompletionItemResolve              = Text -> Value
A.String Text
"completionItem/resolve"
  toJSON SMethod m
STextDocumentHover                  = Text -> Value
A.String Text
"textDocument/hover"
  toJSON SMethod m
STextDocumentSignatureHelp          = Text -> Value
A.String Text
"textDocument/signatureHelp"
  toJSON SMethod m
STextDocumentReferences             = Text -> Value
A.String Text
"textDocument/references"
  toJSON SMethod m
STextDocumentDocumentHighlight      = Text -> Value
A.String Text
"textDocument/documentHighlight"
  toJSON SMethod m
STextDocumentDocumentSymbol         = Text -> Value
A.String Text
"textDocument/documentSymbol"
  toJSON SMethod m
STextDocumentDeclaration            = Text -> Value
A.String Text
"textDocument/declaration"
  toJSON SMethod m
STextDocumentDefinition             = Text -> Value
A.String Text
"textDocument/definition"
  toJSON SMethod m
STextDocumentTypeDefinition         = Text -> Value
A.String Text
"textDocument/typeDefinition"
  toJSON SMethod m
STextDocumentImplementation         = Text -> Value
A.String Text
"textDocument/implementation"
  toJSON SMethod m
STextDocumentCodeAction             = Text -> Value
A.String Text
"textDocument/codeAction"
  toJSON SMethod m
STextDocumentCodeLens               = Text -> Value
A.String Text
"textDocument/codeLens"
  toJSON SMethod m
SCodeLensResolve                    = Text -> Value
A.String Text
"codeLens/resolve"
  toJSON SMethod m
STextDocumentDocumentColor          = Text -> Value
A.String Text
"textDocument/documentColor"
  toJSON SMethod m
STextDocumentColorPresentation      = Text -> Value
A.String Text
"textDocument/colorPresentation"
  toJSON SMethod m
STextDocumentFormatting             = Text -> Value
A.String Text
"textDocument/formatting"
  toJSON SMethod m
STextDocumentRangeFormatting        = Text -> Value
A.String Text
"textDocument/rangeFormatting"
  toJSON SMethod m
STextDocumentOnTypeFormatting       = Text -> Value
A.String Text
"textDocument/onTypeFormatting"
  toJSON SMethod m
STextDocumentRename                 = Text -> Value
A.String Text
"textDocument/rename"
  toJSON SMethod m
STextDocumentPrepareRename          = Text -> Value
A.String Text
"textDocument/prepareRename"
  toJSON SMethod m
STextDocumentFoldingRange           = Text -> Value
A.String Text
"textDocument/foldingRange"
  toJSON SMethod m
STextDocumentSelectionRange         = Text -> Value
A.String Text
"textDocument/selectionRange"
  toJSON SMethod m
STextDocumentDocumentLink           = Text -> Value
A.String Text
"textDocument/documentLink"
  toJSON SMethod m
SDocumentLinkResolve                = Text -> Value
A.String Text
"documentLink/resolve"
  toJSON SMethod m
SWindowWorkDoneProgressCancel       = Text -> Value
A.String Text
"window/workDoneProgress/cancel"
-- Server
  -- Window
  toJSON SMethod m
SWindowShowMessage                  = Text -> Value
A.String Text
"window/showMessage"
  toJSON SMethod m
SWindowShowMessageRequest           = Text -> Value
A.String Text
"window/showMessageRequest"
  toJSON SMethod m
SWindowLogMessage                   = Text -> Value
A.String Text
"window/logMessage"
  toJSON SMethod m
SWindowWorkDoneProgressCreate       = Text -> Value
A.String Text
"window/workDoneProgress/create"
  toJSON SMethod m
SProgress                           = Text -> Value
A.String Text
"$/progress"
  toJSON SMethod m
STelemetryEvent                     = Text -> Value
A.String Text
"telemetry/event"
  -- Client
  toJSON SMethod m
SClientRegisterCapability           = Text -> Value
A.String Text
"client/registerCapability"
  toJSON SMethod m
SClientUnregisterCapability         = Text -> Value
A.String Text
"client/unregisterCapability"
  -- Workspace
  toJSON SMethod m
SWorkspaceWorkspaceFolders          = Text -> Value
A.String Text
"workspace/workspaceFolders"
  toJSON SMethod m
SWorkspaceConfiguration             = Text -> Value
A.String Text
"workspace/configuration"
  toJSON SMethod m
SWorkspaceApplyEdit                 = Text -> Value
A.String Text
"workspace/applyEdit"
  -- Document
  toJSON SMethod m
STextDocumentPublishDiagnostics     = Text -> Value
A.String Text
"textDocument/publishDiagnostics"
  -- Cancelling
  toJSON SMethod m
SCancelRequest                      = Text -> Value
A.String Text
"$/cancelRequest"
-- Custom
  toJSON (SCustomMethod Text
m)                   = Text -> Value
A.String Text
m