From 89c2ffbf78100c4c516b587558f04192dfe86255 Mon Sep 17 00:00:00 2001 From: Spencer Brower <6729162+sbrow@users.noreply.github.com> Date: Thu, 30 Jul 2026 11:12:20 -0400 Subject: [PATCH] style: Cleaned up `#partial` switches. --- mustache/data.odin | 1 + mustache/mustache.odin | 9 +++++++-- treesitter/treesitter.odin | 4 +++- vfs.odin | 5 +++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/mustache/data.odin b/mustache/data.odin index c859a43..e0dd657 100644 --- a/mustache/data.odin +++ b/mustache/data.odin @@ -302,3 +302,4 @@ write_value :: proc(b: ^strings.Builder, a: any, escape: bool) { strings.write_string(b, s[start:]) } } + diff --git a/mustache/mustache.odin b/mustache/mustache.odin index aea0bc8..ade4ea4 100644 --- a/mustache/mustache.odin +++ b/mustache/mustache.odin @@ -78,9 +78,11 @@ Node :: struct { // 1 for leaf nodes, 1 + len(children) for container nodes (whose children // are stored contiguously after them in the array). node_span :: proc(n: Node) -> int { - #partial switch n.kind { + switch n.kind { case .Section, .Inverted, .Parent, .Block: return 1 + len(n.children) + case .Text, .Variable, .Unescaped, .Partial: + fallthrough case: return 1 } @@ -374,7 +376,7 @@ parse_section :: proc( deindent_blocks :: proc(nodes: []Node, allocator := context.allocator) { i := 0 for i < len(nodes) { - #partial switch nodes[i].kind { + switch nodes[i].kind { case .Block: if len(nodes[i].children) > 0 { children := nodes[i].children @@ -401,6 +403,8 @@ deindent_blocks :: proc(nodes: []Node, allocator := context.allocator) { if len(nodes[i].children) > 0 { deindent_blocks(nodes[i].children, allocator) } + case .Text, .Variable, .Unescaped, .Partial: + // Do nothing } i += node_span(nodes[i]) } @@ -981,3 +985,4 @@ warn_context_depth :: proc(current: Template, node: Node) { diag := format_error(path, current.source, node.pos, msg, "", colorize = should_colorize()) log.warnf("%s", diag) } + diff --git a/treesitter/treesitter.odin b/treesitter/treesitter.odin index 3522f15..f3a6d66 100644 --- a/treesitter/treesitter.odin +++ b/treesitter/treesitter.odin @@ -269,7 +269,7 @@ compile_query :: proc( if query == nil { tok := extract_query_token(transmute([]byte)query_src, err_offset) cause := fmt.tprintf("query error at byte %d (type %v)", err_offset, err_type) - #partial switch err_type { + switch err_type { case .NodeType: if tok != "" { cause = fmt.tprintf( @@ -295,6 +295,7 @@ compile_query :: proc( cause = fmt.tprintf("query has an illegal pattern structure at byte %d", err_offset) case .Language: cause = "grammar language is null (broken grammar .so)" + case .None: } log.errorf("treesitter: %s query failed: %s", lang, cause) @@ -458,3 +459,4 @@ helix_version_from_path :: proc(path: string) -> string { if end <= start do return "" return path[start:end] } + diff --git a/vfs.odin b/vfs.odin index 3a96bb0..4934be7 100644 --- a/vfs.odin +++ b/vfs.odin @@ -49,7 +49,7 @@ mount_recursive :: proc(vfs: ^VFS, current_dir: string, target_prefix: string) { defer os.file_info_slice_delete(entries, context.allocator) for entry in entries { - #partial switch entry.type { + switch entry.type { case .Regular: virtual := fmt.tprintf("%s/%s", target_prefix, entry.name) vfs.files[virtual] = VFS_Entry { @@ -58,7 +58,7 @@ mount_recursive :: proc(vfs: ^VFS, current_dir: string, target_prefix: string) { case .Directory: sub_prefix := fmt.tprintf("%s/%s", target_prefix, entry.name) mount_recursive(vfs, entry.fullpath, sub_prefix) - case: + case .Undetermined, .Symlink, .Named_Pipe, .Socket, .Block_Device, .Character_Device: } } } @@ -109,3 +109,4 @@ vfs_entry_data :: proc(entry: VFS_Entry) -> ([]byte, bool) { } return data, true } +