diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-24 21:20:56 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-06-24 21:56:09 -0400 |
| commit | 98d8cc304ee4e433e9011c1e2faef779ae86df35 (patch) | |
| tree | 49cc6f857b65d79ce0d4b1cd4bf17c0219afe365 /src/server/clone.odin | |
| parent | e4804807bb7c7a26b2bff10919d719a1a430870f (diff) | |
Correctly clone comment groups
Diffstat (limited to 'src/server/clone.odin')
| -rw-r--r-- | src/server/clone.odin | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/server/clone.odin b/src/server/clone.odin index c49152d..43f8d24 100644 --- a/src/server/clone.odin +++ b/src/server/clone.odin @@ -33,6 +33,7 @@ clone_type :: proc { clone_expr, clone_array, clone_dynamic_array, + clone_comment_group, } clone_array :: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A { @@ -279,8 +280,27 @@ clone_node :: proc(node: ^ast.Node, allocator: mem.Allocator, unique_strings: ^m case ^Or_Else_Expr: r.x = clone_type(r.x, allocator, unique_strings) r.y = clone_type(r.y, allocator, unique_strings) + case ^Comment_Group: + list := make([dynamic]tokenizer.Token, 0, len(r.list), allocator) + for t in r.list { + append(&list, tokenizer.Token { + text = strings.clone(t.text, allocator), + kind = t.kind, + pos = tokenizer.Pos { + file = strings.clone(t.pos.file, allocator), + offset = t.pos.offset, + line = t.pos.line, + column = t.pos.column, + }, + }) + } + r.list = list[:] case: } return res } + +clone_comment_group :: proc(node: ^ast.Comment_Group, allocator: mem.Allocator, unique_strings: ^map[string]string) -> ^ast.Comment_Group { + return cast(^ast.Comment_Group)clone_node(node, allocator, unique_strings) +} |