Skip to content

Commit 8c85ffd

Browse files
committed
Use GetAnnotatedParsedSource in rename plugin
We already have a cached delta AST at hand
1 parent f637286 commit 8c85ffd

File tree

1 file changed

+5
-4
lines changed
  • plugins/hls-rename-plugin/src/Ide/Plugin

1 file changed

+5
-4
lines changed

plugins/hls-rename-plugin/src/Ide/Plugin/Rename.hs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import GHC.Types.Name
2525
#else
2626
import Name
2727
#endif
28+
import Development.IDE.GHC.ExactPrint (GetAnnotatedParsedSource (GetAnnotatedParsedSource))
2829
import HieDb.Query
2930
import Ide.Plugin.Config
3031
import Ide.PluginUtils
@@ -67,14 +68,14 @@ getSrcEdits ::
6768
getSrcEdits state updateMod uri = do
6869
ccs <- lift getClientCapabilities
6970
nfp <- safeUriToNfp uri
70-
~ParsedModule{pm_parsed_source = ps, pm_annotations = apiAnns} <-
71+
annotatedAst <-
7172
handleMaybeM "Error: could not get parsed source" $ liftIO $ runAction
7273
"Rename.GetParsedModuleWithComments"
7374
state
74-
(use GetParsedModuleWithComments nfp)
75+
(use GetAnnotatedParsedSource nfp)
76+
let (ps, apiAnns) = (astA annotatedAst, annsA annotatedAst)
7577
#if !MIN_VERSION_ghc(9,2,1)
76-
let anns = relativiseApiAnns ps apiAnns
77-
src = T.pack $ exactPrint ps anns
78+
let src = T.pack $ exactPrint ps anns
7879
res = T.pack $ exactPrint (updateMod <$> ps) anns
7980
#else
8081
let src = T.pack $ exactPrint ps

0 commit comments

Comments
 (0)