-
Notifications
You must be signed in to change notification settings - Fork 58
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
Changes from all commits
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 |
---|---|---|
|
@@ -125,31 +125,44 @@ let getHoverViaCompletions ~debug ~path ~pos ~currentFile ~forHover | |
~supportsMarkdownLinks = | ||
match Completions.getCompletions ~debug ~path ~pos ~currentFile ~forHover with | ||
| None -> None | ||
| Some (completions, {file; package}) -> ( | ||
| Some (completions, ({file; package} as full), scope) -> ( | ||
let rawOpens = Scope.getRawOpens scope in | ||
let allFiles = | ||
FileSet.union package.projectFiles package.dependenciesFiles | ||
in | ||
match completions with | ||
| {kind = Label typString; docstring} :: _ -> | ||
let parts = | ||
(if typString = "" then [] else [Markdown.codeBlock typString]) | ||
@ docstring | ||
in | ||
Some (Protocol.stringifyHover (String.concat "\n\n" parts)) | ||
| {kind = Field _; docstring} :: _ -> ( | ||
match CompletionBackEnd.completionsGetTypeEnv completions with | ||
| {kind = Field _; env; docstring} :: _ -> ( | ||
let opens = CompletionBackEnd.getOpens ~debug ~rawOpens ~package ~env in | ||
match | ||
CompletionBackEnd.completionsGetTypeEnv2 ~debug ~full ~rawOpens ~opens | ||
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 had not noticed much the business of 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. 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. |
||
~allFiles ~pos ~scope completions | ||
with | ||
| Some (typ, _env) -> | ||
let typeString = | ||
hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks typ | ||
in | ||
let parts = typeString :: docstring in | ||
Some (Protocol.stringifyHover (String.concat "\n\n" parts)) | ||
| None -> None) | ||
| _ -> ( | ||
match CompletionBackEnd.completionsGetTypeEnv completions with | ||
| {env} :: _ -> ( | ||
let opens = CompletionBackEnd.getOpens ~debug ~rawOpens ~package ~env in | ||
match | ||
CompletionBackEnd.completionsGetTypeEnv2 ~debug ~full ~rawOpens ~opens | ||
~allFiles ~pos ~scope completions | ||
with | ||
| Some (typ, _env) -> | ||
let typeString = | ||
hoverWithExpandedTypes ~file ~package ~supportsMarkdownLinks typ | ||
in | ||
Some (Protocol.stringifyHover typeString) | ||
| None -> None)) | ||
| None -> None) | ||
| _ -> None) | ||
|
||
let newHover ~full:{file; package} ~supportsMarkdownLinks locItem = | ||
match locItem.locType with | ||
|
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.
Nit: there's a bit of redundancy.
allFiles
comes frompackage
.There are functions that take both
allFiles
andpackage
(orfull
). So they' don't really need all those args.I guess
allFiles
can be either a function ofpackage
, or directly a field there. So it's computed on the spot when needed instead of being passed around.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.
Will fix in separate PR.