fix field access type
This commit is contained in:
parent
353c9b3261
commit
40235cbdbb
@ -341,11 +341,37 @@ pub fn getFieldAccessTypeNode(analysis_ctx: *AnalysisContext, tokenizer: *std.zi
|
||||
return current_node;
|
||||
}
|
||||
|
||||
pub fn isPublic(tree: *ast.Tree, node: *ast.Node) bool {
|
||||
switch (node.id) {
|
||||
.VarDecl => {
|
||||
const var_decl = node.cast(ast.Node.VarDecl).?;
|
||||
if (var_decl.visib_token) |visib_token| {
|
||||
return std.mem.eql(u8, tree.tokenSlice(visib_token), "pub");
|
||||
} else return false;
|
||||
},
|
||||
.FnProto => {
|
||||
const func = node.cast(ast.Node.FnProto).?;
|
||||
if (func.visib_token) |visib_token| {
|
||||
return std.mem.eql(u8, tree.tokenSlice(visib_token), "pub");
|
||||
} else return false;
|
||||
},
|
||||
.ContainerField => {
|
||||
return true;
|
||||
},
|
||||
else => {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
pub fn getCompletionsFromNode(allocator: *std.mem.Allocator, tree: *ast.Tree, node: *ast.Node) ![]*ast.Node {
|
||||
var nodes = std.ArrayList(*ast.Node).init(allocator);
|
||||
|
||||
var index: usize = 0;
|
||||
while (node.iterate(index)) |child_node| {
|
||||
if (isPublic(tree, node))
|
||||
try nodes.append(child_node);
|
||||
|
||||
index += 1;
|
||||
|
@ -277,9 +277,11 @@ fn completeFieldAccess(id: i64, handle: *DocumentStore.Handle, position: types.P
|
||||
if (analysis.getFieldAccessTypeNode(&analysis_ctx, &tokenizer)) |node| {
|
||||
var index: usize = 0;
|
||||
while (node.iterate(index)) |child_node| {
|
||||
if (analysis.isPublic(analysis_ctx.tree, child_node)) {
|
||||
if (try nodeToCompletion(&arena.allocator, analysis_ctx.tree, child_node, config)) |completion| {
|
||||
try completions.append(completion);
|
||||
}
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user