fix bug with latest pr

This commit is contained in:
SuperAuguste 2020-05-08 13:02:46 -04:00
parent b939b9cefa
commit 01b2c2e328

View File

@ -168,11 +168,11 @@ fn publishDiagnostics(document: *types.TextDocument) !void {
while (decls.next()) |decl_ptr| { while (decls.next()) |decl_ptr| {
var decl = decl_ptr.*; var decl = decl_ptr.*;
switch (decl.id) { switch (decl.id) {
.FnProto => { .FnProto => blk: {
const func = decl.cast(std.zig.ast.Node.FnProto).?; const func = decl.cast(std.zig.ast.Node.FnProto).?;
const is_extern = func.extern_export_inline_token != null; const is_extern = func.extern_export_inline_token != null;
if (is_extern) if (is_extern)
break; break :blk;
if (func.name_token) |name_token| { if (func.name_token) |name_token| {
const loc = tree.tokenLocation(0, name_token); const loc = tree.tokenLocation(0, name_token);
@ -249,17 +249,19 @@ fn completeGlobal(id: i64, document: *types.TextDocument) !void {
switch (decl.id) { switch (decl.id) {
.FnProto => { .FnProto => {
const func = decl.cast(std.zig.ast.Node.FnProto).?; const func = decl.cast(std.zig.ast.Node.FnProto).?;
var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl); if (func.name_token) |name_token| {
var doc = types.MarkupContent{ var doc_comments = try analysis.getDocComments(&arena.allocator, tree, decl);
.kind = .Markdown, var doc = types.MarkupContent{
.value = doc_comments orelse "", .kind = .Markdown,
}; .value = doc_comments orelse "",
try completions.append(.{ };
.label = tree.tokenSlice(func.name_token.?), try completions.append(.{
.kind = .Function, .label = tree.tokenSlice(name_token),
.documentation = doc, .kind = .Function,
.detail = analysis.getFunctionSignature(tree, func), .documentation = doc,
}); .detail = analysis.getFunctionSignature(tree, func),
});
}
}, },
.VarDecl => { .VarDecl => {
const var_decl = decl.cast(std.zig.ast.Node.VarDecl).?; const var_decl = decl.cast(std.zig.ast.Node.VarDecl).?;