Skip to content

Commit f9f1adc

Browse files
committed
Fix 'binding'
1 parent e5329a9 commit f9f1adc

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

haskell-language-server.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ test-suite func-test
222222
build-depends:
223223
, bytestring
224224
, data-default
225+
, fingertree
225226
, lens
226227
, ghc
227228
, ghc-source-gen

plugins/default/src/Ide/LocalBindings.hs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Data.Maybe
2121
import Data.Ord
2222
import Data.Set (Set)
2323
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(..))
2525
import HsExpr
2626
import Id
2727
import OccName
@@ -41,11 +41,21 @@ realSrcSpanToInterval rss =
4141
-- 'getLocalScope' to find the results.
4242
bindings :: RefMap -> Bindings
4343
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
4646
(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
4959
, S.singleton $ mkVanillaGlobal name ty
5060
)
5161

0 commit comments

Comments
 (0)