write dot graph to file
This commit is contained in:
@ -68,7 +68,7 @@ let str_of_primary_value (exp : Typedtree.expression) =
|
|||||||
| Texp_ifthenelse (_, _, None) -> Fmt.str "if/then"
|
| Texp_ifthenelse (_, _, None) -> Fmt.str "if/then"
|
||||||
| _ -> "????"
|
| _ -> "????"
|
||||||
|
|
||||||
let dot_of_impl (s : Typedtree.structure) : unit =
|
let graph_of_impl (s : Typedtree.structure) : G.t =
|
||||||
let g = G.create () in
|
let g = G.create () in
|
||||||
let iterator =
|
let iterator =
|
||||||
{
|
{
|
||||||
@ -104,9 +104,10 @@ let dot_of_impl (s : Typedtree.structure) : unit =
|
|||||||
in
|
in
|
||||||
iterator.structure iterator s;
|
iterator.structure iterator s;
|
||||||
Log.info (fun m ->
|
Log.info (fun m ->
|
||||||
m "dot_of_impl fprint_graph:@ %a" Dot.fprint_graph g)
|
m "g_of_impl fprint_graph:@ %a" Dot.fprint_graph g);
|
||||||
|
g
|
||||||
|
|
||||||
let merlin_parse str : unit =
|
let merlin_parse str : G.t =
|
||||||
let config, _command_args =
|
let config, _command_args =
|
||||||
Mconfig.parse_arguments ~wd:(Sys.getcwd ())
|
Mconfig.parse_arguments ~wd:(Sys.getcwd ())
|
||||||
~warning:(fun _ -> ())
|
~warning:(fun _ -> ())
|
||||||
@ -127,5 +128,12 @@ let merlin_parse str : unit =
|
|||||||
(Untypeast.untype_structure t));
|
(Untypeast.untype_structure t));
|
||||||
Log.info (fun m ->
|
Log.info (fun m ->
|
||||||
m "Printtyped:@ %a" Ocaml_typing.Printtyped.implementation t);
|
m "Printtyped:@ %a" Ocaml_typing.Printtyped.implementation t);
|
||||||
dot_of_impl t
|
graph_of_impl t
|
||||||
| `Interface _ -> ()
|
| `Interface _ -> G.create ()
|
||||||
|
|
||||||
|
let dot_of_tast ?(fname = "x.dot") str : unit =
|
||||||
|
let oc = open_out fname in
|
||||||
|
F.pf
|
||||||
|
(Format.formatter_of_out_channel oc)
|
||||||
|
"%a" Dot.fprint_graph (merlin_parse str);
|
||||||
|
close_out oc
|
||||||
|
|||||||
@ -1 +1 @@
|
|||||||
val merlin_parse : string -> unit
|
val dot_of_tast : ?fname:string -> string -> unit
|
||||||
|
|||||||
Reference in New Issue
Block a user