mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
zig fmt: fix Tree.lastToken() for empty *Two nodes
This commit is contained in:
parent
4c8caf3343
commit
b6448a533d
@ -676,20 +676,11 @@ pub const Tree = struct {
|
||||
},
|
||||
.ArrayInitDotTwo,
|
||||
.BlockTwo,
|
||||
.BuiltinCallTwo,
|
||||
.StructInitDotTwo,
|
||||
.ContainerDeclTwo,
|
||||
.TaggedUnionTwo,
|
||||
=> {
|
||||
end_offset += 1; // for the rparen/rbrace
|
||||
if (datas[n].rhs != 0) {
|
||||
n = datas[n].rhs;
|
||||
} else if (datas[n].lhs != 0) {
|
||||
n = datas[n].lhs;
|
||||
} else {
|
||||
return main_tokens[n] + end_offset;
|
||||
}
|
||||
},
|
||||
.BuiltinCallTwo => {
|
||||
if (datas[n].rhs != 0) {
|
||||
end_offset += 1; // for the rparen/rbrace
|
||||
n = datas[n].rhs;
|
||||
@ -697,7 +688,17 @@ pub const Tree = struct {
|
||||
end_offset += 1; // for the rparen/rbrace
|
||||
n = datas[n].lhs;
|
||||
} else {
|
||||
end_offset += 2; // for the lparen and rparen
|
||||
switch (tags[n]) {
|
||||
.ArrayInitDotTwo,
|
||||
.BlockTwo,
|
||||
.StructInitDotTwo,
|
||||
=> end_offset += 1, // rbrace
|
||||
.BuiltinCallTwo,
|
||||
.ContainerDeclTwo,
|
||||
=> end_offset += 2, // lparen/lbrace + rparen/rbrace
|
||||
.TaggedUnionTwo => end_offset += 5, // (enum) {}
|
||||
else => unreachable,
|
||||
}
|
||||
return main_tokens[n] + end_offset;
|
||||
}
|
||||
},
|
||||
@ -2708,7 +2709,7 @@ pub const Node = struct {
|
||||
/// `{}`. `sub_list[lhs..rhs]`.
|
||||
/// main_token points at the lbrace.
|
||||
Block,
|
||||
/// Same as BlockTwo but there is known to be a semicolon before the rbrace.
|
||||
/// Same as Block but there is known to be a semicolon before the rbrace.
|
||||
BlockSemicolon,
|
||||
/// `asm(lhs)`. rhs is the token index of the rparen.
|
||||
AsmSimple,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user