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