Fix completion of functions

This commit is contained in:
SuperAuguste 2020-05-23 22:07:09 -04:00
parent ac485f65f8
commit dd9ec8e450
2 changed files with 20 additions and 0 deletions

View File

@ -464,6 +464,19 @@ pub fn getFieldAccessTypeNode(
} else return null; } 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}), else => std.debug.warn("Not implemented; {}\n", .{next.id}),
} }
} }

View File

@ -543,6 +543,11 @@ fn documentPositionContext(doc: types.TextDocument, pos_index: usize) PositionCo
curr_position = 0; curr_position = 0;
var expr_start: usize = skipped_ws; 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 new_token = true;
var context: PositionContext = .other; var context: PositionContext = .other;
var string_pop_ctx: 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_index = try handle.document.positionToIndex(pos);
const pos_context = documentPositionContext(handle.document, pos_index); const pos_context = documentPositionContext(handle.document, pos_index);
std.debug.warn("{}", .{pos_context});
const this_config = configFromUriOr(uri, config); const this_config = configFromUriOr(uri, config);
switch (pos_context) { switch (pos_context) {
.builtin => try send(types.Response{ .builtin => try send(types.Response{