Merge pull request #448 from ikrima/add-typefunc-outline-nodes

add type function symbols to document symbol outline
This commit is contained in:
Auguste Rame 2022-01-12 23:56:55 -05:00 committed by GitHub
commit fefabc658f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1809,6 +1809,16 @@ fn getDocumentSymbolsInternal(allocator: std.mem.Allocator, tree: Ast, node: Ast
if (var_decl.ast.init_node != 0)
try addOutlineNodes(allocator, tree, var_decl.ast.init_node, &child_context);
}
if (tags[node] == .fn_decl) fn_ch: {
const fn_decl = tree.nodes.items(.data)[node];
var params: [1]Ast.Node.Index = undefined;
const fn_proto = ast.fnProto(tree, fn_decl.lhs, &params) orelse break :fn_ch;
if (!isTypeFunction(tree, fn_proto)) break :fn_ch;
const ret_stmt = findReturnStatement(tree, fn_proto, fn_decl.rhs) orelse break :fn_ch;
const type_decl = tree.nodes.items(.data)[ret_stmt].lhs;
if (type_decl != 0)
try addOutlineNodes(allocator, tree, type_decl, &child_context);
}
break :ch children.items;
},
};