diff --git a/src/Server.zig b/src/Server.zig index 01eabd2..57fffb1 100644 --- a/src/Server.zig +++ b/src/Server.zig @@ -718,7 +718,8 @@ fn hoverSymbol( return try respondGeneric(writer, id, null_result_response); } }, - .param_decl => |param| def: { + .param_payload => |pay| def: { + const param = pay.param; if (param.first_doc_comment) |doc_comments| { doc_str = try analysis.collectDocComments(server.arena.allocator(), handle.tree, doc_comments, hover_kind, false); } @@ -1040,7 +1041,8 @@ fn declToCompletion(context: DeclToCompletionContext, decl_handle: analysis.Decl false, context.parent_is_type_val, ), - .param_decl => |param| { + .param_payload => |pay| { + const param = pay.param; const doc_kind: types.MarkupContent.Kind = if (context.server.client_capabilities.completion_doc_supports_md) .Markdown else .PlainText; const doc = if (param.first_doc_comment) |doc_comments| types.MarkupContent{ diff --git a/src/analysis.zig b/src/analysis.zig index c90f57b..e0c196c 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -1844,7 +1844,10 @@ pub const Declaration = union(enum) { /// Index of the ast node ast_node: Ast.Node.Index, /// Function parameter - param_decl: Ast.full.FnProto.Param, + param_payload: struct { + param: Ast.full.FnProto.Param, + func: Ast.Node.Index, + }, pointer_payload: struct { name: Ast.TokenIndex, condition: Ast.Node.Index, @@ -1870,7 +1873,7 @@ pub const DeclWithHandle = struct { const tree = self.handle.tree; return switch (self.decl.*) { .ast_node => |n| getDeclNameToken(tree, n).?, - .param_decl => |p| p.name_token.?, + .param_payload => |pp| pp.param.name_token.?, .pointer_payload => |pp| pp.name, .array_payload => |ap| ap.identifier, .array_index => |ai| ai, @@ -1897,7 +1900,8 @@ pub const DeclWithHandle = struct { .{ .node = node, .handle = self.handle }, bound_type_params, ), - .param_decl => |param_decl| { + .param_payload => |pay| { + const param_decl = pay.param; if (isMetaType(self.handle.tree, param_decl.type_expr)) { var bound_param_it = bound_type_params.iterator(); while (bound_param_it.next()) |entry| { @@ -2555,7 +2559,7 @@ fn makeScopeInternal(allocator: std.mem.Allocator, context: ScopeContext, node_i if (try scopes.items[scope_idx].decls.fetchPut( allocator, tree.tokenSlice(name_token), - .{ .param_decl = param }, + .{ .param_payload = .{ .param = param, .func = node_idx } }, )) |existing| { _ = existing; // TODO record a redefinition error diff --git a/src/references.zig b/src/references.zig index 09bcaaf..4283c3a 100644 --- a/src/references.zig +++ b/src/references.zig @@ -516,8 +516,9 @@ pub fn symbolReferences( try imports.resize(arena.allocator(), 0); } }, - .param_decl => |param| blk: { + .param_payload => |pay| blk: { // Rename the param tok. + const param = pay.param; for (curr_handle.document_scope.scopes.items) |scope| { if (scope.data != .function) continue; diff --git a/src/semantic_tokens.zig b/src/semantic_tokens.zig index e345081..b57f810 100644 --- a/src/semantic_tokens.zig +++ b/src/semantic_tokens.zig @@ -417,7 +417,7 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D name, tree.tokens.items(.start)[main_token], )) |child| { - if (child.decl.* == .param_decl) { + if (child.decl.* == .param_payload) { return try writeToken(builder, main_token, .parameter); } var bound_type_params = analysis.BoundTypeParams{}; @@ -716,8 +716,7 @@ fn writeNodeTokens(builder: *Builder, arena: *std.heap.ArenaAllocator, store: *D try writeToken(builder, main_token, .keyword); try await @asyncCall(child_frame, {}, writeNodeTokens, .{ builder, arena, store, node_data[node].lhs }); }, - .number_literal, - => { + .number_literal => { try writeToken(builder, main_token, .number); }, .enum_literal => {