Skip to content

Commit e429304

Browse files
committed
wip
1 parent 1ca33e3 commit e429304

File tree

1 file changed

+7
-3
lines changed
  • plugins/hls-rename-plugin/src/Ide/Plugin

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import Ide.Types
5252
import qualified Language.LSP.Protocol.Lens as L
5353
import Language.LSP.Protocol.Message
5454
import Language.LSP.Protocol.Types
55+
import Data.List
5556

5657
instance Hashable (Mod a) where hash n = hash (unMod n)
5758

@@ -197,19 +198,22 @@ refsAtName state nfp name = do
197198
ast <- handleGetHieAst state nfp
198199
dbRefs <- case nameModule_maybe name of
199200
Nothing -> pure []
200-
Just mod -> liftIO $ mapMaybe rowToLoc <$> withHieDb (\hieDb ->
201+
Just mod -> liftIO $ mapMaybe rowToLoc <$> withHieDb (\hieDb -> do
201202
-- GHC inserts `Use`s of record constructor everywhere where its record selectors are used,
202203
-- which leads to fields being renamed whenever corresponding constructor is renamed.
203204
-- see https://github.com/haskell/haskell-language-server/issues/2915
204205
-- To work around this, we filter out compiler-generated references.
205-
filter (\(refRow HieDb.:. _) -> not $ refIsGenerated refRow) <$>
206-
findReferences
206+
207+
xs <- findReferences
207208
hieDb
208209
True
209210
(nameOccName name)
210211
(Just $ moduleName mod)
211212
(Just $ moduleUnit mod)
212213
[fromNormalizedFilePath nfp]
214+
let (gen,notGen) = partition (\(refRow HieDb.:. _) -> refIsGenerated refRow) xs
215+
putStrLn $ "Found " ++ show (length xs) ++ " references in HieDb: " ++ show (length xs) ++ ", of which " ++ show (length gen) ++ " are generated"
216+
pure notGen
213217
)
214218
pure $ nameLocs name ast ++ dbRefs
215219

0 commit comments

Comments
 (0)