, waitForDiagnosticsSource
, noDiagnostics
, getCurrentDiagnostics
+ , getIncompleteProgressSessions
-- ** Commands
, executeCommand
-- ** Code Actions
import Control.Exception
import Control.Lens hiding ((.=), List, Empty)
import qualified Data.Map.Strict as Map
+import qualified Data.Set as Set
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Data.Aeson
where
checkDocumentChanges req =
let changes = req ^. params . edit . documentChanges
- maybeDocs = fmap (fmap (^. textDocument . uri)) changes
+ maybeDocs = fmap (fmap documentChangeUri) changes
in case maybeDocs of
Just docs -> (doc ^. uri) `elem` docs
Nothing -> False
-- The initialize requests and responses are not included the session,
-- so if you need to test it use this.
initializeResponse :: Session (ResponseMessage Initialize)
-initializeResponse = initRsp <$> ask >>= (liftIO . readMVar)
+initializeResponse = ask >>= (liftIO . readMVar) . initRsp
-- | /Creates/ a new text document. This is different from 'openDoc'
-- as it sends a workspace/didChangeWatchedFiles notification letting the server
--
-- @since 11.0.0.0
createDoc :: FilePath -- ^ The path to the document to open, __relative to the root directory__.
- -> String -- ^ The text document's language identifier, e.g. @"haskell"@.
+ -> T.Text -- ^ The text document's language identifier, e.g. @"haskell"@.
-> T.Text -- ^ The content of the text document to create.
-> Session TextDocumentIdentifier -- ^ The identifier of the document just created.
createDoc file languageId contents = do
watchHits :: FileSystemWatcher -> Bool
watchHits (FileSystemWatcher pattern kind) =
-- If WatchKind is exlcuded, defaults to all true as per spec
- fileMatches pattern && createHits (fromMaybe (WatchKind True True True) kind)
+ fileMatches (T.unpack pattern) && createHits (fromMaybe (WatchKind True True True) kind)
fileMatches pattern = Glob.match (Glob.compile pattern) relOrAbs
-- If the pattern is absolute then match against the absolute fp
-- | Opens a text document that /exists on disk/, and sends a
-- textDocument/didOpen notification to the server.
-openDoc :: FilePath -> String -> Session TextDocumentIdentifier
+openDoc :: FilePath -> T.Text -> Session TextDocumentIdentifier
openDoc file languageId = do
context <- ask
let fp = rootDir context </> file
-- | This is a variant of `openDoc` that takes the file content as an argument.
-- Use this is the file exists /outside/ of the current workspace.
-openDoc' :: FilePath -> String -> T.Text -> Session TextDocumentIdentifier
+openDoc' :: FilePath -> T.Text -> T.Text -> Session TextDocumentIdentifier
openDoc' file languageId contents = do
context <- ask
let fp = rootDir context </> file
uri = filePathToUri fp
- item = TextDocumentItem uri (T.pack languageId) 0 contents
+ item = TextDocumentItem uri languageId 0 contents
sendNotification STextDocumentDidOpen (DidOpenTextDocumentParams item)
pure $ TextDocumentIdentifier uri
getCurrentDiagnostics :: TextDocumentIdentifier -> Session [Diagnostic]
getCurrentDiagnostics doc = fromMaybe [] . Map.lookup (toNormalizedUri $ doc ^. uri) . curDiagnostics <$> get
+-- | Returns the tokens of all progress sessions that have started but not yet ended.
+getIncompleteProgressSessions :: Session (Set.Set ProgressToken)
+getIncompleteProgressSessions = curProgressSessions <$> get
+
-- | Executes a command.
executeCommand :: Command -> Session ()
executeCommand cmd = do
let wEdit = if supportsDocChanges
then
let docEdit = TextDocumentEdit verDoc (List [edit])
- in WorkspaceEdit Nothing (Just (List [docEdit]))
+ in WorkspaceEdit Nothing (Just (List [InL docEdit]))
else
let changes = HashMap.singleton (doc ^. uri) (List [edit])
in WorkspaceEdit (Just changes) Nothing
--
-- @since 0.11.0.0
getRegisteredCapabilities :: Session [SomeRegistration]
-getRegisteredCapabilities = (Map.elems . curDynCaps) <$> get
+getRegisteredCapabilities = Map.elems . curDynCaps <$> get