Commit 73cbc13a97

Meghan Denny <hello@nektro.net>
2022-01-08 02:27:58
std: fix zig.Ast being called Tree internally
1 parent adf7c65
Changed files (1)
lib
std
lib/std/zig/Ast.zig
@@ -16,7 +16,7 @@ const assert = std.debug.assert;
 const testing = std.testing;
 const mem = std.mem;
 const Token = std.zig.Token;
-const Tree = @This();
+const Ast = @This();
 
 pub const TokenIndex = u32;
 pub const ByteOffset = u32;
@@ -34,7 +34,7 @@ pub const Location = struct {
     line_end: usize,
 };
 
-pub fn deinit(tree: *Tree, gpa: mem.Allocator) void {
+pub fn deinit(tree: *Ast, gpa: mem.Allocator) void {
     tree.tokens.deinit(gpa);
     tree.nodes.deinit(gpa);
     gpa.free(tree.extra_data);
@@ -52,7 +52,7 @@ pub const RenderError = error{
 /// for allocating extra stack memory if needed, because this function utilizes recursion.
 /// Note: that's not actually true yet, see https://github.com/ziglang/zig/issues/1006.
 /// Caller owns the returned slice of bytes, allocated with `gpa`.
-pub fn render(tree: Tree, gpa: mem.Allocator) RenderError![]u8 {
+pub fn render(tree: Ast, gpa: mem.Allocator) RenderError![]u8 {
     var buffer = std.ArrayList(u8).init(gpa);
     defer buffer.deinit();
 
@@ -60,11 +60,11 @@ pub fn render(tree: Tree, gpa: mem.Allocator) RenderError![]u8 {
     return buffer.toOwnedSlice();
 }
 
-pub fn renderToArrayList(tree: Tree, buffer: *std.ArrayList(u8)) RenderError!void {
+pub fn renderToArrayList(tree: Ast, buffer: *std.ArrayList(u8)) RenderError!void {
     return @import("./render.zig").renderTree(buffer, tree);
 }
 
-pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenIndex) Location {
+pub fn tokenLocation(self: Ast, start_offset: ByteOffset, token_index: TokenIndex) Location {
     var loc = Location{
         .line = 0,
         .column = 0,
@@ -91,7 +91,7 @@ pub fn tokenLocation(self: Tree, start_offset: ByteOffset, token_index: TokenInd
     return loc;
 }
 
-pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 {
+pub fn tokenSlice(tree: Ast, token_index: TokenIndex) []const u8 {
     const token_starts = tree.tokens.items(.start);
     const token_tags = tree.tokens.items(.tag);
     const token_tag = token_tags[token_index];
@@ -112,7 +112,7 @@ pub fn tokenSlice(tree: Tree, token_index: TokenIndex) []const u8 {
     return tree.source[token.loc.start..token.loc.end];
 }
 
-pub fn extraData(tree: Tree, index: usize, comptime T: type) T {
+pub fn extraData(tree: Ast, index: usize, comptime T: type) T {
     const fields = std.meta.fields(T);
     var result: T = undefined;
     inline for (fields) |field, i| {
@@ -122,13 +122,13 @@ pub fn extraData(tree: Tree, index: usize, comptime T: type) T {
     return result;
 }
 
-pub fn rootDecls(tree: Tree) []const Node.Index {
+pub fn rootDecls(tree: Ast) []const Node.Index {
     // Root is always index 0.
     const nodes_data = tree.nodes.items(.data);
     return tree.extra_data[nodes_data[0].lhs..nodes_data[0].rhs];
 }
 
-pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
+pub fn renderError(tree: Ast, parse_error: Error, stream: anytype) !void {
     const token_tags = tree.tokens.items(.tag);
     switch (parse_error.tag) {
         .asterisk_after_ptr_deref => {
@@ -321,7 +321,7 @@ pub fn renderError(tree: Tree, parse_error: Error, stream: anytype) !void {
     }
 }
 
-pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex {
+pub fn firstToken(tree: Ast, node: Node.Index) TokenIndex {
     const tags = tree.nodes.items(.tag);
     const datas = tree.nodes.items(.data);
     const main_tokens = tree.nodes.items(.main_token);
@@ -625,7 +625,7 @@ pub fn firstToken(tree: Tree, node: Node.Index) TokenIndex {
     };
 }
 
-pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
+pub fn lastToken(tree: Ast, node: Node.Index) TokenIndex {
     const tags = tree.nodes.items(.tag);
     const datas = tree.nodes.items(.data);
     const main_tokens = tree.nodes.items(.main_token);
@@ -1157,13 +1157,13 @@ pub fn lastToken(tree: Tree, node: Node.Index) TokenIndex {
     };
 }
 
-pub fn tokensOnSameLine(tree: Tree, token1: TokenIndex, token2: TokenIndex) bool {
+pub fn tokensOnSameLine(tree: Ast, token1: TokenIndex, token2: TokenIndex) bool {
     const token_starts = tree.tokens.items(.start);
     const source = tree.source[token_starts[token1]..token_starts[token2]];
     return mem.indexOfScalar(u8, source, '\n') == null;
 }
 
-pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 {
+pub fn getNodeSource(tree: Ast, node: Node.Index) []const u8 {
     const token_starts = tree.tokens.items(.start);
     const first_token = tree.firstToken(node);
     const last_token = tree.lastToken(node);
@@ -1172,7 +1172,7 @@ pub fn getNodeSource(tree: Tree, node: Node.Index) []const u8 {
     return tree.source[start..end];
 }
 
-pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+pub fn globalVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
     assert(tree.nodes.items(.tag)[node] == .global_var_decl);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.GlobalVarDecl);
@@ -1186,7 +1186,7 @@ pub fn globalVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
     });
 }
 
-pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+pub fn localVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
     assert(tree.nodes.items(.tag)[node] == .local_var_decl);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.LocalVarDecl);
@@ -1200,7 +1200,7 @@ pub fn localVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
     });
 }
 
-pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+pub fn simpleVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
     assert(tree.nodes.items(.tag)[node] == .simple_var_decl);
     const data = tree.nodes.items(.data)[node];
     return tree.fullVarDecl(.{
@@ -1213,7 +1213,7 @@ pub fn simpleVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
     });
 }
 
-pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
+pub fn alignedVarDecl(tree: Ast, node: Node.Index) full.VarDecl {
     assert(tree.nodes.items(.tag)[node] == .aligned_var_decl);
     const data = tree.nodes.items(.data)[node];
     return tree.fullVarDecl(.{
@@ -1226,7 +1226,7 @@ pub fn alignedVarDecl(tree: Tree, node: Node.Index) full.VarDecl {
     });
 }
 
-pub fn ifSimple(tree: Tree, node: Node.Index) full.If {
+pub fn ifSimple(tree: Ast, node: Node.Index) full.If {
     assert(tree.nodes.items(.tag)[node] == .if_simple);
     const data = tree.nodes.items(.data)[node];
     return tree.fullIf(.{
@@ -1237,7 +1237,7 @@ pub fn ifSimple(tree: Tree, node: Node.Index) full.If {
     });
 }
 
-pub fn ifFull(tree: Tree, node: Node.Index) full.If {
+pub fn ifFull(tree: Ast, node: Node.Index) full.If {
     assert(tree.nodes.items(.tag)[node] == .@"if");
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.If);
@@ -1249,7 +1249,7 @@ pub fn ifFull(tree: Tree, node: Node.Index) full.If {
     });
 }
 
-pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField {
+pub fn containerField(tree: Ast, node: Node.Index) full.ContainerField {
     assert(tree.nodes.items(.tag)[node] == .container_field);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.ContainerField);
@@ -1261,7 +1261,7 @@ pub fn containerField(tree: Tree, node: Node.Index) full.ContainerField {
     });
 }
 
-pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField {
+pub fn containerFieldInit(tree: Ast, node: Node.Index) full.ContainerField {
     assert(tree.nodes.items(.tag)[node] == .container_field_init);
     const data = tree.nodes.items(.data)[node];
     return tree.fullContainerField(.{
@@ -1272,7 +1272,7 @@ pub fn containerFieldInit(tree: Tree, node: Node.Index) full.ContainerField {
     });
 }
 
-pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField {
+pub fn containerFieldAlign(tree: Ast, node: Node.Index) full.ContainerField {
     assert(tree.nodes.items(.tag)[node] == .container_field_align);
     const data = tree.nodes.items(.data)[node];
     return tree.fullContainerField(.{
@@ -1283,7 +1283,7 @@ pub fn containerFieldAlign(tree: Tree, node: Node.Index) full.ContainerField {
     });
 }
 
-pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
+pub fn fnProtoSimple(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
     assert(tree.nodes.items(.tag)[node] == .fn_proto_simple);
     const data = tree.nodes.items(.data)[node];
     buffer[0] = data.lhs;
@@ -1300,7 +1300,7 @@ pub fn fnProtoSimple(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.
     });
 }
 
-pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
+pub fn fnProtoMulti(tree: Ast, node: Node.Index) full.FnProto {
     assert(tree.nodes.items(.tag)[node] == .fn_proto_multi);
     const data = tree.nodes.items(.data)[node];
     const params_range = tree.extraData(data.lhs, Node.SubRange);
@@ -1317,7 +1317,7 @@ pub fn fnProtoMulti(tree: Tree, node: Node.Index) full.FnProto {
     });
 }
 
-pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
+pub fn fnProtoOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.FnProto {
     assert(tree.nodes.items(.tag)[node] == .fn_proto_one);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.FnProtoOne);
@@ -1335,7 +1335,7 @@ pub fn fnProtoOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.FnP
     });
 }
 
-pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
+pub fn fnProto(tree: Ast, node: Node.Index) full.FnProto {
     assert(tree.nodes.items(.tag)[node] == .fn_proto);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.FnProto);
@@ -1352,7 +1352,7 @@ pub fn fnProto(tree: Tree, node: Node.Index) full.FnProto {
     });
 }
 
-pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.StructInit {
+pub fn structInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.StructInit {
     assert(tree.nodes.items(.tag)[node] == .struct_init_one or
         tree.nodes.items(.tag)[node] == .struct_init_one_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1365,7 +1365,7 @@ pub fn structInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.
     });
 }
 
-pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.StructInit {
+pub fn structInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.StructInit {
     assert(tree.nodes.items(.tag)[node] == .struct_init_dot_two or
         tree.nodes.items(.tag)[node] == .struct_init_dot_two_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1383,7 +1383,7 @@ pub fn structInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) fu
     });
 }
 
-pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit {
+pub fn structInitDot(tree: Ast, node: Node.Index) full.StructInit {
     assert(tree.nodes.items(.tag)[node] == .struct_init_dot or
         tree.nodes.items(.tag)[node] == .struct_init_dot_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1394,7 +1394,7 @@ pub fn structInitDot(tree: Tree, node: Node.Index) full.StructInit {
     });
 }
 
-pub fn structInit(tree: Tree, node: Node.Index) full.StructInit {
+pub fn structInit(tree: Ast, node: Node.Index) full.StructInit {
     assert(tree.nodes.items(.tag)[node] == .struct_init or
         tree.nodes.items(.tag)[node] == .struct_init_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1406,7 +1406,7 @@ pub fn structInit(tree: Tree, node: Node.Index) full.StructInit {
     });
 }
 
-pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit {
+pub fn arrayInitOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.ArrayInit {
     assert(tree.nodes.items(.tag)[node] == .array_init_one or
         tree.nodes.items(.tag)[node] == .array_init_one_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1421,7 +1421,7 @@ pub fn arrayInitOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.A
     };
 }
 
-pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit {
+pub fn arrayInitDotTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ArrayInit {
     assert(tree.nodes.items(.tag)[node] == .array_init_dot_two or
         tree.nodes.items(.tag)[node] == .array_init_dot_two_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1441,7 +1441,7 @@ pub fn arrayInitDotTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) ful
     };
 }
 
-pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit {
+pub fn arrayInitDot(tree: Ast, node: Node.Index) full.ArrayInit {
     assert(tree.nodes.items(.tag)[node] == .array_init_dot or
         tree.nodes.items(.tag)[node] == .array_init_dot_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1454,7 +1454,7 @@ pub fn arrayInitDot(tree: Tree, node: Node.Index) full.ArrayInit {
     };
 }
 
-pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit {
+pub fn arrayInit(tree: Ast, node: Node.Index) full.ArrayInit {
     assert(tree.nodes.items(.tag)[node] == .array_init or
         tree.nodes.items(.tag)[node] == .array_init_comma);
     const data = tree.nodes.items(.data)[node];
@@ -1468,7 +1468,7 @@ pub fn arrayInit(tree: Tree, node: Node.Index) full.ArrayInit {
     };
 }
 
-pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType {
+pub fn arrayType(tree: Ast, node: Node.Index) full.ArrayType {
     assert(tree.nodes.items(.tag)[node] == .array_type);
     const data = tree.nodes.items(.data)[node];
     return .{
@@ -1481,7 +1481,7 @@ pub fn arrayType(tree: Tree, node: Node.Index) full.ArrayType {
     };
 }
 
-pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType {
+pub fn arrayTypeSentinel(tree: Ast, node: Node.Index) full.ArrayType {
     assert(tree.nodes.items(.tag)[node] == .array_type_sentinel);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.ArrayTypeSentinel);
@@ -1496,7 +1496,7 @@ pub fn arrayTypeSentinel(tree: Tree, node: Node.Index) full.ArrayType {
     };
 }
 
-pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
+pub fn ptrTypeAligned(tree: Ast, node: Node.Index) full.PtrType {
     assert(tree.nodes.items(.tag)[node] == .ptr_type_aligned);
     const data = tree.nodes.items(.data)[node];
     return tree.fullPtrType(.{
@@ -1510,7 +1510,7 @@ pub fn ptrTypeAligned(tree: Tree, node: Node.Index) full.PtrType {
     });
 }
 
-pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
+pub fn ptrTypeSentinel(tree: Ast, node: Node.Index) full.PtrType {
     assert(tree.nodes.items(.tag)[node] == .ptr_type_sentinel);
     const data = tree.nodes.items(.data)[node];
     return tree.fullPtrType(.{
@@ -1524,7 +1524,7 @@ pub fn ptrTypeSentinel(tree: Tree, node: Node.Index) full.PtrType {
     });
 }
 
-pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
+pub fn ptrType(tree: Ast, node: Node.Index) full.PtrType {
     assert(tree.nodes.items(.tag)[node] == .ptr_type);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.PtrType);
@@ -1539,7 +1539,7 @@ pub fn ptrType(tree: Tree, node: Node.Index) full.PtrType {
     });
 }
 
-pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
+pub fn ptrTypeBitRange(tree: Ast, node: Node.Index) full.PtrType {
     assert(tree.nodes.items(.tag)[node] == .ptr_type_bit_range);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.PtrTypeBitRange);
@@ -1554,7 +1554,7 @@ pub fn ptrTypeBitRange(tree: Tree, node: Node.Index) full.PtrType {
     });
 }
 
-pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice {
+pub fn sliceOpen(tree: Ast, node: Node.Index) full.Slice {
     assert(tree.nodes.items(.tag)[node] == .slice_open);
     const data = tree.nodes.items(.data)[node];
     return .{
@@ -1568,7 +1568,7 @@ pub fn sliceOpen(tree: Tree, node: Node.Index) full.Slice {
     };
 }
 
-pub fn slice(tree: Tree, node: Node.Index) full.Slice {
+pub fn slice(tree: Ast, node: Node.Index) full.Slice {
     assert(tree.nodes.items(.tag)[node] == .slice);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.Slice);
@@ -1583,7 +1583,7 @@ pub fn slice(tree: Tree, node: Node.Index) full.Slice {
     };
 }
 
-pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice {
+pub fn sliceSentinel(tree: Ast, node: Node.Index) full.Slice {
     assert(tree.nodes.items(.tag)[node] == .slice_sentinel);
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.SliceSentinel);
@@ -1598,7 +1598,7 @@ pub fn sliceSentinel(tree: Tree, node: Node.Index) full.Slice {
     };
 }
 
-pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
+pub fn containerDeclTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
     assert(tree.nodes.items(.tag)[node] == .container_decl_two or
         tree.nodes.items(.tag)[node] == .container_decl_two_trailing);
     const data = tree.nodes.items(.data)[node];
@@ -1617,7 +1617,7 @@ pub fn containerDeclTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) fu
     });
 }
 
-pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl {
+pub fn containerDecl(tree: Ast, node: Node.Index) full.ContainerDecl {
     assert(tree.nodes.items(.tag)[node] == .container_decl or
         tree.nodes.items(.tag)[node] == .container_decl_trailing);
     const data = tree.nodes.items(.data)[node];
@@ -1629,7 +1629,7 @@ pub fn containerDecl(tree: Tree, node: Node.Index) full.ContainerDecl {
     });
 }
 
-pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl {
+pub fn containerDeclArg(tree: Ast, node: Node.Index) full.ContainerDecl {
     assert(tree.nodes.items(.tag)[node] == .container_decl_arg or
         tree.nodes.items(.tag)[node] == .container_decl_arg_trailing);
     const data = tree.nodes.items(.data)[node];
@@ -1642,7 +1642,7 @@ pub fn containerDeclArg(tree: Tree, node: Node.Index) full.ContainerDecl {
     });
 }
 
-pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
+pub fn taggedUnionTwo(tree: Ast, buffer: *[2]Node.Index, node: Node.Index) full.ContainerDecl {
     assert(tree.nodes.items(.tag)[node] == .tagged_union_two or
         tree.nodes.items(.tag)[node] == .tagged_union_two_trailing);
     const data = tree.nodes.items(.data)[node];
@@ -1662,7 +1662,7 @@ pub fn taggedUnionTwo(tree: Tree, buffer: *[2]Node.Index, node: Node.Index) full
     });
 }
 
-pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl {
+pub fn taggedUnion(tree: Ast, node: Node.Index) full.ContainerDecl {
     assert(tree.nodes.items(.tag)[node] == .tagged_union or
         tree.nodes.items(.tag)[node] == .tagged_union_trailing);
     const data = tree.nodes.items(.data)[node];
@@ -1675,7 +1675,7 @@ pub fn taggedUnion(tree: Tree, node: Node.Index) full.ContainerDecl {
     });
 }
 
-pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl {
+pub fn taggedUnionEnumTag(tree: Ast, node: Node.Index) full.ContainerDecl {
     assert(tree.nodes.items(.tag)[node] == .tagged_union_enum_tag or
         tree.nodes.items(.tag)[node] == .tagged_union_enum_tag_trailing);
     const data = tree.nodes.items(.data)[node];
@@ -1689,7 +1689,7 @@ pub fn taggedUnionEnumTag(tree: Tree, node: Node.Index) full.ContainerDecl {
     });
 }
 
-pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase {
+pub fn switchCaseOne(tree: Ast, node: Node.Index) full.SwitchCase {
     const data = &tree.nodes.items(.data)[node];
     const values: *[1]Node.Index = &data.lhs;
     return tree.fullSwitchCase(.{
@@ -1699,7 +1699,7 @@ pub fn switchCaseOne(tree: Tree, node: Node.Index) full.SwitchCase {
     });
 }
 
-pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase {
+pub fn switchCase(tree: Ast, node: Node.Index) full.SwitchCase {
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.lhs, Node.SubRange);
     return tree.fullSwitchCase(.{
@@ -1709,7 +1709,7 @@ pub fn switchCase(tree: Tree, node: Node.Index) full.SwitchCase {
     });
 }
 
-pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm {
+pub fn asmSimple(tree: Ast, node: Node.Index) full.Asm {
     const data = tree.nodes.items(.data)[node];
     return tree.fullAsm(.{
         .asm_token = tree.nodes.items(.main_token)[node],
@@ -1719,7 +1719,7 @@ pub fn asmSimple(tree: Tree, node: Node.Index) full.Asm {
     });
 }
 
-pub fn asmFull(tree: Tree, node: Node.Index) full.Asm {
+pub fn asmFull(tree: Ast, node: Node.Index) full.Asm {
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.Asm);
     return tree.fullAsm(.{
@@ -1730,7 +1730,7 @@ pub fn asmFull(tree: Tree, node: Node.Index) full.Asm {
     });
 }
 
-pub fn whileSimple(tree: Tree, node: Node.Index) full.While {
+pub fn whileSimple(tree: Ast, node: Node.Index) full.While {
     const data = tree.nodes.items(.data)[node];
     return tree.fullWhile(.{
         .while_token = tree.nodes.items(.main_token)[node],
@@ -1741,7 +1741,7 @@ pub fn whileSimple(tree: Tree, node: Node.Index) full.While {
     });
 }
 
-pub fn whileCont(tree: Tree, node: Node.Index) full.While {
+pub fn whileCont(tree: Ast, node: Node.Index) full.While {
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.WhileCont);
     return tree.fullWhile(.{
@@ -1753,7 +1753,7 @@ pub fn whileCont(tree: Tree, node: Node.Index) full.While {
     });
 }
 
-pub fn whileFull(tree: Tree, node: Node.Index) full.While {
+pub fn whileFull(tree: Ast, node: Node.Index) full.While {
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.While);
     return tree.fullWhile(.{
@@ -1765,7 +1765,7 @@ pub fn whileFull(tree: Tree, node: Node.Index) full.While {
     });
 }
 
-pub fn forSimple(tree: Tree, node: Node.Index) full.While {
+pub fn forSimple(tree: Ast, node: Node.Index) full.While {
     const data = tree.nodes.items(.data)[node];
     return tree.fullWhile(.{
         .while_token = tree.nodes.items(.main_token)[node],
@@ -1776,7 +1776,7 @@ pub fn forSimple(tree: Tree, node: Node.Index) full.While {
     });
 }
 
-pub fn forFull(tree: Tree, node: Node.Index) full.While {
+pub fn forFull(tree: Ast, node: Node.Index) full.While {
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.If);
     return tree.fullWhile(.{
@@ -1788,7 +1788,7 @@ pub fn forFull(tree: Tree, node: Node.Index) full.While {
     });
 }
 
-pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call {
+pub fn callOne(tree: Ast, buffer: *[1]Node.Index, node: Node.Index) full.Call {
     const data = tree.nodes.items(.data)[node];
     buffer.* = .{data.rhs};
     const params = if (data.rhs != 0) buffer[0..1] else buffer[0..0];
@@ -1799,7 +1799,7 @@ pub fn callOne(tree: Tree, buffer: *[1]Node.Index, node: Node.Index) full.Call {
     });
 }
 
-pub fn callFull(tree: Tree, node: Node.Index) full.Call {
+pub fn callFull(tree: Ast, node: Node.Index) full.Call {
     const data = tree.nodes.items(.data)[node];
     const extra = tree.extraData(data.rhs, Node.SubRange);
     return tree.fullCall(.{
@@ -1809,7 +1809,7 @@ pub fn callFull(tree: Tree, node: Node.Index) full.Call {
     });
 }
 
-fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl {
+fn fullVarDecl(tree: Ast, info: full.VarDecl.Components) full.VarDecl {
     const token_tags = tree.tokens.items(.tag);
     var result: full.VarDecl = .{
         .ast = info,
@@ -1834,7 +1834,7 @@ fn fullVarDecl(tree: Tree, info: full.VarDecl.Components) full.VarDecl {
     return result;
 }
 
-fn fullIf(tree: Tree, info: full.If.Components) full.If {
+fn fullIf(tree: Ast, info: full.If.Components) full.If {
     const token_tags = tree.tokens.items(.tag);
     var result: full.If = .{
         .ast = info,
@@ -1859,7 +1859,7 @@ fn fullIf(tree: Tree, info: full.If.Components) full.If {
     return result;
 }
 
-fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.ContainerField {
+fn fullContainerField(tree: Ast, info: full.ContainerField.Components) full.ContainerField {
     const token_tags = tree.tokens.items(.tag);
     var result: full.ContainerField = .{
         .ast = info,
@@ -1873,7 +1873,7 @@ fn fullContainerField(tree: Tree, info: full.ContainerField.Components) full.Con
     return result;
 }
 
-fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto {
+fn fullFnProto(tree: Ast, info: full.FnProto.Components) full.FnProto {
     const token_tags = tree.tokens.items(.tag);
     var result: full.FnProto = .{
         .ast = info,
@@ -1909,7 +1909,7 @@ fn fullFnProto(tree: Tree, info: full.FnProto.Components) full.FnProto {
     return result;
 }
 
-fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit {
+fn fullStructInit(tree: Ast, info: full.StructInit.Components) full.StructInit {
     _ = tree;
     var result: full.StructInit = .{
         .ast = info,
@@ -1917,7 +1917,7 @@ fn fullStructInit(tree: Tree, info: full.StructInit.Components) full.StructInit
     return result;
 }
 
-fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType {
+fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
     const token_tags = tree.tokens.items(.tag);
     // TODO: looks like stage1 isn't quite smart enough to handle enum
     // literals in some places here
@@ -1966,7 +1966,7 @@ fn fullPtrType(tree: Tree, info: full.PtrType.Components) full.PtrType {
     return result;
 }
 
-fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.ContainerDecl {
+fn fullContainerDecl(tree: Ast, info: full.ContainerDecl.Components) full.ContainerDecl {
     const token_tags = tree.tokens.items(.tag);
     var result: full.ContainerDecl = .{
         .ast = info,
@@ -1979,7 +1979,7 @@ fn fullContainerDecl(tree: Tree, info: full.ContainerDecl.Components) full.Conta
     return result;
 }
 
-fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase {
+fn fullSwitchCase(tree: Ast, info: full.SwitchCase.Components) full.SwitchCase {
     const token_tags = tree.tokens.items(.tag);
     var result: full.SwitchCase = .{
         .ast = info,
@@ -1991,7 +1991,7 @@ fn fullSwitchCase(tree: Tree, info: full.SwitchCase.Components) full.SwitchCase
     return result;
 }
 
-fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm {
+fn fullAsm(tree: Ast, info: full.Asm.Components) full.Asm {
     const token_tags = tree.tokens.items(.tag);
     const node_tags = tree.nodes.items(.tag);
     var result: full.Asm = .{
@@ -2054,7 +2054,7 @@ fn fullAsm(tree: Tree, info: full.Asm.Components) full.Asm {
     return result;
 }
 
-fn fullWhile(tree: Tree, info: full.While.Components) full.While {
+fn fullWhile(tree: Ast, info: full.While.Components) full.While {
     const token_tags = tree.tokens.items(.tag);
     var result: full.While = .{
         .ast = info,
@@ -2089,7 +2089,7 @@ fn fullWhile(tree: Tree, info: full.While.Components) full.While {
     return result;
 }
 
-fn fullCall(tree: Tree, info: full.Call.Components) full.Call {
+fn fullCall(tree: Ast, info: full.Call.Components) full.Call {
     const token_tags = tree.tokens.items(.tag);
     var result: full.Call = .{
         .ast = info,
@@ -2201,7 +2201,7 @@ pub const full = struct {
         /// in the params slice, since they are simple identifiers and
         /// not sub-expressions.
         pub const Iterator = struct {
-            tree: *const Tree,
+            tree: *const Ast,
             fn_proto: *const FnProto,
             param_i: usize,
             tok_i: TokenIndex,
@@ -2291,7 +2291,7 @@ pub const full = struct {
             }
         };
 
-        pub fn iterate(fn_proto: FnProto, tree: Tree) Iterator {
+        pub fn iterate(fn_proto: FnProto, tree: Ast) Iterator {
             return .{
                 .tree = &tree,
                 .fn_proto = &fn_proto,
@@ -2485,7 +2485,7 @@ pub const Node = struct {
     }
 
     /// Note: The FooComma/FooSemicolon variants exist to ease the implementation of
-    /// Tree.lastToken()
+    /// Ast.lastToken()
     pub const Tag = enum {
         /// sub_list[lhs...rhs]
         root,