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

Initial pattern completion #670

Merged
merged 31 commits into from
Jan 5, 2023
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9a63a84
basic setup of some sort of structure, and complete tuple patterns
zth Dec 30, 2022
112ee62
nested tuple
zth Dec 30, 2022
c18e7bf
start integrating completion for records
zth Dec 30, 2022
352872f
complete record bodies/fields in patterns
zth Jan 1, 2023
01516a6
handle completing for new record fields, and filtering already seen f…
zth Jan 1, 2023
5f4d7e0
add test for patterns under other patterns, and handle unsetting what…
zth Jan 1, 2023
3c7562c
identify and handle completing destructuring patterns
zth Jan 1, 2023
cc8412f
comments and cleanup
zth Jan 1, 2023
4df242f
add nested destructure test
zth Jan 1, 2023
26b0e68
fix
zth Jan 1, 2023
779e1be
descend through variant payloads
zth Jan 1, 2023
d349f43
handle polyvariants
zth Jan 1, 2023
72039e2
complete arrays in patterns
zth Jan 1, 2023
57ba325
handle multiple payloads in variants/polyvariants via regular tuple h…
zth Jan 2, 2023
3eb59e2
move from ast iterator to traversal function for finding completables…
zth Jan 3, 2023
8e3baf5
ignore unused var
zth Jan 3, 2023
dda7fd4
handle options
zth Jan 3, 2023
3ea5168
handle completing new items in constructor/variant payloads with mult…
zth Jan 3, 2023
124509e
handle completing new items in tuples
zth Jan 3, 2023
68e22db
add broken parser case
zth Jan 3, 2023
23b7833
remove unused
zth Jan 3, 2023
5976234
refactor and unify how pat tuple items are traversed
zth Jan 3, 2023
c601823
simplify setting completion pattern
zth Jan 3, 2023
a828e79
handle completing root switch case when theres more than one case
zth Jan 3, 2023
11cb6ae
refactor
zth Jan 3, 2023
9429664
handle ppat_or
zth Jan 3, 2023
a61f06b
handle or patterns (including broken patterns) in variant/polyvariant…
zth Jan 4, 2023
3659013
changelog
zth Jan 4, 2023
bb63093
add way to use fallbacks when completing patterns, restoring old beha…
zth Jan 5, 2023
bba5805
refactor nested pattern completion handling in backend
zth Jan 5, 2023
391d8d4
remove unecessary log
zth Jan 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
handle options
  • Loading branch information
zth committed Jan 4, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit dda7fd4f0748646b81b53e600a6f05445743a5a4
7 changes: 5 additions & 2 deletions analysis/src/CompletionBackEnd.ml
Original file line number Diff line number Diff line change
@@ -1778,8 +1778,11 @@ let rec resolveNestedPattern typ ~env ~package ~nested =
| Some {typ} -> typ |> resolveNestedPattern ~env ~package ~nested)
| PRecordBody {seenFields}, Some (Trecord {env; typeExpr}) ->
Some (typeExpr, env, Some (Completable.RecordField {seenFields}))
| PVariantPayload {constructorName; itemNum}, Some (Tvariant {env; constructors})
-> (
| ( PVariantPayload {constructorName = "Some"; itemNum = 0},
Some (Toption (env, typ)) ) ->
typ |> resolveNestedPattern ~env ~package ~nested
| ( PVariantPayload {constructorName; itemNum},
Some (Tvariant {env; constructors}) ) -> (
match
constructors
|> List.find_opt (fun (c : Constructor.t) ->
6 changes: 6 additions & 0 deletions analysis/tests/src/CompletionPattern.res
Original file line number Diff line number Diff line change
@@ -121,3 +121,9 @@ ignore(c)

// switch c { | [] }
// ^com

let o = Some(true)
ignore(o)

// switch o { | Some() }
// ^com
20 changes: 20 additions & 0 deletions analysis/tests/src/expected/CompletionPattern.res.txt
Original file line number Diff line number Diff line change
@@ -453,3 +453,23 @@ Completable: Cpattern Value[c]->array
"documentation": null
}]

Complete src/CompletionPattern.res 127:21
looking for: Cpath Value[o]
posCursor:[127:21] posNoWhite:[127:20] Found expr:[127:3->127:24]
posCursor:[127:21] posNoWhite:[127:20] Found pattern:[127:16->127:22]
posCursor:[127:21] posNoWhite:[127:20] Found pattern:[127:20->127:22]
Completable: Cpattern Value[o]->variantPayload::Some($0)
[{
"label": "true",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}, {
"label": "false",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}]