mirror of
https://github.com/ziglang/zig.git
synced 2026-02-02 12:43:40 +00:00
zig fmt: deref, unwrap optional
This commit is contained in:
parent
725adf8332
commit
4428acf0f7
@ -462,6 +462,7 @@ pub const Tree = struct {
|
||||
.UndefinedLiteral,
|
||||
.UnreachableLiteral,
|
||||
.Identifier,
|
||||
.Deref,
|
||||
=> return main_tokens[n] + end_offset,
|
||||
|
||||
.Call,
|
||||
@ -515,7 +516,6 @@ pub const Tree = struct {
|
||||
.Asm => unreachable, // TODO
|
||||
.SliceOpen => unreachable, // TODO
|
||||
.Slice => unreachable, // TODO
|
||||
.Deref => unreachable, // TODO
|
||||
.ArrayInitOne => unreachable, // TODO
|
||||
.ArrayInit => unreachable, // TODO
|
||||
.StructInitOne => unreachable, // TODO
|
||||
|
||||
@ -1503,15 +1503,15 @@ test "zig fmt: top-level fields" {
|
||||
// \\
|
||||
// );
|
||||
//}
|
||||
//
|
||||
//test "zig fmt: ptr deref operator and unwrap optional operator" {
|
||||
// try testCanonical(
|
||||
// \\const a = b.*;
|
||||
// \\const a = b.?;
|
||||
// \\
|
||||
// );
|
||||
//}
|
||||
//
|
||||
|
||||
test "zig fmt: ptr deref operator and unwrap optional operator" {
|
||||
try testCanonical(
|
||||
\\const a = b.*;
|
||||
\\const a = b.?;
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
//test "zig fmt: comment after if before another if" {
|
||||
// try testCanonical(
|
||||
// \\test "aoeu" {
|
||||
|
||||
@ -991,21 +991,16 @@ fn renderExpression(ais: *Ais, tree: ast.Tree, node: ast.Node.Index, space: Spac
|
||||
// return renderToken(ais, tree, suffix_op.rtoken, space); // ]
|
||||
//},
|
||||
|
||||
.Deref => unreachable, // TODO
|
||||
//.Deref => {
|
||||
// const suffix_op = base.castTag(.Deref).?;
|
||||
.Deref => {
|
||||
try renderExpression(ais, tree, datas[node].lhs, .None);
|
||||
return renderToken(ais, tree, main_tokens[node], space);
|
||||
},
|
||||
|
||||
// try renderExpression(ais, tree, suffix_op.lhs, Space.None);
|
||||
// return renderToken(ais, tree, suffix_op.rtoken, space); // .*
|
||||
//},
|
||||
.UnwrapOptional => unreachable, // TODO
|
||||
//.UnwrapOptional => {
|
||||
// const suffix_op = base.castTag(.UnwrapOptional).?;
|
||||
|
||||
// try renderExpression(ais, tree, suffix_op.lhs, Space.None);
|
||||
// try renderToken(ais, tree, tree.prevToken(suffix_op.rtoken), Space.None); // .
|
||||
// return renderToken(ais, tree, suffix_op.rtoken, space); // ?
|
||||
//},
|
||||
.UnwrapOptional => {
|
||||
try renderExpression(ais, tree, datas[node].lhs, .None);
|
||||
try renderToken(ais, tree, main_tokens[node], .None);
|
||||
return renderToken(ais, tree, datas[node].rhs, space);
|
||||
},
|
||||
|
||||
.Break => unreachable, // TODO
|
||||
//.Break => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user