From dd9ec8e4506dc432e34350e52e689bf8de0f99d2 Mon Sep 17 00:00:00 2001 From: SuperAuguste Date: Sat, 23 May 2020 22:07:09 -0400 Subject: [PATCH] Fix completion of functions --- src/analysis.zig | 13 +++++++++++++ src/main.zig | 7 +++++++ 2 files changed, 20 insertions(+) diff --git a/src/analysis.zig b/src/analysis.zig index 8f44c72..da5d245 100644 --- a/src/analysis.zig +++ b/src/analysis.zig @@ -464,6 +464,19 @@ pub fn getFieldAccessTypeNode( } else return null; } }, + .LParen => { + switch (current_node.id) { + .FnProto => { + const func = current_node.cast(ast.Node.FnProto).?; + if (resolveReturnType(analysis_ctx, func, current_node)) |ret| { + current_node = ret; + } else { + return null; + } + }, + else => {} + } + }, else => std.debug.warn("Not implemented; {}\n", .{next.id}), } } diff --git a/src/main.zig b/src/main.zig index 9eb657c..a35b7ab 100644 --- a/src/main.zig +++ b/src/main.zig @@ -543,6 +543,11 @@ fn documentPositionContext(doc: types.TextDocument, pos_index: usize) PositionCo curr_position = 0; var expr_start: usize = skipped_ws; + // std.debug.warn("{}", .{curr_position}); + + if (pos_index != 0 and doc.text[pos_index - 1] == ')') + return .{ .field_access = expr_start }; + var new_token = true; var context: PositionContext = .other; var string_pop_ctx: PositionContext = .other; @@ -791,6 +796,8 @@ fn processJsonRpc(parser: *std.json.Parser, json: []const u8, config: Config) !v const pos_index = try handle.document.positionToIndex(pos); const pos_context = documentPositionContext(handle.document, pos_index); + std.debug.warn("{}", .{pos_context}); + const this_config = configFromUriOr(uri, config); switch (pos_context) { .builtin => try send(types.Response{