Skip to content

Commit 558b9d4

Browse files
committed
remove unused code
1 parent 9cbad12 commit 558b9d4

File tree

1 file changed

+4
-78
lines changed

1 file changed

+4
-78
lines changed

jscomp/syntax/reactjs_jsx_ppx.cppo.ml

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -439,80 +439,8 @@ let jsxMapper () =
439439
args
440440
in
441441

442-
let transformUppercaseCall modulePath mapper loc attrs _ callArguments =
443-
let (children, argsWithLabels) = extractChildren ~loc ~removeLastPositionUnit:true callArguments in
444-
let (argsKeyRef, argsForMake) = List.partition argIsKeyRef argsWithLabels in
445-
let childrenExpr = transformChildrenIfList ~loc ~mapper children in
446-
let recursivelyTransformedArgsForMake = argsForMake |> List.map (fun (label, expression) -> (label, mapper.expr mapper expression)) in
447-
let args = recursivelyTransformedArgsForMake @ [ (nolabel, childrenExpr) ] in
448-
let wrapWithReasonReactElement e = (* ReasonReact.element(~key, ~ref, ...) *)
449-
Exp.apply
450-
~loc
451-
(Exp.ident ~loc {loc; txt = Ldot (Lident "ReasonReact", "element")})
452-
(argsKeyRef @ [(nolabel, e)]) in
453-
Exp.apply
454-
~loc
455-
~attrs
456-
(* Foo.make *)
457-
(Exp.ident ~loc {loc; txt = Ldot (modulePath, "make")})
458-
args
459-
|> wrapWithReasonReactElement in
460-
461-
let transformLowercaseCall mapper loc attrs callArguments id =
462-
let (children, nonChildrenProps) = extractChildren ~loc callArguments in
463-
let componentNameExpr = constantString ~loc id in
464-
let childrenExpr = transformChildrenIfList ~loc ~mapper children in
465-
let createElementCall = match children with
466-
(* [@JSX] div(~children=[a]), coming from <div> a </div> *)
467-
| {
468-
pexp_desc =
469-
Pexp_construct ({txt = Lident "::"}, Some {pexp_desc = Pexp_tuple _ })
470-
| Pexp_construct ({txt = Lident "[]"}, None)
471-
} -> "createElement"
472-
(* [@JSX] div(~children=[|a|]), coming from <div> ...[|a|] </div> *)
473-
| { pexp_desc = (Pexp_array _) } ->
474-
raise (Invalid_argument "A spread + an array literal as a DOM element's \
475-
children would cancel each other out, and thus don't make sense written \
476-
together. You can simply remove the spread and the array literal.")
477-
(* [@JSX] div(~children= <div />), coming from <div> ...<div/> </div> *)
478-
| {
479-
pexp_attributes
480-
} when pexp_attributes |> List.exists (fun (attribute, _) -> attribute.txt = "JSX") ->
481-
raise (Invalid_argument "A spread + a JSX literal as a DOM element's \
482-
children don't make sense written together. You can simply remove the spread.")
483-
| _ -> "createElementVariadic"
484-
in
485-
let args = match nonChildrenProps with
486-
| [_justTheUnitArgumentAtEnd] ->
487-
[
488-
(* "div" *)
489-
(nolabel, componentNameExpr);
490-
(* [|moreCreateElementCallsHere|] *)
491-
(nolabel, childrenExpr)
492-
]
493-
| nonEmptyProps ->
494-
let propsCall =
495-
Exp.apply
496-
~loc
497-
(Exp.ident ~loc {loc; txt = Ldot (Lident "ReactDOMRe", "props")})
498-
(nonEmptyProps |> List.map (fun (label, expression) -> (label, mapper.expr mapper expression)))
499-
in
500-
[
501-
(* "div" *)
502-
(nolabel, componentNameExpr);
503-
(* ReactDOMRe.props(~className=blabla, ~foo=bar, ()) *)
504-
(labelled "props", propsCall);
505-
(* [|moreCreateElementCallsHere|] *)
506-
(nolabel, childrenExpr)
507-
] in
508-
Exp.apply
509-
~loc
510-
(* throw away the [@JSX] attribute and keep the others, if any *)
511-
~attrs
512-
(* ReactDOMRe.createElement *)
513-
(Exp.ident ~loc {loc; txt = Ldot (Lident "ReactDOMRe", createElementCall)})
514-
args
515-
in
442+
443+
516444

517445
let rec recursivelyTransformNamedArgsForMake mapper expr list =
518446
let expr = mapper.expr mapper expr in
@@ -932,20 +860,18 @@ let jsxMapper () =
932860
(* Foo.createElement(~prop1=foo, ~prop2=bar, ~children=[], ()) *)
933861
| {loc; txt = Ldot (modulePath, ("createElement" | "make"))} ->
934862
(match !jsxVersion with
935-
| Some 2 -> transformUppercaseCall modulePath mapper loc attrs callExpression callArguments
936863
| None
937864
| Some 3 -> transformUppercaseCall3 modulePath mapper loc attrs callExpression callArguments
938-
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
865+
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 3"))
939866

940867
(* div(~prop1=foo, ~prop2=bar, ~children=[bla], ()) *)
941868
(* turn that into
942869
ReactDOMRe.createElement(~props=ReactDOMRe.props(~props1=foo, ~props2=bar, ()), [|bla|]) *)
943870
| {loc; txt = Lident id} ->
944871
(match !jsxVersion with
945-
| Some 2 -> transformLowercaseCall mapper loc attrs callArguments id
946872
| None
947873
| Some 3 -> transformLowercaseCall3 mapper loc attrs callArguments id
948-
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 2 or 3"))
874+
| Some _ -> raise (Invalid_argument "JSX: the JSX version must be 3"))
949875

950876
| {txt = Ldot (_, anythingNotCreateElementOrMake)} ->
951877
raise (

0 commit comments

Comments
 (0)