analysis: store function node in parameter declaration
This commit is contained in:
parent
adb012001f
commit
6ff19e8b5f
@ -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{
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 => {
|
||||
|
Loading…
Reference in New Issue
Block a user