-
Notifications
You must be signed in to change notification settings - Fork 97
Add GetHieAsts rule, Replace SpanInfo, add support for DocumentHighlight and scope-aware completions for local variables #784
Conversation
Marvelous. Thank you so much! |
Will other clients like Stan be able to use the hie files produced by ghcide? If not, maybe we should change the file extension |
Any changes worth upstreaming to ghc? |
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.
This PR seems a bit incomplete. Is there any reason for that?
Yes, the hie files are generated in precisely the same way.
Yeah, we need |
I just updated the benchmarks to measure allocations and delayed actions |
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.
@@ -392,19 +396,7 @@ getCompletions ideOpts cc pm pmapping prefixInfo caps withSnippets = do | |||
to 'foo :: Int -> String -> ' | |||
^ | |||
-} | |||
pos = |
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.
We don't need this stuff anymore because of fuzzy position mapping. I had to wade through multiple git commits across repositories to find @bubba as the source of this code. If I understand correctly, it existed so that we could detect type contexts even if the module didn't parse.
Suppose the cursor is at the |
foo :: Integer -> Integer -> |
So the idea was to strip out the trailing "-> ", and then look for the "context" of the position (whether it was in a value/type/import etc.) at the position (newPositionToOld
would just return Nothing
).
Now, fromDelta
will return the original range that was inserted to/replaced, so we can use it instead.
Implement Document Hightlight LSP request Add GetDocMap, GetHieFile rules.
I am leaning towards not adding back the "relevant constraints on hover" feature.
/cc @pepeiborra @ndmitchell thoughts? |
I have fixed as many tests as I plan to. The remaining failures are genuine behavior divergences that I don't think are worth fixing. Please review them once CI completes. The only TODO remaining is to add tests for the new features. |
I am fine with dropping the "constraints on hover" feature, it was bit erratic for me and only seemed to work on declaration lhs's. Is there any chance of back porting #1286 to the ghcide fork of Hie files? Ignoring the tests related to that feature, there are only 5 failing tests, all related to hover. Good job! Please share some benchmarks if you have the chance too. |
Here are the interesting benchmark results:
There is some funkyness with the allocations for document symbols I can't explain: The rest seem to be unchanged, except for the shape of the allocation graph: http://78.47.113.11/benchmarks/ |
Look at the "Delayed work" column in the
|
What exactly is delayed time? |
The time spent waiting for all the delayed actions in the Shake queue to complete |
The regression in completion performance is expected since we now depend on |
I have no idea why there is a change for |
Added tests! This is done except for that one |
I don't have the energy to figure out why the test is passing on 8.10 but not on GHC versions before that. I diffed the |
Any opinions on whether I should remove 8.4 specific CPP in this PR, or a different one? |
I would say merge this when ready and clean up 8.4 CPP in another PR to minimise conflicts |
OK, I think this is ready, we can merge if you are happy. |
…ght and scope-aware completions for local variables (haskell#784) * Add GetHieAsts rule * hlint * fix build for 8.4 * Reimplement Hover/GotoDefn in terms of HIE Files. Implement Document Hightlight LSP request Add GetDocMap, GetHieFile rules. * Fix gotodef for record fields * Completion for locals * Don't need to hack cursor position because of fuzzy ranges * hlint * fix bench and warning on 8.10 * disable 8.4 CI jobs * Don't collect module level bindings * tweaks * Show kinds * docs * Defs for ModuleNames * Fix some tests * hlint * Mark remaining tests as broken * Add completion tests * add highlight tests * Fix HieAst for 8.6 * CPP away the unexpected success * More CPP hacks for 8.10 tests
…ght and scope-aware completions for local variables (haskell/ghcide#784) * Add GetHieAsts rule * hlint * fix build for 8.4 * Reimplement Hover/GotoDefn in terms of HIE Files. Implement Document Hightlight LSP request Add GetDocMap, GetHieFile rules. * Fix gotodef for record fields * Completion for locals * Don't need to hack cursor position because of fuzzy ranges * hlint * fix bench and warning on 8.10 * disable 8.4 CI jobs * Don't collect module level bindings * tweaks * Show kinds * docs * Defs for ModuleNames * Fix some tests * hlint * Mark remaining tests as broken * Add completion tests * add highlight tests * Fix HieAst for 8.6 * CPP away the unexpected success * More CPP hacks for 8.10 tests
…ght and scope-aware completions for local variables (haskell/ghcide#784) * Add GetHieAsts rule * hlint * fix build for 8.4 * Reimplement Hover/GotoDefn in terms of HIE Files. Implement Document Hightlight LSP request Add GetDocMap, GetHieFile rules. * Fix gotodef for record fields * Completion for locals * Don't need to hack cursor position because of fuzzy ranges * hlint * fix bench and warning on 8.10 * disable 8.4 CI jobs * Don't collect module level bindings * tweaks * Show kinds * docs * Defs for ModuleNames * Fix some tests * hlint * Mark remaining tests as broken * Add completion tests * add highlight tests * Fix HieAst for 8.6 * CPP away the unexpected success * More CPP hacks for 8.10 tests
…ght and scope-aware completions for local variables (haskell/ghcide#784) * Add GetHieAsts rule * hlint * fix build for 8.4 * Reimplement Hover/GotoDefn in terms of HIE Files. Implement Document Hightlight LSP request Add GetDocMap, GetHieFile rules. * Fix gotodef for record fields * Completion for locals * Don't need to hack cursor position because of fuzzy ranges * hlint * fix bench and warning on 8.10 * disable 8.4 CI jobs * Don't collect module level bindings * tweaks * Show kinds * docs * Defs for ModuleNames * Fix some tests * hlint * Mark remaining tests as broken * Add completion tests * add highlight tests * Fix HieAst for 8.6 * CPP away the unexpected success * More CPP hacks for 8.10 tests
This is all the remaining changes from the
hls-3
branch.Drops support for GHC 8.4
Fixes #663
Changes:
GetSpanInfo
rule, depend entirely onGetHieAst
for hover, go to definition etc.New features:
GetBindings
Missing features:
Go to definition for module namesKind info on hoverTODOs:
DocMap
mechanismRelated GHC MRs for
.hie
file changes:https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4037
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4068
One has already been merged into the ghc-9.0 branch, the other will be merged soon hopefully
Old description:
This is the slight modification of what already lives in the
hls-3
andhiedb-3
branches, necessary for haskell/haskell-language-server#391We make some modifications to be able to save the
HieAst
before compressing the types. We compress the types on demand when we actually need to write the file to disk. This should improvehls
performance somewhat as we get rid of the overhead of type compression (which can be expensive) in most cases.