diff options
author | Ville Penttinen <[email protected]> | 2019-03-24 17:45:11 +0000 |
---|---|---|
committer | Ville Penttinen <[email protected]> | 2019-03-31 11:20:56 +0100 |
commit | 3f62ab8f510fdac1eeab515c515c437d6dd141e6 (patch) | |
tree | 91bb5a70b999474e4d8212245fe265e71c3afde4 /crates/ra_syntax/src/ast | |
parent | 4666138c910a655deb0e8129b0a1dc5974b49bdf (diff) |
Add WherePred to allow predicate access in WhereClause
This also unifies parsing of WHERE_PRED bounds, now Lifetime bounds will also be
parsed using TYPE_BOUND_LIST
Diffstat (limited to 'crates/ra_syntax/src/ast')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 9ea423b40..c51b4caa4 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -4810,7 +4810,48 @@ impl ToOwned for WhereClause { | |||
4810 | } | 4810 | } |
4811 | 4811 | ||
4812 | 4812 | ||
4813 | impl WhereClause {} | 4813 | impl WhereClause { |
4814 | pub fn predicates(&self) -> impl Iterator<Item = &WherePred> { | ||
4815 | super::children(self) | ||
4816 | } | ||
4817 | } | ||
4818 | |||
4819 | // WherePred | ||
4820 | #[derive(Debug, PartialEq, Eq, Hash)] | ||
4821 | #[repr(transparent)] | ||
4822 | pub struct WherePred { | ||
4823 | pub(crate) syntax: SyntaxNode, | ||
4824 | } | ||
4825 | unsafe impl TransparentNewType for WherePred { | ||
4826 | type Repr = rowan::SyntaxNode<RaTypes>; | ||
4827 | } | ||
4828 | |||
4829 | impl AstNode for WherePred { | ||
4830 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | ||
4831 | match syntax.kind() { | ||
4832 | WHERE_PRED => Some(WherePred::from_repr(syntax.into_repr())), | ||
4833 | _ => None, | ||
4834 | } | ||
4835 | } | ||
4836 | fn syntax(&self) -> &SyntaxNode { &self.syntax } | ||
4837 | } | ||
4838 | |||
4839 | impl ToOwned for WherePred { | ||
4840 | type Owned = TreeArc<WherePred>; | ||
4841 | fn to_owned(&self) -> TreeArc<WherePred> { TreeArc::cast(self.syntax.to_owned()) } | ||
4842 | } | ||
4843 | |||
4844 | |||
4845 | impl ast::TypeBoundsOwner for WherePred {} | ||
4846 | impl WherePred { | ||
4847 | pub fn type_ref(&self) -> Option<&TypeRef> { | ||
4848 | super::child_opt(self) | ||
4849 | } | ||
4850 | |||
4851 | pub fn lifetime(&self) -> Option<&Lifetime> { | ||
4852 | super::child_opt(self) | ||
4853 | } | ||
4854 | } | ||
4814 | 4855 | ||
4815 | // WhileExpr | 4856 | // WhileExpr |
4816 | #[derive(Debug, PartialEq, Eq, Hash)] | 4857 | #[derive(Debug, PartialEq, Eq, Hash)] |