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

module Language.LSP.Types.DocumentLink where

import Data.Aeson
import Data.Aeson.TH
import Language.LSP.Types.Location
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Uri
import Language.LSP.Types.Utils
import Data.Text (Text)

data DocumentLinkClientCapabilities =
  DocumentLinkClientCapabilities
  { -- | Whether document link supports dynamic registration.
    DocumentLinkClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
    -- | Whether the client supports the `tooltip` property on `DocumentLink`.
    --
    -- Since LSP 3.15.0
  , DocumentLinkClientCapabilities -> Maybe Bool
_tooltipSupport :: Maybe Bool
  } deriving (ReadPrec [DocumentLinkClientCapabilities]
ReadPrec DocumentLinkClientCapabilities
Int -> ReadS DocumentLinkClientCapabilities
ReadS [DocumentLinkClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentLinkClientCapabilities]
$creadListPrec :: ReadPrec [DocumentLinkClientCapabilities]
readPrec :: ReadPrec DocumentLinkClientCapabilities
$creadPrec :: ReadPrec DocumentLinkClientCapabilities
readList :: ReadS [DocumentLinkClientCapabilities]
$creadList :: ReadS [DocumentLinkClientCapabilities]
readsPrec :: Int -> ReadS DocumentLinkClientCapabilities
$creadsPrec :: Int -> ReadS DocumentLinkClientCapabilities
Read, Int -> DocumentLinkClientCapabilities -> ShowS
[DocumentLinkClientCapabilities] -> ShowS
DocumentLinkClientCapabilities -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentLinkClientCapabilities] -> ShowS
$cshowList :: [DocumentLinkClientCapabilities] -> ShowS
show :: DocumentLinkClientCapabilities -> String
$cshow :: DocumentLinkClientCapabilities -> String
showsPrec :: Int -> DocumentLinkClientCapabilities -> ShowS
$cshowsPrec :: Int -> DocumentLinkClientCapabilities -> ShowS
Show, DocumentLinkClientCapabilities
-> DocumentLinkClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentLinkClientCapabilities
-> DocumentLinkClientCapabilities -> Bool
$c/= :: DocumentLinkClientCapabilities
-> DocumentLinkClientCapabilities -> Bool
== :: DocumentLinkClientCapabilities
-> DocumentLinkClientCapabilities -> Bool
$c== :: DocumentLinkClientCapabilities
-> DocumentLinkClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''DocumentLinkClientCapabilities

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

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

makeExtendingDatatype "DocumentLinkRegistrationOptions"
  [ ''TextDocumentRegistrationOptions
  , ''DocumentLinkOptions
  ] []
deriveJSON lspOptions ''DocumentLinkRegistrationOptions

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

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

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

-- | A document link is a range in a text document that links to an internal or
-- external resource, like another text document or a web site.
data DocumentLink =
  DocumentLink
  { -- | The range this link applies to.
    DocumentLink -> Range
_range :: Range
    -- | The uri this link points to. If missing a resolve request is sent
    -- later.
  , DocumentLink -> Maybe Uri
_target :: Maybe Uri
    -- | The tooltip text when you hover over this link.
    --
    -- If a tooltip is provided, is will be displayed in a string that includes
    -- instructions on how to trigger the link, such as @{0} (ctrl + click)@.
    -- The specific instructions vary depending on OS, user settings, and
    -- localization.
    --
    -- Since LSP 3.15.0
  , DocumentLink -> Maybe Text
_tooltip :: Maybe Text
    -- | A data entry field that is preserved on a document link between a
    -- DocumentLinkRequest and a DocumentLinkResolveRequest.
  , DocumentLink -> Maybe Value
_xdata :: Maybe Value
  } deriving (ReadPrec [DocumentLink]
ReadPrec DocumentLink
Int -> ReadS DocumentLink
ReadS [DocumentLink]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DocumentLink]
$creadListPrec :: ReadPrec [DocumentLink]
readPrec :: ReadPrec DocumentLink
$creadPrec :: ReadPrec DocumentLink
readList :: ReadS [DocumentLink]
$creadList :: ReadS [DocumentLink]
readsPrec :: Int -> ReadS DocumentLink
$creadsPrec :: Int -> ReadS DocumentLink
Read, Int -> DocumentLink -> ShowS
[DocumentLink] -> ShowS
DocumentLink -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DocumentLink] -> ShowS
$cshowList :: [DocumentLink] -> ShowS
show :: DocumentLink -> String
$cshow :: DocumentLink -> String
showsPrec :: Int -> DocumentLink -> ShowS
$cshowsPrec :: Int -> DocumentLink -> ShowS
Show, DocumentLink -> DocumentLink -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DocumentLink -> DocumentLink -> Bool
$c/= :: DocumentLink -> DocumentLink -> Bool
== :: DocumentLink -> DocumentLink -> Bool
$c== :: DocumentLink -> DocumentLink -> Bool
Eq)
deriveJSON lspOptions ''DocumentLink