Skip to content

Commit e0caf83

Browse files
committed
Update analysis for jsx_fragment
1 parent 019c31d commit e0caf83

File tree

5 files changed

+12
-15
lines changed

5 files changed

+12
-15
lines changed

analysis/src/CompletionFrontEnd.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1222,7 +1222,8 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
12221222
then ValueOrField
12231223
else Value);
12241224
}))
1225-
| Pexp_construct ({txt = Lident ("::" | "()")}, _) ->
1225+
| Pexp_construct ({txt = Lident ("::" | "()")}, _) | Pexp_jsx_fragment _
1226+
->
12261227
(* Ignore list expressions, used in JSX, unit, and more *) ()
12271228
| Pexp_construct (lid, eOpt) -> (
12281229
let lidPath = flattenLidCheckDot lid in

analysis/src/Utils.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ let identifyPexp pexp =
111111
| Pexp_pack _ -> "Pexp_pack"
112112
| Pexp_extension _ -> "Pexp_extension"
113113
| Pexp_open _ -> "Pexp_open"
114+
| Pexp_jsx_fragment _ -> "Pexp_jsx_fragment"
114115

115116
let identifyPpat pat =
116117
match pat with
@@ -154,6 +155,10 @@ let isJsxComponent (vb : Parsetree.value_binding) =
154155
|> List.exists (function
155156
| {Location.txt = "react.component" | "jsx.component"}, _payload -> true
156157
| _ -> false)
158+
||
159+
match vb.pvb_expr.pexp_desc with
160+
| Parsetree.Pexp_jsx_fragment _ -> true
161+
| _ -> false
157162

158163
let checkName name ~prefix ~exact =
159164
if exact then name = prefix else startsWith name prefix

tests/analysis_tests/tests/src/expected/Completion.res.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,7 @@ Path Objects.Rec.
10001000

10011001
Complete src/Completion.res 120:7
10021002
posCursor:[120:7] posNoWhite:[120:6] Found expr:[119:11->123:1]
1003-
posCursor:[120:7] posNoWhite:[120:6] Found expr:[120:5->122:5]
1003+
posCursor:[120:7] posNoWhite:[120:6] Found expr:[120:5->123:0]
10041004
posCursor:[120:7] posNoWhite:[120:6] Found expr:[120:5->120:7]
10051005
Pexp_ident my:[120:5->120:7]
10061006
Completable: Cpath Value[my]

tests/analysis_tests/tests/src/expected/Fragment.res.txt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,8 @@ Hover src/Fragment.res 6:19
33

44
Hover src/Fragment.res 9:56
55
Nothing at that position. Now trying to use completion.
6-
posCursor:[9:56] posNoWhite:[9:55] Found expr:[9:10->9:67]
7-
posCursor:[9:56] posNoWhite:[9:55] Found expr:[9:13->9:67]
6+
posCursor:[9:56] posNoWhite:[9:55] Found expr:[9:9->11:0]
87
posCursor:[9:56] posNoWhite:[9:55] Found expr:[9:13->9:66]
98
JSX <SectionHeader:[9:13->9:26] > _children:9:26
10-
posCursor:[9:56] posNoWhite:[9:55] Found expr:__ghost__[9:10->9:67]
11-
Pexp_construct []:__ghost__[9:10->9:67] None
12-
Completable: Cexpression CTypeAtPos()=[]->variantPayload::::($1)
13-
Package opens Pervasives.JsxModules.place holder
14-
ContextPath CTypeAtPos()
159
null
1610

tests/analysis_tests/tests/src/expected/Jsx2.res.txt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,7 @@ Path Nested.
511511

512512
Hover src/Jsx2.res 162:12
513513
Nothing at that position. Now trying to use completion.
514-
posCursor:[162:12] posNoWhite:[162:11] Found expr:[162:3->162:21]
515-
posCursor:[162:12] posNoWhite:[162:11] Found expr:[162:6->162:21]
514+
posCursor:[162:12] posNoWhite:[162:11] Found expr:[162:2->164:0]
516515
posCursor:[162:12] posNoWhite:[162:11] Found expr:[162:6->162:20]
517516
JSX <Comp:[162:6->162:10] age[162:11->162:14]=...[162:15->162:17]> _children:162:18
518517
Completable: Cjsx([Comp], age, [age])
@@ -522,10 +521,8 @@ Path Comp.make
522521

523522
Hover src/Jsx2.res 167:16
524523
Nothing at that position. Now trying to use completion.
525-
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:3->167:30]
526-
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:7->167:30]
527-
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:7->167:25]
528-
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:10->167:25]
524+
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:2->169:0]
525+
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:6->167:28]
529526
posCursor:[167:16] posNoWhite:[167:15] Found expr:[167:10->167:24]
530527
JSX <Comp:[167:10->167:14] age[167:15->167:18]=...[167:19->167:21]> _children:167:22
531528
Completable: Cjsx([Comp], age, [age])

0 commit comments

Comments
 (0)