mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-21 14:55:20 +00:00
c: remove the config load string API
It was unused and doesn't match our diagnostic API.
This commit is contained in:
@@ -129,7 +129,7 @@ pub fn parse(
|
||||
try dst._diagnostics.append(arena_alloc, .{
|
||||
.key = try arena_alloc.dupeZ(u8, key),
|
||||
.message = message,
|
||||
.location = Diagnostic.Location.fromIter(iter),
|
||||
.location = diags.Location.fromIter(iter),
|
||||
});
|
||||
};
|
||||
}
|
||||
@@ -475,7 +475,7 @@ test "parse: diagnostic tracking" {
|
||||
try testing.expect(data._diagnostics.items().len == 1);
|
||||
{
|
||||
const diag = data._diagnostics.items()[0];
|
||||
try testing.expectEqual(Diagnostic.Location.none, diag.location);
|
||||
try testing.expectEqual(diags.Location.none, diag.location);
|
||||
try testing.expectEqualStrings("what", diag.key);
|
||||
try testing.expectEqualStrings("unknown field", diag.message);
|
||||
}
|
||||
@@ -878,7 +878,7 @@ pub fn ArgsIterator(comptime Iterator: type) type {
|
||||
}
|
||||
|
||||
/// Returns a location for a diagnostic message.
|
||||
pub fn location(self: *const Self) ?Diagnostic.Location {
|
||||
pub fn location(self: *const Self) ?diags.Location {
|
||||
return .{ .cli = self.index };
|
||||
}
|
||||
};
|
||||
@@ -975,7 +975,7 @@ pub fn LineIterator(comptime ReaderType: type) type {
|
||||
}
|
||||
|
||||
/// Returns a location for a diagnostic message.
|
||||
pub fn location(self: *const Self) ?Diagnostic.Location {
|
||||
pub fn location(self: *const Self) ?diags.Location {
|
||||
// If we have no filepath then we have no location.
|
||||
if (self.filepath.len == 0) return null;
|
||||
|
||||
|
||||
@@ -15,31 +15,6 @@ pub const Diagnostic = struct {
|
||||
key: [:0]const u8 = "",
|
||||
message: [:0]const u8,
|
||||
|
||||
/// The possible locations for a diagnostic message. This is used
|
||||
/// to provide context for the message.
|
||||
pub const Location = union(enum) {
|
||||
none,
|
||||
cli: usize,
|
||||
file: struct {
|
||||
path: []const u8,
|
||||
line: usize,
|
||||
},
|
||||
|
||||
pub fn fromIter(iter: anytype) Location {
|
||||
const Iter = t: {
|
||||
const T = @TypeOf(iter);
|
||||
break :t switch (@typeInfo(T)) {
|
||||
.Pointer => |v| v.child,
|
||||
.Struct => T,
|
||||
else => return .none,
|
||||
};
|
||||
};
|
||||
|
||||
if (!@hasDecl(Iter, "location")) return .none;
|
||||
return iter.location() orelse .none;
|
||||
}
|
||||
};
|
||||
|
||||
/// Write the full user-friendly diagnostic message to the writer.
|
||||
pub fn write(self: *const Diagnostic, writer: anytype) !void {
|
||||
switch (self.location) {
|
||||
@@ -61,6 +36,31 @@ pub const Diagnostic = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// The possible locations for a diagnostic message. This is used
|
||||
/// to provide context for the message.
|
||||
pub const Location = union(enum) {
|
||||
none,
|
||||
cli: usize,
|
||||
file: struct {
|
||||
path: []const u8,
|
||||
line: usize,
|
||||
},
|
||||
|
||||
pub fn fromIter(iter: anytype) Location {
|
||||
const Iter = t: {
|
||||
const T = @TypeOf(iter);
|
||||
break :t switch (@typeInfo(T)) {
|
||||
.Pointer => |v| v.child,
|
||||
.Struct => T,
|
||||
else => return .none,
|
||||
};
|
||||
};
|
||||
|
||||
if (!@hasDecl(Iter, "location")) return .none;
|
||||
return iter.location() orelse .none;
|
||||
}
|
||||
};
|
||||
|
||||
/// A list of diagnostics. The "_diagnostics" field must be this type
|
||||
/// for diagnostics to be supported. If this field is an incorrect type
|
||||
/// a compile-time error will be raised.
|
||||
|
||||
Reference in New Issue
Block a user