Fixed field access

This commit is contained in:
Alexandros Naskos 2020-06-11 00:24:57 +03:00
parent 86e417e8dc
commit b8b6c534e8
2 changed files with 5 additions and 3 deletions

View File

@ -555,6 +555,7 @@ pub fn getFieldAccessTypeNode(
store: *DocumentStore,
arena: *std.heap.ArenaAllocator,
handle: *DocumentStore.Handle,
source_index: usize,
tokenizer: *std.zig.Tokenizer,
) !?NodeWithHandle {
var current_node = NodeWithHandle{
@ -567,7 +568,7 @@ pub fn getFieldAccessTypeNode(
switch (tok.id) {
.Eof => return try resolveFieldAccessLhsType(store, arena, current_node),
.Identifier => {
if (try lookupSymbolGlobal(store, current_node.handle, tokenizer.buffer[tok.loc.start..tok.loc.end], tok.loc.start)) |child| {
if (try lookupSymbolGlobal(store, current_node.handle, tokenizer.buffer[tok.loc.start..tok.loc.end], source_index)) |child| {
current_node = (try child.resolveType(store, arena)) orelse return null;
} else return null;
},

View File

@ -525,7 +525,7 @@ fn getSymbolFieldAccess(
const line = try handle.document.getLine(@intCast(usize, position.line));
var tokenizer = std.zig.Tokenizer.init(line[range.start..range.end]);
if (try analysis.getFieldAccessTypeNode(&document_store, arena, handle, &tokenizer)) |container_handle| {
if (try analysis.getFieldAccessTypeNode(&document_store, arena, handle, pos_index, &tokenizer)) |container_handle| {
return try analysis.lookupSymbolContainer(&document_store, container_handle, name, true);
}
return null;
@ -670,7 +670,8 @@ fn completeFieldAccess(id: types.RequestId, handle: *DocumentStore.Handle, posit
const line = try handle.document.getLine(@intCast(usize, position.line));
var tokenizer = std.zig.Tokenizer.init(line[range.start..range.end]);
if (try analysis.getFieldAccessTypeNode(&document_store, &arena, handle, &tokenizer)) |node| {
const pos_index = try handle.document.positionToIndex(position);
if (try analysis.getFieldAccessTypeNode(&document_store, &arena, handle, pos_index, &tokenizer)) |node| {
try nodeToCompletion(&arena, &completions, node, handle, config);
}