{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE DuplicateRecordFields #-}
module Language.LSP.Types.Hover where
import Data.Aeson.TH
import Data.Text ( Text )
import Language.LSP.Types.Common
import Language.LSP.Types.Location
import Language.LSP.Types.MarkupContent
import Language.LSP.Types.Progress
import Language.LSP.Types.TextDocument
import Language.LSP.Types.Utils
data HoverClientCapabilities =
HoverClientCapabilities
{ HoverClientCapabilities -> Maybe Bool
_dynamicRegistration :: Maybe Bool
, HoverClientCapabilities -> Maybe (List MarkupKind)
_contentFormat :: Maybe (List MarkupKind)
} deriving (Int -> HoverClientCapabilities -> ShowS
[HoverClientCapabilities] -> ShowS
HoverClientCapabilities -> String
(Int -> HoverClientCapabilities -> ShowS)
-> (HoverClientCapabilities -> String)
-> ([HoverClientCapabilities] -> ShowS)
-> Show HoverClientCapabilities
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HoverClientCapabilities -> ShowS
showsPrec :: Int -> HoverClientCapabilities -> ShowS
$cshow :: HoverClientCapabilities -> String
show :: HoverClientCapabilities -> String
$cshowList :: [HoverClientCapabilities] -> ShowS
showList :: [HoverClientCapabilities] -> ShowS
Show, ReadPrec [HoverClientCapabilities]
ReadPrec HoverClientCapabilities
Int -> ReadS HoverClientCapabilities
ReadS [HoverClientCapabilities]
(Int -> ReadS HoverClientCapabilities)
-> ReadS [HoverClientCapabilities]
-> ReadPrec HoverClientCapabilities
-> ReadPrec [HoverClientCapabilities]
-> Read HoverClientCapabilities
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS HoverClientCapabilities
readsPrec :: Int -> ReadS HoverClientCapabilities
$creadList :: ReadS [HoverClientCapabilities]
readList :: ReadS [HoverClientCapabilities]
$creadPrec :: ReadPrec HoverClientCapabilities
readPrec :: ReadPrec HoverClientCapabilities
$creadListPrec :: ReadPrec [HoverClientCapabilities]
readListPrec :: ReadPrec [HoverClientCapabilities]
Read, HoverClientCapabilities -> HoverClientCapabilities -> Bool
(HoverClientCapabilities -> HoverClientCapabilities -> Bool)
-> (HoverClientCapabilities -> HoverClientCapabilities -> Bool)
-> Eq HoverClientCapabilities
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
== :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
$c/= :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
/= :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
Eq)
deriveJSON lspOptions ''HoverClientCapabilities
makeExtendingDatatype "HoverOptions" [''WorkDoneProgressOptions] []
deriveJSON lspOptions ''HoverOptions
makeExtendingDatatype "HoverRegistrationOptions" [''TextDocumentRegistrationOptions, ''HoverOptions] []
deriveJSON lspOptions ''HoverRegistrationOptions
makeExtendingDatatype "HoverParams" [''TextDocumentPositionParams, ''WorkDoneProgressParams] []
deriveJSON lspOptions ''HoverParams
data LanguageString =
LanguageString
{ LanguageString -> Text
_language :: Text
, LanguageString -> Text
_value :: Text
} deriving (ReadPrec [LanguageString]
ReadPrec LanguageString
Int -> ReadS LanguageString
ReadS [LanguageString]
(Int -> ReadS LanguageString)
-> ReadS [LanguageString]
-> ReadPrec LanguageString
-> ReadPrec [LanguageString]
-> Read LanguageString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS LanguageString
readsPrec :: Int -> ReadS LanguageString
$creadList :: ReadS [LanguageString]
readList :: ReadS [LanguageString]
$creadPrec :: ReadPrec LanguageString
readPrec :: ReadPrec LanguageString
$creadListPrec :: ReadPrec [LanguageString]
readListPrec :: ReadPrec [LanguageString]
Read,Int -> LanguageString -> ShowS
[LanguageString] -> ShowS
LanguageString -> String
(Int -> LanguageString -> ShowS)
-> (LanguageString -> String)
-> ([LanguageString] -> ShowS)
-> Show LanguageString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LanguageString -> ShowS
showsPrec :: Int -> LanguageString -> ShowS
$cshow :: LanguageString -> String
show :: LanguageString -> String
$cshowList :: [LanguageString] -> ShowS
showList :: [LanguageString] -> ShowS
Show,LanguageString -> LanguageString -> Bool
(LanguageString -> LanguageString -> Bool)
-> (LanguageString -> LanguageString -> Bool) -> Eq LanguageString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LanguageString -> LanguageString -> Bool
== :: LanguageString -> LanguageString -> Bool
$c/= :: LanguageString -> LanguageString -> Bool
/= :: LanguageString -> LanguageString -> Bool
Eq)
deriveJSON lspOptions ''LanguageString
{-# DEPRECATED MarkedString, PlainString, CodeString "Use MarkupContent instead, since 3.3.0 (11/24/2017)" #-}
data MarkedString =
PlainString Text
| CodeString LanguageString
deriving (MarkedString -> MarkedString -> Bool
(MarkedString -> MarkedString -> Bool)
-> (MarkedString -> MarkedString -> Bool) -> Eq MarkedString
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MarkedString -> MarkedString -> Bool
== :: MarkedString -> MarkedString -> Bool
$c/= :: MarkedString -> MarkedString -> Bool
/= :: MarkedString -> MarkedString -> Bool
Eq,ReadPrec [MarkedString]
ReadPrec MarkedString
Int -> ReadS MarkedString
ReadS [MarkedString]
(Int -> ReadS MarkedString)
-> ReadS [MarkedString]
-> ReadPrec MarkedString
-> ReadPrec [MarkedString]
-> Read MarkedString
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS MarkedString
readsPrec :: Int -> ReadS MarkedString
$creadList :: ReadS [MarkedString]
readList :: ReadS [MarkedString]
$creadPrec :: ReadPrec MarkedString
readPrec :: ReadPrec MarkedString
$creadListPrec :: ReadPrec [MarkedString]
readListPrec :: ReadPrec [MarkedString]
Read,Int -> MarkedString -> ShowS
[MarkedString] -> ShowS
MarkedString -> String
(Int -> MarkedString -> ShowS)
-> (MarkedString -> String)
-> ([MarkedString] -> ShowS)
-> Show MarkedString
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MarkedString -> ShowS
showsPrec :: Int -> MarkedString -> ShowS
$cshow :: MarkedString -> String
show :: MarkedString -> String
$cshowList :: [MarkedString] -> ShowS
showList :: [MarkedString] -> ShowS
Show)
deriveJSON lspOptionsUntagged ''MarkedString
data HoverContents =
HoverContentsMS (List MarkedString)
| HoverContents MarkupContent
deriving (ReadPrec [HoverContents]
ReadPrec HoverContents
Int -> ReadS HoverContents
ReadS [HoverContents]
(Int -> ReadS HoverContents)
-> ReadS [HoverContents]
-> ReadPrec HoverContents
-> ReadPrec [HoverContents]
-> Read HoverContents
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS HoverContents
readsPrec :: Int -> ReadS HoverContents
$creadList :: ReadS [HoverContents]
readList :: ReadS [HoverContents]
$creadPrec :: ReadPrec HoverContents
readPrec :: ReadPrec HoverContents
$creadListPrec :: ReadPrec [HoverContents]
readListPrec :: ReadPrec [HoverContents]
Read,Int -> HoverContents -> ShowS
[HoverContents] -> ShowS
HoverContents -> String
(Int -> HoverContents -> ShowS)
-> (HoverContents -> String)
-> ([HoverContents] -> ShowS)
-> Show HoverContents
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HoverContents -> ShowS
showsPrec :: Int -> HoverContents -> ShowS
$cshow :: HoverContents -> String
show :: HoverContents -> String
$cshowList :: [HoverContents] -> ShowS
showList :: [HoverContents] -> ShowS
Show,HoverContents -> HoverContents -> Bool
(HoverContents -> HoverContents -> Bool)
-> (HoverContents -> HoverContents -> Bool) -> Eq HoverContents
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HoverContents -> HoverContents -> Bool
== :: HoverContents -> HoverContents -> Bool
$c/= :: HoverContents -> HoverContents -> Bool
/= :: HoverContents -> HoverContents -> Bool
Eq)
deriveJSON lspOptionsUntagged ''HoverContents
instance Semigroup HoverContents where
HoverContents MarkupContent
h1 <> :: HoverContents -> HoverContents -> HoverContents
<> HoverContents MarkupContent
h2 = MarkupContent -> HoverContents
HoverContents (MarkupContent
h1 MarkupContent -> MarkupContent -> MarkupContent
forall a. Monoid a => a -> a -> a
`mappend` MarkupContent
h2)
HoverContents MarkupContent
h1 <> HoverContentsMS (List [MarkedString]
h2s) = MarkupContent -> HoverContents
HoverContents ([MarkupContent] -> MarkupContent
forall a. Monoid a => [a] -> a
mconcat (MarkupContent
h1MarkupContent -> [MarkupContent] -> [MarkupContent]
forall a. a -> [a] -> [a]
: ((MarkedString -> MarkupContent)
-> [MarkedString] -> [MarkupContent]
forall a b. (a -> b) -> [a] -> [b]
map MarkedString -> MarkupContent
toMarkupContent [MarkedString]
h2s)))
HoverContentsMS (List [MarkedString]
h1s) <> HoverContents MarkupContent
h2 = MarkupContent -> HoverContents
HoverContents ([MarkupContent] -> MarkupContent
forall a. Monoid a => [a] -> a
mconcat (((MarkedString -> MarkupContent)
-> [MarkedString] -> [MarkupContent]
forall a b. (a -> b) -> [a] -> [b]
map MarkedString -> MarkupContent
toMarkupContent [MarkedString]
h1s) [MarkupContent] -> [MarkupContent] -> [MarkupContent]
forall a. [a] -> [a] -> [a]
++ [MarkupContent
h2]))
HoverContentsMS (List [MarkedString]
h1s) <> HoverContentsMS (List [MarkedString]
h2s) = List MarkedString -> HoverContents
HoverContentsMS ([MarkedString] -> List MarkedString
forall a. [a] -> List a
List ([MarkedString]
h1s [MarkedString] -> [MarkedString] -> [MarkedString]
forall a. Monoid a => a -> a -> a
`mappend` [MarkedString]
h2s))
instance Monoid HoverContents where
mempty :: HoverContents
mempty = List MarkedString -> HoverContents
HoverContentsMS ([MarkedString] -> List MarkedString
forall a. [a] -> List a
List [])
toMarkupContent :: MarkedString -> MarkupContent
toMarkupContent :: MarkedString -> MarkupContent
toMarkupContent (PlainString Text
s) = Text -> MarkupContent
unmarkedUpContent Text
s
toMarkupContent (CodeString (LanguageString Text
lang Text
s)) = Text -> Text -> MarkupContent
markedUpContent Text
lang Text
s
data Hover =
Hover
{ Hover -> HoverContents
_contents :: HoverContents
, Hover -> Maybe Range
_range :: Maybe Range
} deriving (ReadPrec [Hover]
ReadPrec Hover
Int -> ReadS Hover
ReadS [Hover]
(Int -> ReadS Hover)
-> ReadS [Hover]
-> ReadPrec Hover
-> ReadPrec [Hover]
-> Read Hover
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Hover
readsPrec :: Int -> ReadS Hover
$creadList :: ReadS [Hover]
readList :: ReadS [Hover]
$creadPrec :: ReadPrec Hover
readPrec :: ReadPrec Hover
$creadListPrec :: ReadPrec [Hover]
readListPrec :: ReadPrec [Hover]
Read,Int -> Hover -> ShowS
[Hover] -> ShowS
Hover -> String
(Int -> Hover -> ShowS)
-> (Hover -> String) -> ([Hover] -> ShowS) -> Show Hover
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Hover -> ShowS
showsPrec :: Int -> Hover -> ShowS
$cshow :: Hover -> String
show :: Hover -> String
$cshowList :: [Hover] -> ShowS
showList :: [Hover] -> ShowS
Show,Hover -> Hover -> Bool
(Hover -> Hover -> Bool) -> (Hover -> Hover -> Bool) -> Eq Hover
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Hover -> Hover -> Bool
== :: Hover -> Hover -> Bool
$c/= :: Hover -> Hover -> Bool
/= :: Hover -> Hover -> Bool
Eq)
deriveJSON lspOptions ''Hover