Skip to content
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

Nested expression completion #682

Merged
merged 13 commits into from
Jan 11, 2023
Merged

Nested expression completion #682

merged 13 commits into from
Jan 11, 2023

Conversation

zth
Copy link
Collaborator

@zth zth commented Jan 7, 2023

This extends the current expression completion to handle more cases (records, arrays, tuples, etc), and also handle nested expressions (record fields, constructor payloads, etc etc).

It's essentially a one-to-one port of the nested pattern completion, but for expressions instead.

After this lands, we can soon start refactoring and break up the giant CompletionFrontend/CompletionBackend a bit in my opinion.

@zth zth requested a review from cristianoc January 7, 2023 19:54
@zth zth mentioned this pull request Jan 7, 2023
24 tasks
analysis/src/CompletionBackEnd.ml Outdated Show resolved Hide resolved
@@ -931,6 +931,30 @@ let findLocalCompletionsForValuesAndConstructors ~(localTables : LocalTables.t)
(processLocalModule ~prefix ~exact ~env ~localTables);
List.rev_append localTables.resultRev valuesFromOpens

let findLocalCompletionsForValues ~(localTables : LocalTables.t) ~env ~prefix
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Slimmed down version of a pre-existing function (but that handles both this + constructors). We don't want constructors in typed completion, since they are handled by the typed completion itself.

@@ -1098,6 +1122,28 @@ let extractFunctionType ~env ~package typ =
in
loop ~env [] typ

let getComplementaryCompletionsForTypedValue ~opens ~allFiles ~scope ~env prefix
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also a slimmed down version of a pre-existing fn.

@@ -1193,6 +1239,111 @@ let findReturnTypeOfFunctionAtLoc loc ~(env : QueryEnv.t) ~full ~debug =
| _ -> None)
| _ -> None

let getJsxLabels ~componentPath ~findTypeOfValue ~package =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved, not changed.

typ |> getLabels
| None -> []

let getArgs ~env (t : Types.type_expr) ~full =
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Moved, not changed.

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

some minor comments

@zth zth force-pushed the initial-expr-completion branch from 5a031fd to 3245210 Compare January 11, 2023 15:02
@zth zth merged commit e595eae into master Jan 11, 2023
@zth zth deleted the initial-expr-completion branch January 11, 2023 15:11
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