-
Notifications
You must be signed in to change notification settings - Fork 57
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
Complete function argument values #665
Conversation
@@ -1455,6 +1455,131 @@ let getOpens ~debug ~rawOpens ~package ~env = | |||
(* Last open takes priority *) | |||
List.rev resolvedOpens | |||
|
|||
let getArgs ~env (t : Types.type_expr) ~full = |
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 one is mostly copied from a pre-existing fn, but with identifying what type of argument is found (labelled or unlabelled).
analysis/src/CompletionBackEnd.ml
Outdated
~name: | ||
(constructor.cname.txt |
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.
Bonus points @cristianoc - can we somehow figure out if we need to qualify the constructor here? Not something we need to do now, but something worth thinking about for the future.
analysis/src/CompletionBackEnd.ml
Outdated
Completion.create ~name:"None" | ||
~kind:(Label (t |> Shared.typeToString)) | ||
~env; | ||
Completion.create ~name:"Some(_)" | ||
~kind:(Label (t |> Shared.typeToString)) | ||
~env; |
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 going to improve this a lot soon. Mainly 2 things:
Some(_)
will eventually be a snippetSome($1:_)
, which means that the cursor is automatically positioned in the option payload (so we can keep completing the option value)- If the inner type is "small" enough (bool, variant with few payloads, etc), we can expand those into the list directly, so that instead of
None/Some(_)
, it'd beNone/Some(true)/Some(false)
for bools, etc.
…structor argument
… is a prefix to filter on
f866efb
to
5995f45
Compare
The first in likely a long series of PRs bringing in and refining the work done in #493, but little bit by bit.
This PR does the following:
There are caveats that I've added comments for in the PR.
The next step will be getting support for snippets in completion items in, so we can intelligently move the cursor for the user into payloads of constructors etc. That'll come in a separate PR.
After that, completing polyvariants.
Then the same work as in this PR, but for JSX props.