diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-08-28 18:39:50 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-08-28 18:39:50 +0200 |
| commit | bd60025df3b54c22a8bcb5745b98a30f88162ddd (patch) | |
| tree | 7e128208304e2b5e1fcbaf7021764a4d5e948411 /src | |
| parent | 1c62e7c29a2d31260c4f45c6d0d1944061c93d23 (diff) | |
Add config for inline single case stmts
Diffstat (limited to 'src')
| -rw-r--r-- | src/odin/printer/printer.odin | 21 | ||||
| -rw-r--r-- | src/odin/printer/visit.odin | 4 |
2 files changed, 13 insertions, 12 deletions
diff --git a/src/odin/printer/printer.odin b/src/odin/printer/printer.odin index 5a36bcb..1c5f5b2 100644 --- a/src/odin/printer/printer.odin +++ b/src/odin/printer/printer.odin @@ -40,16 +40,17 @@ Disabled_Info :: struct { } Config :: struct { - character_width: int, - spaces: int, //Spaces per indentation - newline_limit: int, //The limit of newlines between statements and declarations. - tabs: bool, //Enable or disable tabs - tabs_width: int, - convert_do: bool, //Convert all do statements to brace blocks - brace_style: Brace_Style, - indent_cases: bool, - newline_style: Newline_Style, - sort_imports: bool, + character_width: int, + spaces: int, //Spaces per indentation + newline_limit: int, //The limit of newlines between statements and declarations. + tabs: bool, //Enable or disable tabs + tabs_width: int, + convert_do: bool, //Convert all do statements to brace blocks + brace_style: Brace_Style, + indent_cases: bool, + newline_style: Newline_Style, + sort_imports: bool, + inline_single_stmt_case: bool, } Brace_Style :: enum { diff --git a/src/odin/printer/visit.odin b/src/odin/printer/visit.odin index c2161bd..02e2867 100644 --- a/src/odin/printer/visit.odin +++ b/src/odin/printer/visit.odin @@ -1044,7 +1044,7 @@ visit_stmt :: proc( if count := len(v.body); count > 0 { set_source_position(p, v.body[0].pos) fst_stmt, is_assign := v.body[0].derived_stmt.(^Assign_Stmt) - if is_assign && count == 1 { + if is_assign && count == 1 && p.config.inline_single_stmt_case { document = cons_with_opl(document, nest(visit_stmt(p, fst_stmt))) } else { document = cons(document, nest(cons(newline(1), visit_block_stmts(p, v.body)))) @@ -1550,7 +1550,7 @@ visit_expr :: proc( document = cons_with_nopl(document, text("#raw_union")) } - if v.is_no_copy { + if v.is_no_copy { document = cons_with_nopl(document, text("#no_copy")) } |