diff options
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 119 |
1 files changed, 100 insertions, 19 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index c619fc130..7df6a9c46 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -1407,41 +1407,73 @@ impl<'a> IfExpr<'a> { | |||
1407 | } | 1407 | } |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | // ImplItem | 1410 | // ImplBlock |
1411 | #[derive(Debug, Clone, Copy,)] | 1411 | #[derive(Debug, Clone, Copy,)] |
1412 | pub struct ImplItemNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 1412 | pub struct ImplBlockNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
1413 | pub(crate) syntax: SyntaxNode<R>, | 1413 | pub(crate) syntax: SyntaxNode<R>, |
1414 | } | 1414 | } |
1415 | pub type ImplItem<'a> = ImplItemNode<RefRoot<'a>>; | 1415 | pub type ImplBlock<'a> = ImplBlockNode<RefRoot<'a>>; |
1416 | 1416 | ||
1417 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplItemNode<R1>> for ImplItemNode<R2> { | 1417 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<ImplBlockNode<R1>> for ImplBlockNode<R2> { |
1418 | fn eq(&self, other: &ImplItemNode<R1>) -> bool { self.syntax == other.syntax } | 1418 | fn eq(&self, other: &ImplBlockNode<R1>) -> bool { self.syntax == other.syntax } |
1419 | } | 1419 | } |
1420 | impl<R: TreeRoot<RaTypes>> Eq for ImplItemNode<R> {} | 1420 | impl<R: TreeRoot<RaTypes>> Eq for ImplBlockNode<R> {} |
1421 | impl<R: TreeRoot<RaTypes>> Hash for ImplItemNode<R> { | 1421 | impl<R: TreeRoot<RaTypes>> Hash for ImplBlockNode<R> { |
1422 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | 1422 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } |
1423 | } | 1423 | } |
1424 | 1424 | ||
1425 | impl<'a> AstNode<'a> for ImplItem<'a> { | 1425 | impl<'a> AstNode<'a> for ImplBlock<'a> { |
1426 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | 1426 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { |
1427 | match syntax.kind() { | 1427 | match syntax.kind() { |
1428 | IMPL_ITEM => Some(ImplItem { syntax }), | 1428 | IMPL_BLOCK => Some(ImplBlock { syntax }), |
1429 | _ => None, | 1429 | _ => None, |
1430 | } | 1430 | } |
1431 | } | 1431 | } |
1432 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | 1432 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } |
1433 | } | 1433 | } |
1434 | 1434 | ||
1435 | impl<R: TreeRoot<RaTypes>> ImplItemNode<R> { | 1435 | impl<R: TreeRoot<RaTypes>> ImplBlockNode<R> { |
1436 | pub fn borrowed(&self) -> ImplItem { | 1436 | pub fn borrowed(&self) -> ImplBlock { |
1437 | ImplItemNode { syntax: self.syntax.borrowed() } | 1437 | ImplBlockNode { syntax: self.syntax.borrowed() } |
1438 | } | 1438 | } |
1439 | pub fn owned(&self) -> ImplItemNode { | 1439 | pub fn owned(&self) -> ImplBlockNode { |
1440 | ImplItemNode { syntax: self.syntax.owned() } | 1440 | ImplBlockNode { syntax: self.syntax.owned() } |
1441 | } | 1441 | } |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | 1444 | ||
1445 | impl<'a> ImplBlock<'a> { | ||
1446 | pub fn item_list(self) -> Option<ItemList<'a>> { | ||
1447 | super::child_opt(self) | ||
1448 | } | ||
1449 | } | ||
1450 | |||
1451 | // ImplItem | ||
1452 | #[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
1453 | pub enum ImplItem<'a> { | ||
1454 | FnDef(FnDef<'a>), | ||
1455 | TypeDef(TypeDef<'a>), | ||
1456 | ConstDef(ConstDef<'a>), | ||
1457 | } | ||
1458 | |||
1459 | impl<'a> AstNode<'a> for ImplItem<'a> { | ||
1460 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
1461 | match syntax.kind() { | ||
1462 | FN_DEF => Some(ImplItem::FnDef(FnDef { syntax })), | ||
1463 | TYPE_DEF => Some(ImplItem::TypeDef(TypeDef { syntax })), | ||
1464 | CONST_DEF => Some(ImplItem::ConstDef(ConstDef { syntax })), | ||
1465 | _ => None, | ||
1466 | } | ||
1467 | } | ||
1468 | fn syntax(self) -> SyntaxNodeRef<'a> { | ||
1469 | match self { | ||
1470 | ImplItem::FnDef(inner) => inner.syntax(), | ||
1471 | ImplItem::TypeDef(inner) => inner.syntax(), | ||
1472 | ImplItem::ConstDef(inner) => inner.syntax(), | ||
1473 | } | ||
1474 | } | ||
1475 | } | ||
1476 | |||
1445 | impl<'a> ImplItem<'a> {} | 1477 | impl<'a> ImplItem<'a> {} |
1446 | 1478 | ||
1447 | // ImplTraitType | 1479 | // ImplTraitType |
@@ -1555,7 +1587,11 @@ impl<R: TreeRoot<RaTypes>> ItemListNode<R> { | |||
1555 | 1587 | ||
1556 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} | 1588 | impl<'a> ast::FnDefOwner<'a> for ItemList<'a> {} |
1557 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} | 1589 | impl<'a> ast::ModuleItemOwner<'a> for ItemList<'a> {} |
1558 | impl<'a> ItemList<'a> {} | 1590 | impl<'a> ItemList<'a> { |
1591 | pub fn impl_items(self) -> impl Iterator<Item = ImplItem<'a>> + 'a { | ||
1592 | super::children(self) | ||
1593 | } | ||
1594 | } | ||
1559 | 1595 | ||
1560 | // Label | 1596 | // Label |
1561 | #[derive(Debug, Clone, Copy,)] | 1597 | #[derive(Debug, Clone, Copy,)] |
@@ -2157,7 +2193,7 @@ pub enum ModuleItem<'a> { | |||
2157 | FnDef(FnDef<'a>), | 2193 | FnDef(FnDef<'a>), |
2158 | TraitDef(TraitDef<'a>), | 2194 | TraitDef(TraitDef<'a>), |
2159 | TypeDef(TypeDef<'a>), | 2195 | TypeDef(TypeDef<'a>), |
2160 | ImplItem(ImplItem<'a>), | 2196 | ImplBlock(ImplBlock<'a>), |
2161 | UseItem(UseItem<'a>), | 2197 | UseItem(UseItem<'a>), |
2162 | ExternCrateItem(ExternCrateItem<'a>), | 2198 | ExternCrateItem(ExternCrateItem<'a>), |
2163 | ConstDef(ConstDef<'a>), | 2199 | ConstDef(ConstDef<'a>), |
@@ -2173,7 +2209,7 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
2173 | FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })), | 2209 | FN_DEF => Some(ModuleItem::FnDef(FnDef { syntax })), |
2174 | TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })), | 2210 | TRAIT_DEF => Some(ModuleItem::TraitDef(TraitDef { syntax })), |
2175 | TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })), | 2211 | TYPE_DEF => Some(ModuleItem::TypeDef(TypeDef { syntax })), |
2176 | IMPL_ITEM => Some(ModuleItem::ImplItem(ImplItem { syntax })), | 2212 | IMPL_BLOCK => Some(ModuleItem::ImplBlock(ImplBlock { syntax })), |
2177 | USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })), | 2213 | USE_ITEM => Some(ModuleItem::UseItem(UseItem { syntax })), |
2178 | EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })), | 2214 | EXTERN_CRATE_ITEM => Some(ModuleItem::ExternCrateItem(ExternCrateItem { syntax })), |
2179 | CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })), | 2215 | CONST_DEF => Some(ModuleItem::ConstDef(ConstDef { syntax })), |
@@ -2189,7 +2225,7 @@ impl<'a> AstNode<'a> for ModuleItem<'a> { | |||
2189 | ModuleItem::FnDef(inner) => inner.syntax(), | 2225 | ModuleItem::FnDef(inner) => inner.syntax(), |
2190 | ModuleItem::TraitDef(inner) => inner.syntax(), | 2226 | ModuleItem::TraitDef(inner) => inner.syntax(), |
2191 | ModuleItem::TypeDef(inner) => inner.syntax(), | 2227 | ModuleItem::TypeDef(inner) => inner.syntax(), |
2192 | ModuleItem::ImplItem(inner) => inner.syntax(), | 2228 | ModuleItem::ImplBlock(inner) => inner.syntax(), |
2193 | ModuleItem::UseItem(inner) => inner.syntax(), | 2229 | ModuleItem::UseItem(inner) => inner.syntax(), |
2194 | ModuleItem::ExternCrateItem(inner) => inner.syntax(), | 2230 | ModuleItem::ExternCrateItem(inner) => inner.syntax(), |
2195 | ModuleItem::ConstDef(inner) => inner.syntax(), | 2231 | ModuleItem::ConstDef(inner) => inner.syntax(), |
@@ -3452,6 +3488,43 @@ impl<'a> ReturnExpr<'a> { | |||
3452 | } | 3488 | } |
3453 | } | 3489 | } |
3454 | 3490 | ||
3491 | // SelfKw | ||
3492 | #[derive(Debug, Clone, Copy,)] | ||
3493 | pub struct SelfKwNode<R: TreeRoot<RaTypes> = OwnedRoot> { | ||
3494 | pub(crate) syntax: SyntaxNode<R>, | ||
3495 | } | ||
3496 | pub type SelfKw<'a> = SelfKwNode<RefRoot<'a>>; | ||
3497 | |||
3498 | impl<R1: TreeRoot<RaTypes>, R2: TreeRoot<RaTypes>> PartialEq<SelfKwNode<R1>> for SelfKwNode<R2> { | ||
3499 | fn eq(&self, other: &SelfKwNode<R1>) -> bool { self.syntax == other.syntax } | ||
3500 | } | ||
3501 | impl<R: TreeRoot<RaTypes>> Eq for SelfKwNode<R> {} | ||
3502 | impl<R: TreeRoot<RaTypes>> Hash for SelfKwNode<R> { | ||
3503 | fn hash<H: Hasher>(&self, state: &mut H) { self.syntax.hash(state) } | ||
3504 | } | ||
3505 | |||
3506 | impl<'a> AstNode<'a> for SelfKw<'a> { | ||
3507 | fn cast(syntax: SyntaxNodeRef<'a>) -> Option<Self> { | ||
3508 | match syntax.kind() { | ||
3509 | SELF_KW => Some(SelfKw { syntax }), | ||
3510 | _ => None, | ||
3511 | } | ||
3512 | } | ||
3513 | fn syntax(self) -> SyntaxNodeRef<'a> { self.syntax } | ||
3514 | } | ||
3515 | |||
3516 | impl<R: TreeRoot<RaTypes>> SelfKwNode<R> { | ||
3517 | pub fn borrowed(&self) -> SelfKw { | ||
3518 | SelfKwNode { syntax: self.syntax.borrowed() } | ||
3519 | } | ||
3520 | pub fn owned(&self) -> SelfKwNode { | ||
3521 | SelfKwNode { syntax: self.syntax.owned() } | ||
3522 | } | ||
3523 | } | ||
3524 | |||
3525 | |||
3526 | impl<'a> SelfKw<'a> {} | ||
3527 | |||
3455 | // SelfParam | 3528 | // SelfParam |
3456 | #[derive(Debug, Clone, Copy,)] | 3529 | #[derive(Debug, Clone, Copy,)] |
3457 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { | 3530 | pub struct SelfParamNode<R: TreeRoot<RaTypes> = OwnedRoot> { |
@@ -3487,7 +3560,15 @@ impl<R: TreeRoot<RaTypes>> SelfParamNode<R> { | |||
3487 | } | 3560 | } |
3488 | 3561 | ||
3489 | 3562 | ||
3490 | impl<'a> SelfParam<'a> {} | 3563 | impl<'a> SelfParam<'a> { |
3564 | pub fn type_ref(self) -> Option<TypeRef<'a>> { | ||
3565 | super::child_opt(self) | ||
3566 | } | ||
3567 | |||
3568 | pub fn self_kw(self) -> Option<SelfKw<'a>> { | ||
3569 | super::child_opt(self) | ||
3570 | } | ||
3571 | } | ||
3491 | 3572 | ||
3492 | // SlicePat | 3573 | // SlicePat |
3493 | #[derive(Debug, Clone, Copy,)] | 3574 | #[derive(Debug, Clone, Copy,)] |