diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-08-26 15:54:54 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-08-26 15:54:54 -0400 |
| commit | 76aac20d8ed7482f4ee7f3b3a69e3e08138251fa (patch) | |
| tree | afaff56b67618d185f2282608a543a32f4c520ef /src | |
| parent | e5677cb9a670ca9e1e4c5d47f3c130622c619772 (diff) | |
Add formatting for defer
Diffstat (limited to 'src')
| -rw-r--r-- | src/formatter/formatter.c | 4 | ||||
| -rw-r--r-- | src/formatter/utils.c | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/src/formatter/formatter.c b/src/formatter/formatter.c index 6f0fc5aa..64158876 100644 --- a/src/formatter/formatter.c +++ b/src/formatter/formatter.c @@ -54,6 +54,8 @@ OptionalText_t format_inline_code(ast_t *ast, Table_t comments) { Text_t message = fmt_inline(assert->message, comments); return Texts("assert ", expr, ", ", message); } + /*inline*/ case Defer: + return Texts("defer ", fmt_inline(Match(ast, Defer)->body, comments)); /*inline*/ case Lambda: { DeclareMatch(lambda, ast, Lambda); Text_t code = Texts("func(", format_inline_args(lambda->args, comments)); @@ -459,6 +461,8 @@ Text_t format_code(ast_t *ast, Table_t comments, Text_t indent) { DeclareMatch(extend, ast, Extend); return Texts("lang ", Text$from_str(extend->name), format_namespace(extend->body, comments, indent)); } + /*inline*/ case Defer: + return Texts("defer ", format_namespace(Match(ast, Defer)->body, comments, indent)); /*multiline*/ case List: /*multiline*/ case Set: { if (inlined_fits) return inlined; diff --git a/src/formatter/utils.c b/src/formatter/utils.c index fa4ec806..084a6667 100644 --- a/src/formatter/utils.c +++ b/src/formatter/utils.c @@ -51,7 +51,8 @@ CONSTFUNC bool should_have_blank_line(ast_t *ast) { case EnumDef: case LangDef: case ConvertDef: - case Extend: return true; + case Extend: + case Defer: return true; default: return false; } } |
