mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Start replacing tokens
This commit is contained in:
parent
c8b4c36f81
commit
1c5d859195
3 changed files with 17 additions and 35 deletions
|
@ -58,9 +58,7 @@ impl FnDef {
|
||||||
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
pub fn param_list(&self) -> Option<ParamList> { support::child(&self.syntax) }
|
||||||
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
pub fn ret_type(&self) -> Option<RetType> { support::child(&self.syntax) }
|
||||||
pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct RetType {
|
pub struct RetType {
|
||||||
|
@ -78,7 +76,7 @@ impl AstNode for RetType {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl RetType {
|
impl RetType {
|
||||||
pub fn thin_arrow_token(&self) -> Option<ThinArrow> { support::token(&self.syntax) }
|
pub fn thin_arrow_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)]
|
||||||
|
@ -104,9 +102,7 @@ impl ast::DocCommentsOwner for StructDef {}
|
||||||
impl StructDef {
|
impl StructDef {
|
||||||
pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![struct]) }
|
pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![struct]) }
|
||||||
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 semicolon_token(&self) -> Option<SyntaxToken> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct UnionDef {
|
pub struct UnionDef {
|
||||||
|
@ -332,9 +328,7 @@ impl ast::DocCommentsOwner for Module {}
|
||||||
impl Module {
|
impl Module {
|
||||||
pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mod]) }
|
pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![mod]) }
|
||||||
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct ItemList {
|
pub struct ItemList {
|
||||||
|
@ -385,9 +379,7 @@ impl ConstDef {
|
||||||
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<Eq> { support::token(&self.syntax) }
|
||||||
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> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct StaticDef {
|
pub struct StaticDef {
|
||||||
|
@ -415,9 +407,7 @@ impl StaticDef {
|
||||||
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<Eq> { support::token(&self.syntax) }
|
||||||
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> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct TypeAliasDef {
|
pub struct TypeAliasDef {
|
||||||
|
@ -447,9 +437,7 @@ impl TypeAliasDef {
|
||||||
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<Eq> { support::token(&self.syntax) }
|
||||||
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> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct ImplDef {
|
pub struct ImplDef {
|
||||||
|
@ -594,9 +582,7 @@ impl AstNode for ArrayType {
|
||||||
impl ArrayType {
|
impl ArrayType {
|
||||||
pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
|
pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
|
||||||
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> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
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) }
|
||||||
pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
|
pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -779,9 +765,7 @@ impl ast::AttrsOwner for ArrayExpr {}
|
||||||
impl ArrayExpr {
|
impl ArrayExpr {
|
||||||
pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
|
pub fn l_brack_token(&self) -> Option<LBrack> { support::token(&self.syntax) }
|
||||||
pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
|
pub fn exprs(&self) -> AstChildren<Expr> { support::children(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
|
pub fn r_brack_token(&self) -> Option<RBrack> { support::token(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1875,9 +1859,7 @@ impl MacroCall {
|
||||||
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
pub fn path(&self) -> Option<Path> { support::child(&self.syntax) }
|
||||||
pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
|
pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
|
||||||
pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
|
pub fn token_tree(&self) -> Option<TokenTree> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Attr {
|
pub struct Attr {
|
||||||
|
@ -2118,9 +2100,7 @@ impl AstNode for ExprStmt {
|
||||||
impl ast::AttrsOwner for ExprStmt {}
|
impl ast::AttrsOwner for ExprStmt {}
|
||||||
impl ExprStmt {
|
impl ExprStmt {
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn semicolon_token(&self) -> Option<SyntaxToken> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct LetStmt {
|
pub struct LetStmt {
|
||||||
|
@ -2144,9 +2124,7 @@ impl LetStmt {
|
||||||
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<Eq> { support::token(&self.syntax) }
|
||||||
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> {
|
pub fn semicolon_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, T![;]) }
|
||||||
support::token2(&self.syntax, T ! [ ; ])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Condition {
|
pub struct Condition {
|
||||||
|
|
|
@ -322,7 +322,7 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
T![;]
|
T![;]
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RetType { ThinArrow, TypeRef }
|
struct RetType { T![->], TypeRef }
|
||||||
|
|
||||||
struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
|
struct StructDef: VisibilityOwner, NameOwner, TypeParamsOwner, AttrsOwner, DocCommentsOwner {
|
||||||
T![struct],
|
T![struct],
|
||||||
|
|
|
@ -345,6 +345,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
#(#displays)*
|
#(#displays)*
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let ast = ast.to_string().replace("T ! [ ", "T![").replace(" ] )", "])");
|
||||||
let pretty = crate::reformat(ast)?;
|
let pretty = crate::reformat(ast)?;
|
||||||
Ok(pretty)
|
Ok(pretty)
|
||||||
}
|
}
|
||||||
|
@ -527,6 +528,9 @@ impl Field<'_> {
|
||||||
Field::Token(name) => {
|
Field::Token(name) => {
|
||||||
let name = match *name {
|
let name = match *name {
|
||||||
";" => "semicolon",
|
";" => "semicolon",
|
||||||
|
"->" => "thin_arrow",
|
||||||
|
"'{'" => "l_curly",
|
||||||
|
"'}'" => "r_curly",
|
||||||
_ => name,
|
_ => name,
|
||||||
};
|
};
|
||||||
format_ident!("{}_token", name)
|
format_ident!("{}_token", name)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue