Do not add every node when adding decls, just the supported nodes
This commit is contained in:
parent
39bbf9c8bc
commit
077a17e2f5
@ -513,7 +513,7 @@ pub fn nodeToString(tree: *ast.Tree, node: *ast.Node) ?[]const u8 {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn declsFromIndexInternal(decls: *std.ArrayList(*ast.Node), tree: *ast.Tree, node: *ast.Node) anyerror!void {
|
pub fn declsFromIndexInternal(decls: *std.ArrayList(*ast.Node), tree: *ast.Tree, node: *ast.Node) error{OutOfMemory}!void {
|
||||||
switch (node.id) {
|
switch (node.id) {
|
||||||
.FnProto => {
|
.FnProto => {
|
||||||
const func = node.cast(ast.Node.FnProto).?;
|
const func = node.cast(ast.Node.FnProto).?;
|
||||||
@ -536,7 +536,7 @@ pub fn declsFromIndexInternal(decls: *std.ArrayList(*ast.Node), tree: *ast.Tree,
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
.VarDecl, .ParamDecl => try decls.append(node),
|
.VarDecl, .ParamDecl => try decls.append(node),
|
||||||
else => try addChildrenNodes(decls, tree, node),
|
else => {},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -553,7 +553,7 @@ pub fn declsFromIndex(decls: *std.ArrayList(*ast.Node), tree: *ast.Tree, index:
|
|||||||
try addChildrenNodes(decls, tree, node);
|
try addChildrenNodes(decls, tree, node);
|
||||||
var node_index: usize = 0;
|
var node_index: usize = 0;
|
||||||
while (node.iterate(node_index)) |inode| : (node_index += 1) {
|
while (node.iterate(node_index)) |inode| : (node_index += 1) {
|
||||||
if (tree.tokens.at(inode.firstToken()).start < index and index < tree.tokens.at(inode.lastToken()).end) {
|
if (nodeContainsSourceIndex(tree, inode, index)) {
|
||||||
try declsFromIndexInternal(decls, tree, inode);
|
try declsFromIndexInternal(decls, tree, inode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,8 @@ fn nodeToCompletion(list: *std.ArrayList(types.CompletionItem), analysis_ctx: *D
|
|||||||
else
|
else
|
||||||
null;
|
null;
|
||||||
|
|
||||||
|
std.debug.warn("{}\n", .{node.id});
|
||||||
|
|
||||||
switch (node.id) {
|
switch (node.id) {
|
||||||
.ErrorSetDecl, .Root, .ContainerDecl => {
|
.ErrorSetDecl, .Root, .ContainerDecl => {
|
||||||
try containerToCompletion(list, analysis_ctx, node, config);
|
try containerToCompletion(list, analysis_ctx, node, config);
|
||||||
@ -411,6 +413,7 @@ fn completeGlobal(id: i64, pos_index: usize, handle: *DocumentStore.Handle, conf
|
|||||||
try analysis.declsFromIndex(&decl_nodes, analysis_ctx.tree, pos_index);
|
try analysis.declsFromIndex(&decl_nodes, analysis_ctx.tree, pos_index);
|
||||||
for (decl_nodes.items) |decl_ptr| {
|
for (decl_nodes.items) |decl_ptr| {
|
||||||
var decl = decl_ptr.*;
|
var decl = decl_ptr.*;
|
||||||
|
std.debug.warn("Global completion: {}\n", .{decl});
|
||||||
try nodeToCompletion(&completions, &analysis_ctx, decl_ptr, config);
|
try nodeToCompletion(&completions, &analysis_ctx, decl_ptr, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user