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

Editor: Iterate objects #7230

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

- Editor: Fix issue where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript/pull/7231
- Fix leftover assert false in code for `null != undefined`. https://github.com/rescript-lang/rescript/pull/7232
- Editor: Fix issue where completions would not show up inside of object bodies. https://github.com/rescript-lang/rescript/pull/7230

# 12.0.0-alpha.7

Expand Down
2 changes: 2 additions & 0 deletions analysis/src/CompletionFrontEnd.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1107,6 +1107,8 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
if expr.pexp_loc |> Loc.hasPos ~pos:posNoWhite && !result = None then (
setFound ();
match expr.pexp_desc with
| Pexp_extension ({txt = "obj"}, PStr [str_item]) ->
Ast_iterator.default_iterator.structure_item iterator str_item
| Pexp_extension ({txt}, _) -> setResult (CextensionNode txt)
| Pexp_constant _ -> setResult Cnone
| Pexp_ident lid ->
Expand Down
10 changes: 10 additions & 0 deletions tests/analysis_tests/tests/src/CompletionObjects.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
let x = Some(true)

let _ff = {
"one": switch x {
| Some(true) => "hello"
// |
// ^com
| _ => ""
},
}
37 changes: 37 additions & 0 deletions tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Complete src/CompletionObjects.res 5:7
posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1]
posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1]
posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5]
posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5]
Completable: Cpattern Value[x]
Package opens Pervasives.JsxModules.place holder
ContextPath Value[x]
Path x
[{
"label": "None",
"kind": 12,
"tags": [],
"detail": "bool",
"documentation": null
}, {
"label": "Some(_)",
"kind": 12,
"tags": [],
"detail": "bool",
"documentation": null,
"insertText": "Some(${1:_})",
"insertTextFormat": 2
}, {
"label": "Some(true)",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}, {
"label": "Some(false)",
"kind": 4,
"tags": [],
"detail": "bool",
"documentation": null
}]

Loading