From 9010a4e52501e4128caa2254a86f93faf3b3c726 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Sun, 5 Jan 2025 13:17:52 +0100 Subject: [PATCH 1/3] iterate objects --- CHANGELOG.md | 1 + analysis/src/CompletionFrontEnd.ml | 2 + .../tests/src/CompletionObjects.res | 10 +++++ .../src/expected/CompletionObjects.res.txt | 37 +++++++++++++++++++ tst.res | 9 +++++ 5 files changed, 59 insertions(+) create mode 100644 tests/analysis_tests/tests/src/CompletionObjects.res create mode 100644 tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt create mode 100644 tst.res diff --git a/CHANGELOG.md b/CHANGELOG.md index 5234be8b7d..3498f7ee4c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. # 12.0.0-alpha.7 diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index e22b24b891..ceebf92274 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -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 -> diff --git a/tests/analysis_tests/tests/src/CompletionObjects.res b/tests/analysis_tests/tests/src/CompletionObjects.res new file mode 100644 index 0000000000..6de39bd1a2 --- /dev/null +++ b/tests/analysis_tests/tests/src/CompletionObjects.res @@ -0,0 +1,10 @@ +let x = Some(true) + +let _ff = { + "one": switch x { + | Some(true) => "hello" + // | + // ^com + | _ => "" + }, +} diff --git a/tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt b/tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt new file mode 100644 index 0000000000..f9a78b5378 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt @@ -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 + }] + diff --git a/tst.res b/tst.res new file mode 100644 index 0000000000..1946422b39 --- /dev/null +++ b/tst.res @@ -0,0 +1,9 @@ +let x = Some(true) +let _ff = { + "one": switch x { + | Some(true) => "hello" + // | + // ^com + | _ => "" + }, +} \ No newline at end of file From e8a314a41c02306bff214db0e3a21b18f78809e1 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Sun, 5 Jan 2025 13:19:24 +0100 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3498f7ee4c..f49ef00fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +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. +- 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 From eb308b250b517a8ff73a80e706ce8dde023cfa73 Mon Sep 17 00:00:00 2001 From: Gabriel Nordeborn Date: Sun, 5 Jan 2025 13:20:10 +0100 Subject: [PATCH 3/3] remove test file --- tst.res | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 tst.res diff --git a/tst.res b/tst.res deleted file mode 100644 index 1946422b39..0000000000 --- a/tst.res +++ /dev/null @@ -1,9 +0,0 @@ -let x = Some(true) -let _ff = { - "one": switch x { - | Some(true) => "hello" - // | - // ^com - | _ => "" - }, -} \ No newline at end of file