mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Go to Implementation for structs and enums
This commit is contained in:
parent
48d2acb297
commit
3c17643b30
14 changed files with 279 additions and 18 deletions
|
@ -13,7 +13,7 @@ use ra_syntax::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
HirDatabase, Function, ModuleDef,
|
||||
HirDatabase, Function, ModuleDef, Struct, Enum,
|
||||
AsName, Module, HirFileId,
|
||||
ids::{LocationCtx, SourceFileItemId},
|
||||
};
|
||||
|
@ -128,6 +128,28 @@ pub fn function_from_child_node(
|
|||
function_from_source(db, file_id, fn_def)
|
||||
}
|
||||
|
||||
pub fn struct_from_module(
|
||||
db: &impl HirDatabase,
|
||||
module: Module,
|
||||
struct_def: &ast::StructDef,
|
||||
) -> Struct {
|
||||
let (file_id, _) = module.definition_source(db);
|
||||
let file_id = file_id.into();
|
||||
let ctx = LocationCtx::new(db, module, file_id);
|
||||
Struct {
|
||||
id: ctx.to_def(struct_def),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn enum_from_module(db: &impl HirDatabase, module: Module, enum_def: &ast::EnumDef) -> Enum {
|
||||
let (file_id, _) = module.definition_source(db);
|
||||
let file_id = file_id.into();
|
||||
let ctx = LocationCtx::new(db, module, file_id);
|
||||
Enum {
|
||||
id: ctx.to_def(enum_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