-
-
Notifications
You must be signed in to change notification settings - Fork 371
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
Fix completion for qualified import #2838
Conversation
Can we mark this as failing somehow so we can merge it without the fix? |
@michaelpj there are other tests marked as such, so it can surely be done. The second one should be passing though, so I need to check what I am testing. 😅 |
914a216
to
e14f12d
Compare
@michaelpj I marked it as expected to fail, but then I found the fix anyway 😀 |
Btw. I have no idea what is CI trying to tell me: EDIT: OK, now that I have my glasses, I see there is one grey job not skipped but cancelled, which caused this condition to fail. |
I reran the failed jobs, let's see what happens. |
61d1d30
to
9806d3f
Compare
@michaelpj Good news, using the parsed context seems to have fixed the problem with multiline import completions! 👍 |
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.
Good news, using the parsed context seems to have fixed the problem with multiline import completions!
Could we add a regression test for this?
9806d3f
to
4de4bb1
Compare
@michaelpj sure, I added a regression test. 🙂 |
4de4bb1
to
2b1cf8a
Compare
The CI smiles on me this day! ☀️ @pepeiborra could you please check the comments above? 🙂 |
277faef
to
ab717b3
Compare
After inspecting the CI (see comment above), @pepeiborra @michaelpj If the CI passes, I think it is ready to merge. EDIT: Let me backtrack on backtracking and try the CI again... 👀 |
ab717b3
to
48ed975
Compare
Weird, the test fails on GHC 8.8.4 because there is an unexpected command with -- explicit qualified post: FAIL (1.80s)
-- test/exe/Main.hs:4826:
-- Expected no command but got:
Just (Command {
_title = "extend import",
_command = "143210:ghcide-completions:extendImport",
_arguments = Just [Object (fromList
[("doc",String "file:///tmp/extra-dir-35255587795340/A.hs")
,("importName",String "Control.Monad")
,("importQual",Null)
,("newThing",String "join")
,("thingParent",Null)
])]
}) This seems very strange to me because it does not happen on 8.10 and to normal pre-qualified import test. 😕 Also from what I gather "extend import" should show up only if the |
I restarted the tests, and now the 8.6.5 one fails as well in the same way. It also doesn't fail except on ubuntu. Perhaps it's just flaky, and we're missing a call to wait for something somewhere? |
Consistent failure:
The test needs adjusting, the new result is more correct thanks to the changes in this PR. @xsebek are you able to adjust the test and get this PR finally merged? |
bcbcd28
to
a619e5c
Compare
- add test for post-qualified completion - add failing test for pre-qualified completion - add failing test for multiline import
- fix how we get the module name considering it can be preceded by `qualified` - use parsed context for import completions - add regression test for fixed multiline import - refactor `getCompletions` function
a619e5c
to
cf6db6c
Compare
Sorry for leaving this open for so long! @pepeiborra I fixed the test failing on I will wait to see what the CI says this time and hopefully finally get this merged. |
@xsebek That's my fault, we cleaned up the |
@fendor thanks for the quick response. 👍 The CI did not finish well:
Any tips to make the CI green? |
We don't run the tests on macos (honestly, I don't know why, this will surely bite us at some point) and nix CI is optional. It will actually be reduced #3804 quite soon, so don't worry about that. I restarted the test suite for the flaky test, sounds like this PR is green and doesn't require your input at the moment. |
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 changes look good to me. Am I correct in the assumption, the way this actually fixes the issue is by using maybeContext
parsing the module and reliably giving a module name?
This PR has the trade-off that we sometimes can't suggest a module correctly if there is a parse error in the file, for example,
module Test where
import
import
-- ^ Put your cursor here
will not suggest imports. That's a change in behaviour, but I don't think it is a blocking one.
I think we should document, perhaps in the function documentation of getCompletions
, which classes of completions are dependent on an existing parsed module and which are not?
@fendor Yes, I switched to using the (hopefully) parsed context, which makes it work in more situations including multiline. Maintaining the ad-hoc parsing does not seem worthwhile to me. I assume GHC does not stop on first parse error, so anything that it can manage to parse we will be able to use for suggestions. Your example seems to me like something GHC could (and should) handle better than HLS. The rest of the completions seem to use a mix of HIE AST ( |
GHC does stop after the first parse error. I think that's fine by me. A Haskell file shouldn't have parse errors in it anyway. |
qualified
getCompletions
function