Sort files by name in packages

This commit is contained in:
gingerBill
2021-08-02 22:55:22 +01:00
parent 9e6e769141
commit 3e961af5f1
+10
View File
@@ -4095,11 +4095,21 @@ bool collect_file_decls(CheckerContext *ctx, Slice<Ast *> const &decls) {
return false;
}
GB_COMPARE_PROC(sort_file_by_name) {
AstFile const *x = *cast(AstFile const **)a;
AstFile const *y = *cast(AstFile const **)b;
String x_name = filename_from_path(x->fullpath);
String y_name = filename_from_path(y->fullpath);
return string_compare(x_name, y_name);
}
void check_create_file_scopes(Checker *c) {
for_array(i, c->parser->packages) {
AstPackage *pkg = c->parser->packages[i];
isize total_pkg_decl_count = 0;
gb_sort_array(pkg->files.data, pkg->files.count, sort_file_by_name);
for_array(j, pkg->files) {
AstFile *f = pkg->files[j];
string_map_set(&c->info.files, f->fullpath, f);