mirror of
https://github.com/sbrow/thor.git
synced 2026-08-26 11:23:32 -04:00
style: Cleaned up #partial switches.
This commit is contained in:
@@ -302,3 +302,4 @@ write_value :: proc(b: ^strings.Builder, a: any, escape: bool) {
|
|||||||
strings.write_string(b, s[start:])
|
strings.write_string(b, s[start:])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -78,9 +78,11 @@ Node :: struct {
|
|||||||
// 1 for leaf nodes, 1 + len(children) for container nodes (whose children
|
// 1 for leaf nodes, 1 + len(children) for container nodes (whose children
|
||||||
// are stored contiguously after them in the array).
|
// are stored contiguously after them in the array).
|
||||||
node_span :: proc(n: Node) -> int {
|
node_span :: proc(n: Node) -> int {
|
||||||
#partial switch n.kind {
|
switch n.kind {
|
||||||
case .Section, .Inverted, .Parent, .Block:
|
case .Section, .Inverted, .Parent, .Block:
|
||||||
return 1 + len(n.children)
|
return 1 + len(n.children)
|
||||||
|
case .Text, .Variable, .Unescaped, .Partial:
|
||||||
|
fallthrough
|
||||||
case:
|
case:
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
@@ -374,7 +376,7 @@ parse_section :: proc(
|
|||||||
deindent_blocks :: proc(nodes: []Node, allocator := context.allocator) {
|
deindent_blocks :: proc(nodes: []Node, allocator := context.allocator) {
|
||||||
i := 0
|
i := 0
|
||||||
for i < len(nodes) {
|
for i < len(nodes) {
|
||||||
#partial switch nodes[i].kind {
|
switch nodes[i].kind {
|
||||||
case .Block:
|
case .Block:
|
||||||
if len(nodes[i].children) > 0 {
|
if len(nodes[i].children) > 0 {
|
||||||
children := nodes[i].children
|
children := nodes[i].children
|
||||||
@@ -401,6 +403,8 @@ deindent_blocks :: proc(nodes: []Node, allocator := context.allocator) {
|
|||||||
if len(nodes[i].children) > 0 {
|
if len(nodes[i].children) > 0 {
|
||||||
deindent_blocks(nodes[i].children, allocator)
|
deindent_blocks(nodes[i].children, allocator)
|
||||||
}
|
}
|
||||||
|
case .Text, .Variable, .Unescaped, .Partial:
|
||||||
|
// Do nothing
|
||||||
}
|
}
|
||||||
i += node_span(nodes[i])
|
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())
|
diag := format_error(path, current.source, node.pos, msg, "", colorize = should_colorize())
|
||||||
log.warnf("%s", diag)
|
log.warnf("%s", diag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ compile_query :: proc(
|
|||||||
if query == nil {
|
if query == nil {
|
||||||
tok := extract_query_token(transmute([]byte)query_src, err_offset)
|
tok := extract_query_token(transmute([]byte)query_src, err_offset)
|
||||||
cause := fmt.tprintf("query error at byte %d (type %v)", err_offset, err_type)
|
cause := fmt.tprintf("query error at byte %d (type %v)", err_offset, err_type)
|
||||||
#partial switch err_type {
|
switch err_type {
|
||||||
case .NodeType:
|
case .NodeType:
|
||||||
if tok != "" {
|
if tok != "" {
|
||||||
cause = fmt.tprintf(
|
cause = fmt.tprintf(
|
||||||
@@ -295,6 +295,7 @@ compile_query :: proc(
|
|||||||
cause = fmt.tprintf("query has an illegal pattern structure at byte %d", err_offset)
|
cause = fmt.tprintf("query has an illegal pattern structure at byte %d", err_offset)
|
||||||
case .Language:
|
case .Language:
|
||||||
cause = "grammar language is null (broken grammar .so)"
|
cause = "grammar language is null (broken grammar .so)"
|
||||||
|
case .None:
|
||||||
}
|
}
|
||||||
log.errorf("treesitter: %s query failed: %s", lang, cause)
|
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 ""
|
if end <= start do return ""
|
||||||
return path[start:end]
|
return path[start:end]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ mount_recursive :: proc(vfs: ^VFS, current_dir: string, target_prefix: string) {
|
|||||||
defer os.file_info_slice_delete(entries, context.allocator)
|
defer os.file_info_slice_delete(entries, context.allocator)
|
||||||
|
|
||||||
for entry in entries {
|
for entry in entries {
|
||||||
#partial switch entry.type {
|
switch entry.type {
|
||||||
case .Regular:
|
case .Regular:
|
||||||
virtual := fmt.tprintf("%s/%s", target_prefix, entry.name)
|
virtual := fmt.tprintf("%s/%s", target_prefix, entry.name)
|
||||||
vfs.files[virtual] = VFS_Entry {
|
vfs.files[virtual] = VFS_Entry {
|
||||||
@@ -58,7 +58,7 @@ mount_recursive :: proc(vfs: ^VFS, current_dir: string, target_prefix: string) {
|
|||||||
case .Directory:
|
case .Directory:
|
||||||
sub_prefix := fmt.tprintf("%s/%s", target_prefix, entry.name)
|
sub_prefix := fmt.tprintf("%s/%s", target_prefix, entry.name)
|
||||||
mount_recursive(vfs, entry.fullpath, sub_prefix)
|
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
|
return data, true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user