mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 20:43:21 +00:00
Simpler acessors for keywords
This commit is contained in:
parent
00ec0c1066
commit
30084a56a5
14 changed files with 128 additions and 1025 deletions
|
@ -29,7 +29,7 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx) -> Option<Assist> {
|
||||||
ast::Pat::BindPat(pat) => pat,
|
ast::Pat::BindPat(pat) => pat,
|
||||||
_ => return None,
|
_ => return None,
|
||||||
};
|
};
|
||||||
if bind_pat.mut_kw_token().is_some() {
|
if bind_pat.mut_token().is_some() {
|
||||||
tested_by!(test_not_inline_mut_variable);
|
tested_by!(test_not_inline_mut_variable);
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
|
@ -372,7 +372,7 @@ impl ExprCollector<'_> {
|
||||||
}
|
}
|
||||||
ast::Expr::RefExpr(e) => {
|
ast::Expr::RefExpr(e) => {
|
||||||
let expr = self.collect_expr_opt(e.expr());
|
let expr = self.collect_expr_opt(e.expr());
|
||||||
let mutability = Mutability::from_mutable(e.mut_kw_token().is_some());
|
let mutability = Mutability::from_mutable(e.mut_token().is_some());
|
||||||
self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr)
|
self.alloc_expr(Expr::Ref { expr, mutability }, syntax_ptr)
|
||||||
}
|
}
|
||||||
ast::Expr::PrefixExpr(e) => {
|
ast::Expr::PrefixExpr(e) => {
|
||||||
|
@ -587,10 +587,8 @@ impl ExprCollector<'_> {
|
||||||
let pattern = match &pat {
|
let pattern = match &pat {
|
||||||
ast::Pat::BindPat(bp) => {
|
ast::Pat::BindPat(bp) => {
|
||||||
let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
|
let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
|
||||||
let annotation = BindingAnnotation::new(
|
let annotation =
|
||||||
bp.mut_kw_token().is_some(),
|
BindingAnnotation::new(bp.mut_token().is_some(), bp.ref_token().is_some());
|
||||||
bp.ref_kw_token().is_some(),
|
|
||||||
);
|
|
||||||
let subpat = bp.pat().map(|subpat| self.collect_pat(subpat));
|
let subpat = bp.pat().map(|subpat| self.collect_pat(subpat));
|
||||||
if annotation == BindingAnnotation::Unannotated && subpat.is_none() {
|
if annotation == BindingAnnotation::Unannotated && subpat.is_none() {
|
||||||
// This could also be a single-segment path pattern. To
|
// This could also be a single-segment path pattern. To
|
||||||
|
@ -631,7 +629,7 @@ impl ExprCollector<'_> {
|
||||||
}
|
}
|
||||||
ast::Pat::RefPat(p) => {
|
ast::Pat::RefPat(p) => {
|
||||||
let pat = self.collect_pat_opt(p.pat());
|
let pat = self.collect_pat_opt(p.pat());
|
||||||
let mutability = Mutability::from_mutable(p.mut_kw_token().is_some());
|
let mutability = Mutability::from_mutable(p.mut_token().is_some());
|
||||||
Pat::Ref { pat, mutability }
|
Pat::Ref { pat, mutability }
|
||||||
}
|
}
|
||||||
ast::Pat::PathPat(p) => {
|
ast::Pat::PathPat(p) => {
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl FunctionData {
|
||||||
TypeRef::unit()
|
TypeRef::unit()
|
||||||
};
|
};
|
||||||
|
|
||||||
let ret_type = if src.value.async_kw_token().is_some() {
|
let ret_type = if src.value.async_token().is_some() {
|
||||||
let future_impl = desugar_future_path(ret_type);
|
let future_impl = desugar_future_path(ret_type);
|
||||||
let ty_bound = TypeBound::Path(future_impl);
|
let ty_bound = TypeBound::Path(future_impl);
|
||||||
TypeRef::ImplTrait(vec![ty_bound])
|
TypeRef::ImplTrait(vec![ty_bound])
|
||||||
|
@ -135,7 +135,7 @@ impl TraitData {
|
||||||
pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> {
|
pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> {
|
||||||
let src = tr.lookup(db).source(db);
|
let src = tr.lookup(db).source(db);
|
||||||
let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
|
let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
|
||||||
let auto = src.value.auto_kw_token().is_some();
|
let auto = src.value.auto_token().is_some();
|
||||||
let ast_id_map = db.ast_id_map(src.file_id);
|
let ast_id_map = db.ast_id_map(src.file_id);
|
||||||
|
|
||||||
let container = AssocContainerId::TraitId(tr);
|
let container = AssocContainerId::TraitId(tr);
|
||||||
|
|
|
@ -77,7 +77,7 @@ impl TypeRef {
|
||||||
}
|
}
|
||||||
ast::TypeRef::PointerType(inner) => {
|
ast::TypeRef::PointerType(inner) => {
|
||||||
let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
|
let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
|
||||||
let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some());
|
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
|
||||||
TypeRef::RawPtr(Box::new(inner_ty), mutability)
|
TypeRef::RawPtr(Box::new(inner_ty), mutability)
|
||||||
}
|
}
|
||||||
ast::TypeRef::ArrayType(inner) => {
|
ast::TypeRef::ArrayType(inner) => {
|
||||||
|
@ -88,7 +88,7 @@ impl TypeRef {
|
||||||
}
|
}
|
||||||
ast::TypeRef::ReferenceType(inner) => {
|
ast::TypeRef::ReferenceType(inner) => {
|
||||||
let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
|
let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
|
||||||
let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some());
|
let mutability = Mutability::from_mutable(inner.mut_token().is_some());
|
||||||
TypeRef::Reference(Box::new(inner_ty), mutability)
|
TypeRef::Reference(Box::new(inner_ty), mutability)
|
||||||
}
|
}
|
||||||
ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder,
|
ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder,
|
||||||
|
|
|
@ -23,7 +23,7 @@ use insta::assert_snapshot;
|
||||||
use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase};
|
use ra_db::{fixture::WithFixture, salsa::Database, FilePosition, SourceDatabase};
|
||||||
use ra_syntax::{
|
use ra_syntax::{
|
||||||
algo,
|
algo,
|
||||||
ast::{self, AstNode, AstToken},
|
ast::{self, AstNode},
|
||||||
};
|
};
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
|
||||||
let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db));
|
let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db));
|
||||||
|
|
||||||
let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) {
|
let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) {
|
||||||
(self_param.self_kw_token().unwrap().syntax().text_range(), "self".to_string())
|
(self_param.self_token().unwrap().text_range(), "self".to_string())
|
||||||
} else {
|
} else {
|
||||||
(src_ptr.value.range(), node.text().to_string().replace("\n", " "))
|
(src_ptr.value.range(), node.text().to_string().replace("\n", " "))
|
||||||
};
|
};
|
||||||
|
|
|
@ -191,8 +191,8 @@ impl<'a> CompletionContext<'a> {
|
||||||
if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) {
|
if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) {
|
||||||
self.is_pat_binding_or_const = true;
|
self.is_pat_binding_or_const = true;
|
||||||
if bind_pat.at_token().is_some()
|
if bind_pat.at_token().is_some()
|
||||||
|| bind_pat.ref_kw_token().is_some()
|
|| bind_pat.ref_token().is_some()
|
||||||
|| bind_pat.mut_kw_token().is_some()
|
|| bind_pat.mut_token().is_some()
|
||||||
{
|
{
|
||||||
self.is_pat_binding_or_const = false;
|
self.is_pat_binding_or_const = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -152,7 +152,7 @@ fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Optio
|
||||||
if stmt.initializer().is_some() {
|
if stmt.initializer().is_some() {
|
||||||
let pat = stmt.pat()?;
|
let pat = stmt.pat()?;
|
||||||
if let ast::Pat::BindPat(it) = pat {
|
if let ast::Pat::BindPat(it) = pat {
|
||||||
if it.mut_kw_token().is_some() {
|
if it.mut_token().is_some() {
|
||||||
return Some(ReferenceAccess::Write);
|
return Some(ReferenceAccess::Write);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ impl<N: AstNode> Iterator for AstChildren<N> {
|
||||||
}
|
}
|
||||||
|
|
||||||
mod support {
|
mod support {
|
||||||
use super::{AstChildren, AstNode, AstToken, SyntaxNode};
|
use super::{AstChildren, AstNode, AstToken, SyntaxKind, SyntaxNode, SyntaxToken};
|
||||||
|
|
||||||
pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
|
pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
|
||||||
parent.children().find_map(N::cast)
|
parent.children().find_map(N::cast)
|
||||||
|
@ -93,6 +93,10 @@ mod support {
|
||||||
pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
|
pub(super) fn token<T: AstToken>(parent: &SyntaxNode) -> Option<T> {
|
||||||
parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
|
parent.children_with_tokens().filter_map(|it| it.into_token()).find_map(T::cast)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn token2(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
|
||||||
|
parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -48,12 +48,6 @@ impl ast::IfExpr {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::RefExpr {
|
|
||||||
pub fn raw_token(&self) -> Option<SyntaxToken> {
|
|
||||||
None // FIXME: implement &raw
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum PrefixOp {
|
pub enum PrefixOp {
|
||||||
/// The `*` operator for dereferencing
|
/// The `*` operator for dereferencing
|
||||||
|
|
|
@ -279,7 +279,7 @@ pub enum SelfParamKind {
|
||||||
impl ast::SelfParam {
|
impl ast::SelfParam {
|
||||||
pub fn kind(&self) -> SelfParamKind {
|
pub fn kind(&self) -> SelfParamKind {
|
||||||
if self.amp_token().is_some() {
|
if self.amp_token().is_some() {
|
||||||
if self.amp_mut_kw_token().is_some() {
|
if self.amp_mut_token().is_some() {
|
||||||
SelfParamKind::MutRef
|
SelfParamKind::MutRef
|
||||||
} else {
|
} else {
|
||||||
SelfParamKind::Ref
|
SelfParamKind::Ref
|
||||||
|
@ -290,21 +290,21 @@ impl ast::SelfParam {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the "mut" in "mut self", not the one in "&mut self"
|
/// the "mut" in "mut self", not the one in "&mut self"
|
||||||
pub fn mut_kw_token(&self) -> Option<ast::MutKw> {
|
pub fn mut_token(&self) -> Option<SyntaxToken> {
|
||||||
self.syntax()
|
self.syntax()
|
||||||
.children_with_tokens()
|
.children_with_tokens()
|
||||||
.filter_map(|it| it.into_token())
|
.filter_map(|it| it.into_token())
|
||||||
.take_while(|it| it.kind() != T![&])
|
.take_while(|it| it.kind() != T![&])
|
||||||
.find_map(ast::MutKw::cast)
|
.find(|it| it.kind() == T![mut])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// the "mut" in "&mut self", not the one in "mut self"
|
/// the "mut" in "&mut self", not the one in "mut self"
|
||||||
pub fn amp_mut_kw_token(&self) -> Option<ast::MutKw> {
|
pub fn amp_mut_token(&self) -> Option<SyntaxToken> {
|
||||||
self.syntax()
|
self.syntax()
|
||||||
.children_with_tokens()
|
.children_with_tokens()
|
||||||
.filter_map(|it| it.into_token())
|
.filter_map(|it| it.into_token())
|
||||||
.skip_while(|it| it.kind() != T![&])
|
.skip_while(|it| it.kind() != T![&])
|
||||||
.find_map(ast::MutKw::cast)
|
.find(|it| it.kind() == T![mut])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,7 +340,7 @@ impl ast::TypeBound {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn question_token(&self) -> Option<ast::Question> {
|
pub fn question_token(&self) -> Option<ast::Question> {
|
||||||
if self.const_kw_token().is_some() {
|
if self.const_token().is_some() {
|
||||||
self.syntax()
|
self.syntax()
|
||||||
.children_with_tokens()
|
.children_with_tokens()
|
||||||
.filter_map(|it| it.into_token())
|
.filter_map(|it| it.into_token())
|
||||||
|
@ -364,11 +364,11 @@ impl ast::Visibility {
|
||||||
pub fn kind(&self) -> VisibilityKind {
|
pub fn kind(&self) -> VisibilityKind {
|
||||||
if let Some(path) = support::children(self.syntax()).next() {
|
if let Some(path) = support::children(self.syntax()).next() {
|
||||||
VisibilityKind::In(path)
|
VisibilityKind::In(path)
|
||||||
} else if self.crate_kw_token().is_some() {
|
} else if self.crate_token().is_some() {
|
||||||
VisibilityKind::PubCrate
|
VisibilityKind::PubCrate
|
||||||
} else if self.super_kw_token().is_some() {
|
} else if self.super_token().is_some() {
|
||||||
VisibilityKind::PubSuper
|
VisibilityKind::PubSuper
|
||||||
} else if self.self_kw_token().is_some() {
|
} else if self.self_token().is_some() {
|
||||||
VisibilityKind::PubSuper
|
VisibilityKind::PubSuper
|
||||||
} else {
|
} else {
|
||||||
VisibilityKind::Pub
|
VisibilityKind::Pub
|
||||||
|
|
|
@ -4,7 +4,7 @@ use super::tokens::*;
|
||||||
use crate::{
|
use crate::{
|
||||||
ast::{self, support, AstChildren, AstNode},
|
ast::{self, support, AstChildren, AstNode},
|
||||||
SyntaxKind::{self, *},
|
SyntaxKind::{self, *},
|
||||||
SyntaxNode,
|
SyntaxNode, SyntaxToken,
|
||||||
};
|
};
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct SourceFile {
|
pub struct SourceFile {
|
||||||
|
@ -48,11 +48,11 @@ impl ast::DocCommentsOwner for FnDef {}
|
||||||
impl ast::AttrsOwner for FnDef {}
|
impl ast::AttrsOwner for FnDef {}
|
||||||
impl FnDef {
|
impl FnDef {
|
||||||
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
||||||
pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
|
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
|
||||||
pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
|
pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
|
||||||
pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) }
|
pub fn async_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ASYNC_KW) }
|
||||||
pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
|
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
|
||||||
pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) }
|
pub fn fn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FN_KW) }
|
||||||
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) }
|
||||||
|
@ -98,7 +98,7 @@ impl ast::TypeParamsOwner for StructDef {}
|
||||||
impl ast::AttrsOwner for StructDef {}
|
impl ast::AttrsOwner for StructDef {}
|
||||||
impl ast::DocCommentsOwner for StructDef {}
|
impl ast::DocCommentsOwner for StructDef {}
|
||||||
impl StructDef {
|
impl StructDef {
|
||||||
pub fn struct_kw_token(&self) -> Option<StructKw> { support::token(&self.syntax) }
|
pub fn struct_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STRUCT_KW) }
|
||||||
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 semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ impl ast::TypeParamsOwner for UnionDef {}
|
||||||
impl ast::AttrsOwner for UnionDef {}
|
impl ast::AttrsOwner for UnionDef {}
|
||||||
impl ast::DocCommentsOwner for UnionDef {}
|
impl ast::DocCommentsOwner for UnionDef {}
|
||||||
impl UnionDef {
|
impl UnionDef {
|
||||||
pub fn union_kw_token(&self) -> Option<UnionKw> { support::token(&self.syntax) }
|
pub fn union_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNION_KW) }
|
||||||
pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
|
pub fn record_field_def_list(&self) -> Option<RecordFieldDefList> {
|
||||||
support::child(&self.syntax)
|
support::child(&self.syntax)
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ impl ast::TypeParamsOwner for EnumDef {}
|
||||||
impl ast::AttrsOwner for EnumDef {}
|
impl ast::AttrsOwner for EnumDef {}
|
||||||
impl ast::DocCommentsOwner for EnumDef {}
|
impl ast::DocCommentsOwner for EnumDef {}
|
||||||
impl EnumDef {
|
impl EnumDef {
|
||||||
pub fn enum_kw_token(&self) -> Option<EnumKw> { support::token(&self.syntax) }
|
pub fn enum_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ENUM_KW) }
|
||||||
pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
|
pub fn variant_list(&self) -> Option<EnumVariantList> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -299,9 +299,9 @@ impl ast::DocCommentsOwner for TraitDef {}
|
||||||
impl ast::TypeParamsOwner for TraitDef {}
|
impl ast::TypeParamsOwner for TraitDef {}
|
||||||
impl ast::TypeBoundsOwner for TraitDef {}
|
impl ast::TypeBoundsOwner for TraitDef {}
|
||||||
impl TraitDef {
|
impl TraitDef {
|
||||||
pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
|
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
|
||||||
pub fn auto_kw_token(&self) -> Option<AutoKw> { support::token(&self.syntax) }
|
pub fn auto_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AUTO_KW) }
|
||||||
pub fn trait_kw_token(&self) -> Option<TraitKw> { support::token(&self.syntax) }
|
pub fn trait_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRAIT_KW) }
|
||||||
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -324,7 +324,7 @@ impl ast::NameOwner for Module {}
|
||||||
impl ast::AttrsOwner for Module {}
|
impl ast::AttrsOwner for Module {}
|
||||||
impl ast::DocCommentsOwner for Module {}
|
impl ast::DocCommentsOwner for Module {}
|
||||||
impl Module {
|
impl Module {
|
||||||
pub fn mod_kw_token(&self) -> Option<ModKw> { support::token(&self.syntax) }
|
pub fn mod_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MOD_KW) }
|
||||||
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
||||||
pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -371,8 +371,8 @@ impl ast::AttrsOwner for ConstDef {}
|
||||||
impl ast::DocCommentsOwner for ConstDef {}
|
impl ast::DocCommentsOwner for ConstDef {}
|
||||||
impl ast::TypeAscriptionOwner for ConstDef {}
|
impl ast::TypeAscriptionOwner for ConstDef {}
|
||||||
impl ConstDef {
|
impl ConstDef {
|
||||||
pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
|
pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
|
||||||
pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
|
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
|
||||||
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 semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
||||||
|
@ -399,8 +399,8 @@ impl ast::AttrsOwner for StaticDef {}
|
||||||
impl ast::DocCommentsOwner for StaticDef {}
|
impl ast::DocCommentsOwner for StaticDef {}
|
||||||
impl ast::TypeAscriptionOwner for StaticDef {}
|
impl ast::TypeAscriptionOwner for StaticDef {}
|
||||||
impl StaticDef {
|
impl StaticDef {
|
||||||
pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) }
|
pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STATIC_KW) }
|
||||||
pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
|
||||||
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 semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
||||||
|
@ -427,8 +427,8 @@ impl ast::AttrsOwner for TypeAliasDef {}
|
||||||
impl ast::DocCommentsOwner for TypeAliasDef {}
|
impl ast::DocCommentsOwner for TypeAliasDef {}
|
||||||
impl ast::TypeBoundsOwner for TypeAliasDef {}
|
impl ast::TypeBoundsOwner for TypeAliasDef {}
|
||||||
impl TypeAliasDef {
|
impl TypeAliasDef {
|
||||||
pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
|
pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
|
||||||
pub fn type_kw_token(&self) -> Option<TypeKw> { support::token(&self.syntax) }
|
pub fn type_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TYPE_KW) }
|
||||||
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 semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
pub fn semi_token(&self) -> Option<Semi> { support::token(&self.syntax) }
|
||||||
|
@ -451,12 +451,12 @@ impl AstNode for ImplDef {
|
||||||
impl ast::TypeParamsOwner for ImplDef {}
|
impl ast::TypeParamsOwner for ImplDef {}
|
||||||
impl ast::AttrsOwner for ImplDef {}
|
impl ast::AttrsOwner for ImplDef {}
|
||||||
impl ImplDef {
|
impl ImplDef {
|
||||||
pub fn default_kw_token(&self) -> Option<DefaultKw> { support::token(&self.syntax) }
|
pub fn default_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DEFAULT_KW) }
|
||||||
pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
|
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
|
||||||
pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
|
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
|
||||||
pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) }
|
pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IMPL_KW) }
|
||||||
pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
|
pub fn excl_token(&self) -> Option<Excl> { support::token(&self.syntax) }
|
||||||
pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) }
|
pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) }
|
||||||
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
pub fn item_list(&self) -> Option<ItemList> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -552,8 +552,8 @@ impl AstNode for PointerType {
|
||||||
}
|
}
|
||||||
impl PointerType {
|
impl PointerType {
|
||||||
pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) }
|
pub fn star_token(&self) -> Option<Star> { support::token(&self.syntax) }
|
||||||
pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
|
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
|
||||||
pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
|
||||||
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)]
|
||||||
|
@ -616,7 +616,7 @@ impl AstNode for ReferenceType {
|
||||||
impl ReferenceType {
|
impl ReferenceType {
|
||||||
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
||||||
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
||||||
pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
|
||||||
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)]
|
||||||
|
@ -654,8 +654,8 @@ impl AstNode for FnPointerType {
|
||||||
}
|
}
|
||||||
impl FnPointerType {
|
impl FnPointerType {
|
||||||
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
pub fn abi(&self) -> Option<Abi> { support::child(&self.syntax) }
|
||||||
pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
|
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
|
||||||
pub fn fn_kw_token(&self) -> Option<FnKw> { support::token(&self.syntax) }
|
pub fn fn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FN_KW) }
|
||||||
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) }
|
||||||
}
|
}
|
||||||
|
@ -675,7 +675,7 @@ impl AstNode for ForType {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl ForType {
|
impl ForType {
|
||||||
pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) }
|
pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) }
|
||||||
pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
|
pub fn type_param_list(&self) -> Option<TypeParamList> { support::child(&self.syntax) }
|
||||||
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
pub fn type_ref(&self) -> Option<TypeRef> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -696,7 +696,7 @@ impl AstNode for ImplTraitType {
|
||||||
}
|
}
|
||||||
impl ast::TypeBoundsOwner for ImplTraitType {}
|
impl ast::TypeBoundsOwner for ImplTraitType {}
|
||||||
impl ImplTraitType {
|
impl ImplTraitType {
|
||||||
pub fn impl_kw_token(&self) -> Option<ImplKw> { support::token(&self.syntax) }
|
pub fn impl_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IMPL_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct DynTraitType {
|
pub struct DynTraitType {
|
||||||
|
@ -715,7 +715,7 @@ impl AstNode for DynTraitType {
|
||||||
}
|
}
|
||||||
impl ast::TypeBoundsOwner for DynTraitType {}
|
impl ast::TypeBoundsOwner for DynTraitType {}
|
||||||
impl DynTraitType {
|
impl DynTraitType {
|
||||||
pub fn dyn_kw_token(&self) -> Option<DynKw> { support::token(&self.syntax) }
|
pub fn dyn_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, DYN_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct TupleExpr {
|
pub struct TupleExpr {
|
||||||
|
@ -816,9 +816,9 @@ impl AstNode for LambdaExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for LambdaExpr {}
|
impl ast::AttrsOwner for LambdaExpr {}
|
||||||
impl LambdaExpr {
|
impl LambdaExpr {
|
||||||
pub fn static_kw_token(&self) -> Option<StaticKw> { support::token(&self.syntax) }
|
pub fn static_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, STATIC_KW) }
|
||||||
pub fn async_kw_token(&self) -> Option<AsyncKw> { support::token(&self.syntax) }
|
pub fn async_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, ASYNC_KW) }
|
||||||
pub fn move_kw_token(&self) -> Option<MoveKw> { support::token(&self.syntax) }
|
pub fn move_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MOVE_KW) }
|
||||||
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<Expr> { support::child(&self.syntax) }
|
pub fn body(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
|
@ -840,7 +840,7 @@ impl AstNode for IfExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for IfExpr {}
|
impl ast::AttrsOwner for IfExpr {}
|
||||||
impl IfExpr {
|
impl IfExpr {
|
||||||
pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) }
|
pub fn if_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IF_KW) }
|
||||||
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
|
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -861,7 +861,7 @@ impl AstNode for LoopExpr {
|
||||||
impl ast::AttrsOwner for LoopExpr {}
|
impl ast::AttrsOwner for LoopExpr {}
|
||||||
impl ast::LoopBodyOwner for LoopExpr {}
|
impl ast::LoopBodyOwner for LoopExpr {}
|
||||||
impl LoopExpr {
|
impl LoopExpr {
|
||||||
pub fn loop_kw_token(&self) -> Option<LoopKw> { support::token(&self.syntax) }
|
pub fn loop_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LOOP_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct TryBlockExpr {
|
pub struct TryBlockExpr {
|
||||||
|
@ -880,7 +880,7 @@ impl AstNode for TryBlockExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for TryBlockExpr {}
|
impl ast::AttrsOwner for TryBlockExpr {}
|
||||||
impl TryBlockExpr {
|
impl TryBlockExpr {
|
||||||
pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) }
|
pub fn try_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRY_KW) }
|
||||||
pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
pub fn body(&self) -> Option<BlockExpr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -901,9 +901,9 @@ impl AstNode for ForExpr {
|
||||||
impl ast::AttrsOwner for ForExpr {}
|
impl ast::AttrsOwner for ForExpr {}
|
||||||
impl ast::LoopBodyOwner for ForExpr {}
|
impl ast::LoopBodyOwner for ForExpr {}
|
||||||
impl ForExpr {
|
impl ForExpr {
|
||||||
pub fn for_kw_token(&self) -> Option<ForKw> { support::token(&self.syntax) }
|
pub fn for_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, FOR_KW) }
|
||||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||||
pub fn in_kw_token(&self) -> Option<InKw> { support::token(&self.syntax) }
|
pub fn in_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IN_KW) }
|
||||||
pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn iterable(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -924,7 +924,7 @@ impl AstNode for WhileExpr {
|
||||||
impl ast::AttrsOwner for WhileExpr {}
|
impl ast::AttrsOwner for WhileExpr {}
|
||||||
impl ast::LoopBodyOwner for WhileExpr {}
|
impl ast::LoopBodyOwner for WhileExpr {}
|
||||||
impl WhileExpr {
|
impl WhileExpr {
|
||||||
pub fn while_kw_token(&self) -> Option<WhileKw> { support::token(&self.syntax) }
|
pub fn while_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, WHILE_KW) }
|
||||||
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
|
pub fn condition(&self) -> Option<Condition> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -944,7 +944,9 @@ impl AstNode for ContinueExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for ContinueExpr {}
|
impl ast::AttrsOwner for ContinueExpr {}
|
||||||
impl ContinueExpr {
|
impl ContinueExpr {
|
||||||
pub fn continue_kw_token(&self) -> Option<ContinueKw> { support::token(&self.syntax) }
|
pub fn continue_token(&self) -> Option<SyntaxToken> {
|
||||||
|
support::token2(&self.syntax, CONTINUE_KW)
|
||||||
|
}
|
||||||
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -964,7 +966,7 @@ impl AstNode for BreakExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for BreakExpr {}
|
impl ast::AttrsOwner for BreakExpr {}
|
||||||
impl BreakExpr {
|
impl BreakExpr {
|
||||||
pub fn break_kw_token(&self) -> Option<BreakKw> { support::token(&self.syntax) }
|
pub fn break_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BREAK_KW) }
|
||||||
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -1004,7 +1006,7 @@ impl AstNode for BlockExpr {
|
||||||
impl ast::AttrsOwner for BlockExpr {}
|
impl ast::AttrsOwner for BlockExpr {}
|
||||||
impl BlockExpr {
|
impl BlockExpr {
|
||||||
pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
|
pub fn label(&self) -> Option<Label> { support::child(&self.syntax) }
|
||||||
pub fn unsafe_kw_token(&self) -> Option<UnsafeKw> { support::token(&self.syntax) }
|
pub fn unsafe_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, UNSAFE_KW) }
|
||||||
pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
|
pub fn block(&self) -> Option<Block> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1128,7 +1130,7 @@ impl ast::AttrsOwner for AwaitExpr {}
|
||||||
impl AwaitExpr {
|
impl AwaitExpr {
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) }
|
pub fn dot_token(&self) -> Option<Dot> { support::token(&self.syntax) }
|
||||||
pub fn await_kw_token(&self) -> Option<AwaitKw> { support::token(&self.syntax) }
|
pub fn await_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AWAIT_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct TryExpr {
|
pub struct TryExpr {
|
||||||
|
@ -1147,7 +1149,7 @@ impl AstNode for TryExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for TryExpr {}
|
impl ast::AttrsOwner for TryExpr {}
|
||||||
impl TryExpr {
|
impl TryExpr {
|
||||||
pub fn try_kw_token(&self) -> Option<TryKw> { support::token(&self.syntax) }
|
pub fn try_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, TRY_KW) }
|
||||||
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)]
|
||||||
|
@ -1168,7 +1170,7 @@ impl AstNode for CastExpr {
|
||||||
impl ast::AttrsOwner for CastExpr {}
|
impl ast::AttrsOwner for CastExpr {}
|
||||||
impl CastExpr {
|
impl CastExpr {
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) }
|
pub fn as_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AS_KW) }
|
||||||
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)]
|
||||||
|
@ -1189,8 +1191,8 @@ impl AstNode for RefExpr {
|
||||||
impl ast::AttrsOwner for RefExpr {}
|
impl ast::AttrsOwner for RefExpr {}
|
||||||
impl RefExpr {
|
impl RefExpr {
|
||||||
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
||||||
pub fn raw_kw_token(&self) -> Option<RawKw> { support::token(&self.syntax) }
|
pub fn raw_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, RAW_KW) }
|
||||||
pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
|
||||||
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)]
|
||||||
|
@ -1230,7 +1232,7 @@ impl AstNode for BoxExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for BoxExpr {}
|
impl ast::AttrsOwner for BoxExpr {}
|
||||||
impl BoxExpr {
|
impl BoxExpr {
|
||||||
pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) }
|
pub fn box_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BOX_KW) }
|
||||||
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)]
|
||||||
|
@ -1306,7 +1308,7 @@ impl AstNode for MatchExpr {
|
||||||
}
|
}
|
||||||
impl ast::AttrsOwner for MatchExpr {}
|
impl ast::AttrsOwner for MatchExpr {}
|
||||||
impl MatchExpr {
|
impl MatchExpr {
|
||||||
pub fn match_kw_token(&self) -> Option<MatchKw> { support::token(&self.syntax) }
|
pub fn match_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MATCH_KW) }
|
||||||
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
|
pub fn match_arm_list(&self) -> Option<MatchArmList> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -1369,7 +1371,7 @@ impl AstNode for MatchGuard {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl MatchGuard {
|
impl MatchGuard {
|
||||||
pub fn if_kw_token(&self) -> Option<IfKw> { support::token(&self.syntax) }
|
pub fn if_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, IF_KW) }
|
||||||
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)]
|
||||||
|
@ -1489,7 +1491,7 @@ impl AstNode for RefPat {
|
||||||
}
|
}
|
||||||
impl RefPat {
|
impl RefPat {
|
||||||
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
||||||
pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
|
||||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1508,7 +1510,7 @@ impl AstNode for BoxPat {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl BoxPat {
|
impl BoxPat {
|
||||||
pub fn box_kw_token(&self) -> Option<BoxKw> { support::token(&self.syntax) }
|
pub fn box_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, BOX_KW) }
|
||||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -1529,8 +1531,8 @@ impl AstNode for BindPat {
|
||||||
impl ast::AttrsOwner for BindPat {}
|
impl ast::AttrsOwner for BindPat {}
|
||||||
impl ast::NameOwner for BindPat {}
|
impl ast::NameOwner for BindPat {}
|
||||||
impl BindPat {
|
impl BindPat {
|
||||||
pub fn ref_kw_token(&self) -> Option<RefKw> { support::token(&self.syntax) }
|
pub fn ref_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, REF_KW) }
|
||||||
pub fn mut_kw_token(&self) -> Option<MutKw> { support::token(&self.syntax) }
|
pub fn mut_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, MUT_KW) }
|
||||||
pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) }
|
pub fn at_token(&self) -> Option<At> { support::token(&self.syntax) }
|
||||||
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
pub fn pat(&self) -> Option<Pat> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
@ -1786,10 +1788,10 @@ impl AstNode for Visibility {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl Visibility {
|
impl Visibility {
|
||||||
pub fn pub_kw_token(&self) -> Option<PubKw> { support::token(&self.syntax) }
|
pub fn pub_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, PUB_KW) }
|
||||||
pub fn super_kw_token(&self) -> Option<SuperKw> { support::token(&self.syntax) }
|
pub fn super_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SUPER_KW) }
|
||||||
pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) }
|
pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SELF_KW) }
|
||||||
pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) }
|
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CRATE_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Name {
|
pub struct Name {
|
||||||
|
@ -1994,7 +1996,7 @@ impl AstNode for TypeBound {
|
||||||
}
|
}
|
||||||
impl TypeBound {
|
impl TypeBound {
|
||||||
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
||||||
pub fn const_kw_token(&self) -> Option<ConstKw> { support::token(&self.syntax) }
|
pub fn const_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CONST_KW) }
|
||||||
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)]
|
||||||
|
@ -2051,7 +2053,7 @@ impl AstNode for WhereClause {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl WhereClause {
|
impl WhereClause {
|
||||||
pub fn where_kw_token(&self) -> Option<WhereKw> { support::token(&self.syntax) }
|
pub fn where_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, WHERE_KW) }
|
||||||
pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
|
pub fn predicates(&self) -> AstChildren<WherePred> { support::children(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2110,7 +2112,7 @@ impl AstNode for LetStmt {
|
||||||
impl ast::AttrsOwner for LetStmt {}
|
impl ast::AttrsOwner for LetStmt {}
|
||||||
impl ast::TypeAscriptionOwner for LetStmt {}
|
impl ast::TypeAscriptionOwner for LetStmt {}
|
||||||
impl LetStmt {
|
impl LetStmt {
|
||||||
pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) }
|
pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LET_KW) }
|
||||||
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) }
|
||||||
|
@ -2132,7 +2134,7 @@ impl AstNode for Condition {
|
||||||
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
fn syntax(&self) -> &SyntaxNode { &self.syntax }
|
||||||
}
|
}
|
||||||
impl Condition {
|
impl Condition {
|
||||||
pub fn let_kw_token(&self) -> Option<LetKw> { support::token(&self.syntax) }
|
pub fn let_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, LET_KW) }
|
||||||
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 expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
pub fn expr(&self) -> Option<Expr> { support::child(&self.syntax) }
|
||||||
|
@ -2201,7 +2203,7 @@ impl ast::AttrsOwner for SelfParam {}
|
||||||
impl SelfParam {
|
impl SelfParam {
|
||||||
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
pub fn amp_token(&self) -> Option<Amp> { support::token(&self.syntax) }
|
||||||
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
pub fn lifetime_token(&self) -> Option<Lifetime> { support::token(&self.syntax) }
|
||||||
pub fn self_kw_token(&self) -> Option<SelfKw> { support::token(&self.syntax) }
|
pub fn self_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, SELF_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct Param {
|
pub struct Param {
|
||||||
|
@ -2242,7 +2244,7 @@ impl AstNode for UseItem {
|
||||||
impl ast::AttrsOwner for UseItem {}
|
impl ast::AttrsOwner for UseItem {}
|
||||||
impl ast::VisibilityOwner for UseItem {}
|
impl ast::VisibilityOwner for UseItem {}
|
||||||
impl UseItem {
|
impl UseItem {
|
||||||
pub fn use_kw_token(&self) -> Option<UseKw> { support::token(&self.syntax) }
|
pub fn use_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, USE_KW) }
|
||||||
pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
|
pub fn use_tree(&self) -> Option<UseTree> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
@ -2283,7 +2285,7 @@ impl AstNode for Alias {
|
||||||
}
|
}
|
||||||
impl ast::NameOwner for Alias {}
|
impl ast::NameOwner for Alias {}
|
||||||
impl Alias {
|
impl Alias {
|
||||||
pub fn as_kw_token(&self) -> Option<AsKw> { support::token(&self.syntax) }
|
pub fn as_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, AS_KW) }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct UseTreeList {
|
pub struct UseTreeList {
|
||||||
|
@ -2323,8 +2325,8 @@ impl AstNode for ExternCrateItem {
|
||||||
impl ast::AttrsOwner for ExternCrateItem {}
|
impl ast::AttrsOwner for ExternCrateItem {}
|
||||||
impl ast::VisibilityOwner for ExternCrateItem {}
|
impl ast::VisibilityOwner for ExternCrateItem {}
|
||||||
impl ExternCrateItem {
|
impl ExternCrateItem {
|
||||||
pub fn extern_kw_token(&self) -> Option<ExternKw> { support::token(&self.syntax) }
|
pub fn extern_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, EXTERN_KW) }
|
||||||
pub fn crate_kw_token(&self) -> Option<CrateKw> { support::token(&self.syntax) }
|
pub fn crate_token(&self) -> Option<SyntaxToken> { support::token2(&self.syntax, CRATE_KW) }
|
||||||
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
pub fn name_ref(&self) -> Option<NameRef> { support::child(&self.syntax) }
|
||||||
pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
|
pub fn alias(&self) -> Option<Alias> { support::child(&self.syntax) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -1046,906 +1046,6 @@ impl AstToken for Shreq {
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||||
}
|
}
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct AsKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for AsKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for AsKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == AS_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct AsyncKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for AsyncKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for AsyncKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == ASYNC_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct AwaitKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for AwaitKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for AwaitKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == AWAIT_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct BoxKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for BoxKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for BoxKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == BOX_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct BreakKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for BreakKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for BreakKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == BREAK_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ConstKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ConstKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ConstKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CONST_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ContinueKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ContinueKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ContinueKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CONTINUE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct CrateKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for CrateKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for CrateKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == CRATE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct DynKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for DynKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for DynKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == DYN_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ElseKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ElseKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ElseKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == ELSE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct EnumKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for EnumKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for EnumKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == ENUM_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ExternKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ExternKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ExternKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == EXTERN_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct FalseKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for FalseKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for FalseKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FALSE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct FnKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for FnKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for FnKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FN_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ForKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ForKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ForKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == FOR_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct IfKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for IfKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for IfKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == IF_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ImplKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ImplKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ImplKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == IMPL_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct InKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for InKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for InKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == IN_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct LetKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for LetKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for LetKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == LET_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct LoopKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for LoopKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for LoopKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == LOOP_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct MacroKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for MacroKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for MacroKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == MACRO_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct MatchKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for MatchKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for MatchKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == MATCH_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ModKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ModKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ModKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == MOD_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct MoveKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for MoveKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for MoveKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == MOVE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct MutKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for MutKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for MutKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == MUT_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct PubKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for PubKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for PubKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == PUB_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct RefKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for RefKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for RefKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == REF_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ReturnKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ReturnKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ReturnKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RETURN_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct SelfKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for SelfKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for SelfKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SELF_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct StaticKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for StaticKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for StaticKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == STATIC_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct StructKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for StructKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for StructKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == STRUCT_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct SuperKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for SuperKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for SuperKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == SUPER_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct TraitKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for TraitKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for TraitKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == TRAIT_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct TrueKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for TrueKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for TrueKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == TRUE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct TryKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for TryKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for TryKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == TRY_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct TypeKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for TypeKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for TypeKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == TYPE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct UnsafeKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for UnsafeKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for UnsafeKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == UNSAFE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct UseKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for UseKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for UseKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == USE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct WhereKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for WhereKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for WhereKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == WHERE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct WhileKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for WhileKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for WhileKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == WHILE_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct AutoKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for AutoKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for AutoKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == AUTO_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct DefaultKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for DefaultKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for DefaultKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == DEFAULT_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct ExistentialKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for ExistentialKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for ExistentialKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == EXISTENTIAL_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct UnionKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for UnionKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for UnionKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == UNION_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct RawKw {
|
|
||||||
pub(crate) syntax: SyntaxToken,
|
|
||||||
}
|
|
||||||
impl std::fmt::Display for RawKw {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
||||||
std::fmt::Display::fmt(&self.syntax, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl AstToken for RawKw {
|
|
||||||
fn can_cast(kind: SyntaxKind) -> bool { kind == RAW_KW }
|
|
||||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
|
||||||
if Self::can_cast(syntax.kind()) {
|
|
||||||
Some(Self { syntax })
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
|
||||||
}
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
|
||||||
pub struct IntNumber {
|
pub struct IntNumber {
|
||||||
pub(crate) syntax: SyntaxToken,
|
pub(crate) syntax: SyntaxToken,
|
||||||
}
|
}
|
||||||
|
@ -2687,8 +1787,6 @@ pub enum LiteralToken {
|
||||||
FloatNumber(FloatNumber),
|
FloatNumber(FloatNumber),
|
||||||
String(String),
|
String(String),
|
||||||
RawString(RawString),
|
RawString(RawString),
|
||||||
TrueKw(TrueKw),
|
|
||||||
FalseKw(FalseKw),
|
|
||||||
ByteString(ByteString),
|
ByteString(ByteString),
|
||||||
RawByteString(RawByteString),
|
RawByteString(RawByteString),
|
||||||
Char(Char),
|
Char(Char),
|
||||||
|
@ -2706,12 +1804,6 @@ impl From<String> for LiteralToken {
|
||||||
impl From<RawString> for LiteralToken {
|
impl From<RawString> for LiteralToken {
|
||||||
fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) }
|
fn from(node: RawString) -> LiteralToken { LiteralToken::RawString(node) }
|
||||||
}
|
}
|
||||||
impl From<TrueKw> for LiteralToken {
|
|
||||||
fn from(node: TrueKw) -> LiteralToken { LiteralToken::TrueKw(node) }
|
|
||||||
}
|
|
||||||
impl From<FalseKw> for LiteralToken {
|
|
||||||
fn from(node: FalseKw) -> LiteralToken { LiteralToken::FalseKw(node) }
|
|
||||||
}
|
|
||||||
impl From<ByteString> for LiteralToken {
|
impl From<ByteString> for LiteralToken {
|
||||||
fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) }
|
fn from(node: ByteString) -> LiteralToken { LiteralToken::ByteString(node) }
|
||||||
}
|
}
|
||||||
|
@ -2732,8 +1824,8 @@ impl std::fmt::Display for LiteralToken {
|
||||||
impl AstToken for LiteralToken {
|
impl AstToken for LiteralToken {
|
||||||
fn can_cast(kind: SyntaxKind) -> bool {
|
fn can_cast(kind: SyntaxKind) -> bool {
|
||||||
match kind {
|
match kind {
|
||||||
INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | TRUE_KW | FALSE_KW | BYTE_STRING
|
INT_NUMBER | FLOAT_NUMBER | STRING | RAW_STRING | BYTE_STRING | RAW_BYTE_STRING
|
||||||
| RAW_BYTE_STRING | CHAR | BYTE => true,
|
| CHAR | BYTE => true,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2743,8 +1835,6 @@ impl AstToken for LiteralToken {
|
||||||
FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
|
FLOAT_NUMBER => LiteralToken::FloatNumber(FloatNumber { syntax }),
|
||||||
STRING => LiteralToken::String(String { syntax }),
|
STRING => LiteralToken::String(String { syntax }),
|
||||||
RAW_STRING => LiteralToken::RawString(RawString { syntax }),
|
RAW_STRING => LiteralToken::RawString(RawString { syntax }),
|
||||||
TRUE_KW => LiteralToken::TrueKw(TrueKw { syntax }),
|
|
||||||
FALSE_KW => LiteralToken::FalseKw(FalseKw { syntax }),
|
|
||||||
BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
|
BYTE_STRING => LiteralToken::ByteString(ByteString { syntax }),
|
||||||
RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
|
RAW_BYTE_STRING => LiteralToken::RawByteString(RawByteString { syntax }),
|
||||||
CHAR => LiteralToken::Char(Char { syntax }),
|
CHAR => LiteralToken::Char(Char { syntax }),
|
||||||
|
@ -2759,8 +1849,6 @@ impl AstToken for LiteralToken {
|
||||||
LiteralToken::FloatNumber(it) => &it.syntax,
|
LiteralToken::FloatNumber(it) => &it.syntax,
|
||||||
LiteralToken::String(it) => &it.syntax,
|
LiteralToken::String(it) => &it.syntax,
|
||||||
LiteralToken::RawString(it) => &it.syntax,
|
LiteralToken::RawString(it) => &it.syntax,
|
||||||
LiteralToken::TrueKw(it) => &it.syntax,
|
|
||||||
LiteralToken::FalseKw(it) => &it.syntax,
|
|
||||||
LiteralToken::ByteString(it) => &it.syntax,
|
LiteralToken::ByteString(it) => &it.syntax,
|
||||||
LiteralToken::RawByteString(it) => &it.syntax,
|
LiteralToken::RawByteString(it) => &it.syntax,
|
||||||
LiteralToken::Char(it) => &it.syntax,
|
LiteralToken::Char(it) => &it.syntax,
|
||||||
|
|
|
@ -814,8 +814,8 @@ pub(crate) const AST_SRC: AstSrc = AstSrc {
|
||||||
FloatNumber,
|
FloatNumber,
|
||||||
String,
|
String,
|
||||||
RawString,
|
RawString,
|
||||||
TrueKw,
|
// TrueKw,
|
||||||
FalseKw,
|
// FalseKw,
|
||||||
ByteString,
|
ByteString,
|
||||||
RawByteString,
|
RawByteString,
|
||||||
Char,
|
Char,
|
||||||
|
|
|
@ -58,11 +58,14 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
.chain(kinds.tokens.into_iter().copied().map(|x| x.into()))
|
.chain(kinds.tokens.into_iter().copied().map(|x| x.into()))
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let tokens = all_token_kinds.iter().map(|kind_str| {
|
let tokens = all_token_kinds.iter().filter_map(|kind_str| {
|
||||||
|
if kind_str.ends_with("_KW") {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let kind_str = &**kind_str;
|
let kind_str = &**kind_str;
|
||||||
let kind = format_ident!("{}", kind_str);
|
let kind = format_ident!("{}", kind_str);
|
||||||
let name = format_ident!("{}", to_pascal_case(kind_str));
|
let name = format_ident!("{}", to_pascal_case(kind_str));
|
||||||
quote! {
|
let res = quote! {
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
pub struct #name {
|
pub struct #name {
|
||||||
pub(crate) syntax: SyntaxToken,
|
pub(crate) syntax: SyntaxToken,
|
||||||
|
@ -81,7 +84,8 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
}
|
}
|
||||||
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
fn syntax(&self) -> &SyntaxToken { &self.syntax }
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
Some(res)
|
||||||
});
|
});
|
||||||
|
|
||||||
let enums = grammar.token_enums.iter().map(|en| {
|
let enums = grammar.token_enums.iter().map(|en| {
|
||||||
|
@ -186,8 +190,12 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
});
|
});
|
||||||
|
|
||||||
let methods = node.fields.iter().map(|(name, field)| {
|
let methods = node.fields.iter().map(|(name, field)| {
|
||||||
|
let is_kw = name.ends_with("Kw");
|
||||||
let method_name = match field {
|
let method_name = match field {
|
||||||
FieldSrc::Shorthand => format_ident!("{}", to_lower_snake_case(&name)),
|
FieldSrc::Shorthand => {
|
||||||
|
let name = if is_kw { &name[..name.len() - 2] } else { &name };
|
||||||
|
format_ident!("{}", to_lower_snake_case(name))
|
||||||
|
}
|
||||||
_ => format_ident!("{}", name),
|
_ => format_ident!("{}", name),
|
||||||
};
|
};
|
||||||
let ty = match field {
|
let ty = match field {
|
||||||
|
@ -209,9 +217,18 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
let is_token = token_kinds.contains(&ty.to_string());
|
let is_token = token_kinds.contains(&ty.to_string());
|
||||||
if is_token {
|
if is_token {
|
||||||
let method_name = format_ident!("{}_token", method_name);
|
let method_name = format_ident!("{}_token", method_name);
|
||||||
quote! {
|
if is_kw {
|
||||||
pub fn #method_name(&self) -> Option<#ty> {
|
let token_kind = format_ident!("{}", to_upper_snake_case(name));
|
||||||
support::token(&self.syntax)
|
quote! {
|
||||||
|
pub fn #method_name(&self) -> Option<SyntaxToken> {
|
||||||
|
support::token2(&self.syntax, #token_kind)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
quote! {
|
||||||
|
pub fn #method_name(&self) -> Option<#ty> {
|
||||||
|
support::token(&self.syntax)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -332,7 +349,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
||||||
|
|
||||||
let ast = quote! {
|
let ast = quote! {
|
||||||
use crate::{
|
use crate::{
|
||||||
SyntaxNode, SyntaxKind::{self, *},
|
SyntaxNode, SyntaxToken, SyntaxKind::{self, *},
|
||||||
ast::{self, AstNode, AstChildren, support},
|
ast::{self, AstNode, AstChildren, support},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue