cli: positional arguments are invalid when parsing configuration

This commit is contained in:
Mitchell Hashimoto
2024-10-17 21:39:34 -07:00
parent 4e25840e08
commit 940a46d41f
2 changed files with 87 additions and 37 deletions

View File

@@ -46,6 +46,8 @@ pub const Location = union(enum) {
line: usize,
},
pub const Key = @typeInfo(Location).Union.tag_type.?;
pub fn fromIter(iter: anytype) Location {
const Iter = t: {
const T = @TypeOf(iter);
@@ -121,4 +123,17 @@ pub const DiagnosticList = struct {
pub fn items(self: *const DiagnosticList) []const Diagnostic {
return self.list.items;
}
/// Returns true if there are any diagnostics for the given
/// location type.
pub fn containsLocation(
self: *const DiagnosticList,
location: Location.Key,
) bool {
for (self.list.items) |diag| {
if (diag.location == location) return true;
}
return false;
}
};