Run zig fmt

This commit is contained in:
Jonathan Hähne 2021-04-15 11:21:49 +02:00
parent b90c9b49ac
commit f61c9d8d4f
3 changed files with 27 additions and 31 deletions

View File

@ -29,9 +29,9 @@ pub fn getDocComments(
const tokens = tree.tokens.items(.tag);
switch (base_kind) {
// As far as I know, this does not actually happen yet, but it may come in useful.
.root =>
return try collectDocComments(allocator, tree, 0, format, true),
// As far as I know, this does not actually happen yet, but it
// may come in useful.
.root => return try collectDocComments(allocator, tree, 0, format, true),
.fn_proto,
.fn_proto_one,
.fn_proto_simple,
@ -40,10 +40,12 @@ pub fn getDocComments(
.local_var_decl,
.global_var_decl,
.aligned_var_decl,
.simple_var_decl =>
.simple_var_decl,
=> {
if (getDocCommentTokenIndex(tokens, base)) |doc_comment_index|
return try collectDocComments(allocator, tree, doc_comment_index, format, false),
else => {}
return try collectDocComments(allocator, tree, doc_comment_index, format, false);
},
else => {},
}
return null;
}
@ -82,8 +84,7 @@ pub fn collectDocComments(
var curr_line_tok = doc_comments;
while (true) : (curr_line_tok += 1) {
const comm = tokens[curr_line_tok];
if ((container_doc and comm == .container_doc_comment)
or (!container_doc and comm == .doc_comment)) {
if ((container_doc and comm == .container_doc_comment) or (!container_doc and comm == .doc_comment)) {
try lines.append(std.mem.trim(u8, tree.tokenSlice(curr_line_tok)[3..], &std.ascii.spaces));
} else break;
}
@ -97,7 +98,8 @@ pub fn getFunctionSignature(tree: ast.Tree, func: ast.full.FnProto) []const u8 {
const end = if (func.ast.return_type != 0)
offsets.tokenLocation(tree, lastToken(tree, func.ast.return_type))
else start;
else
start;
return tree.source[start.start..end.end];
}
@ -513,8 +515,7 @@ pub fn resolveReturnType(
.type = .{ .data = .{ .error_union = child_type_node }, .is_type_val = false },
.handle = child_type.handle,
};
} else
return child_type.instanceTypeVal();
} else return child_type.instanceTypeVal();
}
/// Resolves the child type of an optional type
@ -2646,7 +2647,7 @@ fn makeInnerScope(
.insertText = name,
.insertTextFormat = .PlainText,
.documentation = if (try getDocComments(allocator, tree, decl, .Markdown)) |docs|
.{ .kind = .Markdown, .value = docs }
types.MarkupContent{ .kind = .Markdown, .value = docs }
else
null,
}, {});
@ -2937,15 +2938,12 @@ fn makeScopeInternal(
std.debug.assert(token_tags[name_token] == .identifier);
const name = tree.tokenSlice(name_token);
try scope.decls.putNoClobber(name, if (is_for)
.{
try scope.decls.putNoClobber(name, if (is_for) .{
.array_payload = .{
.identifier = name_token,
.array_expr = while_node.ast.cond_expr,
},
}
else
.{
} else .{
.pointer_payload = .{
.name = name_token,
.condition = while_node.ast.cond_expr,

View File

@ -337,7 +337,6 @@ fn writeNodeTokens(
const main_tokens = tree.nodes.items(.main_token);
if (start_node > node_data.len) return;
var stack = std.ArrayList(ast.Node.Index).init(arena.child_allocator);
defer stack.deinit();
@ -1130,7 +1129,6 @@ fn writeContainerField(
}
}
// TODO Range version, edit version.
pub fn writeAllSemanticTokens(arena: *std.heap.ArenaAllocator, store: *DocumentStore, handle: *DocumentStore.Handle, encoding: offsets.Encoding) ![]u32 {
var builder = Builder.init(arena.child_allocator, handle, encoding);

View File

@ -224,7 +224,7 @@ test "Missing return type" {
try server.request("textDocument/completion",
\\{"textDocument":{"uri":"file:///test.zig"}, "position":{"line":1,"character":1}}
,
\\{"isIncomplete":false,"items":[{"label":"w","kind":3,"textEdit":null,"filterText":null,"insertText":"w()","insertTextFormat":2,"detail":"fn","documentation":null}]}
\\{"isIncomplete":false,"items":[{"label":"w","kind":3,"textEdit":null,"filterText":null,"insertText":"w","insertTextFormat":1,"detail":"fn","documentation":null}]}
);
}