Skip to content

Commit dde77ce

Browse files
committed
Move getDiagnostics to STM
1 parent 60cdccd commit dde77ce

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

ghcide/src/Development/IDE/Core/Shake.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -757,13 +757,13 @@ instantiateDelayedAction (DelayedAction _ s p a) = do
757757
d' = DelayedAction (Just u) s p a'
758758
return (b, d')
759759

760-
getDiagnostics :: IdeState -> IO [FileDiagnostic]
760+
getDiagnostics :: IdeState -> STM [FileDiagnostic]
761761
getDiagnostics IdeState{shakeExtras = ShakeExtras{diagnostics}} = do
762-
atomically $ getAllDiagnostics diagnostics
762+
getAllDiagnostics diagnostics
763763

764-
getHiddenDiagnostics :: IdeState -> IO [FileDiagnostic]
764+
getHiddenDiagnostics :: IdeState -> STM [FileDiagnostic]
765765
getHiddenDiagnostics IdeState{shakeExtras = ShakeExtras{hiddenDiagnostics}} = do
766-
atomically $ getAllDiagnostics hiddenDiagnostics
766+
getAllDiagnostics hiddenDiagnostics
767767

768768
-- | Find and release old keys from the state Hashmap
769769
-- For the record, there are other state sources that this process does not release:

ghcide/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module Development.IDE.Plugin.CodeAction
2121
import Control.Applicative ((<|>))
2222
import Control.Arrow (second,
2323
(>>>))
24+
import Control.Concurrent.STM.Stats (atomically)
2425
import Control.Monad (guard, join)
2526
import Control.Monad.IO.Class
2627
import Data.Char
@@ -90,7 +91,7 @@ codeAction state _ (CodeActionParams _ _ (TextDocumentIdentifier uri) _range Cod
9091
liftIO $ do
9192
let text = Rope.toText . (_text :: VirtualFile -> Rope.Rope) <$> contents
9293
mbFile = toNormalizedFilePath' <$> uriToFilePath uri
93-
diag <- fmap (\(_, _, d) -> d) . filter (\(p, _, _) -> mbFile == Just p) <$> getDiagnostics state
94+
diag <- atomically $ fmap (\(_, _, d) -> d) . filter (\(p, _, _) -> mbFile == Just p) <$> getDiagnostics state
9495
(join -> parsedModule) <- runAction "GhcideCodeActions.getParsedModule" state $ getParsedModule `traverse` mbFile
9596
let
9697
actions = caRemoveRedundantImports parsedModule text diag xs uri

ghcide/src/Development/IDE/Plugin/TypeLenses.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module Development.IDE.Plugin.TypeLenses (
1212
GlobalBindingTypeSigsResult (..),
1313
) where
1414

15+
import Control.Concurrent.STM.Stats (atomically)
1516
import Control.DeepSeq (rwhnf)
1617
import Control.Monad (mzero)
1718
import Control.Monad.Extra (whenMaybe)
@@ -100,8 +101,8 @@ codeLensProvider ideState pId CodeLensParams{_textDocument = TextDocumentIdentif
100101
bindings <- runAction "codeLens.GetBindings" ideState (use GetBindings filePath)
101102
gblSigs <- runAction "codeLens.GetGlobalBindingTypeSigs" ideState (use GetGlobalBindingTypeSigs filePath)
102103

103-
diag <- getDiagnostics ideState
104-
hDiag <- getHiddenDiagnostics ideState
104+
diag <- atomically $ getDiagnostics ideState
105+
hDiag <- atomically $ getHiddenDiagnostics ideState
105106

106107
let toWorkSpaceEdit tedit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing Nothing
107108
generateLensForGlobal sig@GlobalBindingTypeSig{..} = do

0 commit comments

Comments
 (0)