Skip to content

Commit

Permalink
Improve readability of snap files for import test
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-Nak committed Jul 28, 2023
1 parent a95f75e commit be1f9db
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions crates/hir-analysis/test_files/imports/cycle_glob.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ note:
┌─ test_file.fe:4:5
4pub use super::mod2::*
^^^^^^^^^^^^^^^^^^^^^^ test_file::mod1::Foo | test_file::mod2::Bar | test_file::mod2::Bar
^^^^^^^^^^^^^^^^^^^^^^ test_file::mod1::Foo as Foo | test_file::mod2::Bar as Bar | test_file::mod2::Bar as BarImported

note:
┌─ test_file.fe:12:5
12pub use super::mod1::*
^^^^^^^^^^^^^^^^^^^^^^ test_file::mod1::Foo | test_file::mod2::Bar | test_file::mod2::Bar
^^^^^^^^^^^^^^^^^^^^^^ test_file::mod1::Foo as Foo | test_file::mod2::Bar as Bar | test_file::mod2::Bar as BarImported


4 changes: 2 additions & 2 deletions crates/hir-analysis/test_files/imports/glob_chain.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ note:
┌─ test_file.fe:1:1
1use foo::*
^^^^^^^^^^ test_file::foo::MyEnum | test_file::foo::MyEnum::Variant | test_file::foo::MyEnum::Variant2 | test_file::foo::Variant
^^^^^^^^^^ test_file::foo::MyEnum as MyEnum | test_file::foo::MyEnum::Variant as Variant | test_file::foo::MyEnum::Variant2 as Variant2 | test_file::foo::Variant as Variant

note:
┌─ test_file.fe:4:5
4pub use MyEnum::*
^^^^^^^^^^^^^^^^^ test_file::foo::MyEnum::Variant | test_file::foo::MyEnum::Variant2
^^^^^^^^^^^^^^^^^ test_file::foo::MyEnum::Variant as Variant | test_file::foo::MyEnum::Variant2 as Variant2


6 changes: 3 additions & 3 deletions crates/hir-analysis/test_files/imports/glob_mutual_dep.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,18 @@ note:
┌─ test_file.fe:1:1
1use foo::*
^^^^^^^^^^ test_file::bar::Bar | test_file::foo::Foo
^^^^^^^^^^ test_file::bar::Bar as Bar | test_file::foo::Foo as Foo

note:
┌─ test_file.fe:4:5
4pub use super::bar::*
^^^^^^^^^^^^^^^^^^^^^ test_file::bar::Bar | test_file::foo::Foo
^^^^^^^^^^^^^^^^^^^^^ test_file::bar::Bar as Bar | test_file::foo::Foo as Foo

note:
┌─ test_file.fe:10:5
10pub use super::foo::*
^^^^^^^^^^^^^^^^^^^^^ test_file::bar::Bar | test_file::foo::Foo
^^^^^^^^^^^^^^^^^^^^^ test_file::bar::Bar as Bar | test_file::foo::Foo as Foo


4 changes: 2 additions & 2 deletions crates/hir-analysis/test_files/imports/glob_shadow.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ note:
┌─ test_file.fe:1:1
1use foo::*
^^^^^^^^^^ test_file::foo::MyEnum | test_file::foo::MyEnum::Variant2 | test_file::foo::Variant
^^^^^^^^^^ test_file::foo::MyEnum as MyEnum | test_file::foo::MyEnum::Variant2 as Variant2 | test_file::foo::Variant as Variant

note:
┌─ test_file.fe:4:5
4pub use MyEnum::*
^^^^^^^^^^^^^^^^^ test_file::foo::MyEnum::Variant | test_file::foo::MyEnum::Variant2
^^^^^^^^^^^^^^^^^ test_file::foo::MyEnum::Variant as Variant | test_file::foo::MyEnum::Variant2 as Variant2


Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ note:
┌─ test_file.fe:2:1
2use foo::*
^^^^^^^^^^ test_file::foo::bar
^^^^^^^^^^ test_file::foo::bar as bar


14 changes: 8 additions & 6 deletions crates/hir-analysis/tests/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ fn format_imports(
}

for (_, glob_set) in imports.glob_resolved.iter() {
for (&use_, res_set) in glob_set.iter() {
for res in res_set.values().flatten() {
use_res_map
.entry(use_)
.or_default()
.push(res.pretty_path(db).unwrap())
for (&use_, res_set_with_ident) in glob_set.iter() {
for (ident, res_set) in res_set_with_ident.iter() {
let ident = ident.data(db);
for res in res_set {
let def_path = res.pretty_path(db).unwrap();
let resolved = format!("{} as {}", def_path, ident);
use_res_map.entry(use_).or_default().push(resolved)
}
}
}
}
Expand Down

0 comments on commit be1f9db

Please sign in to comment.