mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 04:53:34 +00:00
Rename Dyn*
nodes to Any*
nodes
This commit is contained in:
parent
009e6ceb1d
commit
a28c5d7311
5 changed files with 80 additions and 80 deletions
|
@ -682,7 +682,7 @@ impl<'db> SemanticsImpl<'db> {
|
||||||
fn resolve_lifetime_param(&self, lifetime: &ast::Lifetime) -> Option<LifetimeParam> {
|
fn resolve_lifetime_param(&self, lifetime: &ast::Lifetime) -> Option<LifetimeParam> {
|
||||||
let text = lifetime.text();
|
let text = lifetime.text();
|
||||||
let lifetime_param = lifetime.syntax().ancestors().find_map(|syn| {
|
let lifetime_param = lifetime.syntax().ancestors().find_map(|syn| {
|
||||||
let gpl = ast::DynGenericParamsOwner::cast(syn)?.generic_param_list()?;
|
let gpl = ast::AnyGenericParamsOwner::cast(syn)?.generic_param_list()?;
|
||||||
gpl.lifetime_params()
|
gpl.lifetime_params()
|
||||||
.find(|tp| tp.lifetime().as_ref().map(|lt| lt.text()).as_ref() == Some(&text))
|
.find(|tp| tp.lifetime().as_ref().map(|lt| lt.text()).as_ref() == Some(&text))
|
||||||
})?;
|
})?;
|
||||||
|
|
|
@ -411,47 +411,47 @@ impl AttrsWithOwner {
|
||||||
let file_id = id.parent.file_id(db);
|
let file_id = id.parent.file_id(db);
|
||||||
let root = db.parse_or_expand(file_id).unwrap();
|
let root = db.parse_or_expand(file_id).unwrap();
|
||||||
let owner = match &map[id.local_id] {
|
let owner = match &map[id.local_id] {
|
||||||
Either::Left(it) => ast::DynAttrsOwner::new(it.to_node(&root)),
|
Either::Left(it) => ast::AnyAttrsOwner::new(it.to_node(&root)),
|
||||||
Either::Right(it) => ast::DynAttrsOwner::new(it.to_node(&root)),
|
Either::Right(it) => ast::AnyAttrsOwner::new(it.to_node(&root)),
|
||||||
};
|
};
|
||||||
InFile::new(file_id, owner)
|
InFile::new(file_id, owner)
|
||||||
}
|
}
|
||||||
AttrDefId::AdtId(adt) => match adt {
|
AttrDefId::AdtId(adt) => match adt {
|
||||||
AdtId::StructId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AdtId::StructId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AdtId::UnionId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AdtId::UnionId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AdtId::EnumId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AdtId::EnumId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
},
|
},
|
||||||
AttrDefId::FunctionId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AttrDefId::FunctionId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AttrDefId::EnumVariantId(id) => {
|
AttrDefId::EnumVariantId(id) => {
|
||||||
let map = db.variants_attrs_source_map(id.parent);
|
let map = db.variants_attrs_source_map(id.parent);
|
||||||
let file_id = id.parent.lookup(db).id.file_id();
|
let file_id = id.parent.lookup(db).id.file_id();
|
||||||
let root = db.parse_or_expand(file_id).unwrap();
|
let root = db.parse_or_expand(file_id).unwrap();
|
||||||
InFile::new(file_id, ast::DynAttrsOwner::new(map[id.local_id].to_node(&root)))
|
InFile::new(file_id, ast::AnyAttrsOwner::new(map[id.local_id].to_node(&root)))
|
||||||
}
|
}
|
||||||
AttrDefId::StaticId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AttrDefId::StaticId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AttrDefId::ConstId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AttrDefId::ConstId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AttrDefId::TraitId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AttrDefId::TraitId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AttrDefId::TypeAliasId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AttrDefId::TypeAliasId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AttrDefId::MacroDefId(id) => id.ast_id().either(
|
AttrDefId::MacroDefId(id) => id.ast_id().either(
|
||||||
|it| it.with_value(ast::DynAttrsOwner::new(it.to_node(db.upcast()))),
|
|it| it.with_value(ast::AnyAttrsOwner::new(it.to_node(db.upcast()))),
|
||||||
|it| it.with_value(ast::DynAttrsOwner::new(it.to_node(db.upcast()))),
|
|it| it.with_value(ast::AnyAttrsOwner::new(it.to_node(db.upcast()))),
|
||||||
),
|
),
|
||||||
AttrDefId::ImplId(id) => id.lookup(db).source(db).map(ast::DynAttrsOwner::new),
|
AttrDefId::ImplId(id) => id.lookup(db).source(db).map(ast::AnyAttrsOwner::new),
|
||||||
AttrDefId::GenericParamId(id) => match id {
|
AttrDefId::GenericParamId(id) => match id {
|
||||||
GenericParamId::TypeParamId(id) => {
|
GenericParamId::TypeParamId(id) => {
|
||||||
id.parent.child_source(db).map(|source| match &source[id.local_id] {
|
id.parent.child_source(db).map(|source| match &source[id.local_id] {
|
||||||
Either::Left(id) => ast::DynAttrsOwner::new(id.clone()),
|
Either::Left(id) => ast::AnyAttrsOwner::new(id.clone()),
|
||||||
Either::Right(id) => ast::DynAttrsOwner::new(id.clone()),
|
Either::Right(id) => ast::AnyAttrsOwner::new(id.clone()),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
GenericParamId::LifetimeParamId(id) => id
|
GenericParamId::LifetimeParamId(id) => id
|
||||||
.parent
|
.parent
|
||||||
.child_source(db)
|
.child_source(db)
|
||||||
.map(|source| ast::DynAttrsOwner::new(source[id.local_id].clone())),
|
.map(|source| ast::AnyAttrsOwner::new(source[id.local_id].clone())),
|
||||||
GenericParamId::ConstParamId(id) => id
|
GenericParamId::ConstParamId(id) => id
|
||||||
.parent
|
.parent
|
||||||
.child_source(db)
|
.child_source(db)
|
||||||
.map(|source| ast::DynAttrsOwner::new(source[id.local_id].clone())),
|
.map(|source| ast::AnyAttrsOwner::new(source[id.local_id].clone())),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1444,45 +1444,45 @@ pub enum GenericParam {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for GenericParam {}
|
impl ast::AttrsOwner for GenericParam {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynArgListOwner {
|
pub struct AnyArgListOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::ArgListOwner for DynArgListOwner {}
|
impl ast::ArgListOwner for AnyArgListOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynAttrsOwner {
|
pub struct AnyAttrsOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for DynAttrsOwner {}
|
impl ast::AttrsOwner for AnyAttrsOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynGenericParamsOwner {
|
pub struct AnyGenericParamsOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::GenericParamsOwner for DynGenericParamsOwner {}
|
impl ast::GenericParamsOwner for AnyGenericParamsOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynLoopBodyOwner {
|
pub struct AnyLoopBodyOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::LoopBodyOwner for DynLoopBodyOwner {}
|
impl ast::LoopBodyOwner for AnyLoopBodyOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynModuleItemOwner {
|
pub struct AnyModuleItemOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::ModuleItemOwner for DynModuleItemOwner {}
|
impl ast::ModuleItemOwner for AnyModuleItemOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynNameOwner {
|
pub struct AnyNameOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::NameOwner for DynNameOwner {}
|
impl ast::NameOwner for AnyNameOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynTypeBoundsOwner {
|
pub struct AnyTypeBoundsOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::TypeBoundsOwner for DynTypeBoundsOwner {}
|
impl ast::TypeBoundsOwner for AnyTypeBoundsOwner {}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynVisibilityOwner {
|
pub struct AnyVisibilityOwner {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
}
|
}
|
||||||
impl ast::VisibilityOwner for DynVisibilityOwner {}
|
impl ast::VisibilityOwner for AnyVisibilityOwner {}
|
||||||
impl AstNode for Name {
|
impl AstNode for Name {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
|
fn can_cast(kind: SyntaxKind) -> bool { kind == NAME }
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
|
@ -3597,13 +3597,13 @@ impl AstNode for GenericParam {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl DynArgListOwner {
|
impl AnyArgListOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::ArgListOwner>(node: T) -> DynArgListOwner {
|
pub fn new<T: ast::ArgListOwner>(node: T) -> AnyArgListOwner {
|
||||||
DynArgListOwner { syntax: node.syntax().clone() }
|
AnyArgListOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynArgListOwner {
|
impl AstNode for AnyArgListOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
CALL_EXPR | METHOD_CALL_EXPR => true,
|
CALL_EXPR | METHOD_CALL_EXPR => true,
|
||||||
|
@ -3611,17 +3611,17 @@ impl AstNode for DynArgListOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynArgListOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyArgListOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynAttrsOwner {
|
impl AnyAttrsOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::AttrsOwner>(node: T) -> DynAttrsOwner {
|
pub fn new<T: ast::AttrsOwner>(node: T) -> AnyAttrsOwner {
|
||||||
DynAttrsOwner { syntax: node.syntax().clone() }
|
AnyAttrsOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynAttrsOwner {
|
impl AstNode for AnyAttrsOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
MACRO_CALL
|
MACRO_CALL
|
||||||
|
@ -3692,17 +3692,17 @@ impl AstNode for DynAttrsOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynAttrsOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyAttrsOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynGenericParamsOwner {
|
impl AnyGenericParamsOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::GenericParamsOwner>(node: T) -> DynGenericParamsOwner {
|
pub fn new<T: ast::GenericParamsOwner>(node: T) -> AnyGenericParamsOwner {
|
||||||
DynGenericParamsOwner { syntax: node.syntax().clone() }
|
AnyGenericParamsOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynGenericParamsOwner {
|
impl AstNode for AnyGenericParamsOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
ENUM | FN | IMPL | STRUCT | TRAIT | TYPE_ALIAS | UNION => true,
|
ENUM | FN | IMPL | STRUCT | TRAIT | TYPE_ALIAS | UNION => true,
|
||||||
|
@ -3710,17 +3710,17 @@ impl AstNode for DynGenericParamsOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynGenericParamsOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyGenericParamsOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynLoopBodyOwner {
|
impl AnyLoopBodyOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::LoopBodyOwner>(node: T) -> DynLoopBodyOwner {
|
pub fn new<T: ast::LoopBodyOwner>(node: T) -> AnyLoopBodyOwner {
|
||||||
DynLoopBodyOwner { syntax: node.syntax().clone() }
|
AnyLoopBodyOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynLoopBodyOwner {
|
impl AstNode for AnyLoopBodyOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
FOR_EXPR | LOOP_EXPR | WHILE_EXPR => true,
|
FOR_EXPR | LOOP_EXPR | WHILE_EXPR => true,
|
||||||
|
@ -3728,17 +3728,17 @@ impl AstNode for DynLoopBodyOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynLoopBodyOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyLoopBodyOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynModuleItemOwner {
|
impl AnyModuleItemOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::ModuleItemOwner>(node: T) -> DynModuleItemOwner {
|
pub fn new<T: ast::ModuleItemOwner>(node: T) -> AnyModuleItemOwner {
|
||||||
DynModuleItemOwner { syntax: node.syntax().clone() }
|
AnyModuleItemOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynModuleItemOwner {
|
impl AstNode for AnyModuleItemOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
MACRO_ITEMS | SOURCE_FILE | ITEM_LIST => true,
|
MACRO_ITEMS | SOURCE_FILE | ITEM_LIST => true,
|
||||||
|
@ -3746,17 +3746,17 @@ impl AstNode for DynModuleItemOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynModuleItemOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyModuleItemOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynNameOwner {
|
impl AnyNameOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::NameOwner>(node: T) -> DynNameOwner {
|
pub fn new<T: ast::NameOwner>(node: T) -> AnyNameOwner {
|
||||||
DynNameOwner { syntax: node.syntax().clone() }
|
AnyNameOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynNameOwner {
|
impl AstNode for AnyNameOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
CONST | ENUM | FN | MACRO_RULES | MACRO_DEF | MODULE | STATIC | STRUCT | TRAIT
|
CONST | ENUM | FN | MACRO_RULES | MACRO_DEF | MODULE | STATIC | STRUCT | TRAIT
|
||||||
|
@ -3766,17 +3766,17 @@ impl AstNode for DynNameOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynNameOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyNameOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynTypeBoundsOwner {
|
impl AnyTypeBoundsOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::TypeBoundsOwner>(node: T) -> DynTypeBoundsOwner {
|
pub fn new<T: ast::TypeBoundsOwner>(node: T) -> AnyTypeBoundsOwner {
|
||||||
DynTypeBoundsOwner { syntax: node.syntax().clone() }
|
AnyTypeBoundsOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynTypeBoundsOwner {
|
impl AstNode for AnyTypeBoundsOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
ASSOC_TYPE_ARG | TRAIT | TYPE_ALIAS | LIFETIME_PARAM | TYPE_PARAM | WHERE_PRED => true,
|
ASSOC_TYPE_ARG | TRAIT | TYPE_ALIAS | LIFETIME_PARAM | TYPE_PARAM | WHERE_PRED => true,
|
||||||
|
@ -3784,17 +3784,17 @@ impl AstNode for DynTypeBoundsOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynTypeBoundsOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyTypeBoundsOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl DynVisibilityOwner {
|
impl AnyVisibilityOwner {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn new<T: ast::VisibilityOwner>(node: T) -> DynVisibilityOwner {
|
pub fn new<T: ast::VisibilityOwner>(node: T) -> AnyVisibilityOwner {
|
||||||
DynVisibilityOwner { syntax: node.syntax().clone() }
|
AnyVisibilityOwner { syntax: node.syntax().clone() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl AstNode for DynVisibilityOwner {
|
impl AstNode for AnyVisibilityOwner {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
CONST | ENUM | EXTERN_CRATE | FN | IMPL | MACRO_RULES | MACRO_DEF | MODULE | STATIC
|
CONST | ENUM | EXTERN_CRATE | FN | IMPL | MACRO_RULES | MACRO_DEF | MODULE | STATIC
|
||||||
|
@ -3805,7 +3805,7 @@ impl AstNode for DynVisibilityOwner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||||
Self::can_cast(syntax.kind()).then(|| DynVisibilityOwner { syntax })
|
Self::can_cast(syntax.kind()).then(|| AnyVisibilityOwner { syntax })
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
|
|
|
@ -531,7 +531,7 @@ impl ast::Variant {
|
||||||
|
|
||||||
impl ast::Item {
|
impl ast::Item {
|
||||||
pub fn generic_param_list(&self) -> Option<ast::GenericParamList> {
|
pub fn generic_param_list(&self) -> Option<ast::GenericParamList> {
|
||||||
ast::DynGenericParamsOwner::cast(self.syntax().clone())?.generic_param_list()
|
ast::AnyGenericParamsOwner::cast(self.syntax().clone())?.generic_param_list()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -209,7 +209,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
|
||||||
})
|
})
|
||||||
.unzip();
|
.unzip();
|
||||||
|
|
||||||
let (dyn_node_defs, dyn_node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
|
let (any_node_defs, any_node_boilerplate_impls): (Vec<_>, Vec<_>) = grammar
|
||||||
.nodes
|
.nodes
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|node| node.traits.iter().map(move |t| (t, node)))
|
.flat_map(|node| node.traits.iter().map(move |t| (t, node)))
|
||||||
|
@ -217,7 +217,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.sorted_by_key(|(k, _)| k.clone())
|
.sorted_by_key(|(k, _)| k.clone())
|
||||||
.map(|(trait_name, nodes)| {
|
.map(|(trait_name, nodes)| {
|
||||||
let name = format_ident!("Dyn{}", trait_name);
|
let name = format_ident!("Any{}", trait_name);
|
||||||
let trait_name = format_ident!("{}", trait_name);
|
let trait_name = format_ident!("{}", trait_name);
|
||||||
let kinds: Vec<_> = nodes
|
let kinds: Vec<_> = nodes
|
||||||
.iter()
|
.iter()
|
||||||
|
@ -297,10 +297,10 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: &AstSrc) -> String {
|
||||||
|
|
||||||
#(#node_defs)*
|
#(#node_defs)*
|
||||||
#(#enum_defs)*
|
#(#enum_defs)*
|
||||||
#(#dyn_node_defs)*
|
#(#any_node_defs)*
|
||||||
#(#node_boilerplate_impls)*
|
#(#node_boilerplate_impls)*
|
||||||
#(#enum_boilerplate_impls)*
|
#(#enum_boilerplate_impls)*
|
||||||
#(#dyn_node_boilerplate_impls)*
|
#(#any_node_boilerplate_impls)*
|
||||||
#(#display_impls)*
|
#(#display_impls)*
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue