[std.zig.] parse(alloc, src) -> Ast.parse(alloc, src, Ast.Mode) (#966)

* Work in Zig's breaking changes (build sys apis)

* [`std.zig.`] `parse(alloc, src)` -> `Ast.parse(alloc, src, Ast.Mode)`
This commit is contained in:
nullptrdevs
2023-02-04 10:19:24 -08:00
committed by GitHub
parent 384f227cb7
commit bd539ae989
5 changed files with 9 additions and 7 deletions

View File

@@ -47,7 +47,7 @@ fn testNodesAtLoc(source: []const u8) !void {
const new_source = try allocator.dupeZ(u8, ccp.new_source);
defer allocator.free(new_source);
var tree = try std.zig.parse(allocator, new_source);
var tree = try std.zig.Ast.parse(allocator, new_source, .zig);
defer tree.deinit(allocator);
const nodes = try ast.nodesAtLoc(allocator, tree, inner_loc);

View File

@@ -4,6 +4,8 @@ const zls = @import("zls");
const types = zls.types;
const offsets = zls.offsets;
const Ast = std.zig.Ast;
test "offsets - index <-> Position" {
try testIndexPosition("", 0, 0, .{ 0, 0, 0 });
@@ -116,8 +118,8 @@ fn testIndexPosition(text: []const u8, index: usize, line: u32, characters: [3]u
try std.testing.expectEqual(index, offsets.positionToIndex(text, position32, .@"utf-32"));
}
fn testTokenToLoc(text: [:0]const u8, token_index: std.zig.Ast.TokenIndex, start: usize, end: usize) !void {
var tree = try std.zig.parse(std.testing.allocator, text);
fn testTokenToLoc(text: [:0]const u8, token_index: Ast.TokenIndex, start: usize, end: usize) !void {
var tree = try Ast.parse(std.testing.allocator, text, .zig);
defer tree.deinit(std.testing.allocator);
const actual = offsets.tokenToLoc(tree, token_index);