mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 07:04:49 +00:00
Support more IDE features for asm operands
This commit is contained in:
parent
811905fce8
commit
95d8d8e697
13 changed files with 180 additions and 40 deletions
|
@ -237,15 +237,14 @@ impl TryToNav for Definition {
|
|||
Definition::Trait(it) => it.try_to_nav(db),
|
||||
Definition::TraitAlias(it) => it.try_to_nav(db),
|
||||
Definition::TypeAlias(it) => it.try_to_nav(db),
|
||||
Definition::ExternCrateDecl(it) => Some(it.try_to_nav(db)?),
|
||||
Definition::ExternCrateDecl(it) => it.try_to_nav(db),
|
||||
Definition::InlineAsmOperand(it) => it.try_to_nav(db),
|
||||
Definition::BuiltinLifetime(_)
|
||||
| Definition::BuiltinType(_)
|
||||
| Definition::TupleField(_)
|
||||
| Definition::ToolModule(_)
|
||||
| Definition::InlineAsmRegOrRegClass(_)
|
||||
| Definition::BuiltinAttr(_) => None,
|
||||
// FIXME
|
||||
Definition::InlineAsmOperand(_) => None,
|
||||
// FIXME: The focus range should be set to the helper declaration
|
||||
Definition::DeriveHelper(it) => it.derive().try_to_nav(db),
|
||||
}
|
||||
|
@ -696,6 +695,31 @@ impl TryToNav for hir::ConstParam {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryToNav for hir::InlineAsmOperand {
|
||||
fn try_to_nav(&self, db: &RootDatabase) -> Option<UpmappingResult<NavigationTarget>> {
|
||||
let InFile { file_id, value } = &self.source(db)?;
|
||||
let file_id = *file_id;
|
||||
Some(orig_range_with_focus(db, file_id, value.syntax(), value.name()).map(
|
||||
|(FileRange { file_id, range: full_range }, focus_range)| {
|
||||
let edition = self.parent(db).module(db).krate().edition(db);
|
||||
NavigationTarget {
|
||||
file_id,
|
||||
name: self
|
||||
.name(db)
|
||||
.map_or_else(|| "_".into(), |it| it.display(db, edition).to_smolstr()),
|
||||
alias: None,
|
||||
kind: Some(SymbolKind::Local),
|
||||
full_range,
|
||||
focus_range,
|
||||
container_name: None,
|
||||
description: None,
|
||||
docs: None,
|
||||
}
|
||||
},
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UpmappingResult<T> {
|
||||
/// The macro call site.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue