mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Go To Implementation for Trait
This commit is contained in:
parent
4c0ab7db85
commit
f0fdc9d5c0
3 changed files with 140 additions and 26 deletions
|
@ -14,7 +14,7 @@ use ra_syntax::{
|
|||
|
||||
use crate::{
|
||||
HirDatabase, Function, ModuleDef, Struct, Enum,
|
||||
AsName, Module, HirFileId, Crate,
|
||||
AsName, Module, HirFileId, Crate, Trait,
|
||||
ids::{LocationCtx, SourceFileItemId},
|
||||
};
|
||||
|
||||
|
@ -151,6 +151,19 @@ pub fn enum_from_module(db: &impl HirDatabase, module: Module, enum_def: &ast::E
|
|||
}
|
||||
}
|
||||
|
||||
pub fn trait_from_module(
|
||||
db: &impl HirDatabase,
|
||||
module: Module,
|
||||
trait_def: &ast::TraitDef,
|
||||
) -> Trait {
|
||||
let (file_id, _) = module.definition_source(db);
|
||||
let file_id = file_id.into();
|
||||
let ctx = LocationCtx::new(db, module, file_id);
|
||||
Trait {
|
||||
id: ctx.to_def(trait_def),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn macro_symbols(db: &impl HirDatabase, file_id: FileId) -> Vec<(SmolStr, TextRange)> {
|
||||
let module = match module_from_file_id(db, file_id) {
|
||||
Some(it) => it,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue