{-# 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
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HoverClientCapabilities] -> ShowS
$cshowList :: [HoverClientCapabilities] -> ShowS
show :: HoverClientCapabilities -> String
$cshow :: HoverClientCapabilities -> String
showsPrec :: Int -> HoverClientCapabilities -> ShowS
$cshowsPrec :: Int -> HoverClientCapabilities -> ShowS
Show, ReadPrec [HoverClientCapabilities]
ReadPrec HoverClientCapabilities
Int -> ReadS HoverClientCapabilities
ReadS [HoverClientCapabilities]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HoverClientCapabilities]
$creadListPrec :: ReadPrec [HoverClientCapabilities]
readPrec :: ReadPrec HoverClientCapabilities
$creadPrec :: ReadPrec HoverClientCapabilities
readList :: ReadS [HoverClientCapabilities]
$creadList :: ReadS [HoverClientCapabilities]
readsPrec :: Int -> ReadS HoverClientCapabilities
$creadsPrec :: Int -> ReadS HoverClientCapabilities
Read, HoverClientCapabilities -> HoverClientCapabilities -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
$c/= :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
== :: HoverClientCapabilities -> HoverClientCapabilities -> Bool
$c== :: 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]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [LanguageString]
$creadListPrec :: ReadPrec [LanguageString]
readPrec :: ReadPrec LanguageString
$creadPrec :: ReadPrec LanguageString
readList :: ReadS [LanguageString]
$creadList :: ReadS [LanguageString]
readsPrec :: Int -> ReadS LanguageString
$creadsPrec :: Int -> ReadS LanguageString
Read,Int -> LanguageString -> ShowS
[LanguageString] -> ShowS
LanguageString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LanguageString] -> ShowS
$cshowList :: [LanguageString] -> ShowS
show :: LanguageString -> String
$cshow :: LanguageString -> String
showsPrec :: Int -> LanguageString -> ShowS
$cshowsPrec :: Int -> LanguageString -> ShowS
Show,LanguageString -> LanguageString -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LanguageString -> LanguageString -> Bool
$c/= :: LanguageString -> LanguageString -> Bool
== :: LanguageString -> LanguageString -> Bool
$c== :: 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
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MarkedString -> MarkedString -> Bool
$c/= :: MarkedString -> MarkedString -> Bool
== :: MarkedString -> MarkedString -> Bool
$c== :: MarkedString -> MarkedString -> Bool
Eq,ReadPrec [MarkedString]
ReadPrec MarkedString
Int -> ReadS MarkedString
ReadS [MarkedString]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MarkedString]
$creadListPrec :: ReadPrec [MarkedString]
readPrec :: ReadPrec MarkedString
$creadPrec :: ReadPrec MarkedString
readList :: ReadS [MarkedString]
$creadList :: ReadS [MarkedString]
readsPrec :: Int -> ReadS MarkedString
$creadsPrec :: Int -> ReadS MarkedString
Read,Int -> MarkedString -> ShowS
[MarkedString] -> ShowS
MarkedString -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MarkedString] -> ShowS
$cshowList :: [MarkedString] -> ShowS
show :: MarkedString -> String
$cshow :: MarkedString -> String
showsPrec :: Int -> MarkedString -> ShowS
$cshowsPrec :: Int -> MarkedString -> ShowS
Show)
deriveJSON lspOptionsUntagged ''MarkedString
data HoverContents =
HoverContentsMS (List MarkedString)
| HoverContents MarkupContent
deriving (ReadPrec [HoverContents]
ReadPrec HoverContents
Int -> ReadS HoverContents
ReadS [HoverContents]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HoverContents]
$creadListPrec :: ReadPrec [HoverContents]
readPrec :: ReadPrec HoverContents
$creadPrec :: ReadPrec HoverContents
readList :: ReadS [HoverContents]
$creadList :: ReadS [HoverContents]
readsPrec :: Int -> ReadS HoverContents
$creadsPrec :: Int -> ReadS HoverContents
Read,Int -> HoverContents -> ShowS
[HoverContents] -> ShowS
HoverContents -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HoverContents] -> ShowS
$cshowList :: [HoverContents] -> ShowS
show :: HoverContents -> String
$cshow :: HoverContents -> String
showsPrec :: Int -> HoverContents -> ShowS
$cshowsPrec :: Int -> HoverContents -> ShowS
Show,HoverContents -> HoverContents -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HoverContents -> HoverContents -> Bool
$c/= :: HoverContents -> HoverContents -> Bool
== :: HoverContents -> HoverContents -> Bool
$c== :: 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 forall a. Monoid a => a -> a -> a
`mappend` MarkupContent
h2)
HoverContents MarkupContent
h1 <> HoverContentsMS (List [MarkedString]
h2s) = MarkupContent -> HoverContents
HoverContents (forall a. Monoid a => [a] -> a
mconcat (MarkupContent
h1forall a. a -> [a] -> [a]
: (forall a b. (a -> b) -> [a] -> [b]
map MarkedString -> MarkupContent
toMarkupContent [MarkedString]
h2s)))
HoverContentsMS (List [MarkedString]
h1s) <> HoverContents MarkupContent
h2 = MarkupContent -> HoverContents
HoverContents (forall a. Monoid a => [a] -> a
mconcat ((forall a b. (a -> b) -> [a] -> [b]
map MarkedString -> MarkupContent
toMarkupContent [MarkedString]
h1s) forall a. [a] -> [a] -> [a]
++ [MarkupContent
h2]))
HoverContentsMS (List [MarkedString]
h1s) <> HoverContentsMS (List [MarkedString]
h2s) = List MarkedString -> HoverContents
HoverContentsMS (forall a. [a] -> List a
List ([MarkedString]
h1s forall a. Monoid a => a -> a -> a
`mappend` [MarkedString]
h2s))
instance Monoid HoverContents where
mempty :: HoverContents
mempty = List MarkedString -> HoverContents
HoverContentsMS (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]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Hover]
$creadListPrec :: ReadPrec [Hover]
readPrec :: ReadPrec Hover
$creadPrec :: ReadPrec Hover
readList :: ReadS [Hover]
$creadList :: ReadS [Hover]
readsPrec :: Int -> ReadS Hover
$creadsPrec :: Int -> ReadS Hover
Read,Int -> Hover -> ShowS
[Hover] -> ShowS
Hover -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Hover] -> ShowS
$cshowList :: [Hover] -> ShowS
show :: Hover -> String
$cshow :: Hover -> String
showsPrec :: Int -> Hover -> ShowS
$cshowsPrec :: Int -> Hover -> ShowS
Show,Hover -> Hover -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Hover -> Hover -> Bool
$c/= :: Hover -> Hover -> Bool
== :: Hover -> Hover -> Bool
$c== :: Hover -> Hover -> Bool
Eq)
deriveJSON lspOptions ''Hover