Skip to content

leverage new completion features to provide hover on (some) unsaved code #749

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

Merged
merged 3 commits into from
Mar 21, 2023

Conversation

zth
Copy link
Collaborator

@zth zth commented Mar 11, 2023

This leverages the new unsaved completion code to get hovers on some unsaved code.

I would eventually like this to also work on assigned identifiers, like (all unsaved):

let fff = makeSomeRecord()
//   ^hov should show `someRecord`, but it doesn't because it doesn't handle the actual assigned identifier
let ccc = fff
//               ^hov here it works though

But this is a win nonetheless so adding support for something like that can be a separate thing.

@zth zth requested a review from cristianoc March 11, 2023 08:50
| Some (completions, {file; package}) -> (
| Some (completions, ({file; package} as full), scope) -> (
let rawOpens = Scope.getRawOpens scope in
let allFiles =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: there's a bit of redundancy.
allFiles comes from package.
There are functions that take both allFiles and package (or full). So they' don't really need all those args.
I guess allFiles can be either a function of package, or directly a field there. So it's computed on the spot when needed instead of being passed around.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will fix in separate PR.

| {kind = Field _; env; docstring} :: _ -> (
let opens = CompletionBackEnd.getOpens ~debug ~rawOpens ~package ~env in
match
CompletionBackEnd.completionsGetTypeEnv2 ~debug ~full ~rawOpens ~opens
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had not noticed much the business of completionsGetTypeEnv vs completionsGetTypeEnv2. Is there ever a reason for using the former given the latter is more powerful?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not. Mostly a bridge for migrating to the new one. Will take care of this as we do our major refactor of all of this new functionality.

@zth zth merged commit 2bfd98c into master Mar 21, 2023
@zth zth deleted the hover-on-unsaved-content branch March 21, 2023 19:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants