File tree Expand file tree Collapse file tree 2 files changed +12
-18
lines changed Expand file tree Collapse file tree 2 files changed +12
-18
lines changed Original file line number Diff line number Diff line change @@ -4909,16 +4909,11 @@ and parse_type_constructor_declaration_with_bar p =
49094909 let start_pos = p.Parser. start_pos in
49104910 Parser. next p;
49114911 let constr = parse_type_constructor_declaration ~start_pos p in
4912+ (* if there is doc comment attached, we ensure that the constructor is placed at the same line
4913+ as the bar *)
49124914 let pcd_loc =
49134915 if has_doc_comment then
4914- {
4915- constr.Parsetree. pcd_loc with
4916- loc_end =
4917- {
4918- constr.pcd_loc.loc_end with
4919- pos_lnum = constr.pcd_loc.loc_end.pos_lnum + 1 ;
4920- };
4921- }
4916+ {constr.Parsetree. pcd_loc with loc_end = start_pos}
49224917 else constr.pcd_loc
49234918 in
49244919 Some
@@ -4968,16 +4963,11 @@ and parse_type_constructor_declarations ?first p =
49684963 let start_pos = p.Parser. start_pos in
49694964 ignore (Parser. optional p Token. Bar );
49704965 let constr = parse_type_constructor_declaration ~start_pos p in
4966+ (* if there is doc comment attached, we ensure that the constructor is placed at the same line
4967+ as the bar *)
49714968 let pcd_loc =
49724969 if has_doc_comment then
4973- {
4974- constr.Parsetree. pcd_loc with
4975- loc_end =
4976- {
4977- constr.pcd_loc.loc_end with
4978- pos_lnum = constr.pcd_loc.loc_end.pos_lnum + 1 ;
4979- };
4980- }
4970+ {constr.Parsetree. pcd_loc with loc_end = start_pos}
49814971 else constr.pcd_loc
49824972 in
49834973 {
Original file line number Diff line number Diff line change @@ -1549,11 +1549,15 @@ and print_constructor_declarations ~state ~private_flag
15491549
15501550and print_constructor_declaration2 ~state i
15511551 (cd : Parsetree.constructor_declaration ) cmt_tbl =
1552- let comment_attrs, attrs = ParsetreeViewer. partition_doc_comment_attributes cd.pcd_attributes in
1552+ let comment_attrs, attrs =
1553+ ParsetreeViewer. partition_doc_comment_attributes cd.pcd_attributes
1554+ in
15531555 let comment_doc =
15541556 match comment_attrs with
15551557 | [] -> Doc. nil
1556- | comment_attrs -> print_doc_comments ~sep: Doc. hard_line ~state cmt_tbl comment_attrs in
1558+ | comment_attrs ->
1559+ print_doc_comments ~sep: Doc. hard_line ~state cmt_tbl comment_attrs
1560+ in
15571561 let attrs = print_attributes ~state attrs cmt_tbl in
15581562 let is_dot_dot_dot = cd.pcd_name.txt = " ..." in
15591563 let bar =
You can’t perform that action at this time.
0 commit comments