Skip to content

Commit d3d1444

Browse files
authored
Editor: Iterate objects (#7230)
* iterate objects * changelog * remove test file
1 parent 5628a84 commit d3d1444

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

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

2021
# 12.0.0-alpha.7
2122

analysis/src/CompletionFrontEnd.ml

+2
Original file line numberDiff line numberDiff line change
@@ -1107,6 +1107,8 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
11071107
if expr.pexp_loc |> Loc.hasPos ~pos:posNoWhite && !result = None then (
11081108
setFound ();
11091109
match expr.pexp_desc with
1110+
| Pexp_extension ({txt = "obj"}, PStr [str_item]) ->
1111+
Ast_iterator.default_iterator.structure_item iterator str_item
11101112
| Pexp_extension ({txt}, _) -> setResult (CextensionNode txt)
11111113
| Pexp_constant _ -> setResult Cnone
11121114
| Pexp_ident lid ->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let x = Some(true)
2+
3+
let _ff = {
4+
"one": switch x {
5+
| Some(true) => "hello"
6+
// |
7+
// ^com
8+
| _ => ""
9+
},
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Complete src/CompletionObjects.res 5:7
2+
posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1]
3+
posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1]
4+
posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5]
5+
posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5]
6+
Completable: Cpattern Value[x]
7+
Package opens Pervasives.JsxModules.place holder
8+
ContextPath Value[x]
9+
Path x
10+
[{
11+
"label": "None",
12+
"kind": 12,
13+
"tags": [],
14+
"detail": "bool",
15+
"documentation": null
16+
}, {
17+
"label": "Some(_)",
18+
"kind": 12,
19+
"tags": [],
20+
"detail": "bool",
21+
"documentation": null,
22+
"insertText": "Some(${1:_})",
23+
"insertTextFormat": 2
24+
}, {
25+
"label": "Some(true)",
26+
"kind": 4,
27+
"tags": [],
28+
"detail": "bool",
29+
"documentation": null
30+
}, {
31+
"label": "Some(false)",
32+
"kind": 4,
33+
"tags": [],
34+
"detail": "bool",
35+
"documentation": null
36+
}]
37+

0 commit comments

Comments
 (0)