@@ -21,7 +21,7 @@ import Data.Maybe
21
21
import Data.Ord
22
22
import Data.Set (Set )
23
23
import qualified Data.Set as S
24
- import Development.IDE.GHC.Compat (GhcTc , RefMap , identType , noExt )
24
+ import Development.IDE.GHC.Compat (GhcTc , RefMap , identType , identInfo , noExt , getScopeFromContext , Scope ( .. ) )
25
25
import HsExpr
26
26
import Id
27
27
import OccName
@@ -41,11 +41,21 @@ realSrcSpanToInterval rss =
41
41
-- 'getLocalScope' to find the results.
42
42
bindings :: RefMap -> Bindings
43
43
bindings refmap = Bindings $ foldr (uncurry IM. insert) mempty $ do
44
- (ident, refs) <- M. toList refmap
45
- Right name <- pure ident
44
+ (ident, refs) <- M. toList refmap
45
+ Right name <- pure ident
46
46
(ref_span, ident_details) <- refs
47
- Just ty <- pure $ identType ident_details
48
- pure ( realSrcSpanToInterval ref_span
47
+ Just ty <- pure $ identType ident_details
48
+ info <- S. toList $ identInfo ident_details
49
+ Just scopes <- pure $ getScopeFromContext info
50
+ scope <- scopes >>= \ case
51
+ ModuleScope -> pure $
52
+ let file = srcSpanFile ref_span
53
+ in Interval
54
+ (mkRealSrcLoc file minBound minBound )
55
+ (mkRealSrcLoc file maxBound maxBound )
56
+ LocalScope scope -> pure $ realSrcSpanToInterval scope
57
+ NoScope -> []
58
+ pure ( scope
49
59
, S. singleton $ mkVanillaGlobal name ty
50
60
)
51
61
0 commit comments