Fixed field access
This commit is contained in:
parent
86e417e8dc
commit
b8b6c534e8
@ -555,6 +555,7 @@ pub fn getFieldAccessTypeNode(
|
|||||||
store: *DocumentStore,
|
store: *DocumentStore,
|
||||||
arena: *std.heap.ArenaAllocator,
|
arena: *std.heap.ArenaAllocator,
|
||||||
handle: *DocumentStore.Handle,
|
handle: *DocumentStore.Handle,
|
||||||
|
source_index: usize,
|
||||||
tokenizer: *std.zig.Tokenizer,
|
tokenizer: *std.zig.Tokenizer,
|
||||||
) !?NodeWithHandle {
|
) !?NodeWithHandle {
|
||||||
var current_node = NodeWithHandle{
|
var current_node = NodeWithHandle{
|
||||||
@ -567,7 +568,7 @@ pub fn getFieldAccessTypeNode(
|
|||||||
switch (tok.id) {
|
switch (tok.id) {
|
||||||
.Eof => return try resolveFieldAccessLhsType(store, arena, current_node),
|
.Eof => return try resolveFieldAccessLhsType(store, arena, current_node),
|
||||||
.Identifier => {
|
.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;
|
current_node = (try child.resolveType(store, arena)) orelse return null;
|
||||||
} else return null;
|
} else return null;
|
||||||
},
|
},
|
||||||
|
@ -525,7 +525,7 @@ fn getSymbolFieldAccess(
|
|||||||
const line = try handle.document.getLine(@intCast(usize, position.line));
|
const line = try handle.document.getLine(@intCast(usize, position.line));
|
||||||
var tokenizer = std.zig.Tokenizer.init(line[range.start..range.end]);
|
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 try analysis.lookupSymbolContainer(&document_store, container_handle, name, true);
|
||||||
}
|
}
|
||||||
return null;
|
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));
|
const line = try handle.document.getLine(@intCast(usize, position.line));
|
||||||
var tokenizer = std.zig.Tokenizer.init(line[range.start..range.end]);
|
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);
|
try nodeToCompletion(&arena, &completions, node, handle, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user