{-# LANGUAGE TemplateHaskell       #-}
{-# LANGUAGE DuplicateRecordFields #-}

module Language.LSP.Types.CodeLens where

import Data.Aeson
import Data.Aeson.TH
import Language.LSP.Types.Command
import Language.LSP.Types.Location
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils

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

data CodeLensClientCapabilities =
  CodeLensClientCapabilities
    { -- | Whether code lens supports dynamic registration.
      CodeLensClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    } deriving (Int -> CodeLensClientCapabilities -> ShowS
[CodeLensClientCapabilities] -> ShowS
CodeLensClientCapabilities -> String
(Int -> CodeLensClientCapabilities -> ShowS)
-> (CodeLensClientCapabilities -> String)
-> ([CodeLensClientCapabilities] -> ShowS)
-> Show CodeLensClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CodeLensClientCapabilities -> ShowS
showsPrec :: Int -> CodeLensClientCapabilities -> ShowS
$cshow :: CodeLensClientCapabilities -> String
show :: CodeLensClientCapabilities -> String
$cshowList :: [CodeLensClientCapabilities] -> ShowS
showList :: [CodeLensClientCapabilities] -> ShowS
Show, ReadPrec [CodeLensClientCapabilities]
ReadPrec CodeLensClientCapabilities
Int -> ReadS CodeLensClientCapabilities
ReadS [CodeLensClientCapabilities]
(Int -> ReadS CodeLensClientCapabilities)
-> ReadS [CodeLensClientCapabilities]
-> ReadPrec CodeLensClientCapabilities
-> ReadPrec [CodeLensClientCapabilities]
-> Read CodeLensClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS CodeLensClientCapabilities
readsPrec :: Int -> ReadS CodeLensClientCapabilities
$creadList :: ReadS [CodeLensClientCapabilities]
readList :: ReadS [CodeLensClientCapabilities]
$creadPrec :: ReadPrec CodeLensClientCapabilities
readPrec :: ReadPrec CodeLensClientCapabilities
$creadListPrec :: ReadPrec [CodeLensClientCapabilities]
readListPrec :: ReadPrec [CodeLensClientCapabilities]
Read, CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
(CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool)
-> (CodeLensClientCapabilities
    -> CodeLensClientCapabilities -> Bool)
-> Eq CodeLensClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
== :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
$c/= :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
/= :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
Eq)

deriveJSON lspOptions ''CodeLensClientCapabilities

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

makeExtendingDatatype "CodeLensOptions" [''WorkDoneProgressOptions]
  [ ("_resolveProvider", [t| Maybe Bool |] )]
deriveJSON lspOptions ''CodeLensOptions

makeExtendingDatatype "CodeLensRegistrationOptions" 
  [ ''TextDocumentRegistrationOptions
  , ''CodeLensOptions
  ] []
deriveJSON lspOptions ''CodeLensRegistrationOptions

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

makeExtendingDatatype "CodeLensParams"
  [ ''WorkDoneProgressParams,
    ''PartialResultParams
  ]
  [("_textDocument", [t|TextDocumentIdentifier|])]
deriveJSON lspOptions ''CodeLensParams

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

-- | A code lens represents a command that should be shown along with source
-- text, like the number of references, a way to run tests, etc.
-- 
-- A code lens is _unresolved_ when no command is associated to it. For
-- performance reasons the creation of a code lens and resolving should be done
-- in two stages.
data CodeLens =
  CodeLens
  { -- | The range in which this code lens is valid. Should only span a single line.
    CodeLens -> Range
_range   :: Range
  , -- | The command this code lens represents.
    CodeLens -> Maybe Command
_command :: Maybe Command
  , -- | A data entry field that is preserved on a code lens item between
    -- a code lens and a code lens resolve request.
    CodeLens -> Maybe Value
_xdata   :: Maybe Value
  } deriving (ReadPrec [CodeLens]
ReadPrec CodeLens
Int -> ReadS CodeLens
ReadS [CodeLens]
(Int -> ReadS CodeLens)
-> ReadS [CodeLens]
-> ReadPrec CodeLens
-> ReadPrec [CodeLens]
-> Read CodeLens
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS CodeLens
readsPrec :: Int -> ReadS CodeLens
$creadList :: ReadS [CodeLens]
readList :: ReadS [CodeLens]
$creadPrec :: ReadPrec CodeLens
readPrec :: ReadPrec CodeLens
$creadListPrec :: ReadPrec [CodeLens]
readListPrec :: ReadPrec [CodeLens]
Read,Int -> CodeLens -> ShowS
[CodeLens] -> ShowS
CodeLens -> String
(Int -> CodeLens -> ShowS)
-> (CodeLens -> String) -> ([CodeLens] -> ShowS) -> Show CodeLens
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CodeLens -> ShowS
showsPrec :: Int -> CodeLens -> ShowS
$cshow :: CodeLens -> String
show :: CodeLens -> String
$cshowList :: [CodeLens] -> ShowS
showList :: [CodeLens] -> ShowS
Show,CodeLens -> CodeLens -> Bool
(CodeLens -> CodeLens -> Bool)
-> (CodeLens -> CodeLens -> Bool) -> Eq CodeLens
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CodeLens -> CodeLens -> Bool
== :: CodeLens -> CodeLens -> Bool
$c/= :: CodeLens -> CodeLens -> Bool
/= :: CodeLens -> CodeLens -> Bool
Eq)

deriveJSON lspOptions ''CodeLens