feat: Resolve builtin-attr and tools in ide layer

This commit is contained in:
Lukas Wirth 2021-12-03 16:32:14 +01:00
parent 4691a0647b
commit e58af219a4
15 changed files with 209 additions and 99 deletions

View file

@ -2023,6 +2023,26 @@ impl Local {
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct BuiltinAttr(usize);
impl BuiltinAttr {
pub(crate) fn by_name(name: &str) -> Option<Self> {
// TODO: def maps registered attrs?
hir_def::builtin_attr::find_builtin_attr_idx(name).map(Self)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Tool(usize);
impl Tool {
pub(crate) fn by_name(name: &str) -> Option<Self> {
// TODO: def maps registered tools
hir_def::builtin_attr::TOOL_MODULES.iter().position(|&tool| tool == name).map(Self)
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Label {
pub(crate) parent: DefWithBodyId,