|
1 | 1 | let loc_to_string (loc : Warnings.loc) : string = |
2 | | - Format.sprintf "(%03d,%03d--%03d,%03d)" loc.loc_start.pos_lnum |
| 2 | + Format.sprintf "(%02d,%02d--%02d,%02d)" loc.loc_start.pos_lnum |
3 | 3 | (loc.loc_start.pos_cnum - loc.loc_start.pos_bol) |
4 | 4 | loc.loc_end.pos_lnum |
5 | 5 | (loc.loc_end.pos_cnum - loc.loc_end.pos_bol) |
@@ -47,6 +47,9 @@ let dump ?filter rescript_json cmt_path = |
47 | 47 | | Some (Cursor (line, col)) -> |
48 | 48 | Printf.printf "Filtering by cursor %d,%d\n" line col |
49 | 49 | | Some (Loc loc) -> Printf.printf "Filtering by loc %s\n" (Loc.toString loc)); |
| 50 | + |
| 51 | + Printf.printf "file moduleName: %s\n\n" full.file.moduleName; |
| 52 | + |
50 | 53 | let stamps = |
51 | 54 | full.file.stamps |> getEntries |
52 | 55 | |> List.filter (fun (_, stamp) -> applyFilter (locOfKind stamp)) |
@@ -78,6 +81,34 @@ let dump ?filter rescript_json cmt_path = |
78 | 81 | Printf.printf "%d kconstructor %s\n" stamp |
79 | 82 | (loc_to_string t.extentLoc)); |
80 | 83 |
|
| 84 | + (* dump the structure *) |
| 85 | + let rec dump_structure indent (structure : Module.structure) = |
| 86 | + if indent > 0 then Printf.printf "%s" (String.make indent ' '); |
| 87 | + Printf.printf "Structure %s:\n" structure.name; |
| 88 | + structure.items |> List.iter (dump_structure_item (indent + 2)) |
| 89 | + and dump_structure_item indent item = |
| 90 | + if indent > 0 then Printf.printf "%s" (String.make indent ' '); |
| 91 | + let open Module in |
| 92 | + match item.kind with |
| 93 | + | Value _typedExpr -> |
| 94 | + Printf.printf "Value %s %s\n" item.name (loc_to_string item.loc) |
| 95 | + | Type _ -> |
| 96 | + Printf.printf "Type %s %s\n" item.name (loc_to_string item.loc) |
| 97 | + | Module {type_ = m} -> |
| 98 | + Printf.printf "Module %s %s\n" item.name (loc_to_string item.loc); |
| 99 | + dump_module indent m |
| 100 | + and dump_module indent (module_ : Module.t) = |
| 101 | + match module_ with |
| 102 | + | Ident path -> Printf.printf "Module (Ident) %s\n" (Path.to_string path) |
| 103 | + | Structure structure -> dump_structure indent structure |
| 104 | + | Constraint (m1, m2) -> |
| 105 | + dump_module indent m1; |
| 106 | + dump_module indent m2 |
| 107 | + in |
| 108 | + |
| 109 | + print_newline (); |
| 110 | + dump_structure 0 full.file.structure; |
| 111 | + |
81 | 112 | (* Dump all locItems (typed nodes) *) |
82 | 113 | let locItems = |
83 | 114 | match full.extra with |
|
0 commit comments