@@ -87,9 +87,7 @@ addMethodPlaceholders _ _ AddMethodsParams{..} = pure (Right Null, Just (Workspa
8787codeAction :: CodeActionProvider
8888codeAction _ state plId docId _ ctx = do
8989 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
9391 pure . Right . List $ actions
9492 where
9593 ghcDiags = filter (\ d -> d ^. J. source == Just " typecheck" ) . unList $ ctx ^. J. diagnostics
@@ -108,23 +106,26 @@ codeAction _ state plId docId _ ctx = do
108106 = CACodeAction
109107 $ CodeAction title (Just CodeActionQuickFix ) (Just (List [] )) Nothing (Just cmd)
110108
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+ )
112118 Just (hscEnv -> hscenv, _) <- runAction " classplugin" state $ useWithStale GhcSessionDeps docPath
119+ Just (tmrTypechecked -> thisMod, _) <- runAction " classplugin" state $ useWithStale TypeCheck docPath
113120 (_, Just cls) <- initTcWithGbl hscenv thisMod ghostSpan $ do
114121 tcthing <- tcLookup name
115122 case tcthing of
116123 AGlobal (AConLike (RealDataCon con))
117124 | Just cls <- tyConClass_maybe (dataConOrigTyCon con) -> pure cls
118125 _ -> panic " Ide.Plugin.Class.mkActions"
119- let minDef = classMinimalDef cls
126+ let
127+ minDef = classMinimalDef cls
120128 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- )
128129
129130unList :: List a -> [a ]
130131unList (List xs) = xs
0 commit comments