Compare commits
4 commits
4ee7a26817
...
724dc9200d
Author | SHA1 | Date | |
---|---|---|---|
724dc9200d | |||
0a74bab466 | |||
b0096bed74 | |||
891945bab1 |
4 changed files with 14 additions and 12 deletions
|
@ -1341,6 +1341,8 @@ pub fn store_to_existing_file_const(self: *const Self, file_path: []const u8) St
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn store_to_new_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
pub fn store_to_new_file_const(self: *const Self, file_path: []const u8) StoreToFileError!void {
|
||||||
|
if (std.fs.path.dirname(file_path)) |dir_name|
|
||||||
|
try cwd().makePath(dir_name);
|
||||||
const file = try cwd().createFile(file_path, .{ .read = true, .truncate = true });
|
const file = try cwd().createFile(file_path, .{ .read = true, .truncate = true });
|
||||||
defer file.close();
|
defer file.close();
|
||||||
try self.store_to_file_const(file);
|
try self.store_to_file_const(file);
|
||||||
|
|
|
@ -14,10 +14,7 @@ pub fn build(b: *std.Build) void {
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
|
|
||||||
const tree_sitter_host_dep = b.dependency("tree_sitter", .{
|
const tree_sitter_host_dep = b.dependency("tree_sitter", .{});
|
||||||
.target = b.graph.host,
|
|
||||||
.optimize = optimize,
|
|
||||||
});
|
|
||||||
|
|
||||||
const cbor_dep = b.dependency("cbor", .{
|
const cbor_dep = b.dependency("cbor", .{
|
||||||
.target = target,
|
.target = target,
|
||||||
|
@ -26,8 +23,11 @@ pub fn build(b: *std.Build) void {
|
||||||
|
|
||||||
const ts_bin_query_gen = b.addExecutable(.{
|
const ts_bin_query_gen = b.addExecutable(.{
|
||||||
.name = "ts_bin_query_gen",
|
.name = "ts_bin_query_gen",
|
||||||
.target = b.graph.host,
|
.root_module = b.createModule(.{
|
||||||
.root_source_file = b.path("src/ts_bin_query_gen.zig"),
|
.root_source_file = b.path("src/ts_bin_query_gen.zig"),
|
||||||
|
.target = target,
|
||||||
|
.optimize = optimize,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
ts_bin_query_gen.linkLibC();
|
ts_bin_query_gen.linkLibC();
|
||||||
ts_bin_query_gen.root_module.addImport("cbor", cbor_dep.module("cbor"));
|
ts_bin_query_gen.root_module.addImport("cbor", cbor_dep.module("cbor"));
|
||||||
|
|
|
@ -6,12 +6,12 @@
|
||||||
|
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.tree_sitter = .{
|
.tree_sitter = .{
|
||||||
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-353313ad92324f2e9edc10082ce4768d49e44e7e/source.tar.gz",
|
.url = "https://github.com/neurocyte/tree-sitter/releases/download/master-f1f032d24f621e2ee4deab1c424d3bf9fb809f6e/source.tar.gz",
|
||||||
.hash = "N-V-__8AAEU0UidDMndETXNGKGW66b0yAu58jXL5dmLbOcfH",
|
.hash = "tree_sitter-0.22.4-150-g7e3f5726-z0LhyN88UicDHlr22vQnOZ3DW9NWN1gOhDwLuCRXvrh2",
|
||||||
},
|
},
|
||||||
.cbor = .{
|
.cbor = .{
|
||||||
.url = "https://github.com/neurocyte/cbor/archive/5ea4b7319146f29bb1aa9acf65982feaba9edc3d.tar.gz",
|
.url = "git+https://github.com/neurocyte/cbor#6eccce0b984296e7d05c20d83933cb31530e4fac",
|
||||||
.hash = "cbor-1.0.0-RcQE_GDyAABovyRXoYFX8zD_NVOLGDc9l5g09-W-svMR",
|
.hash = "cbor-1.0.0-RcQE_N3yAADXjbyvhsmTQ6lf22l1nYgePq5FT8NaC4ic",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
.paths = .{
|
.paths = .{
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub fn get_all() []const FileType {
|
||||||
|
|
||||||
pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType {
|
pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType {
|
||||||
if (guess_first_line_static(content)) |ft| return ft;
|
if (guess_first_line_static(content)) |ft| return ft;
|
||||||
for (static_file_types.values()) |*file_type|
|
for (static_file_types.values()) |file_type|
|
||||||
if (file_path) |fp| if (match_file_type(file_type.extensions, fp))
|
if (file_path) |fp| if (match_file_type(file_type.extensions, fp))
|
||||||
return file_type;
|
return file_type;
|
||||||
return null;
|
return null;
|
||||||
|
@ -38,7 +38,7 @@ pub fn guess_static(file_path: ?[]const u8, content: []const u8) ?FileType {
|
||||||
|
|
||||||
fn guess_first_line_static(content: []const u8) ?FileType {
|
fn guess_first_line_static(content: []const u8) ?FileType {
|
||||||
const first_line = if (std.mem.indexOf(u8, content, "\n")) |pos| content[0..pos] else content;
|
const first_line = if (std.mem.indexOf(u8, content, "\n")) |pos| content[0..pos] else content;
|
||||||
for (static_file_types) |*file_type|
|
for (static_file_types.values()) |file_type|
|
||||||
if (file_type.first_line_matches) |match|
|
if (file_type.first_line_matches) |match|
|
||||||
if (match_first_line(match.prefix, match.content, first_line))
|
if (match_first_line(match.prefix, match.content, first_line))
|
||||||
return file_type;
|
return file_type;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue