Run zig fmt
This commit is contained in:
parent
b90c9b49ac
commit
f61c9d8d4f
@ -29,9 +29,9 @@ pub fn getDocComments(
|
|||||||
const tokens = tree.tokens.items(.tag);
|
const tokens = tree.tokens.items(.tag);
|
||||||
|
|
||||||
switch (base_kind) {
|
switch (base_kind) {
|
||||||
// As far as I know, this does not actually happen yet, but it may come in useful.
|
// As far as I know, this does not actually happen yet, but it
|
||||||
.root =>
|
// may come in useful.
|
||||||
return try collectDocComments(allocator, tree, 0, format, true),
|
.root => return try collectDocComments(allocator, tree, 0, format, true),
|
||||||
.fn_proto,
|
.fn_proto,
|
||||||
.fn_proto_one,
|
.fn_proto_one,
|
||||||
.fn_proto_simple,
|
.fn_proto_simple,
|
||||||
@ -40,10 +40,12 @@ pub fn getDocComments(
|
|||||||
.local_var_decl,
|
.local_var_decl,
|
||||||
.global_var_decl,
|
.global_var_decl,
|
||||||
.aligned_var_decl,
|
.aligned_var_decl,
|
||||||
.simple_var_decl =>
|
.simple_var_decl,
|
||||||
|
=> {
|
||||||
if (getDocCommentTokenIndex(tokens, base)) |doc_comment_index|
|
if (getDocCommentTokenIndex(tokens, base)) |doc_comment_index|
|
||||||
return try collectDocComments(allocator, tree, doc_comment_index, format, false),
|
return try collectDocComments(allocator, tree, doc_comment_index, format, false);
|
||||||
else => {}
|
},
|
||||||
|
else => {},
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -82,8 +84,7 @@ pub fn collectDocComments(
|
|||||||
var curr_line_tok = doc_comments;
|
var curr_line_tok = doc_comments;
|
||||||
while (true) : (curr_line_tok += 1) {
|
while (true) : (curr_line_tok += 1) {
|
||||||
const comm = tokens[curr_line_tok];
|
const comm = tokens[curr_line_tok];
|
||||||
if ((container_doc and comm == .container_doc_comment)
|
if ((container_doc and comm == .container_doc_comment) or (!container_doc and comm == .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));
|
try lines.append(std.mem.trim(u8, tree.tokenSlice(curr_line_tok)[3..], &std.ascii.spaces));
|
||||||
} else break;
|
} 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)
|
const end = if (func.ast.return_type != 0)
|
||||||
offsets.tokenLocation(tree, lastToken(tree, func.ast.return_type))
|
offsets.tokenLocation(tree, lastToken(tree, func.ast.return_type))
|
||||||
else start;
|
else
|
||||||
|
start;
|
||||||
return tree.source[start.start..end.end];
|
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 },
|
.type = .{ .data = .{ .error_union = child_type_node }, .is_type_val = false },
|
||||||
.handle = child_type.handle,
|
.handle = child_type.handle,
|
||||||
};
|
};
|
||||||
} else
|
} else return child_type.instanceTypeVal();
|
||||||
return child_type.instanceTypeVal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Resolves the child type of an optional type
|
/// Resolves the child type of an optional type
|
||||||
@ -2646,7 +2647,7 @@ fn makeInnerScope(
|
|||||||
.insertText = name,
|
.insertText = name,
|
||||||
.insertTextFormat = .PlainText,
|
.insertTextFormat = .PlainText,
|
||||||
.documentation = if (try getDocComments(allocator, tree, decl, .Markdown)) |docs|
|
.documentation = if (try getDocComments(allocator, tree, decl, .Markdown)) |docs|
|
||||||
.{ .kind = .Markdown, .value = docs }
|
types.MarkupContent{ .kind = .Markdown, .value = docs }
|
||||||
else
|
else
|
||||||
null,
|
null,
|
||||||
}, {});
|
}, {});
|
||||||
@ -2937,15 +2938,12 @@ fn makeScopeInternal(
|
|||||||
std.debug.assert(token_tags[name_token] == .identifier);
|
std.debug.assert(token_tags[name_token] == .identifier);
|
||||||
|
|
||||||
const name = tree.tokenSlice(name_token);
|
const name = tree.tokenSlice(name_token);
|
||||||
try scope.decls.putNoClobber(name, if (is_for)
|
try scope.decls.putNoClobber(name, if (is_for) .{
|
||||||
.{
|
|
||||||
.array_payload = .{
|
.array_payload = .{
|
||||||
.identifier = name_token,
|
.identifier = name_token,
|
||||||
.array_expr = while_node.ast.cond_expr,
|
.array_expr = while_node.ast.cond_expr,
|
||||||
},
|
},
|
||||||
}
|
} else .{
|
||||||
else
|
|
||||||
.{
|
|
||||||
.pointer_payload = .{
|
.pointer_payload = .{
|
||||||
.name = name_token,
|
.name = name_token,
|
||||||
.condition = while_node.ast.cond_expr,
|
.condition = while_node.ast.cond_expr,
|
||||||
|
@ -337,7 +337,6 @@ fn writeNodeTokens(
|
|||||||
const main_tokens = tree.nodes.items(.main_token);
|
const main_tokens = tree.nodes.items(.main_token);
|
||||||
if (start_node > node_data.len) return;
|
if (start_node > node_data.len) return;
|
||||||
|
|
||||||
|
|
||||||
var stack = std.ArrayList(ast.Node.Index).init(arena.child_allocator);
|
var stack = std.ArrayList(ast.Node.Index).init(arena.child_allocator);
|
||||||
defer stack.deinit();
|
defer stack.deinit();
|
||||||
|
|
||||||
@ -1130,7 +1129,6 @@ fn writeContainerField(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO Range version, edit version.
|
// TODO Range version, edit version.
|
||||||
pub fn writeAllSemanticTokens(arena: *std.heap.ArenaAllocator, store: *DocumentStore, handle: *DocumentStore.Handle, encoding: offsets.Encoding) ![]u32 {
|
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);
|
var builder = Builder.init(arena.child_allocator, handle, encoding);
|
||||||
|
@ -224,7 +224,7 @@ test "Missing return type" {
|
|||||||
try server.request("textDocument/completion",
|
try server.request("textDocument/completion",
|
||||||
\\{"textDocument":{"uri":"file:///test.zig"}, "position":{"line":1,"character":1}}
|
\\{"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}]}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user