-
-
Notifications
You must be signed in to change notification settings - Fork 378
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
References via hiedb
#704
References via hiedb
#704
Conversation
I wrote some tests in HLS, for looking up references within one module, between a module and a module that imports it, between a module and a module that imports it transitively, and between a package and another package on which it depends (with the two packages being in the same cabal project). textDocument/references has an extra flag includeDeclaration. When this flag is false, looking up the symbol "foo" in "foo = 2; bar = foo + 3" should pick up "... = foo + ..." as a reference, but not "foo = ...". The references provider in this branch currently ignores this flag. There's a test with an expected failure documenting this. There's a test in test/functional/TypeDefinition failing too. "find definition of parameterized data type". It looks like, when we have this code:
And we ask for the type definition of the symbol pid, we get the "data Parameter a = Parameter a" line that defines the type Parameter a AND the "parameterId :: Parameter a -> Parameter a" line that defines the type of parameterId. That's new, is it supposed to be doing that? ... Also I hacked up a bunch of HLS to make it compile (at least on 8.10.2). Don't take that part of the code, it's the unit tests I am interested in here. I just needed them to run. (Hacked up HLS works in vscode though, and get all references does what it's supposed to. XD) (The tactics and class plugins will need to be updated to account for this:
) I also fixed a couple hlint hints, and a couple ghcide tests. |
It's returning the definition of the type variable |
That makes sense. Symbol "pid" has type "Parameter a" ... and if I want the definition of "Parameter a", then that comes in two parts: the definition of "Parameter" ("data Parameter = ...") and the definition of "a" ("forall a. ..."). Okay question answered. That test needs to be updated to expect two type definitions. (I will make this change on my PR.) |
23f091f
to
39f460a
Compare
I think this is ready for review while I work on final tweaks to tests and the HLS CLI parser. |
7429171
to
d8178bd
Compare
let docUri = (<> "#" <> selector <> showGhc name) <$> docFu | ||
srcUri = (<> "#" <> showGhc name) <$> srcFu |
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.
I'm not convinced of replacing showName
here, which is a more intentional operation than showGhc
.
In the future showGhc
could change in unexpected ways, while showName
would be more stable
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.
Completions uses showGhc
all over the place, lets fix this in another PR.
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.
but this PR is making it worse, right? At least previously they calling showName
was expressing the intent. All I am asking is to preserve that intent
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.
I thought we were keeping showName
?
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.
I used showNameWithoutUniques
instead of resurrecting showName
.
d623623
to
4b85e2a
Compare
169000d
to
121ae0b
Compare
I've squashed this down into one commit with a clear commit message. |
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.
The benchmarks do not show any regressions, and I think this is ready to merge. Super awesome, thank you @wz1000 !!!
It's a big change, please land it asap so that HEAD users have a chance to play with it before the next release.
I think it would be good to have a "stable" release before this change lands, since that would buy us some time to address any issues that may arise. |
There hasn't been an HLS release in a while and the last one had a pretty annoying diagnostics bug, so I think this is a good idea (for HLS). But for ghcide, there was a release pretty recently and I don't think it's a priority to make another one. |
cfca3b0
to
5db56b7
Compare
@jneira sorry to bother you, but would you have time to do a release of HLS so that this can land? I would do it, but I'm not familiar enough with the HLS release process. |
Sure, I will try to do asap |
If there's a detailed documentation, I'm good for that. |
Is there any user documentation we need as part of this? e.g. is it possible to clear out the hiedb files if it's misbehaving? Should we add some troubleshooting notes? |
@michaelpj there is a whole |
1. Add 'indexHieFile' and rule 'GetModIfaceFromDiskAndIndex' to maintain database integrity - 'writeHieFile' -> 'writeAndIndexHieFile' 2. References fromm database 3. Use db for go to definition - Return multiple definitions for things defined in boot files - More robust definitions for multi-component 4. Add persistent stale rules to answer queries immedidately on startup - Setup `unsafeGlobalDynFlags` on startup 5. Add hiedb command line to ghcide and hls Co-authored-by: Pepe Iborra <[email protected]> Co-authored-by: Peter Wicks Stringfield <[email protected]>
Co-authored-by: Pepe Iborra <[email protected]>
Continuing from haskell/ghcide#898
Includes support for references, workspace symbols, faster loading by loading (stale) .hie files from disk
and jump to definition for arbitrary dependencies.As described here and here
TODO:
hiedb
on hackageI'll be pressed for time in the near future, so would appreciate any help to get this over the finish line, especially with the first two points above.