, getDocumentSymbols
-- ** Diagnostics
, waitForDiagnostics
+ , waitForDiagnosticsSource
, noDiagnostics
-- ** Commands
, executeCommand
, executeCodeAction
-- ** Completions
, getCompletions
+ -- ** References
+ , getReferences
-- ** Edits
, applyEdit
) where
documentContents :: TextDocumentIdentifier -> Session T.Text
documentContents doc = do
vfs <- vfs <$> get
- liftIO $ print vfs
- liftIO $ print doc
let file = vfs Map.! (doc ^. uri)
return $ Rope.toText $ Language.Haskell.LSP.VFS._text file
let (List diags) = diagsNot ^. params . LSP.diagnostics
return diags
+waitForDiagnosticsSource :: String -> Session [Diagnostic]
+waitForDiagnosticsSource src = do
+ diags <- waitForDiagnostics
+ let res = filter matches diags
+ if null res
+ then waitForDiagnosticsSource src
+ else return res
+ where
+ matches :: Diagnostic -> Bool
+ matches d = d ^. source == Just (T.pack src)
+
-- | Expects a 'PublishDiagnosticsNotification' and throws an
-- 'UnexpectedDiagnosticsException' if there are any diagnostics
-- returned.
case res of
Completions (List items) -> return items
CompletionList (CompletionListType _ (List items)) -> return items
+
+getReferences :: TextDocumentIdentifier -> Position -> Bool -> Session [Location]
+getReferences doc pos inclDecl =
+ let ctx = ReferenceContext inclDecl
+ params = ReferenceParams doc pos ctx
+ in fromMaybe [] . (^. result) <$> sendRequest TextDocumentReferences params