@@ -54,27 +54,25 @@ runGhcideCodeAction :: LSP.MonadLsp Config m => IdeState -> MessageParams TextDo
54
54
runGhcideCodeAction state (CodeActionParams _ _ (TextDocumentIdentifier uri) _range CodeActionContext {_diagnostics = List diags}) codeAction = do
55
55
let mbFile = toNormalizedFilePath' <$> uriToFilePath uri
56
56
runRule key = runAction (" GhcideCodeActions." <> show key) state $ runMaybeT $ MaybeT (pure mbFile) >>= MaybeT . use key
57
- caaExportsMap <-
58
- onceIO $
59
- runRule GhcSession >>= \ case
60
- Just env -> do
61
- pkgExports <- envPackageExports env
62
- localExports <- readVar (exportsMap $ shakeExtras state)
63
- pure $ localExports <> pkgExports
64
- _ -> pure mempty
65
- caaIdeOptions <- onceIO $ runAction " GhcideCodeActions.getIdeOptions" state getIdeOptions
66
- caaParsedModule <- onceIO $ runRule GetParsedModule
67
- caaContents <-
68
- onceIO $
69
- runRule GetFileContents >>= \ case
70
- Just (_, txt) -> pure txt
71
- _ -> pure Nothing
72
- caaDf <- onceIO $ fmap (ms_hspp_opts . pm_mod_summary) <$> caaParsedModule
73
- caaAnnSource <- onceIO $ runRule GetAnnotatedParsedSource
74
- caaTmr <- onceIO $ runRule TypeCheck
75
- caaHar <- onceIO $ runRule GetHieAst
76
- caaBindings <- onceIO $ runRule GetBindings
77
- caaGblSigs <- onceIO $ runRule GetGlobalBindingTypeSigs
57
+ caaExportsMap =
58
+ runRule GhcSession >>= \ case
59
+ Just env -> do
60
+ pkgExports <- envPackageExports env
61
+ localExports <- readVar (exportsMap $ shakeExtras state)
62
+ pure $ localExports <> pkgExports
63
+ _ -> pure mempty
64
+ caaIdeOptions = runAction " GhcideCodeActions.getIdeOptions" state getIdeOptions
65
+ caaParsedModule = runRule GetParsedModule
66
+ caaContents =
67
+ runRule GetFileContents >>= \ case
68
+ Just (_, txt) -> pure txt
69
+ _ -> pure Nothing
70
+ caaDf = fmap (ms_hspp_opts . pm_mod_summary) <$> caaParsedModule
71
+ caaAnnSource = runRule GetAnnotatedParsedSource
72
+ caaTmr = runRule TypeCheck
73
+ caaHar = runRule GetHieAst
74
+ caaBindings = runRule GetBindings
75
+ caaGblSigs = runRule GetGlobalBindingTypeSigs
78
76
liftIO $
79
77
concat
80
78
<$> sequence
@@ -146,15 +144,6 @@ data CodeActionArgs = CodeActionArgs
146
144
caaDiagnostic :: Diagnostic
147
145
}
148
146
149
- -- | There's no concurrency in each provider,
150
- -- so we don't need to be thread-safe here
151
- onceIO :: MonadIO m => IO a -> m (IO a )
152
- onceIO io = do
153
- var <- liftIO $ newIORef Nothing
154
- pure $
155
- readIORef var >>= \ case
156
- Just x -> pure x
157
- _ -> io >>= \ x -> writeIORef' var (Just x) >> pure x
158
147
159
148
-------------------------------------------------------------------------------------------------
160
149
0 commit comments