Repository navigation
Reintroduce hls-retrie-plugin #5147
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
base: master
Are you sure you want to change the base?
Changes from all commits
3e9d08c
71d3b96
5df3c31
fc53d49
1db6ba1
cd0e129
5c96005
4b26427
6c37dbf
6b491a8
53ede24
8121611
2b1f6d3
ca111c0
8ccb447
2edf679
6262c26
57121e3
ba367f9
1ff2507
72f1c8c
14b2f36
fbbd325
c711e06
ffcc26e
9f9fc8e
ccdf39c
01d8f21
1d9a6a0
b3283d1
f0a51c6
3ad3960
842ef57
ab45d80
c6f421d
5bdbfd2
b7b5016
d03f461
49d23d8
d3ea423
ca0c74c
c7370ea
795698d
7f520de
a80db5e
e10e726
dd01b98
d4c6616
b43a44c
feb19b2
6f0797b
4482235
be5c44d
fd1ec5b
713dd7e
22109e3
3b13181
dc34954
89b1703
df3aeb6
da0ce1f
93db181
fe5d5ae
096480a
da47cf0
6b55156
0d630f2
77f72fc
ee0eb32
1a7bbe5
3ab260a
5f3f5cd
8c6a24b
dff5330
e3477ff
a1739f4
989f9b1
d725249
8edb9cd
61e365c
841fe68
076f8fe
b2c1890
b0e400b
0df4ce8
0d41808
8b36fba
e3f6899
5808925
4727fc0
f7fdda1
1946548
1e433cb
efdb147
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| {-# LANGUAGE OverloadedStrings #-} | ||
|
|
||
| module Development.IDE.Spans.Fixity (lookupFixities) where | ||
|
|
||
| import Control.Monad.IO.Class (MonadIO, liftIO) | ||
| import qualified Data.Map.Strict as M | ||
| import Data.Maybe (fromMaybe) | ||
| import qualified Data.Set as S | ||
| import Development.IDE.GHC.Compat | ||
| import qualified Development.IDE.GHC.Compat.Util as Util | ||
|
|
||
| -- | Convert a HieAST to FixityTree with fixity info gathered | ||
| lookupFixities :: MonadIO m => HscEnv -> TcGblEnv -> S.Set Name -> m (M.Map Name Fixity) | ||
| lookupFixities hscEnv tcGblEnv names | ||
| = liftIO | ||
| $ fmap (fromMaybe M.empty . snd) | ||
| $ initTcWithGbl hscEnv tcGblEnv (realSrcLocSpan $ mkRealSrcLoc "<dummy>" 1 1) | ||
| $ M.traverseMaybeWithKey (\_ v -> v) | ||
| $ M.fromSet lookupFixity names | ||
| where | ||
| lookupFixity name = do | ||
| f <- Util.handleGhcException | ||
| (const $ pure Nothing) | ||
| (Just <$> lookupFixityRn name) | ||
| if f == Just defaultFixity | ||
| then pure Nothing | ||
| else pure f | ||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ module Development.IDE.GHC.ExactPrint.Annotation | |||||||||||
| , removeTrailingCommaAnn | ||||||||||||
| , ensureTrailingComma | ||||||||||||
| , withTrailingComma | ||||||||||||
| , withCommas | ||||||||||||
| , modifyAnns | ||||||||||||
| , addParens | ||||||||||||
| , parenthesizeName | ||||||||||||
|
|
@@ -85,6 +86,12 @@ ensureTrailingComma ann | |||||||||||
| | any isCommaAnn (trailingAnns ann) = ann | ||||||||||||
| | otherwise = addComma ann | ||||||||||||
|
|
||||||||||||
| -- | Add a trailing comma to every element but the last. | ||||||||||||
| withCommas :: [LocatedAn AnnListItem a] -> [LocatedAn AnnListItem a] | ||||||||||||
| withCommas [] = [] | ||||||||||||
| withCommas [x] = [x] | ||||||||||||
| withCommas (L l e : xs) = L (ensureTrailingComma l) e : withCommas xs | ||||||||||||
|
Comment on lines
+91
to
+93
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand correctly, you can do this with lenses:
Suggested change
I'm still new to them, so I'm just spotting opportunities to practice with it λ> over _init (map (*10)) ([] :: [Int])
[]
λ> over _init (map (*10)) ([1] :: [Int])
[1]
λ> over _init (map (*10)) ([1..3] :: [Int])
[10,20,3]
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I need to spend some time to learn how to use lenses. It reads quite clearly. |
||||||||||||
|
|
||||||||||||
| -- | Replace an item's trailing comma with @c@, preserving its delta. | ||||||||||||
| withTrailingComma :: TrailingAnn -> SrcSpanAnnA -> SrcSpanAnnA | ||||||||||||
| withTrailingComma c = overTrailingAnns (\as -> filter (not . isCommaAnn) as ++ [c]) | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, this line (which I see already existed) is absurdly dense 😆
I can't even word what ti does...