@@ -124,6 +124,11 @@ module Language.LSP.Test (
124
124
getAndResolveCodeLenses ,
125
125
resolveCodeLens ,
126
126
127
+ -- ** Inlay Hints
128
+ getInlayHints ,
129
+ getAndResolveInlayHints ,
130
+ resolveInlayHint ,
131
+
127
132
-- ** Call hierarchy
128
133
prepareCallHierarchy ,
129
134
incomingCalls ,
@@ -981,6 +986,28 @@ resolveCodeLens cl = do
981
986
Right cl -> return cl
982
987
Left error -> throw (UnexpectedResponseError (SomeLspId $ fromJust $ rsp ^. L. id ) error )
983
988
989
+ -- | Returns the inlay hints in the specified range.
990
+ getInlayHints :: TextDocumentIdentifier -> Range -> Session [InlayHint ]
991
+ getInlayHints tId range = do
992
+ rsp <- request SMethod_TextDocumentInlayHint (InlayHintParams Nothing tId range)
993
+ pure $ absorbNull $ getResponseResult rsp
994
+
995
+ {- | Returns the inlay hints in the specified range, resolving any with
996
+ a non empty _data_ field.
997
+ -}
998
+ getAndResolveInlayHints :: TextDocumentIdentifier -> Range -> Session [InlayHint ]
999
+ getAndResolveInlayHints tId range = do
1000
+ inlayHints <- getInlayHints tId range
1001
+ for inlayHints $ \ inlayHint -> if isJust (inlayHint ^. L. data_) then resolveInlayHint inlayHint else pure inlayHint
1002
+
1003
+ -- | Resolves the provided inlay hint.
1004
+ resolveInlayHint :: InlayHint -> Session InlayHint
1005
+ resolveInlayHint ih = do
1006
+ rsp <- request SMethod_InlayHintResolve ih
1007
+ case rsp ^. L. result of
1008
+ Right ih -> return ih
1009
+ Left error -> throw (UnexpectedResponseError (SomeLspId $ fromJust $ rsp ^. L. id ) error )
1010
+
984
1011
-- | Pass a param and return the response from `prepareCallHierarchy`
985
1012
prepareCallHierarchy :: CallHierarchyPrepareParams -> Session [CallHierarchyItem ]
986
1013
prepareCallHierarchy = resolveRequestWithListResp SMethod_TextDocumentPrepareCallHierarchy
0 commit comments