mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Record derive helper attributes, resolve them in IDE layer
This commit is contained in:
parent
4e60db2d07
commit
aa1491ecde
22 changed files with 144 additions and 58 deletions
|
@ -7,9 +7,9 @@
|
|||
|
||||
use arrayvec::ArrayVec;
|
||||
use hir::{
|
||||
Adt, AsAssocItem, AssocItem, BuiltinAttr, BuiltinType, Const, Crate, Field, Function,
|
||||
GenericParam, HasVisibility, Impl, ItemInNs, Label, Local, Macro, Module, ModuleDef, Name,
|
||||
PathResolution, Semantics, Static, ToolModule, Trait, TypeAlias, Variant, Visibility,
|
||||
Adt, AsAssocItem, AssocItem, BuiltinAttr, BuiltinType, Const, Crate, DeriveHelper, Field,
|
||||
Function, GenericParam, HasVisibility, Impl, ItemInNs, Label, Local, Macro, Module, ModuleDef,
|
||||
Name, PathResolution, Semantics, Static, ToolModule, Trait, TypeAlias, Variant, Visibility,
|
||||
};
|
||||
use stdx::impl_from;
|
||||
use syntax::{
|
||||
|
@ -37,6 +37,7 @@ pub enum Definition {
|
|||
Local(Local),
|
||||
GenericParam(GenericParam),
|
||||
Label(Label),
|
||||
DeriveHelper(DeriveHelper),
|
||||
BuiltinAttr(BuiltinAttr),
|
||||
ToolModule(ToolModule),
|
||||
}
|
||||
|
@ -69,6 +70,7 @@ impl Definition {
|
|||
Definition::Local(it) => it.module(db),
|
||||
Definition::GenericParam(it) => it.module(db),
|
||||
Definition::Label(it) => it.module(db),
|
||||
Definition::DeriveHelper(it) => it.derive().module(db),
|
||||
Definition::BuiltinAttr(_) | Definition::BuiltinType(_) | Definition::ToolModule(_) => {
|
||||
return None
|
||||
}
|
||||
|
@ -94,7 +96,8 @@ impl Definition {
|
|||
| Definition::SelfType(_)
|
||||
| Definition::Local(_)
|
||||
| Definition::GenericParam(_)
|
||||
| Definition::Label(_) => return None,
|
||||
| Definition::Label(_)
|
||||
| Definition::DeriveHelper(_) => return None,
|
||||
};
|
||||
Some(vis)
|
||||
}
|
||||
|
@ -118,6 +121,7 @@ impl Definition {
|
|||
Definition::Label(it) => it.name(db),
|
||||
Definition::BuiltinAttr(_) => return None, // FIXME
|
||||
Definition::ToolModule(_) => return None, // FIXME
|
||||
Definition::DeriveHelper(_) => return None, // FIXME
|
||||
};
|
||||
Some(name)
|
||||
}
|
||||
|
@ -500,6 +504,7 @@ impl From<PathResolution> for Definition {
|
|||
PathResolution::SelfType(impl_def) => Definition::SelfType(impl_def),
|
||||
PathResolution::BuiltinAttr(attr) => Definition::BuiltinAttr(attr),
|
||||
PathResolution::ToolModule(tool) => Definition::ToolModule(tool),
|
||||
PathResolution::DeriveHelper(helper) => Definition::DeriveHelper(helper),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,6 +173,7 @@ pub enum SymbolKind {
|
|||
Const,
|
||||
ConstParam,
|
||||
Derive,
|
||||
DeriveHelper,
|
||||
Enum,
|
||||
Field,
|
||||
Function,
|
||||
|
|
|
@ -224,7 +224,8 @@ impl<'a> Ctx<'a> {
|
|||
| hir::PathResolution::SelfType(_)
|
||||
| hir::PathResolution::Def(_)
|
||||
| hir::PathResolution::BuiltinAttr(_)
|
||||
| hir::PathResolution::ToolModule(_) => (),
|
||||
| hir::PathResolution::ToolModule(_)
|
||||
| hir::PathResolution::DeriveHelper(_) => (),
|
||||
}
|
||||
Some(())
|
||||
}
|
||||
|
|
|
@ -156,6 +156,8 @@ impl Definition {
|
|||
Definition::SelfType(_) => return None,
|
||||
Definition::BuiltinAttr(_) => return None,
|
||||
Definition::ToolModule(_) => return None,
|
||||
// FIXME: This should be doable in theory
|
||||
Definition::DeriveHelper(_) => return None,
|
||||
};
|
||||
return res;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue