mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-26 11:55:04 +00:00
Convert more tokens
This commit is contained in:
parent
548f562dda
commit
779f06ed77
5 changed files with 34 additions and 268 deletions
|
@ -1,6 +1,6 @@
|
||||||
use hir::HirDisplay;
|
use hir::HirDisplay;
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
ast::{self, AstNode, AstToken, LetStmt, NameOwner, TypeAscriptionOwner},
|
ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner},
|
||||||
TextRange,
|
TextRange,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> {
|
||||||
let name = pat.name()?;
|
let name = pat.name()?;
|
||||||
let name_range = name.syntax().text_range();
|
let name_range = name.syntax().text_range();
|
||||||
let stmt_range = stmt.syntax().text_range();
|
let stmt_range = stmt.syntax().text_range();
|
||||||
let eq_range = stmt.eq_token()?.syntax().text_range();
|
let eq_range = stmt.eq_token()?.text_range();
|
||||||
// Assist should only be applicable if cursor is between 'let' and '='
|
// Assist should only be applicable if cursor is between 'let' and '='
|
||||||
let let_range = TextRange::from_to(stmt_range.start(), eq_range.start());
|
let let_range = TextRange::from_to(stmt_range.start(), eq_range.start());
|
||||||
let cursor_in_range = ctx.frange.range.is_subrange(&let_range);
|
let cursor_in_range = ctx.frange.range.is_subrange(&let_range);
|
||||||
|
|
|
@ -276,7 +276,7 @@ impl ast::DocCommentsOwner for EnumVariant {}
|
||||||
impl ast::AttrsOwner for EnumVariant {}
|
impl ast::AttrsOwner for EnumVariant {}
|
||||||
impl EnumVariant {
|
impl EnumVariant {
|
||||||
pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
|
pub fn field_def_list(&self) -> Option<FieldDefList> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -377,7 +377,7 @@ impl ConstDef {
|
||||||
support::token2(&self.syntax, T![default])
|
support::token2(&self.syntax, T![default])
|
||||||
}
|
}
|
||||||
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
|
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![const]) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
|
@ -405,7 +405,7 @@ impl ast::TypeAscriptionOwner for StaticDef {}
|
||||||
impl StaticDef {
|
impl StaticDef {
|
||||||
pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![static]) }
|
pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![static]) }
|
||||||
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mut]) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
|
@ -435,7 +435,7 @@ impl TypeAliasDef {
|
||||||
support::token2(&self.syntax, T![default])
|
support::token2(&self.syntax, T![default])
|
||||||
}
|
}
|
||||||
pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) }
|
pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![type]) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
|
@ -1278,9 +1278,7 @@ impl AstNode for BinExpr {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for BinExpr {}
|
impl ast::AttrsOwner for BinExpr {}
|
||||||
impl BinExpr {
|
impl BinExpr {}
|
||||||
pub fn bin_op_token(&self) -> Option<BinOp> { support::token(&self.syntax) }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Literal {
|
pub struct Literal {
|
||||||
pub(crate) syntax: SyntaxNode,
|
pub(crate) syntax: SyntaxNode,
|
||||||
|
@ -1881,7 +1879,7 @@ impl Attr {
|
||||||
pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
|
pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
|
||||||
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['[']) }
|
pub fn l_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T!['[']) }
|
||||||
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
|
pub fn input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
|
||||||
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![']']) }
|
pub fn r_brack_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![']']) }
|
||||||
}
|
}
|
||||||
|
@ -1943,7 +1941,7 @@ impl ast::NameOwner for TypeParam {}
|
||||||
impl ast::AttrsOwner for TypeParam {}
|
impl ast::AttrsOwner for TypeParam {}
|
||||||
impl ast::TypeBoundsOwner for TypeParam {}
|
impl ast::TypeBoundsOwner for TypeParam {}
|
||||||
impl TypeParam {
|
impl TypeParam {
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
pub fn default_type(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1965,7 +1963,7 @@ impl ast::NameOwner for ConstParam {}
|
||||||
impl ast::AttrsOwner for ConstParam {}
|
impl ast::AttrsOwner for ConstParam {}
|
||||||
impl ast::TypeAscriptionOwner for ConstParam {}
|
impl ast::TypeAscriptionOwner for ConstParam {}
|
||||||
impl ConstParam {
|
impl ConstParam {
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn default_val(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2122,7 +2120,7 @@ impl ast::TypeAscriptionOwner for LetStmt {}
|
||||||
impl LetStmt {
|
impl LetStmt {
|
||||||
pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) }
|
pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) }
|
||||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn initializer(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
}
|
}
|
||||||
|
@ -2144,7 +2142,7 @@ impl AstNode for Condition {
|
||||||
impl Condition {
|
impl Condition {
|
||||||
pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) }
|
pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![let]) }
|
||||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2463,7 +2461,7 @@ impl AstNode for AssocTypeArg {
|
||||||
impl ast::TypeBoundsOwner for AssocTypeArg {}
|
impl ast::TypeBoundsOwner for AssocTypeArg {}
|
||||||
impl AssocTypeArg {
|
impl AssocTypeArg {
|
||||||
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2501,7 +2499,7 @@ impl AstNode for ConstArg {
|
||||||
}
|
}
|
||||||
impl ConstArg {
|
impl ConstArg {
|
||||||
pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
|
pub fn literal(&self) -> Option<Literal> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
pub fn block_expr(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2597,7 +2595,7 @@ impl AstNode for MetaItem {
|
||||||
}
|
}
|
||||||
impl MetaItem {
|
impl MetaItem {
|
||||||
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
||||||
pub fn eq_token(&self) -> Option<Eq> { support::token(&self.syntax) }
|
pub fn eq_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![=]) }
|
||||||
pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
|
pub fn attr_input(&self) -> Option<AttrInput> { support::child(&self.syntax) }
|
||||||
pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
|
pub fn nested_meta_items(&self) -> AstChildren<MetaItem> { support::children(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1410,208 +1410,6 @@ impl AstToken for RangeSeparator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum BinOp {
|
|
||||||
Pipepipe(Pipepipe),
|
|
||||||
Ampamp(Ampamp),
|
|
||||||
Eqeq(Eqeq),
|
|
||||||
Neq(Neq),
|
|
||||||
Lteq(Lteq),
|
|
||||||
Gteq(Gteq),
|
|
||||||
LAngle(LAngle),
|
|
||||||
RAngle(RAngle),
|
|
||||||
Plus(Plus),
|
|
||||||
Star(Star),
|
|
||||||
Minus(Minus),
|
|
||||||
Slash(Slash),
|
|
||||||
Percent(Percent),
|
|
||||||
Shl(Shl),
|
|
||||||
Shr(Shr),
|
|
||||||
Caret(Caret),
|
|
||||||
Pipe(Pipe),
|
|
||||||
Amp(Amp),
|
|
||||||
Eq(Eq),
|
|
||||||
Pluseq(Pluseq),
|
|
||||||
Slasheq(Slasheq),
|
|
||||||
Stareq(Stareq),
|
|
||||||
Percenteq(Percenteq),
|
|
||||||
Shreq(Shreq),
|
|
||||||
Shleq(Shleq),
|
|
||||||
Minuseq(Minuseq),
|
|
||||||
Pipeeq(Pipeeq),
|
|
||||||
Ampeq(Ampeq),
|
|
||||||
Careteq(Careteq),
|
|
||||||
}
|
|
||||||
impl From<Pipepipe> for BinOp {
|
|
||||||
fn from(node: Pipepipe) -> BinOp { BinOp::Pipepipe(node) }
|
|
||||||
}
|
|
||||||
impl From<Ampamp> for BinOp {
|
|
||||||
fn from(node: Ampamp) -> BinOp { BinOp::Ampamp(node) }
|
|
||||||
}
|
|
||||||
impl From<Eqeq> for BinOp {
|
|
||||||
fn from(node: Eqeq) -> BinOp { BinOp::Eqeq(node) }
|
|
||||||
}
|
|
||||||
impl From<Neq> for BinOp {
|
|
||||||
fn from(node: Neq) -> BinOp { BinOp::Neq(node) }
|
|
||||||
}
|
|
||||||
impl From<Lteq> for BinOp {
|
|
||||||
fn from(node: Lteq) -> BinOp { BinOp::Lteq(node) }
|
|
||||||
}
|
|
||||||
impl From<Gteq> for BinOp {
|
|
||||||
fn from(node: Gteq) -> BinOp { BinOp::Gteq(node) }
|
|
||||||
}
|
|
||||||
impl From<LAngle> for BinOp {
|
|
||||||
fn from(node: LAngle) -> BinOp { BinOp::LAngle(node) }
|
|
||||||
}
|
|
||||||
impl From<RAngle> for BinOp {
|
|
||||||
fn from(node: RAngle) -> BinOp { BinOp::RAngle(node) }
|
|
||||||
}
|
|
||||||
impl From<Plus> for BinOp {
|
|
||||||
fn from(node: Plus) -> BinOp { BinOp::Plus(node) }
|
|
||||||
}
|
|
||||||
impl From<Star> for BinOp {
|
|
||||||
fn from(node: Star) -> BinOp { BinOp::Star(node) }
|
|
||||||
}
|
|
||||||
impl From<Minus> for BinOp {
|
|
||||||
fn from(node: Minus) -> BinOp { BinOp::Minus(node) }
|
|
||||||
}
|
|
||||||
impl From<Slash> for BinOp {
|
|
||||||
fn from(node: Slash) -> BinOp { BinOp::Slash(node) }
|
|
||||||
}
|
|
||||||
impl From<Percent> for BinOp {
|
|
||||||
fn from(node: Percent) -> BinOp { BinOp::Percent(node) }
|
|
||||||
}
|
|
||||||
impl From<Shl> for BinOp {
|
|
||||||
fn from(node: Shl) -> BinOp { BinOp::Shl(node) }
|
|
||||||
}
|
|
||||||
impl From<Shr> for BinOp {
|
|
||||||
fn from(node: Shr) -> BinOp { BinOp::Shr(node) }
|
|
||||||
}
|
|
||||||
impl From<Caret> for BinOp {
|
|
||||||
fn from(node: Caret) -> BinOp { BinOp::Caret(node) }
|
|
||||||
}
|
|
||||||
impl From<Pipe> for BinOp {
|
|
||||||
fn from(node: Pipe) -> BinOp { BinOp::Pipe(node) }
|
|
||||||
}
|
|
||||||
impl From<Amp> for BinOp {
|
|
||||||
fn from(node: Amp) -> BinOp { BinOp::Amp(node) }
|
|
||||||
}
|
|
||||||
impl From<Eq> for BinOp {
|
|
||||||
fn from(node: Eq) -> BinOp { BinOp::Eq(node) }
|
|
||||||
}
|
|
||||||
impl From<Pluseq> for BinOp {
|
|
||||||
fn from(node: Pluseq) -> BinOp { BinOp::Pluseq(node) }
|
|
||||||
}
|
|
||||||
impl From<Slasheq> for BinOp {
|
|
||||||
fn from(node: Slasheq) -> BinOp { BinOp::Slasheq(node) }
|
|
||||||
}
|
|
||||||
impl From<Stareq> for BinOp {
|
|
||||||
fn from(node: Stareq) -> BinOp { BinOp::Stareq(node) }
|
|
||||||
}
|
|
||||||
impl From<Percenteq> for BinOp {
|
|
||||||
fn from(node: Percenteq) -> BinOp { BinOp::Percenteq(node) }
|
|
||||||
}
|
|
||||||
impl From<Shreq> for BinOp {
|
|
||||||
fn from(node: Shreq) -> BinOp { BinOp::Shreq(node) }
|
|
||||||
}
|
|
||||||
impl From<Shleq> for BinOp {
|
|
||||||
fn from(node: Shleq) -> BinOp { BinOp::Shleq(node) }
|
|
||||||
}
|
|
||||||
impl From<Minuseq> for BinOp {
|
|
||||||
fn from(node: Minuseq) -> BinOp { BinOp::Minuseq(node) }
|
|
||||||
}
|
|
||||||
impl From<Pipeeq> for BinOp {
|
|
||||||
fn from(node: Pipeeq) -> BinOp { BinOp::Pipeeq(node) }
|
|
||||||
}
|
|
||||||
impl From<Ampeq> for BinOp {
|
|
||||||
fn from(node: Ampeq) -> BinOp { BinOp::Ampeq(node) }
|
|
||||||
}
|
|
||||||
impl From<Careteq> for BinOp {
|
|
||||||
fn from(node: Careteq) -> BinOp { BinOp::Careteq(node) }
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for BinOp {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(self.syntax(), f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for BinOp {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
|
||||||
match kind {
|
|
||||||
PIPEPIPE | AMPAMP | EQEQ | NEQ | LTEQ | GTEQ | L_ANGLE | R_ANGLE | PLUS | STAR
|
|
||||||
| MINUS | SLASH | PERCENT | SHL | SHR | CARET | PIPE | AMP | EQ | PLUSEQ | SLASHEQ
|
|
||||||
| STAREQ | PERCENTEQ | SHREQ | SHLEQ | MINUSEQ | PIPEEQ | AMPEQ | CARETEQ => true,
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
let res = match syntax.kind() {
|
|
||||||
PIPEPIPE => BinOp::Pipepipe(Pipepipe { syntax }),
|
|
||||||
AMPAMP => BinOp::Ampamp(Ampamp { syntax }),
|
|
||||||
EQEQ => BinOp::Eqeq(Eqeq { syntax }),
|
|
||||||
NEQ => BinOp::Neq(Neq { syntax }),
|
|
||||||
LTEQ => BinOp::Lteq(Lteq { syntax }),
|
|
||||||
GTEQ => BinOp::Gteq(Gteq { syntax }),
|
|
||||||
L_ANGLE => BinOp::LAngle(LAngle { syntax }),
|
|
||||||
R_ANGLE => BinOp::RAngle(RAngle { syntax }),
|
|
||||||
PLUS => BinOp::Plus(Plus { syntax }),
|
|
||||||
STAR => BinOp::Star(Star { syntax }),
|
|
||||||
MINUS => BinOp::Minus(Minus { syntax }),
|
|
||||||
SLASH => BinOp::Slash(Slash { syntax }),
|
|
||||||
PERCENT => BinOp::Percent(Percent { syntax }),
|
|
||||||
SHL => BinOp::Shl(Shl { syntax }),
|
|
||||||
SHR => BinOp::Shr(Shr { syntax }),
|
|
||||||
CARET => BinOp::Caret(Caret { syntax }),
|
|
||||||
PIPE => BinOp::Pipe(Pipe { syntax }),
|
|
||||||
AMP => BinOp::Amp(Amp { syntax }),
|
|
||||||
EQ => BinOp::Eq(Eq { syntax }),
|
|
||||||
PLUSEQ => BinOp::Pluseq(Pluseq { syntax }),
|
|
||||||
SLASHEQ => BinOp::Slasheq(Slasheq { syntax }),
|
|
||||||
STAREQ => BinOp::Stareq(Stareq { syntax }),
|
|
||||||
PERCENTEQ => BinOp::Percenteq(Percenteq { syntax }),
|
|
||||||
SHREQ => BinOp::Shreq(Shreq { syntax }),
|
|
||||||
SHLEQ => BinOp::Shleq(Shleq { syntax }),
|
|
||||||
MINUSEQ => BinOp::Minuseq(Minuseq { syntax }),
|
|
||||||
PIPEEQ => BinOp::Pipeeq(Pipeeq { syntax }),
|
|
||||||
AMPEQ => BinOp::Ampeq(Ampeq { syntax }),
|
|
||||||
CARETEQ => BinOp::Careteq(Careteq { syntax }),
|
|
||||||
_ => return None,
|
|
||||||
};
|
|
||||||
Some(res)
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken {
|
|
||||||
match self {
|
|
||||||
BinOp::Pipepipe(it) => &it.syntax,
|
|
||||||
BinOp::Ampamp(it) => &it.syntax,
|
|
||||||
BinOp::Eqeq(it) => &it.syntax,
|
|
||||||
BinOp::Neq(it) => &it.syntax,
|
|
||||||
BinOp::Lteq(it) => &it.syntax,
|
|
||||||
BinOp::Gteq(it) => &it.syntax,
|
|
||||||
BinOp::LAngle(it) => &it.syntax,
|
|
||||||
BinOp::RAngle(it) => &it.syntax,
|
|
||||||
BinOp::Plus(it) => &it.syntax,
|
|
||||||
BinOp::Star(it) => &it.syntax,
|
|
||||||
BinOp::Minus(it) => &it.syntax,
|
|
||||||
BinOp::Slash(it) => &it.syntax,
|
|
||||||
BinOp::Percent(it) => &it.syntax,
|
|
||||||
BinOp::Shl(it) => &it.syntax,
|
|
||||||
BinOp::Shr(it) => &it.syntax,
|
|
||||||
BinOp::Caret(it) => &it.syntax,
|
|
||||||
BinOp::Pipe(it) => &it.syntax,
|
|
||||||
BinOp::Amp(it) => &it.syntax,
|
|
||||||
BinOp::Eq(it) => &it.syntax,
|
|
||||||
BinOp::Pluseq(it) => &it.syntax,
|
|
||||||
BinOp::Slasheq(it) => &it.syntax,
|
|
||||||
BinOp::Stareq(it) => &it.syntax,
|
|
||||||
BinOp::Percenteq(it) => &it.syntax,
|
|
||||||
BinOp::Shreq(it) => &it.syntax,
|
|
||||||
BinOp::Shleq(it) => &it.syntax,
|
|
||||||
BinOp::Minuseq(it) => &it.syntax,
|
|
||||||
BinOp::Pipeeq(it) => &it.syntax,
|
|
||||||
BinOp::Ampeq(it) => &it.syntax,
|
|
||||||
BinOp::Careteq(it) => &it.syntax,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub enum PrefixOp {
|
pub enum PrefixOp {
|
||||||
Minus(Minus),
|
Minus(Minus),
|
||||||
Excl(Excl),
|
Excl(Excl),
|
||||||
|
|
|
@ -354,7 +354,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
}
|
}
|
||||||
struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
|
struct EnumVariant: VisibilityOwner, NameOwner, DocCommentsOwner, AttrsOwner {
|
||||||
FieldDefList,
|
FieldDefList,
|
||||||
Eq,
|
T![=],
|
||||||
Expr
|
Expr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -380,7 +380,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
|
struct ConstDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
|
||||||
T![default],
|
T![default],
|
||||||
T![const],
|
T![const],
|
||||||
Eq,
|
T![=],
|
||||||
body: Expr,
|
body: Expr,
|
||||||
T![;]
|
T![;]
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
|
struct StaticDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeAscriptionOwner {
|
||||||
T![static],
|
T![static],
|
||||||
T![mut],
|
T![mut],
|
||||||
Eq,
|
T![=],
|
||||||
body: Expr,
|
body: Expr,
|
||||||
T![;]
|
T![;]
|
||||||
}
|
}
|
||||||
|
@ -396,7 +396,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
|
struct TypeAliasDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner, TypeBoundsOwner {
|
||||||
T![default],
|
T![default],
|
||||||
T![type],
|
T![type],
|
||||||
Eq,
|
T![=],
|
||||||
TypeRef,
|
TypeRef,
|
||||||
T![;]
|
T![;]
|
||||||
}
|
}
|
||||||
|
@ -406,14 +406,14 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
T![const],
|
T![const],
|
||||||
T![unsafe],
|
T![unsafe],
|
||||||
T![impl],
|
T![impl],
|
||||||
Excl,
|
T![!],
|
||||||
T![for],
|
T![for],
|
||||||
ItemList,
|
ItemList,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ParenType { T!['('], TypeRef, T![')'] }
|
struct ParenType { T!['('], TypeRef, T![')'] }
|
||||||
struct TupleType { T!['('], fields: [TypeRef], T![')'] }
|
struct TupleType { T!['('], fields: [TypeRef], T![')'] }
|
||||||
struct NeverType { Excl }
|
struct NeverType { T![!] }
|
||||||
struct PathType { Path }
|
struct PathType { Path }
|
||||||
struct PointerType { Star, T![const], T![mut], TypeRef }
|
struct PointerType { Star, T![const], T![mut], TypeRef }
|
||||||
struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] }
|
struct ArrayType { T!['['], TypeRef, T![;], Expr, T![']'] }
|
||||||
|
@ -465,7 +465,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
struct PrefixExpr: AttrsOwner { PrefixOp, Expr }
|
struct PrefixExpr: AttrsOwner { PrefixOp, Expr }
|
||||||
struct BoxExpr: AttrsOwner { T![box], Expr }
|
struct BoxExpr: AttrsOwner { T![box], Expr }
|
||||||
struct RangeExpr: AttrsOwner { RangeOp }
|
struct RangeExpr: AttrsOwner { RangeOp }
|
||||||
struct BinExpr: AttrsOwner { BinOp }
|
struct BinExpr: AttrsOwner { /*BinOp*/ }
|
||||||
struct Literal { LiteralToken }
|
struct Literal { LiteralToken }
|
||||||
|
|
||||||
struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList }
|
struct MatchExpr: AttrsOwner { T![match], Expr, MatchArmList }
|
||||||
|
@ -520,9 +520,9 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
struct NameRef { NameRefToken }
|
struct NameRef { NameRefToken }
|
||||||
|
|
||||||
struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner {
|
struct MacroCall: NameOwner, AttrsOwner,DocCommentsOwner {
|
||||||
Path, Excl, TokenTree, T![;]
|
Path, T![!], TokenTree, T![;]
|
||||||
}
|
}
|
||||||
struct Attr { Pound, Excl, T!['['], Path, Eq, input: AttrInput, T![']'] }
|
struct Attr { Pound, T![!], T!['['], Path, T![=], input: AttrInput, T![']'] }
|
||||||
struct TokenTree {}
|
struct TokenTree {}
|
||||||
struct TypeParamList {
|
struct TypeParamList {
|
||||||
LAngle,
|
LAngle,
|
||||||
|
@ -533,11 +533,11 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
RAngle
|
RAngle
|
||||||
}
|
}
|
||||||
struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
|
struct TypeParam: NameOwner, AttrsOwner, TypeBoundsOwner {
|
||||||
Eq,
|
T![=],
|
||||||
default_type: TypeRef,
|
default_type: TypeRef,
|
||||||
}
|
}
|
||||||
struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
|
struct ConstParam: NameOwner, AttrsOwner, TypeAscriptionOwner {
|
||||||
Eq,
|
T![=],
|
||||||
default_val: Expr,
|
default_val: Expr,
|
||||||
}
|
}
|
||||||
struct LifetimeParam: AttrsOwner { Lifetime}
|
struct LifetimeParam: AttrsOwner { Lifetime}
|
||||||
|
@ -550,11 +550,11 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
struct LetStmt: AttrsOwner, TypeAscriptionOwner {
|
struct LetStmt: AttrsOwner, TypeAscriptionOwner {
|
||||||
T![let],
|
T![let],
|
||||||
Pat,
|
Pat,
|
||||||
Eq,
|
T![=],
|
||||||
initializer: Expr,
|
initializer: Expr,
|
||||||
T![;],
|
T![;],
|
||||||
}
|
}
|
||||||
struct Condition { T![let], Pat, Eq, Expr }
|
struct Condition { T![let], Pat, T![=], Expr }
|
||||||
struct Block: AttrsOwner, ModuleItemOwner {
|
struct Block: AttrsOwner, ModuleItemOwner {
|
||||||
T!['{'],
|
T!['{'],
|
||||||
statements: [Stmt],
|
statements: [Stmt],
|
||||||
|
@ -607,9 +607,9 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
RAngle
|
RAngle
|
||||||
}
|
}
|
||||||
struct TypeArg { TypeRef }
|
struct TypeArg { TypeRef }
|
||||||
struct AssocTypeArg : TypeBoundsOwner { NameRef, Eq, TypeRef }
|
struct AssocTypeArg : TypeBoundsOwner { NameRef, T![=], TypeRef }
|
||||||
struct LifetimeArg { Lifetime }
|
struct LifetimeArg { Lifetime }
|
||||||
struct ConstArg { Literal, Eq, BlockExpr }
|
struct ConstArg { Literal, T![=], BlockExpr }
|
||||||
|
|
||||||
struct MacroItems: ModuleItemOwner{ }
|
struct MacroItems: ModuleItemOwner{ }
|
||||||
|
|
||||||
|
@ -630,7 +630,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MetaItem {
|
struct MetaItem {
|
||||||
Path, Eq, AttrInput, nested_meta_items: [MetaItem]
|
Path, T![=], AttrInput, nested_meta_items: [MetaItem]
|
||||||
}
|
}
|
||||||
|
|
||||||
struct MacroDef {
|
struct MacroDef {
|
||||||
|
@ -771,41 +771,9 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
token_enums: &ast_enums! {
|
token_enums: &ast_enums! {
|
||||||
enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq}
|
enum RangeSeparator { Dotdot, Dotdotdot, Dotdoteq}
|
||||||
|
|
||||||
enum BinOp {
|
|
||||||
Pipepipe,
|
|
||||||
Ampamp,
|
|
||||||
Eqeq,
|
|
||||||
Neq,
|
|
||||||
Lteq,
|
|
||||||
Gteq,
|
|
||||||
LAngle,
|
|
||||||
RAngle,
|
|
||||||
Plus,
|
|
||||||
Star,
|
|
||||||
Minus,
|
|
||||||
Slash,
|
|
||||||
Percent,
|
|
||||||
Shl,
|
|
||||||
Shr,
|
|
||||||
Caret,
|
|
||||||
Pipe,
|
|
||||||
Amp,
|
|
||||||
Eq,
|
|
||||||
Pluseq,
|
|
||||||
Slasheq,
|
|
||||||
Stareq,
|
|
||||||
Percenteq,
|
|
||||||
Shreq,
|
|
||||||
Shleq,
|
|
||||||
Minuseq,
|
|
||||||
Pipeeq,
|
|
||||||
Ampeq,
|
|
||||||
Careteq,
|
|
||||||
}
|
|
||||||
|
|
||||||
enum PrefixOp {
|
enum PrefixOp {
|
||||||
Minus,
|
Minus,
|
||||||
Excl,
|
T![!],
|
||||||
Star
|
Star
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -535,6 +535,8 @@ impl Field<'_> {
|
||||||
"')'" => "r_paren",
|
"')'" => "r_paren",
|
||||||
"'['" => "l_brack",
|
"'['" => "l_brack",
|
||||||
"']'" => "r_brack",
|
"']'" => "r_brack",
|
||||||
|
"=" => "eq",
|
||||||
|
"!" => "excl",
|
||||||
_ => name,
|
_ => name,
|
||||||
};
|
};
|
||||||
format_ident!("{}_token", name)
|
format_ident!("{}_token", name)
|
||||||
|
|
Loading…
Reference in a new issue