formatting of if expressions
This commit is contained in:
parent
d7d28ca3b5
commit
97ee572be7
|
|
@ -3387,6 +3387,23 @@ namespace CodeFormatters
|
|||
visit_node(diap.left);
|
||||
visit_node(diap.right);
|
||||
}
|
||||
|
||||
public override void visit(if_expr_new _if_expr_new)
|
||||
{
|
||||
sb.Append("if"); //sb.Append(" ");
|
||||
SetKeywordOffset("if");
|
||||
read_from_beg_pos = true;
|
||||
visit_node(_if_expr_new.condition);
|
||||
if (!in_one_row(_if_expr_new.condition))
|
||||
add_newline_after = true;
|
||||
add_space_before = true;
|
||||
visit_node(_if_expr_new.if_true);
|
||||
if (_if_expr_new.if_false != null)
|
||||
{
|
||||
add_space_before = true;
|
||||
visit_node(_if_expr_new.if_false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
3
TestSuite/formatter_tests/input/ifexpr1.pas
Normal file
3
TestSuite/formatter_tests/input/ifexpr1.pas
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin
|
||||
var b:=if i<2 then (2+4)*4 else 3+5;
|
||||
end.
|
||||
3
TestSuite/formatter_tests/input/ifexpr2.pas
Normal file
3
TestSuite/formatter_tests/input/ifexpr2.pas
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin
|
||||
var b := if a<2 then 2+3 else if a>3 then 2+5 else 3+4;
|
||||
end.
|
||||
3
TestSuite/formatter_tests/should/ifexpr1.pas
Normal file
3
TestSuite/formatter_tests/should/ifexpr1.pas
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin
|
||||
var b := if i < 2 then (2 + 4) * 4 else 3 + 5;
|
||||
end.
|
||||
3
TestSuite/formatter_tests/should/ifexpr2.pas
Normal file
3
TestSuite/formatter_tests/should/ifexpr2.pas
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
begin
|
||||
var b := if a < 2 then 2 + 3 else if a > 3 then 2 + 5 else 3 + 4;
|
||||
end.
|
||||
Loading…
Reference in a new issue