Skip to content

Local binding hints (WIP) #4610

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 35 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ba2d544
Add sig lens for where clauses
July541 Jun 17, 2022
7bf07ca
Compat
July541 Jun 19, 2022
51ef231
Golden tests
July541 Jun 20, 2022
cd34e8c
Merge branch 'master' into local-binding-type-lens
pepeiborra Jun 24, 2022
c9daf86
Merge branch 'master' into local-binding-type-lens
July541 Dec 10, 2022
232e6ba
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Jul 27, 2024
f401ff2
Provide where sigs in inlay hints
jetjinser Jul 30, 2024
287f7fa
add offset for FunBind since infix function
jetjinser Jul 31, 2024
228d669
add ghcide InlayHintTests
jetjinser Jul 31, 2024
52ea29f
use liftZonkM in GHC > 9.7.0
jetjinser Jul 31, 2024
e61663d
Fix accidentally broken codeLens
jetjinser Aug 1, 2024
8b6f15e
Add Inlay Hints payload test for type lens
jetjinser Aug 1, 2024
e544187
update testdata schema
jetjinser Aug 1, 2024
5fa456d
Apply suggestions from code review
jetjinser Aug 16, 2024
561d082
refactor: bindToSig just return signature string
jetjinser Aug 17, 2024
b226661
fix: renamed existingSigNames
jetjinser Aug 17, 2024
837ee45
chore: correct schema property `whereInlayHintOn`
jetjinser Aug 17, 2024
96417e0
fix: typo
jetjinser Aug 17, 2024
20e1274
refactor: rewrite where bindings sig as Rules
jetjinser Aug 18, 2024
6d5f4af
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Aug 21, 2024
efc434b
feat: show local binding instead of just where clause
jetjinser Sep 1, 2024
d065a0a
refactor: correct comment location
jetjinser Sep 1, 2024
2d221d8
ignore things that don't have signatures
jetjinser Sep 1, 2024
953db22
refactor
jetjinser Sep 1, 2024
0df54d2
update local-binding inlayHints config desc
jetjinser Sep 1, 2024
59d56bc
update TypeLenses plugin desc
jetjinser Sep 1, 2024
0e69f46
update TypeLenses test/data dirname
jetjinser Sep 1, 2024
2f27e9a
HsLet compatible
jetjinser Sep 2, 2024
80184f8
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Sep 2, 2024
94c6841
Merge remote-tracking branch 'upstream/master' into inlay-hints-local…
jetjinser Sep 12, 2024
9cde704
Merge remote-tracking branch 'jetjinser/inlay-hints-local-binding' in…
Jun 2, 2025
330cbe9
fix broken explicit export tests
Jun 3, 2025
d2d8633
allow either code lens or inlay hints for local binds
Jun 3, 2025
a2759f6
default inlay hints to False
Jun 3, 2025
78df62b
Merge remote-tracking branch 'origin/master' into local-binding-hints
Jun 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor: correct comment location
  • Loading branch information
jetjinser committed Sep 1, 2024
commit d065a0adaec813dc0424543a9d35e7dedd139640
18 changes: 10 additions & 8 deletions ghcide/src/Development/IDE/Plugin/TypeLenses.hs
Original file line number Diff line number Diff line change
Expand Up @@ -484,18 +484,20 @@ findBindingsQ = something (mkQ Nothing findBindings)
(col (getLoc fun_id) - col (getLoc bind))
in Just $ pure localBinding
PatBind{..} ->
Just $ (everything (<>) $ mkQ [] (fmap (uncurry wb) . maybeToList . findIdFromPat)) pat_lhs
where
wb id srcSpan = LocalBinding id srcSpan (col srcSpan - col (getLoc pat_lhs))
let wb id srcSpan = LocalBinding id srcSpan (col srcSpan - col (getLoc pat_lhs))

-- | Example: Find `a` and `b` from @(a,b) = (1,True)@
findIdFromPat :: Pat GhcTc -> Maybe (Id, SrcSpan)
findIdFromPat (VarPat _ located) = Just (unLoc located, getLoc located)
findIdFromPat _ = Nothing

findIdsFromPat :: LocatedA (Pat GhcTc) -> [LocalBinding]
findIdsFromPat = everything (<>) $ mkQ [] (fmap (uncurry wb) . maybeToList . findIdFromPat)
in Just $ findIdsFromPat pat_lhs
_ -> Nothing
where
col = srcSpanStartCol . realSrcSpan

-- | Example: Find `a` and `b` from @(a,b) = (1,True)@
findIdFromPat :: Pat GhcTc -> Maybe (Id, SrcSpan)
findIdFromPat (VarPat _ located) = Just (unLoc located, getLoc located)
findIdFromPat _ = Nothing

findSigIds :: GenLocated l (Sig GhcRn) -> [IdP GhcRn]
findSigIds (L _ (TypeSig _ names _)) = map unLoc names
findSigIds _ = []
Expand Down