@@ -87,9 +87,7 @@ addMethodPlaceholders _ _ AddMethodsParams{..} = pure (Right Null, Just (Workspa
87
87
codeAction :: CodeActionProvider
88
88
codeAction _ state plId docId _ ctx = do
89
89
let Just docPath = docId ^. J. uri & uriToFilePath <&> toNormalizedFilePath
90
- Just (hieAst -> hf, _) <- runAction " classplugin" state $ useWithStale GetHieAst docPath
91
- Just (tmrTypechecked -> thisMod, _) <- runAction " classplugin" state $ useWithStale TypeCheck docPath
92
- actions <- join <$> mapM (mkActions docPath hf thisMod) methodDiags
90
+ actions <- join <$> mapM (mkActions docPath) methodDiags
93
91
pure . Right . List $ actions
94
92
where
95
93
ghcDiags = filter (\ d -> d ^. J. source == Just " typecheck" ) . unList $ ctx ^. J. diagnostics
@@ -108,23 +106,26 @@ codeAction _ state plId docId _ ctx = do
108
106
= CACodeAction
109
107
$ CodeAction title (Just CodeActionQuickFix ) (Just (List [] )) Nothing (Just cmd)
110
108
111
- mkActions docPath hf thisMod d = do
109
+ mkActions docPath d = do
110
+ Just (hieAst -> hf, _) <- runAction " classplugin" state $ useWithStale GetHieAst docPath
111
+ let
112
+ [([[Right name]], range)]
113
+ = pointCommand hf (d ^. J. range . J. start & J. character -~ 1 )
114
+ $ \ n ->
115
+ ( Map. keys . Map. filter (isNothing . identType) . nodeIdentifiers . nodeInfo <$> nodeChildren n
116
+ , realSrcSpanToRange (nodeSpan n)
117
+ )
112
118
Just (hscEnv -> hscenv, _) <- runAction " classplugin" state $ useWithStale GhcSessionDeps docPath
119
+ Just (tmrTypechecked -> thisMod, _) <- runAction " classplugin" state $ useWithStale TypeCheck docPath
113
120
(_, Just cls) <- initTcWithGbl hscenv thisMod ghostSpan $ do
114
121
tcthing <- tcLookup name
115
122
case tcthing of
116
123
AGlobal (AConLike (RealDataCon con))
117
124
| Just cls <- tyConClass_maybe (dataConOrigTyCon con) -> pure cls
118
125
_ -> panic " Ide.Plugin.Class.mkActions"
119
- let minDef = classMinimalDef cls
126
+ let
127
+ minDef = classMinimalDef cls
120
128
traverse (mkAction range) (minDefToMethodGroups minDef)
121
- where
122
- [([[Right name]], range)] =
123
- pointCommand hf (d ^. J. range . J. start & J. character -~ 1 )
124
- $ \ n ->
125
- ( Map. keys . Map. filter (isNothing . identType) . nodeIdentifiers . nodeInfo <$> nodeChildren n
126
- , realSrcSpanToRange (nodeSpan n)
127
- )
128
129
129
130
unList :: List a -> [a ]
130
131
unList (List xs) = xs
0 commit comments