@@ -21,36 +21,9 @@ let copy tbl = {
2121
2222let empty = make ()
2323
24- let log t =
24+ let printEntries tbl =
2525 let open Location in
26- let leadingStuff = Hashtbl. fold (fun (k : Location.t ) (v : Comment.t list ) acc ->
27- let loc = Doc. concat [
28- Doc. lbracket;
29- Doc. text (string_of_int k.loc_start.pos_lnum);
30- Doc. text " :" ;
31- Doc. text (string_of_int (k.loc_start.pos_cnum - k.loc_start.pos_bol));
32- Doc. text " -" ;
33- Doc. text (string_of_int k.loc_end.pos_lnum);
34- Doc. text " :" ;
35- Doc. text (string_of_int (k.loc_end.pos_cnum - k.loc_end.pos_bol));
36- Doc. rbracket;
37- ] in
38- let doc = Doc. breakableGroup ~force Break:true (
39- Doc. concat [
40- loc;
41- Doc. indent (
42- Doc. concat [
43- Doc. line;
44- Doc. join ~sep: Doc. comma (List. map (fun c -> Doc. text (Comment. txt c)) v)
45- ]
46- );
47- Doc. line;
48- ]
49- ) in
50- doc::acc
51- ) t.leading []
52- in
53- let trailingStuff = Hashtbl. fold (fun (k : Location.t ) (v : Comment.t list ) acc ->
26+ Hashtbl. fold (fun (k : Location.t ) (v : Comment.t list ) acc ->
5427 let loc = Doc. concat [
5528 Doc. lbracket;
5629 Doc. text (string_of_int k.loc_start.pos_lnum);
@@ -75,18 +48,23 @@ let log t =
7548 ]
7649 ) in
7750 doc::acc
78- ) t.trailing []
79- in
51+ ) tbl []
52+
53+ let log t =
54+ let open Location in
55+ let leadingStuff = printEntries t.leading in
56+ let trailingStuff = printEntries t.trailing in
57+ let stuffInside = printEntries t.inside in
8058 Doc. breakableGroup ~force Break:true (
8159 Doc. concat [
8260 Doc. text " leading comments:" ;
61+ Doc. indent (Doc. concat [Doc. line; Doc. concat leadingStuff]);
8362 Doc. line;
84- Doc. indent ( Doc. concat leadingStuff) ;
85- Doc. line;
63+ Doc. text " comments inside: " ;
64+ Doc. indent ( Doc. concat [ Doc. line; Doc. concat stuffInside]) ;
8665 Doc. line;
8766 Doc. text " trailing comments:" ;
88- Doc. indent (Doc. concat trailingStuff);
89- Doc. line;
67+ Doc. indent (Doc. concat [Doc. line; Doc. concat trailingStuff]);
9068 Doc. line;
9169 ]
9270 ) |> Doc. toString ~width: 80 |> print_endline
0 commit comments