{-# 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
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeLensClientCapabilities] -> ShowS
$cshowList :: [CodeLensClientCapabilities] -> ShowS
show :: CodeLensClientCapabilities -> String
$cshow :: CodeLensClientCapabilities -> String
showsPrec :: Int -> CodeLensClientCapabilities -> ShowS
$cshowsPrec :: Int -> CodeLensClientCapabilities -> ShowS
Show, ReadPrec [CodeLensClientCapabilities]
ReadPrec CodeLensClientCapabilities
Int -> ReadS CodeLensClientCapabilities
ReadS [CodeLensClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeLensClientCapabilities]
$creadListPrec :: ReadPrec [CodeLensClientCapabilities]
readPrec :: ReadPrec CodeLensClientCapabilities
$creadPrec :: ReadPrec CodeLensClientCapabilities
readList :: ReadS [CodeLensClientCapabilities]
$creadList :: ReadS [CodeLensClientCapabilities]
readsPrec :: Int -> ReadS CodeLensClientCapabilities
$creadsPrec :: Int -> ReadS CodeLensClientCapabilities
Read, CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
$c/= :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
== :: CodeLensClientCapabilities -> CodeLensClientCapabilities -> Bool
$c== :: 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]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CodeLens]
$creadListPrec :: ReadPrec [CodeLens]
readPrec :: ReadPrec CodeLens
$creadPrec :: ReadPrec CodeLens
readList :: ReadS [CodeLens]
$creadList :: ReadS [CodeLens]
readsPrec :: Int -> ReadS CodeLens
$creadsPrec :: Int -> ReadS CodeLens
Read,Int -> CodeLens -> ShowS
[CodeLens] -> ShowS
CodeLens -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CodeLens] -> ShowS
$cshowList :: [CodeLens] -> ShowS
show :: CodeLens -> String
$cshow :: CodeLens -> String
showsPrec :: Int -> CodeLens -> ShowS
$cshowsPrec :: Int -> CodeLens -> ShowS
Show,CodeLens -> CodeLens -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CodeLens -> CodeLens -> Bool
$c/= :: CodeLens -> CodeLens -> Bool
== :: CodeLens -> CodeLens -> Bool
$c== :: CodeLens -> CodeLens -> Bool
Eq)

deriveJSON lspOptions ''CodeLens