2019-08-18 20:36:22 +00:00
|
|
|
// Generated file, do not edit by hand, see `crate/ra_tools/src/codegen`
|
2018-10-15 21:44:23 +00:00
|
|
|
|
2018-10-15 16:55:32 +00:00
|
|
|
use crate::{
|
2019-08-18 20:36:22 +00:00
|
|
|
ast::{self, AstChildren, AstNode},
|
|
|
|
SyntaxKind::{self, *},
|
|
|
|
SyntaxNode,
|
2018-08-09 14:43:39 +00:00
|
|
|
};
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-02-01 23:18:10 +00:00
|
|
|
pub struct Alias {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for Alias {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ALIAS => true,
|
|
|
|
_ => false,
|
2019-02-01 23:18:10 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-02-01 23:18:10 +00:00
|
|
|
}
|
|
|
|
impl ast::NameOwner for Alias {}
|
|
|
|
impl Alias {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ArgList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ArgList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ARG_LIST => true,
|
|
|
|
_ => false,
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ArgList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn args(&self) -> AstChildren<Expr> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ArrayExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ArrayExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ARRAY_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-13 13:46:10 +00:00
|
|
|
impl ArrayExpr {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn exprs(&self) -> AstChildren<Expr> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-13 13:46:10 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ArrayType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ArrayType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ARRAY_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ArrayType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-12 23:19:20 +00:00
|
|
|
pub struct AssocTypeArg {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for AssocTypeArg {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ASSOC_TYPE_ARG => true,
|
|
|
|
_ => false,
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-12 23:19:20 +00:00
|
|
|
impl AssocTypeArg {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Attr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Attr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ATTR => true,
|
|
|
|
_ => false,
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Attr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn value(&self) -> Option<TokenTree> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-20 10:35:49 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
|
|
pub struct AwaitExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for AwaitExpr {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
AWAIT_EXPR => true,
|
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-20 10:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
impl AwaitExpr {
|
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-07-20 10:35:49 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct BinExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for BinExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
BIN_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl BinExpr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct BindPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for BindPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
BIND_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::NameOwner for BindPat {}
|
2019-01-17 12:08:18 +00:00
|
|
|
impl BindPat {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-17 12:08:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Block {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Block {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
BLOCK => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-28 20:03:56 +00:00
|
|
|
impl ast::AttrsOwner for Block {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Block {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn statements(&self) -> AstChildren<Stmt> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 07:12:28 +00:00
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct BlockExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for BlockExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
BLOCK_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl BlockExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn block(&self) -> Option<Block> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct BreakExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for BreakExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
BREAK_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl BreakExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-05 15:32:07 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct CallExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for CallExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
CALL_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::ArgListOwner for CallExpr {}
|
|
|
|
impl CallExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct CastExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for CastExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
CAST_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl CastExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Condition {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Condition {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
CONDITION => true,
|
|
|
|
_ => false,
|
2018-08-27 09:22:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Condition {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 09:22:09 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 09:22:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ConstDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ConstDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
CONST_DEF => true,
|
|
|
|
_ => false,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for ConstDef {}
|
|
|
|
impl ast::NameOwner for ConstDef {}
|
|
|
|
impl ast::TypeParamsOwner for ConstDef {}
|
|
|
|
impl ast::AttrsOwner for ConstDef {}
|
|
|
|
impl ast::DocCommentsOwner for ConstDef {}
|
2019-02-26 09:35:57 +00:00
|
|
|
impl ast::TypeAscriptionOwner for ConstDef {}
|
2019-03-30 11:17:31 +00:00
|
|
|
impl ConstDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn body(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-03-30 11:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ContinueExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ContinueExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
CONTINUE_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ContinueExpr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct DynTraitType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for DynTraitType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
DYN_TRAIT_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-03-31 07:56:48 +00:00
|
|
|
impl ast::TypeBoundsOwner for DynTraitType {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl DynTraitType {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct EnumDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for EnumDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ENUM_DEF => true,
|
|
|
|
_ => false,
|
2018-08-11 07:56:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for EnumDef {}
|
|
|
|
impl ast::NameOwner for EnumDef {}
|
|
|
|
impl ast::TypeParamsOwner for EnumDef {}
|
|
|
|
impl ast::AttrsOwner for EnumDef {}
|
|
|
|
impl ast::DocCommentsOwner for EnumDef {}
|
|
|
|
impl EnumDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn variant_list(&self) -> Option<EnumVariantList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct EnumVariant {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for EnumVariant {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ENUM_VARIANT => true,
|
|
|
|
_ => false,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::NameOwner for EnumVariant {}
|
2019-01-23 20:59:19 +00:00
|
|
|
impl ast::DocCommentsOwner for EnumVariant {}
|
2019-02-05 22:05:46 +00:00
|
|
|
impl ast::AttrsOwner for EnumVariant {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl EnumVariant {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct EnumVariantList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for EnumVariantList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ENUM_VARIANT_LIST => true,
|
|
|
|
_ => false,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl EnumVariantList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn variants(&self) -> AstChildren<EnumVariant> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Expr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for Expr {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
TUPLE_EXPR | ARRAY_EXPR | PAREN_EXPR | PATH_EXPR | LAMBDA_EXPR | IF_EXPR
|
|
|
|
| LOOP_EXPR | FOR_EXPR | WHILE_EXPR | CONTINUE_EXPR | BREAK_EXPR | LABEL
|
|
|
|
| BLOCK_EXPR | RETURN_EXPR | MATCH_EXPR | STRUCT_LIT | CALL_EXPR | INDEX_EXPR
|
|
|
|
| METHOD_CALL_EXPR | FIELD_EXPR | AWAIT_EXPR | TRY_EXPR | TRY_BLOCK_EXPR
|
|
|
|
| CAST_EXPR | REF_EXPR | PREFIX_EXPR | RANGE_EXPR | BIN_EXPR | LITERAL | MACRO_CALL => {
|
|
|
|
true
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum ExprKind {
|
|
|
|
TupleExpr(TupleExpr),
|
|
|
|
ArrayExpr(ArrayExpr),
|
|
|
|
ParenExpr(ParenExpr),
|
|
|
|
PathExpr(PathExpr),
|
|
|
|
LambdaExpr(LambdaExpr),
|
|
|
|
IfExpr(IfExpr),
|
|
|
|
LoopExpr(LoopExpr),
|
|
|
|
ForExpr(ForExpr),
|
|
|
|
WhileExpr(WhileExpr),
|
|
|
|
ContinueExpr(ContinueExpr),
|
|
|
|
BreakExpr(BreakExpr),
|
|
|
|
Label(Label),
|
|
|
|
BlockExpr(BlockExpr),
|
|
|
|
ReturnExpr(ReturnExpr),
|
|
|
|
MatchExpr(MatchExpr),
|
|
|
|
StructLit(StructLit),
|
|
|
|
CallExpr(CallExpr),
|
|
|
|
IndexExpr(IndexExpr),
|
|
|
|
MethodCallExpr(MethodCallExpr),
|
|
|
|
FieldExpr(FieldExpr),
|
2019-07-20 10:35:49 +00:00
|
|
|
AwaitExpr(AwaitExpr),
|
2019-07-18 16:23:05 +00:00
|
|
|
TryExpr(TryExpr),
|
|
|
|
TryBlockExpr(TryBlockExpr),
|
|
|
|
CastExpr(CastExpr),
|
|
|
|
RefExpr(RefExpr),
|
|
|
|
PrefixExpr(PrefixExpr),
|
|
|
|
RangeExpr(RangeExpr),
|
|
|
|
BinExpr(BinExpr),
|
|
|
|
Literal(Literal),
|
|
|
|
MacroCall(MacroCall),
|
2019-01-07 13:16:02 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TupleExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TupleExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ArrayExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ArrayExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ParenExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ParenExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PathExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PathExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<LambdaExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: LambdaExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<IfExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: IfExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<LoopExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: LoopExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ForExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ForExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<WhileExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: WhileExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ContinueExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ContinueExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<BreakExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: BreakExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<Label> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: Label) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<BlockExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: BlockExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ReturnExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ReturnExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<MatchExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: MatchExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<StructLit> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: StructLit) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<CallExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: CallExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<IndexExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: IndexExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<MethodCallExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: MethodCallExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<FieldExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: FieldExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-20 10:35:49 +00:00
|
|
|
impl From<AwaitExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: AwaitExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-07-20 10:35:49 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TryExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TryExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TryBlockExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TryBlockExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-06-06 11:36:16 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<CastExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: CastExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<RefExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: RefExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PrefixExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PrefixExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<RangeExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: RangeExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<BinExpr> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: BinExpr) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<Literal> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: Literal) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<MacroCall> for Expr {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: MacroCall) -> Expr {
|
|
|
|
Expr { syntax: node.syntax }
|
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Expr {
|
|
|
|
pub fn kind(&self) -> ExprKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
TUPLE_EXPR => ExprKind::TupleExpr(TupleExpr { syntax }),
|
|
|
|
ARRAY_EXPR => ExprKind::ArrayExpr(ArrayExpr { syntax }),
|
|
|
|
PAREN_EXPR => ExprKind::ParenExpr(ParenExpr { syntax }),
|
|
|
|
PATH_EXPR => ExprKind::PathExpr(PathExpr { syntax }),
|
|
|
|
LAMBDA_EXPR => ExprKind::LambdaExpr(LambdaExpr { syntax }),
|
|
|
|
IF_EXPR => ExprKind::IfExpr(IfExpr { syntax }),
|
|
|
|
LOOP_EXPR => ExprKind::LoopExpr(LoopExpr { syntax }),
|
|
|
|
FOR_EXPR => ExprKind::ForExpr(ForExpr { syntax }),
|
|
|
|
WHILE_EXPR => ExprKind::WhileExpr(WhileExpr { syntax }),
|
|
|
|
CONTINUE_EXPR => ExprKind::ContinueExpr(ContinueExpr { syntax }),
|
|
|
|
BREAK_EXPR => ExprKind::BreakExpr(BreakExpr { syntax }),
|
|
|
|
LABEL => ExprKind::Label(Label { syntax }),
|
|
|
|
BLOCK_EXPR => ExprKind::BlockExpr(BlockExpr { syntax }),
|
|
|
|
RETURN_EXPR => ExprKind::ReturnExpr(ReturnExpr { syntax }),
|
|
|
|
MATCH_EXPR => ExprKind::MatchExpr(MatchExpr { syntax }),
|
|
|
|
STRUCT_LIT => ExprKind::StructLit(StructLit { syntax }),
|
|
|
|
CALL_EXPR => ExprKind::CallExpr(CallExpr { syntax }),
|
|
|
|
INDEX_EXPR => ExprKind::IndexExpr(IndexExpr { syntax }),
|
|
|
|
METHOD_CALL_EXPR => ExprKind::MethodCallExpr(MethodCallExpr { syntax }),
|
|
|
|
FIELD_EXPR => ExprKind::FieldExpr(FieldExpr { syntax }),
|
|
|
|
AWAIT_EXPR => ExprKind::AwaitExpr(AwaitExpr { syntax }),
|
|
|
|
TRY_EXPR => ExprKind::TryExpr(TryExpr { syntax }),
|
|
|
|
TRY_BLOCK_EXPR => ExprKind::TryBlockExpr(TryBlockExpr { syntax }),
|
|
|
|
CAST_EXPR => ExprKind::CastExpr(CastExpr { syntax }),
|
|
|
|
REF_EXPR => ExprKind::RefExpr(RefExpr { syntax }),
|
|
|
|
PREFIX_EXPR => ExprKind::PrefixExpr(PrefixExpr { syntax }),
|
|
|
|
RANGE_EXPR => ExprKind::RangeExpr(RangeExpr { syntax }),
|
|
|
|
BIN_EXPR => ExprKind::BinExpr(BinExpr { syntax }),
|
|
|
|
LITERAL => ExprKind::Literal(Literal { syntax }),
|
|
|
|
MACRO_CALL => ExprKind::MacroCall(MacroCall { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl Expr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ExprStmt {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ExprStmt {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
EXPR_STMT => true,
|
|
|
|
_ => false,
|
2018-08-27 07:01:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ExprStmt {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ExternCrateItem {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ExternCrateItem {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
EXTERN_CRATE_ITEM => true,
|
|
|
|
_ => false,
|
2018-08-28 08:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-01 23:33:54 +00:00
|
|
|
impl ExternCrateItem {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-02-01 23:33:54 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn alias(&self) -> Option<Alias> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-02-01 23:33:54 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct FieldExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for FieldExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FIELD_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl FieldExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 12:54:38 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 12:54:38 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-18 13:52:31 +00:00
|
|
|
pub struct FieldPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for FieldPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FIELD_PAT => true,
|
|
|
|
_ => false,
|
2019-01-18 13:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-18 13:52:31 +00:00
|
|
|
impl ast::NameOwner for FieldPat {}
|
|
|
|
impl FieldPat {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-18 13:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct FieldPatList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for FieldPatList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FIELD_PAT_LIST => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-18 13:52:31 +00:00
|
|
|
impl FieldPatList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn field_pats(&self) -> AstChildren<FieldPat> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-19 00:02:38 +00:00
|
|
|
}
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn bind_pats(&self) -> AstChildren<BindPat> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-18 13:52:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct FnDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for FnDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FN_DEF => true,
|
|
|
|
_ => false,
|
2018-08-09 14:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for FnDef {}
|
|
|
|
impl ast::NameOwner for FnDef {}
|
|
|
|
impl ast::TypeParamsOwner for FnDef {}
|
|
|
|
impl ast::AttrsOwner for FnDef {}
|
|
|
|
impl ast::DocCommentsOwner for FnDef {}
|
|
|
|
impl FnDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn param_list(&self) -> Option<ParamList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn body(&self) -> Option<Block> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 07:01:31 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn ret_type(&self) -> Option<RetType> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-28 18:11:17 +00:00
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct FnPointerType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for FnPointerType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FN_POINTER_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl FnPointerType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn param_list(&self) -> Option<ParamList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn ret_type(&self) -> Option<RetType> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ForExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ForExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FOR_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::LoopBodyOwner for ForExpr {}
|
|
|
|
impl ForExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 19:03:19 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn iterable(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 19:03:19 +00:00
|
|
|
}
|
2018-08-27 09:22:09 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ForType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ForType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
FOR_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ForType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct IfExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for IfExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
IF_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl IfExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn condition(&self) -> Option<Condition> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ImplBlock {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ImplBlock {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
IMPL_BLOCK => true,
|
|
|
|
_ => false,
|
2018-08-14 08:20:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-16 20:19:24 +00:00
|
|
|
impl ast::TypeParamsOwner for ImplBlock {}
|
2019-04-14 22:03:54 +00:00
|
|
|
impl ast::AttrsOwner for ImplBlock {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ImplBlock {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn item_list(&self) -> Option<ItemList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-28 13:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ImplItem {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for ImplItem {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
FN_DEF | TYPE_ALIAS_DEF | CONST_DEF => true,
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum ImplItemKind {
|
|
|
|
FnDef(FnDef),
|
|
|
|
TypeAliasDef(TypeAliasDef),
|
|
|
|
ConstDef(ConstDef),
|
2018-12-28 13:34:00 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<FnDef> for ImplItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: FnDef) -> ImplItem {
|
|
|
|
ImplItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TypeAliasDef> for ImplItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TypeAliasDef) -> ImplItem {
|
|
|
|
ImplItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ConstDef> for ImplItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ConstDef) -> ImplItem {
|
|
|
|
ImplItem { syntax: node.syntax }
|
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ImplItem {
|
|
|
|
pub fn kind(&self) -> ImplItemKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
FN_DEF => ImplItemKind::FnDef(FnDef { syntax }),
|
|
|
|
TYPE_ALIAS_DEF => ImplItemKind::TypeAliasDef(TypeAliasDef { syntax }),
|
|
|
|
CONST_DEF => ImplItemKind::ConstDef(ConstDef { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
2018-12-28 13:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ImplItem {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ImplTraitType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ImplTraitType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
IMPL_TRAIT_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-03-31 07:56:48 +00:00
|
|
|
impl ast::TypeBoundsOwner for ImplTraitType {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ImplTraitType {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct IndexExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for IndexExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
INDEX_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl IndexExpr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ItemList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ItemList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
ITEM_LIST => true,
|
|
|
|
_ => false,
|
2018-09-03 12:10:06 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::FnDefOwner for ItemList {}
|
|
|
|
impl ast::ModuleItemOwner for ItemList {}
|
|
|
|
impl ItemList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn impl_items(&self) -> AstChildren<ImplItem> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-12-28 13:34:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Label {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Label {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LABEL => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Label {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct LambdaExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for LambdaExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LAMBDA_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl LambdaExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn param_list(&self) -> Option<ParamList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn body(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct LetStmt {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for LetStmt {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LET_STMT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-26 09:35:57 +00:00
|
|
|
impl ast::TypeAscriptionOwner for LetStmt {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl LetStmt {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn initializer(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 07:01:31 +00:00
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-12 23:19:20 +00:00
|
|
|
pub struct LifetimeArg {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for LifetimeArg {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LIFETIME_ARG => true,
|
|
|
|
_ => false,
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-03-30 10:25:53 +00:00
|
|
|
impl LifetimeArg {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct LifetimeParam {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for LifetimeParam {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LIFETIME_PARAM => true,
|
|
|
|
_ => false,
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-17 20:19:21 +00:00
|
|
|
impl ast::AttrsOwner for LifetimeParam {}
|
2019-03-30 10:25:53 +00:00
|
|
|
impl LifetimeParam {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Literal {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Literal {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LITERAL => true,
|
|
|
|
_ => false,
|
2018-08-28 11:21:37 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-03-30 10:25:53 +00:00
|
|
|
impl Literal {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-02-09 18:07:35 +00:00
|
|
|
pub struct LiteralPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for LiteralPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LITERAL_PAT => true,
|
|
|
|
_ => false,
|
2019-02-09 18:07:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-02-09 18:07:35 +00:00
|
|
|
}
|
|
|
|
impl LiteralPat {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn literal(&self) -> Option<Literal> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-02-09 18:07:35 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct LoopExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for LoopExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
LOOP_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::LoopBodyOwner for LoopExpr {}
|
|
|
|
impl LoopExpr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct MacroCall {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-12-28 10:27:30 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for MacroCall {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MACRO_CALL => true,
|
|
|
|
_ => false,
|
2018-12-28 10:27:30 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-11 16:23:13 +00:00
|
|
|
impl ast::NameOwner for MacroCall {}
|
2019-03-13 13:04:28 +00:00
|
|
|
impl ast::AttrsOwner for MacroCall {}
|
2019-04-24 20:16:50 +00:00
|
|
|
impl ast::DocCommentsOwner for MacroCall {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl MacroCall {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn token_tree(&self) -> Option<TokenTree> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-28 10:27:30 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-28 13:59:58 +00:00
|
|
|
}
|
2018-12-28 10:27:30 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-04-18 18:47:29 +00:00
|
|
|
pub struct MacroItems {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for MacroItems {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MACRO_ITEMS => true,
|
|
|
|
_ => false,
|
2019-04-18 18:47:29 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-04-18 18:47:29 +00:00
|
|
|
}
|
|
|
|
impl ast::ModuleItemOwner for MacroItems {}
|
|
|
|
impl ast::FnDefOwner for MacroItems {}
|
|
|
|
impl MacroItems {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-04-18 18:47:29 +00:00
|
|
|
pub struct MacroStmts {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for MacroStmts {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MACRO_STMTS => true,
|
|
|
|
_ => false,
|
2019-04-18 18:47:29 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-04-18 18:47:29 +00:00
|
|
|
}
|
|
|
|
impl MacroStmts {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn statements(&self) -> AstChildren<Stmt> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-04-18 18:47:29 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-04-18 18:47:29 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct MatchArm {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for MatchArm {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MATCH_ARM => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-17 17:08:34 +00:00
|
|
|
impl ast::AttrsOwner for MatchArm {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl MatchArm {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn pats(&self) -> AstChildren<Pat> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-09-02 22:51:46 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn guard(&self) -> Option<MatchGuard> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-09-02 22:51:46 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-09-02 22:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct MatchArmList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for MatchArmList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MATCH_ARM_LIST => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-17 17:08:34 +00:00
|
|
|
impl ast::AttrsOwner for MatchArmList {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl MatchArmList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn arms(&self) -> AstChildren<MatchArm> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct MatchExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for MatchExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MATCH_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl MatchExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-09-02 22:51:46 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn match_arm_list(&self) -> Option<MatchArmList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-09-02 22:51:46 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct MatchGuard {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for MatchGuard {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MATCH_GUARD => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-28 22:06:11 +00:00
|
|
|
impl MatchGuard {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-28 22:06:11 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct MethodCallExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for MethodCallExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
METHOD_CALL_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::ArgListOwner for MethodCallExpr {}
|
|
|
|
impl MethodCallExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-09-02 23:01:43 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 14:15:40 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_arg_list(&self) -> Option<TypeArgList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-02-16 22:05:57 +00:00
|
|
|
}
|
2018-09-02 23:01:43 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Module {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Module {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
MODULE => true,
|
|
|
|
_ => false,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for Module {}
|
|
|
|
impl ast::NameOwner for Module {}
|
|
|
|
impl ast::AttrsOwner for Module {}
|
|
|
|
impl ast::DocCommentsOwner for Module {}
|
|
|
|
impl Module {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn item_list(&self) -> Option<ItemList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-21 15:30:10 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ModuleItem {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for ModuleItem {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
STRUCT_DEF | ENUM_DEF | FN_DEF | TRAIT_DEF | TYPE_ALIAS_DEF | IMPL_BLOCK | USE_ITEM
|
|
|
|
| EXTERN_CRATE_ITEM | CONST_DEF | STATIC_DEF | MODULE => true,
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum ModuleItemKind {
|
|
|
|
StructDef(StructDef),
|
|
|
|
EnumDef(EnumDef),
|
|
|
|
FnDef(FnDef),
|
|
|
|
TraitDef(TraitDef),
|
|
|
|
TypeAliasDef(TypeAliasDef),
|
|
|
|
ImplBlock(ImplBlock),
|
|
|
|
UseItem(UseItem),
|
|
|
|
ExternCrateItem(ExternCrateItem),
|
|
|
|
ConstDef(ConstDef),
|
|
|
|
StaticDef(StaticDef),
|
|
|
|
Module(Module),
|
2019-01-07 13:16:02 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<StructDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: StructDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<EnumDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: EnumDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<FnDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: FnDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TraitDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TraitDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TypeAliasDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TypeAliasDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ImplBlock> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ImplBlock) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<UseItem> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: UseItem) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ExternCrateItem> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ExternCrateItem) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ConstDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ConstDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<StaticDef> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: StaticDef) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<Module> for ModuleItem {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: Module) -> ModuleItem {
|
|
|
|
ModuleItem { syntax: node.syntax }
|
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ModuleItem {
|
|
|
|
pub fn kind(&self) -> ModuleItemKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
STRUCT_DEF => ModuleItemKind::StructDef(StructDef { syntax }),
|
|
|
|
ENUM_DEF => ModuleItemKind::EnumDef(EnumDef { syntax }),
|
|
|
|
FN_DEF => ModuleItemKind::FnDef(FnDef { syntax }),
|
|
|
|
TRAIT_DEF => ModuleItemKind::TraitDef(TraitDef { syntax }),
|
|
|
|
TYPE_ALIAS_DEF => ModuleItemKind::TypeAliasDef(TypeAliasDef { syntax }),
|
|
|
|
IMPL_BLOCK => ModuleItemKind::ImplBlock(ImplBlock { syntax }),
|
|
|
|
USE_ITEM => ModuleItemKind::UseItem(UseItem { syntax }),
|
|
|
|
EXTERN_CRATE_ITEM => ModuleItemKind::ExternCrateItem(ExternCrateItem { syntax }),
|
|
|
|
CONST_DEF => ModuleItemKind::ConstDef(ConstDef { syntax }),
|
|
|
|
STATIC_DEF => ModuleItemKind::StaticDef(StaticDef { syntax }),
|
|
|
|
MODULE => ModuleItemKind::Module(Module { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl ModuleItem {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Name {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Name {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NAME => true,
|
|
|
|
_ => false,
|
2018-08-09 14:43:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Name {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NameRef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-13 13:35:17 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for NameRef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NAME_REF => true,
|
|
|
|
_ => false,
|
2018-08-13 13:35:17 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl NameRef {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NamedField {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for NamedField {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NAMED_FIELD => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl NamedField {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-24 20:00:14 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-24 20:00:14 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NamedFieldDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 11:45:56 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for NamedFieldDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NAMED_FIELD_DEF => true,
|
|
|
|
_ => false,
|
2018-08-14 11:45:56 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for NamedFieldDef {}
|
|
|
|
impl ast::NameOwner for NamedFieldDef {}
|
|
|
|
impl ast::AttrsOwner for NamedFieldDef {}
|
2019-01-25 19:29:56 +00:00
|
|
|
impl ast::DocCommentsOwner for NamedFieldDef {}
|
2019-02-26 09:35:57 +00:00
|
|
|
impl ast::TypeAscriptionOwner for NamedFieldDef {}
|
2019-02-27 12:00:08 +00:00
|
|
|
impl NamedFieldDef {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NamedFieldDefList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for NamedFieldDefList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NAMED_FIELD_DEF_LIST => true,
|
|
|
|
_ => false,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl NamedFieldDefList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn fields(&self) -> AstChildren<NamedFieldDef> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NamedFieldList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for NamedFieldList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NAMED_FIELD_LIST => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl NamedFieldList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn fields(&self) -> AstChildren<NamedField> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-12-24 20:00:14 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn spread(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-04-10 21:00:56 +00:00
|
|
|
}
|
2018-12-24 20:00:14 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NeverType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for NeverType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
NEVER_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl NeverType {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct NominalDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for NominalDef {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
STRUCT_DEF | ENUM_DEF => true,
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum NominalDefKind {
|
|
|
|
StructDef(StructDef),
|
|
|
|
EnumDef(EnumDef),
|
2018-08-14 10:33:44 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<StructDef> for NominalDef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: StructDef) -> NominalDef {
|
|
|
|
NominalDef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<EnumDef> for NominalDef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: EnumDef) -> NominalDef {
|
|
|
|
NominalDef { syntax: node.syntax }
|
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl NominalDef {
|
|
|
|
pub fn kind(&self) -> NominalDefKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
STRUCT_DEF => NominalDefKind::StructDef(StructDef { syntax }),
|
|
|
|
ENUM_DEF => NominalDefKind::EnumDef(EnumDef { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
2018-08-14 10:33:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::NameOwner for NominalDef {}
|
|
|
|
impl ast::TypeParamsOwner for NominalDef {}
|
|
|
|
impl ast::AttrsOwner for NominalDef {}
|
|
|
|
impl NominalDef {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Param {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Param {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PARAM => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-26 09:35:57 +00:00
|
|
|
impl ast::TypeAscriptionOwner for Param {}
|
2019-08-07 16:42:28 +00:00
|
|
|
impl ast::AttrsOwner for Param {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Param {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ParamList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ParamList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PARAM_LIST => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ParamList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn params(&self) -> AstChildren<Param> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn self_param(&self) -> Option<SelfParam> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-31 13:30:42 +00:00
|
|
|
}
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ParenExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ParenExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PAREN_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ParenExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ParenType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ParenType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PAREN_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ParenType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 16:17:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Pat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for Pat {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
REF_PAT | BIND_PAT | PLACEHOLDER_PAT | PATH_PAT | STRUCT_PAT | TUPLE_STRUCT_PAT
|
|
|
|
| TUPLE_PAT | SLICE_PAT | RANGE_PAT | LITERAL_PAT => true,
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum PatKind {
|
|
|
|
RefPat(RefPat),
|
|
|
|
BindPat(BindPat),
|
|
|
|
PlaceholderPat(PlaceholderPat),
|
|
|
|
PathPat(PathPat),
|
|
|
|
StructPat(StructPat),
|
|
|
|
TupleStructPat(TupleStructPat),
|
|
|
|
TuplePat(TuplePat),
|
|
|
|
SlicePat(SlicePat),
|
|
|
|
RangePat(RangePat),
|
|
|
|
LiteralPat(LiteralPat),
|
2019-01-07 13:16:02 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<RefPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: RefPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<BindPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: BindPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PlaceholderPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PlaceholderPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PathPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PathPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<StructPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: StructPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TupleStructPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TupleStructPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TuplePat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TuplePat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<SlicePat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: SlicePat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<RangePat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: RangePat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<LiteralPat> for Pat {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: LiteralPat) -> Pat {
|
|
|
|
Pat { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Pat {
|
|
|
|
pub fn kind(&self) -> PatKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
REF_PAT => PatKind::RefPat(RefPat { syntax }),
|
|
|
|
BIND_PAT => PatKind::BindPat(BindPat { syntax }),
|
|
|
|
PLACEHOLDER_PAT => PatKind::PlaceholderPat(PlaceholderPat { syntax }),
|
|
|
|
PATH_PAT => PatKind::PathPat(PathPat { syntax }),
|
|
|
|
STRUCT_PAT => PatKind::StructPat(StructPat { syntax }),
|
|
|
|
TUPLE_STRUCT_PAT => PatKind::TupleStructPat(TupleStructPat { syntax }),
|
|
|
|
TUPLE_PAT => PatKind::TuplePat(TuplePat { syntax }),
|
|
|
|
SLICE_PAT => PatKind::SlicePat(SlicePat { syntax }),
|
|
|
|
RANGE_PAT => PatKind::RangePat(RangePat { syntax }),
|
|
|
|
LITERAL_PAT => PatKind::LiteralPat(LiteralPat { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Pat {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Path {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-30 17:03:18 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Path {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PATH => true,
|
|
|
|
_ => false,
|
2018-08-30 17:03:18 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Path {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn segment(&self) -> Option<PathSegment> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn qualifier(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-24 15:37:25 +00:00
|
|
|
}
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PathExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PathExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PATH_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PathExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PathPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PathPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PATH_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-15 14:24:04 +00:00
|
|
|
impl PathPat {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-15 14:24:04 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PathSegment {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PathSegment {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PATH_SEGMENT => true,
|
|
|
|
_ => false,
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PathSegment {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn name_ref(&self) -> Option<NameRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_arg_list(&self) -> Option<TypeArgList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PathType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PathType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PATH_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PathType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-22 21:17:55 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PlaceholderPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PlaceholderPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PLACEHOLDER_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PlaceholderPat {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PlaceholderType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PlaceholderType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PLACEHOLDER_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PlaceholderType {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PointerType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PointerType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
POINTER_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PointerType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 16:17:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-25 21:24:12 +00:00
|
|
|
pub struct PosFieldDef {
|
2019-01-07 13:16:02 +00:00
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
2019-01-25 21:24:12 +00:00
|
|
|
impl AstNode for PosFieldDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
POS_FIELD_DEF => true,
|
|
|
|
_ => false,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-25 21:24:12 +00:00
|
|
|
impl ast::VisibilityOwner for PosFieldDef {}
|
|
|
|
impl ast::AttrsOwner for PosFieldDef {}
|
|
|
|
impl PosFieldDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-25 21:24:12 +00:00
|
|
|
pub struct PosFieldDefList {
|
2019-01-07 13:16:02 +00:00
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
2019-01-25 21:24:12 +00:00
|
|
|
impl AstNode for PosFieldDefList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
POS_FIELD_DEF_LIST => true,
|
|
|
|
_ => false,
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-25 21:24:12 +00:00
|
|
|
impl PosFieldDefList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn fields(&self) -> AstChildren<PosFieldDef> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-12-25 12:01:47 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct PrefixExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for PrefixExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
PREFIX_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl PrefixExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct RangeExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for RangeExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
RANGE_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl RangeExpr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct RangePat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for RangePat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
RANGE_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl RangePat {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct RefExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for RefExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
REF_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl RefExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct RefPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for RefPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
REF_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-13 10:34:57 +00:00
|
|
|
impl RefPat {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn pat(&self) -> Option<Pat> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-13 10:34:57 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ReferenceType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ReferenceType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
REFERENCE_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ReferenceType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 16:17:39 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct RetType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for RetType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
RET_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-28 18:11:17 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl RetType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-23 16:13:11 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct ReturnExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for ReturnExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
RETURN_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ReturnExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct SelfParam {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for SelfParam {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
SELF_PARAM => true,
|
|
|
|
_ => false,
|
2018-08-31 13:30:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-26 09:35:57 +00:00
|
|
|
impl ast::TypeAscriptionOwner for SelfParam {}
|
2019-08-07 16:42:28 +00:00
|
|
|
impl ast::AttrsOwner for SelfParam {}
|
2019-03-30 10:25:53 +00:00
|
|
|
impl SelfParam {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct SlicePat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for SlicePat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
SLICE_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl SlicePat {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct SliceType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for SliceType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
SLICE_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl SliceType {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct SourceFile {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-07 15:38:43 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for SourceFile {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
SOURCE_FILE => true,
|
|
|
|
_ => false,
|
2018-11-07 15:38:43 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::ModuleItemOwner for SourceFile {}
|
|
|
|
impl ast::FnDefOwner for SourceFile {}
|
|
|
|
impl SourceFile {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn modules(&self) -> AstChildren<Module> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-11-07 15:38:43 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct StaticDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for StaticDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
STATIC_DEF => true,
|
|
|
|
_ => false,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for StaticDef {}
|
|
|
|
impl ast::NameOwner for StaticDef {}
|
|
|
|
impl ast::TypeParamsOwner for StaticDef {}
|
|
|
|
impl ast::AttrsOwner for StaticDef {}
|
|
|
|
impl ast::DocCommentsOwner for StaticDef {}
|
2019-02-26 09:35:57 +00:00
|
|
|
impl ast::TypeAscriptionOwner for StaticDef {}
|
2019-03-30 11:17:31 +00:00
|
|
|
impl StaticDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn body(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-03-30 11:17:31 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Stmt {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for Stmt {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
EXPR_STMT | LET_STMT => true,
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum StmtKind {
|
|
|
|
ExprStmt(ExprStmt),
|
|
|
|
LetStmt(LetStmt),
|
2018-08-27 07:12:28 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ExprStmt> for Stmt {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ExprStmt) -> Stmt {
|
|
|
|
Stmt { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<LetStmt> for Stmt {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: LetStmt) -> Stmt {
|
|
|
|
Stmt { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Stmt {
|
|
|
|
pub fn kind(&self) -> StmtKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
EXPR_STMT => StmtKind::ExprStmt(ExprStmt { syntax }),
|
|
|
|
LET_STMT => StmtKind::LetStmt(LetStmt { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
2018-08-27 07:12:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Stmt {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct StructDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for StructDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
STRUCT_DEF => true,
|
|
|
|
_ => false,
|
2018-08-11 07:56:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for StructDef {}
|
|
|
|
impl ast::NameOwner for StructDef {}
|
|
|
|
impl ast::TypeParamsOwner for StructDef {}
|
|
|
|
impl ast::AttrsOwner for StructDef {}
|
|
|
|
impl ast::DocCommentsOwner for StructDef {}
|
|
|
|
impl StructDef {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct StructLit {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for StructLit {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
STRUCT_LIT => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl StructLit {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-24 20:00:14 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn named_field_list(&self) -> Option<NamedFieldList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-24 20:00:14 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct StructPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for StructPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
STRUCT_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-16 18:35:27 +00:00
|
|
|
impl StructPat {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn field_pat_list(&self) -> Option<FieldPatList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-16 18:35:27 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-16 18:35:27 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TokenTree {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TokenTree {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TOKEN_TREE => true,
|
|
|
|
_ => false,
|
2018-08-16 09:51:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TokenTree {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TraitDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TraitDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TRAIT_DEF => true,
|
|
|
|
_ => false,
|
2018-08-11 08:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::VisibilityOwner for TraitDef {}
|
|
|
|
impl ast::NameOwner for TraitDef {}
|
|
|
|
impl ast::AttrsOwner for TraitDef {}
|
|
|
|
impl ast::DocCommentsOwner for TraitDef {}
|
2019-01-24 22:31:32 +00:00
|
|
|
impl ast::TypeParamsOwner for TraitDef {}
|
2019-03-31 07:56:48 +00:00
|
|
|
impl ast::TypeBoundsOwner for TraitDef {}
|
2019-03-24 16:36:15 +00:00
|
|
|
impl TraitDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn item_list(&self) -> Option<ItemList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-03-24 16:36:15 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-06-06 11:36:16 +00:00
|
|
|
pub struct TryBlockExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for TryBlockExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TRY_BLOCK_EXPR => true,
|
|
|
|
_ => false,
|
2019-06-06 11:36:16 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-06-06 11:36:16 +00:00
|
|
|
}
|
|
|
|
impl ast::TryBlockBodyOwner for TryBlockExpr {}
|
|
|
|
impl TryBlockExpr {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TryExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TryExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TRY_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TryExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn expr(&self) -> Option<Expr> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-12-20 20:56:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TupleExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TupleExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TUPLE_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-13 11:52:25 +00:00
|
|
|
impl TupleExpr {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn exprs(&self) -> AstChildren<Expr> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-13 11:52:25 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TuplePat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TuplePat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TUPLE_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-15 14:24:04 +00:00
|
|
|
impl TuplePat {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn args(&self) -> AstChildren<Pat> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-15 14:24:04 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TupleStructPat {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TupleStructPat {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TUPLE_STRUCT_PAT => true,
|
|
|
|
_ => false,
|
2018-08-26 09:09:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TupleStructPat {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn args(&self) -> AstChildren<Pat> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-05 21:37:59 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-05 21:37:59 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TupleType {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TupleType {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TUPLE_TYPE => true,
|
|
|
|
_ => false,
|
2018-08-14 09:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TupleType {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn fields(&self) -> AstChildren<TypeRef> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-12-25 20:14:13 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-02-25 10:38:52 +00:00
|
|
|
pub struct TypeAliasDef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for TypeAliasDef {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_ALIAS_DEF => true,
|
|
|
|
_ => false,
|
2019-02-25 10:38:52 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-02-25 10:38:52 +00:00
|
|
|
}
|
|
|
|
impl ast::VisibilityOwner for TypeAliasDef {}
|
|
|
|
impl ast::NameOwner for TypeAliasDef {}
|
|
|
|
impl ast::TypeParamsOwner for TypeAliasDef {}
|
|
|
|
impl ast::AttrsOwner for TypeAliasDef {}
|
|
|
|
impl ast::DocCommentsOwner for TypeAliasDef {}
|
2019-03-31 07:56:48 +00:00
|
|
|
impl ast::TypeBoundsOwner for TypeAliasDef {}
|
2019-02-25 10:38:52 +00:00
|
|
|
impl TypeAliasDef {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-02-25 10:38:52 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-12 23:19:20 +00:00
|
|
|
pub struct TypeArg {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for TypeArg {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_ARG => true,
|
|
|
|
_ => false,
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-12 23:19:20 +00:00
|
|
|
impl TypeArg {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-12 23:19:20 +00:00
|
|
|
pub struct TypeArgList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for TypeArgList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_ARG_LIST => true,
|
|
|
|
_ => false,
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-12 23:19:20 +00:00
|
|
|
impl TypeArgList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn type_args(&self) -> AstChildren<TypeArg> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn lifetime_args(&self) -> AstChildren<LifetimeArg> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn assoc_type_args(&self) -> AstChildren<AssocTypeArg> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-01-12 23:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-03-30 15:11:21 +00:00
|
|
|
pub struct TypeBound {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for TypeBound {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_BOUND => true,
|
|
|
|
_ => false,
|
2019-03-30 15:11:21 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-03-30 15:11:21 +00:00
|
|
|
}
|
|
|
|
impl TypeBound {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-03-30 15:11:21 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-03-30 15:11:21 +00:00
|
|
|
pub struct TypeBoundList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for TypeBoundList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_BOUND_LIST => true,
|
|
|
|
_ => false,
|
2019-03-30 15:11:21 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-03-30 15:11:21 +00:00
|
|
|
}
|
|
|
|
impl TypeBoundList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn bounds(&self) -> AstChildren<TypeBound> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-03-30 15:11:21 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TypeParam {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TypeParam {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_PARAM => true,
|
|
|
|
_ => false,
|
2018-08-22 16:02:37 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::NameOwner for TypeParam {}
|
2019-02-17 20:19:21 +00:00
|
|
|
impl ast::AttrsOwner for TypeParam {}
|
2019-03-31 07:56:48 +00:00
|
|
|
impl ast::TypeBoundsOwner for TypeParam {}
|
2019-05-03 04:18:35 +00:00
|
|
|
impl ast::DefaultTypeParamOwner for TypeParam {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TypeParam {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TypeParamList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for TypeParamList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
TYPE_PARAM_LIST => true,
|
|
|
|
_ => false,
|
2018-08-22 13:46:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TypeParamList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn type_params(&self) -> AstChildren<TypeParam> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-08-22 16:02:37 +00:00
|
|
|
}
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn lifetime_params(&self) -> AstChildren<LifetimeParam> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-08-28 20:59:57 +00:00
|
|
|
}
|
2018-08-22 16:02:37 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct TypeRef {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
impl AstNode for TypeRef {
|
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
2019-08-18 20:36:22 +00:00
|
|
|
PAREN_TYPE | TUPLE_TYPE | NEVER_TYPE | PATH_TYPE | POINTER_TYPE | ARRAY_TYPE
|
|
|
|
| SLICE_TYPE | REFERENCE_TYPE | PLACEHOLDER_TYPE | FN_POINTER_TYPE | FOR_TYPE
|
|
|
|
| IMPL_TRAIT_TYPE | DYN_TRAIT_TYPE => true,
|
2019-07-19 15:22:00 +00:00
|
|
|
_ => false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub enum TypeRefKind {
|
|
|
|
ParenType(ParenType),
|
|
|
|
TupleType(TupleType),
|
|
|
|
NeverType(NeverType),
|
|
|
|
PathType(PathType),
|
|
|
|
PointerType(PointerType),
|
|
|
|
ArrayType(ArrayType),
|
|
|
|
SliceType(SliceType),
|
|
|
|
ReferenceType(ReferenceType),
|
|
|
|
PlaceholderType(PlaceholderType),
|
|
|
|
FnPointerType(FnPointerType),
|
|
|
|
ForType(ForType),
|
|
|
|
ImplTraitType(ImplTraitType),
|
|
|
|
DynTraitType(DynTraitType),
|
2019-01-07 13:16:02 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ParenType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ParenType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<TupleType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: TupleType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<NeverType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: NeverType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PathType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PathType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PointerType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PointerType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ArrayType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ArrayType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<SliceType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: SliceType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ReferenceType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ReferenceType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<PlaceholderType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: PlaceholderType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<FnPointerType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: FnPointerType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ForType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ForType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<ImplTraitType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: ImplTraitType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
impl From<DynTraitType> for TypeRef {
|
2019-08-18 20:36:22 +00:00
|
|
|
fn from(node: DynTraitType) -> TypeRef {
|
|
|
|
TypeRef { syntax: node.syntax }
|
|
|
|
}
|
2019-02-24 13:57:05 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl TypeRef {
|
|
|
|
pub fn kind(&self) -> TypeRefKind {
|
2019-08-18 20:36:22 +00:00
|
|
|
let syntax = self.syntax.clone();
|
|
|
|
match syntax.kind() {
|
|
|
|
PAREN_TYPE => TypeRefKind::ParenType(ParenType { syntax }),
|
|
|
|
TUPLE_TYPE => TypeRefKind::TupleType(TupleType { syntax }),
|
|
|
|
NEVER_TYPE => TypeRefKind::NeverType(NeverType { syntax }),
|
|
|
|
PATH_TYPE => TypeRefKind::PathType(PathType { syntax }),
|
|
|
|
POINTER_TYPE => TypeRefKind::PointerType(PointerType { syntax }),
|
|
|
|
ARRAY_TYPE => TypeRefKind::ArrayType(ArrayType { syntax }),
|
|
|
|
SLICE_TYPE => TypeRefKind::SliceType(SliceType { syntax }),
|
|
|
|
REFERENCE_TYPE => TypeRefKind::ReferenceType(ReferenceType { syntax }),
|
|
|
|
PLACEHOLDER_TYPE => TypeRefKind::PlaceholderType(PlaceholderType { syntax }),
|
|
|
|
FN_POINTER_TYPE => TypeRefKind::FnPointerType(FnPointerType { syntax }),
|
|
|
|
FOR_TYPE => TypeRefKind::ForType(ForType { syntax }),
|
|
|
|
IMPL_TRAIT_TYPE => TypeRefKind::ImplTraitType(ImplTraitType { syntax }),
|
|
|
|
DYN_TRAIT_TYPE => TypeRefKind::DynTraitType(DynTraitType { syntax }),
|
2019-01-07 13:16:02 +00:00
|
|
|
_ => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
impl TypeRef {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct UseItem {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-28 08:12:42 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for UseItem {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
USE_ITEM => true,
|
|
|
|
_ => false,
|
2018-08-28 08:12:42 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-02-10 19:44:34 +00:00
|
|
|
impl ast::AttrsOwner for UseItem {}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl UseItem {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn use_tree(&self) -> Option<UseTree> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct UseTree {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for UseTree {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
USE_TREE => true,
|
|
|
|
_ => false,
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl UseTree {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn path(&self) -> Option<Path> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn use_tree_list(&self) -> Option<UseTreeList> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn alias(&self) -> Option<Alias> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-02-01 23:18:10 +00:00
|
|
|
}
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct UseTreeList {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for UseTreeList {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
USE_TREE_LIST => true,
|
|
|
|
_ => false,
|
2018-08-30 17:37:33 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl UseTreeList {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn use_trees(&self) -> AstChildren<UseTree> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2018-10-31 07:27:53 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct Visibility {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2019-01-03 10:47:28 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for Visibility {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
VISIBILITY => true,
|
|
|
|
_ => false,
|
2019-01-03 10:47:28 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl Visibility {}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct WhereClause {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for WhereClause {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
WHERE_CLAUSE => true,
|
|
|
|
_ => false,
|
2018-08-22 08:56:36 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-03-24 17:45:11 +00:00
|
|
|
impl WhereClause {
|
2019-08-18 20:36:22 +00:00
|
|
|
pub fn predicates(&self) -> AstChildren<WherePred> {
|
|
|
|
AstChildren::new(&self.syntax)
|
2019-03-24 17:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-03-24 17:45:11 +00:00
|
|
|
pub struct WherePred {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
|
|
|
}
|
|
|
|
impl AstNode for WherePred {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
WHERE_PRED => true,
|
|
|
|
_ => false,
|
2019-03-24 17:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-03-24 17:45:11 +00:00
|
|
|
}
|
|
|
|
impl ast::TypeBoundsOwner for WherePred {}
|
|
|
|
impl WherePred {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn type_ref(&self) -> Option<TypeRef> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2019-03-24 17:45:11 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-18 16:23:05 +00:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
2019-01-07 13:16:02 +00:00
|
|
|
pub struct WhileExpr {
|
|
|
|
pub(crate) syntax: SyntaxNode,
|
2018-11-06 19:47:38 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl AstNode for WhileExpr {
|
2019-07-19 15:22:00 +00:00
|
|
|
fn can_cast(kind: SyntaxKind) -> bool {
|
|
|
|
match kind {
|
|
|
|
WHILE_EXPR => true,
|
|
|
|
_ => false,
|
2018-08-25 10:42:40 +00:00
|
|
|
}
|
|
|
|
}
|
2019-07-19 15:22:00 +00:00
|
|
|
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
2019-08-18 20:36:22 +00:00
|
|
|
if Self::can_cast(syntax.kind()) {
|
|
|
|
Some(Self { syntax })
|
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fn syntax(&self) -> &SyntaxNode {
|
|
|
|
&self.syntax
|
2019-07-19 15:22:00 +00:00
|
|
|
}
|
2019-01-24 23:09:31 +00:00
|
|
|
}
|
2019-01-07 13:16:02 +00:00
|
|
|
impl ast::LoopBodyOwner for WhileExpr {}
|
|
|
|
impl WhileExpr {
|
2019-07-18 16:23:05 +00:00
|
|
|
pub fn condition(&self) -> Option<Condition> {
|
2019-08-18 20:36:22 +00:00
|
|
|
AstChildren::new(&self.syntax).next()
|
2018-08-27 09:22:09 +00:00
|
|
|
}
|
|
|
|
}
|