Fix some tests

This commit is contained in:
Kirill Bulatov 2021-02-25 01:53:59 +02:00
parent 582cee2cdf
commit d386481fac
4 changed files with 143 additions and 49 deletions

View file

@ -2,11 +2,19 @@
pub mod insert_use;
pub mod import_assets;
use hir::{Crate, Enum, Module, ScopeDef, Semantics, Trait};
use hir::{Crate, Enum, ItemInNs, MacroDef, Module, ModuleDef, Name, ScopeDef, Semantics, Trait};
use syntax::ast::{self, make};
use crate::RootDatabase;
pub fn item_name(db: &RootDatabase, item: ItemInNs) -> Option<Name> {
match item {
ItemInNs::Types(module_def_id) => ModuleDef::from(module_def_id).name(db),
ItemInNs::Values(module_def_id) => ModuleDef::from(module_def_id).name(db),
ItemInNs::Macros(macro_def_id) => MacroDef::from(macro_def_id).name(db),
}
}
/// Converts the mod path struct into its ast representation.
pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path {
let _p = profile::span("mod_path_to_ast");