diff --git a/ppx/test/hover.t b/ppx/test/hover.t new file mode 100644 index 00000000..7b147d8a --- /dev/null +++ b/ppx/test/hover.t @@ -0,0 +1,76 @@ +Test some locations in reason-react components, reproduces #840 + + $ cat >dune-project < (lang dune 3.13) + > (using melange 0.1) + > EOF + + $ cat >dune < (melange.emit + > (alias foo) + > (target foo) + > (libraries reason-react) + > (emit_stdlib false) + > (preprocess + > (pps melange.ppx reason-react-ppx))) + > EOF + + $ cat >component.ml < let[@react.component] make ~foo ~bar = + > (div + > ~children:[ React.string foo; bar |> string_of_int |> React.string ] + > () [@JSX]) + > EOF + $ dune build @foo + +Let's test hovering over parts of the component + +`React.string`: + + $ ocamlmerlin single type-enclosing -position 3:25 -verbosity 0 \ + > -filename component.ml < component.ml | jq '.value' + [ + { + "start": { + "line": 3, + "col": 17 + }, + "end": { + "line": 3, + "col": 29 + }, + "type": "string -> React.element", + "tail": "no" + }, + { + "start": { + "line": 1, + "col": 0 + }, + "end": { + "line": 4, + "col": 15 + }, + "type": "< bar : int; foo : string > Js.t -> React.element", + "tail": "no" + } + ] + +The `foo` variable inside the component body + + $ ocamlmerlin single type-enclosing -position 3:31 -verbosity 0 \ + > -filename component.ml < component.ml | jq '.value' + [ + { + "start": { + "line": 1, + "col": 0 + }, + "end": { + "line": 4, + "col": 15 + }, + "type": "< bar : int; foo : string > Js.t -> React.element", + "tail": "no" + } + ]