From 3e961af5f1b80c914cec06ddb3e20881681b1303 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 2 Aug 2021 22:55:22 +0100 Subject: [PATCH] Sort files by name in packages --- src/checker.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/checker.cpp b/src/checker.cpp index 7e56f281e..46373c426 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -4095,11 +4095,21 @@ bool collect_file_decls(CheckerContext *ctx, Slice 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);