{-# LANGUAGE GADTs #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilyDependencies #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
{-# OPTIONS_GHC -Werror=incomplete-patterns #-}
module Language.LSP.Types.Registration where
import Data.Aeson
import Data.Aeson.TH
import Data.Text (Text)
import Data.Function (on)
import Data.Kind
import Data.Void (Void)
import GHC.Generics
import Language.LSP.Types.CodeAction
import Language.LSP.Types.CodeLens
import Language.LSP.Types.Command
import Language.LSP.Types.Common
import Language.LSP.Types.Completion
import Language.LSP.Types.Declaration
import Language.LSP.Types.Definition
import Language.LSP.Types.DocumentColor
import Language.LSP.Types.DocumentHighlight
import Language.LSP.Types.DocumentLink
import Language.LSP.Types.DocumentSymbol
import Language.LSP.Types.FoldingRange
import Language.LSP.Types.Formatting
import Language.LSP.Types.Hover
import Language.LSP.Types.Implementation
import Language.LSP.Types.Method
import Language.LSP.Types.References
import Language.LSP.Types.Rename
import Language.LSP.Types.SignatureHelp
import Language.LSP.Types.SelectionRange
import Language.LSP.Types.TextDocument
import Language.LSP.Types.TypeDefinition
import Language.LSP.Types.Utils
import Language.LSP.Types.WatchedFiles
import Language.LSP.Types.WorkspaceSymbol
type family RegistrationOptions (m :: Method FromClient t) :: Type where
RegistrationOptions WorkspaceDidChangeWorkspaceFolders = Empty
RegistrationOptions WorkspaceDidChangeConfiguration = Empty
RegistrationOptions WorkspaceDidChangeWatchedFiles = DidChangeWatchedFilesRegistrationOptions
RegistrationOptions WorkspaceSymbol = WorkspaceSymbolRegistrationOptions
RegistrationOptions WorkspaceExecuteCommand = ExecuteCommandRegistrationOptions
RegistrationOptions TextDocumentDidOpen = TextDocumentRegistrationOptions
RegistrationOptions TextDocumentDidChange = TextDocumentChangeRegistrationOptions
RegistrationOptions TextDocumentWillSave = TextDocumentRegistrationOptions
RegistrationOptions TextDocumentWillSaveWaitUntil = TextDocumentRegistrationOptions
RegistrationOptions TextDocumentDidSave = TextDocumentSaveRegistrationOptions
RegistrationOptions TextDocumentDidClose = TextDocumentRegistrationOptions
RegistrationOptions TextDocumentCompletion = CompletionRegistrationOptions
RegistrationOptions TextDocumentHover = HoverRegistrationOptions
RegistrationOptions TextDocumentSignatureHelp = SignatureHelpRegistrationOptions
RegistrationOptions TextDocumentDeclaration = DeclarationRegistrationOptions
RegistrationOptions TextDocumentDefinition = DefinitionRegistrationOptions
RegistrationOptions TextDocumentTypeDefinition = TypeDefinitionRegistrationOptions
RegistrationOptions TextDocumentImplementation = ImplementationRegistrationOptions
RegistrationOptions TextDocumentReferences = ReferenceRegistrationOptions
RegistrationOptions TextDocumentDocumentHighlight = DocumentHighlightRegistrationOptions
RegistrationOptions TextDocumentDocumentSymbol = DocumentSymbolRegistrationOptions
RegistrationOptions TextDocumentCodeAction = CodeActionRegistrationOptions
RegistrationOptions TextDocumentCodeLens = CodeLensRegistrationOptions
RegistrationOptions TextDocumentDocumentLink = DocumentLinkRegistrationOptions
RegistrationOptions TextDocumentDocumentColor = DocumentColorRegistrationOptions
RegistrationOptions TextDocumentFormatting = DocumentFormattingRegistrationOptions
RegistrationOptions TextDocumentRangeFormatting = DocumentRangeFormattingRegistrationOptions
RegistrationOptions TextDocumentOnTypeFormatting = DocumentOnTypeFormattingRegistrationOptions
RegistrationOptions TextDocumentRename = RenameRegistrationOptions
RegistrationOptions TextDocumentFoldingRange = FoldingRangeRegistrationOptions
RegistrationOptions TextDocumentSelectionRange = SelectionRangeRegistrationOptions
RegistrationOptions m = Void
data Registration (m :: Method FromClient t) =
Registration
{
_id :: Text
, _method :: SClientMethod m
, _registerOptions :: !(RegistrationOptions m)
}
deriving Generic
deriving instance Eq (RegistrationOptions m) => Eq (Registration m)
deriving instance Show (RegistrationOptions m) => Show (Registration m)
makeRegHelper ''RegistrationOptions
instance ToJSON (Registration m) where
toJSON x@(Registration _ m _) = regHelper m (genericToJSON lspOptions x)
data SomeRegistration = forall t (m :: Method FromClient t). SomeRegistration (Registration m)
instance ToJSON SomeRegistration where
toJSON (SomeRegistration r) = toJSON r
instance FromJSON SomeRegistration where
parseJSON = withObject "Registration" $ \o -> do
SomeClientMethod m <- o .: "method"
r <- Registration <$> o .: "id" <*> pure m <*> regHelper m (o .: "registerOptions")
pure (SomeRegistration r)
instance Eq SomeRegistration where
(==) = (==) `on` toJSON
instance Show SomeRegistration where
show (SomeRegistration r@(Registration _ m _)) = regHelper m (show r)
data RegistrationParams =
RegistrationParams { _registrations :: List SomeRegistration }
deriving (Show, Eq)
deriveJSON lspOptions ''RegistrationParams
data Unregistration =
Unregistration
{
_id :: Text
, _method :: SomeClientMethod
} deriving (Show, Eq)
deriveJSON lspOptions ''Unregistration
data UnregistrationParams =
UnregistrationParams
{
_unregisterations :: List Unregistration
} deriving (Show, Eq)
deriveJSON lspOptions ''UnregistrationParams