Merge branch 'zig-0.14'
This commit is contained in:
commit
2c28091fe5
4 changed files with 8 additions and 2 deletions
|
@ -62,6 +62,7 @@ pub const Error = CacheError || QueryParseError || QuerySerializeError;
|
||||||
|
|
||||||
pub fn create(allocator: std.mem.Allocator, opts: struct { lock: bool = false }) !*Self {
|
pub fn create(allocator: std.mem.Allocator, opts: struct { lock: bool = false }) !*Self {
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
|
errdefer allocator.destroy(self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.mutex = if (opts.lock) .{} else null,
|
.mutex = if (opts.lock) .{} else null,
|
||||||
|
|
|
@ -41,7 +41,7 @@ pub const @"c-sharp" = .{
|
||||||
.icon = "",
|
.icon = "",
|
||||||
.extensions = .{"cs"},
|
.extensions = .{"cs"},
|
||||||
.comment = "//",
|
.comment = "//",
|
||||||
.language_server = .{ "omnisharp", "-lsp" },
|
.language_server = .{ "OmniSharp", "-lsp" },
|
||||||
.formatter = .{ "csharpier", "format" },
|
.formatter = .{ "csharpier", "format" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,13 @@ tree: ?*treez.Tree = null,
|
||||||
|
|
||||||
pub fn create(file_type: FileType, allocator: std.mem.Allocator, query_cache: *QueryCache) !*Self {
|
pub fn create(file_type: FileType, allocator: std.mem.Allocator, query_cache: *QueryCache) !*Self {
|
||||||
const query = try query_cache.get(file_type, .highlights);
|
const query = try query_cache.get(file_type, .highlights);
|
||||||
|
errdefer query_cache.release(query, .highlights);
|
||||||
const errors_query = try query_cache.get(file_type, .errors);
|
const errors_query = try query_cache.get(file_type, .errors);
|
||||||
|
errdefer query_cache.release(errors_query, .highlights);
|
||||||
const injections = try query_cache.get(file_type, .injections);
|
const injections = try query_cache.get(file_type, .injections);
|
||||||
|
errdefer if (injections) |injections_| query_cache.release(injections_, .injections);
|
||||||
const self = try allocator.create(Self);
|
const self = try allocator.create(Self);
|
||||||
|
errdefer allocator.destroy(self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.lang = file_type.lang_fn() orelse std.debug.panic("tree-sitter parser function failed for language: {s}", .{file_type.name}),
|
.lang = file_type.lang_fn() orelse std.debug.panic("tree-sitter parser function failed for language: {s}", .{file_type.name}),
|
||||||
|
@ -40,7 +44,6 @@ pub fn create(file_type: FileType, allocator: std.mem.Allocator, query_cache: *Q
|
||||||
.errors_query = errors_query,
|
.errors_query = errors_query,
|
||||||
.injections = injections,
|
.injections = injections,
|
||||||
};
|
};
|
||||||
errdefer self.destroy(query_cache);
|
|
||||||
try self.parser.setLanguage(self.lang);
|
try self.parser.setLanguage(self.lang);
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -58,6 +61,7 @@ pub fn create_guess_file_type_static(allocator: std.mem.Allocator, content: []co
|
||||||
pub fn destroy(self: *Self, query_cache: *QueryCache) void {
|
pub fn destroy(self: *Self, query_cache: *QueryCache) void {
|
||||||
if (self.tree) |tree| tree.destroy();
|
if (self.tree) |tree| tree.destroy();
|
||||||
query_cache.release(self.query, .highlights);
|
query_cache.release(self.query, .highlights);
|
||||||
|
query_cache.release(self.errors_query, .highlights);
|
||||||
if (self.injections) |injections| query_cache.release(injections, .injections);
|
if (self.injections) |injections| query_cache.release(injections, .injections);
|
||||||
self.parser.destroy();
|
self.parser.destroy();
|
||||||
self.allocator.destroy(self);
|
self.allocator.destroy(self);
|
||||||
|
|
|
@ -289,6 +289,7 @@ pub const DeserializeError = error{
|
||||||
|
|
||||||
pub fn fromCbor(cb: []const u8, allocator: std.mem.Allocator) DeserializeError!struct { *TSQuery, *std.heap.ArenaAllocator } {
|
pub fn fromCbor(cb: []const u8, allocator: std.mem.Allocator) DeserializeError!struct { *TSQuery, *std.heap.ArenaAllocator } {
|
||||||
var arena = try allocator.create(std.heap.ArenaAllocator);
|
var arena = try allocator.create(std.heap.ArenaAllocator);
|
||||||
|
errdefer allocator.destroy(arena);
|
||||||
arena.* = std.heap.ArenaAllocator.init(allocator);
|
arena.* = std.heap.ArenaAllocator.init(allocator);
|
||||||
errdefer arena.deinit();
|
errdefer arena.deinit();
|
||||||
const query = try arena.allocator().create(TSQuery);
|
const query = try arena.allocator().create(TSQuery);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue