mirror of
https://github.com/RustPython/Parser.git
synced 2025-07-13 08:05:17 +00:00
Regenerate code with latest ASDL
This commit is contained in:
parent
25b23998ad
commit
df2b5dfed0
10 changed files with 9288 additions and 19364 deletions
|
@ -108,6 +108,12 @@ pub trait Fold<U> {
|
|||
) -> Result<StmtAssign<Self::TargetU>, Self::Error> {
|
||||
fold_stmt_assign(self, node)
|
||||
}
|
||||
fn fold_stmt_type_alias(
|
||||
&mut self,
|
||||
node: StmtTypeAlias<U>,
|
||||
) -> Result<StmtTypeAlias<Self::TargetU>, Self::Error> {
|
||||
fold_stmt_type_alias(self, node)
|
||||
}
|
||||
fn fold_stmt_aug_assign(
|
||||
&mut self,
|
||||
node: StmtAugAssign<U>,
|
||||
|
@ -507,6 +513,30 @@ pub trait Fold<U> {
|
|||
) -> Result<TypeIgnoreTypeIgnore<Self::TargetU>, Self::Error> {
|
||||
fold_type_ignore_type_ignore(self, node)
|
||||
}
|
||||
fn fold_type_param(
|
||||
&mut self,
|
||||
node: TypeParam<U>,
|
||||
) -> Result<TypeParam<Self::TargetU>, Self::Error> {
|
||||
fold_type_param(self, node)
|
||||
}
|
||||
fn fold_type_param_type_var(
|
||||
&mut self,
|
||||
node: TypeParamTypeVar<U>,
|
||||
) -> Result<TypeParamTypeVar<Self::TargetU>, Self::Error> {
|
||||
fold_type_param_type_var(self, node)
|
||||
}
|
||||
fn fold_type_param_param_spec(
|
||||
&mut self,
|
||||
node: TypeParamParamSpec<U>,
|
||||
) -> Result<TypeParamParamSpec<Self::TargetU>, Self::Error> {
|
||||
fold_type_param_param_spec(self, node)
|
||||
}
|
||||
fn fold_type_param_type_var_tuple(
|
||||
&mut self,
|
||||
node: TypeParamTypeVarTuple<U>,
|
||||
) -> Result<TypeParamTypeVarTuple<Self::TargetU>, Self::Error> {
|
||||
fold_type_param_type_var_tuple(self, node)
|
||||
}
|
||||
fn fold_arg_with_default(
|
||||
&mut self,
|
||||
node: ArgWithDefault<U>,
|
||||
|
@ -653,6 +683,7 @@ pub fn fold_stmt<U, F: Fold<U> + ?Sized>(
|
|||
Stmt::Return(cons) => Stmt::Return(Foldable::fold(cons, folder)?),
|
||||
Stmt::Delete(cons) => Stmt::Delete(Foldable::fold(cons, folder)?),
|
||||
Stmt::Assign(cons) => Stmt::Assign(Foldable::fold(cons, folder)?),
|
||||
Stmt::TypeAlias(cons) => Stmt::TypeAlias(Foldable::fold(cons, folder)?),
|
||||
Stmt::AugAssign(cons) => Stmt::AugAssign(Foldable::fold(cons, folder)?),
|
||||
Stmt::AnnAssign(cons) => Stmt::AnnAssign(Foldable::fold(cons, folder)?),
|
||||
Stmt::For(cons) => Stmt::For(Foldable::fold(cons, folder)?),
|
||||
|
@ -697,6 +728,7 @@ pub fn fold_stmt_function_def<U, F: Fold<U> + ?Sized>(
|
|||
decorator_list,
|
||||
returns,
|
||||
type_comment,
|
||||
type_params,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
@ -707,6 +739,7 @@ pub fn fold_stmt_function_def<U, F: Fold<U> + ?Sized>(
|
|||
let decorator_list = Foldable::fold(decorator_list, folder)?;
|
||||
let returns = Foldable::fold(returns, folder)?;
|
||||
let type_comment = Foldable::fold(type_comment, folder)?;
|
||||
let type_params = Foldable::fold(type_params, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(StmtFunctionDef {
|
||||
name,
|
||||
|
@ -715,6 +748,7 @@ pub fn fold_stmt_function_def<U, F: Fold<U> + ?Sized>(
|
|||
decorator_list,
|
||||
returns,
|
||||
type_comment,
|
||||
type_params,
|
||||
range,
|
||||
})
|
||||
}
|
||||
|
@ -738,6 +772,7 @@ pub fn fold_stmt_async_function_def<U, F: Fold<U> + ?Sized>(
|
|||
decorator_list,
|
||||
returns,
|
||||
type_comment,
|
||||
type_params,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
@ -748,6 +783,7 @@ pub fn fold_stmt_async_function_def<U, F: Fold<U> + ?Sized>(
|
|||
let decorator_list = Foldable::fold(decorator_list, folder)?;
|
||||
let returns = Foldable::fold(returns, folder)?;
|
||||
let type_comment = Foldable::fold(type_comment, folder)?;
|
||||
let type_params = Foldable::fold(type_params, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(StmtAsyncFunctionDef {
|
||||
name,
|
||||
|
@ -756,6 +792,7 @@ pub fn fold_stmt_async_function_def<U, F: Fold<U> + ?Sized>(
|
|||
decorator_list,
|
||||
returns,
|
||||
type_comment,
|
||||
type_params,
|
||||
range,
|
||||
})
|
||||
}
|
||||
|
@ -778,6 +815,7 @@ pub fn fold_stmt_class_def<U, F: Fold<U> + ?Sized>(
|
|||
keywords,
|
||||
body,
|
||||
decorator_list,
|
||||
type_params,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
@ -787,6 +825,7 @@ pub fn fold_stmt_class_def<U, F: Fold<U> + ?Sized>(
|
|||
let keywords = Foldable::fold(keywords, folder)?;
|
||||
let body = Foldable::fold(body, folder)?;
|
||||
let decorator_list = Foldable::fold(decorator_list, folder)?;
|
||||
let type_params = Foldable::fold(type_params, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(StmtClassDef {
|
||||
name,
|
||||
|
@ -794,6 +833,7 @@ pub fn fold_stmt_class_def<U, F: Fold<U> + ?Sized>(
|
|||
keywords,
|
||||
body,
|
||||
decorator_list,
|
||||
type_params,
|
||||
range,
|
||||
})
|
||||
}
|
||||
|
@ -869,6 +909,38 @@ pub fn fold_stmt_assign<U, F: Fold<U> + ?Sized>(
|
|||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for StmtTypeAlias<T> {
|
||||
type Mapped = StmtTypeAlias<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self::Mapped, F::Error> {
|
||||
folder.fold_stmt_type_alias(self)
|
||||
}
|
||||
}
|
||||
pub fn fold_stmt_type_alias<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: StmtTypeAlias<U>,
|
||||
) -> Result<StmtTypeAlias<F::TargetU>, F::Error> {
|
||||
let StmtTypeAlias {
|
||||
name,
|
||||
type_params,
|
||||
value,
|
||||
range,
|
||||
} = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let type_params = Foldable::fold(type_params, folder)?;
|
||||
let value = Foldable::fold(value, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(StmtTypeAlias {
|
||||
name,
|
||||
type_params,
|
||||
value,
|
||||
range,
|
||||
})
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for StmtAugAssign<T> {
|
||||
type Mapped = StmtAugAssign<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
|
@ -2791,6 +2863,87 @@ pub fn fold_type_ignore_type_ignore<U, F: Fold<U> + ?Sized>(
|
|||
let range = folder.map_user_cfg(range, context)?;
|
||||
Ok(TypeIgnoreTypeIgnore { lineno, tag, range })
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for TypeParam<T> {
|
||||
type Mapped = TypeParam<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self::Mapped, F::Error> {
|
||||
folder.fold_type_param(self)
|
||||
}
|
||||
}
|
||||
pub fn fold_type_param<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParam<U>,
|
||||
) -> Result<TypeParam<F::TargetU>, F::Error> {
|
||||
let folded = match node {
|
||||
TypeParam::TypeVar(cons) => TypeParam::TypeVar(Foldable::fold(cons, folder)?),
|
||||
TypeParam::ParamSpec(cons) => TypeParam::ParamSpec(Foldable::fold(cons, folder)?),
|
||||
TypeParam::TypeVarTuple(cons) => TypeParam::TypeVarTuple(Foldable::fold(cons, folder)?),
|
||||
};
|
||||
Ok(folded)
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for TypeParamTypeVar<T> {
|
||||
type Mapped = TypeParamTypeVar<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self::Mapped, F::Error> {
|
||||
folder.fold_type_param_type_var(self)
|
||||
}
|
||||
}
|
||||
pub fn fold_type_param_type_var<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParamTypeVar<U>,
|
||||
) -> Result<TypeParamTypeVar<F::TargetU>, F::Error> {
|
||||
let TypeParamTypeVar { name, bound, range } = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let bound = Foldable::fold(bound, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(TypeParamTypeVar { name, bound, range })
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for TypeParamParamSpec<T> {
|
||||
type Mapped = TypeParamParamSpec<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self::Mapped, F::Error> {
|
||||
folder.fold_type_param_param_spec(self)
|
||||
}
|
||||
}
|
||||
pub fn fold_type_param_param_spec<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParamParamSpec<U>,
|
||||
) -> Result<TypeParamParamSpec<F::TargetU>, F::Error> {
|
||||
let TypeParamParamSpec { name, range } = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(TypeParamParamSpec { name, range })
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for TypeParamTypeVarTuple<T> {
|
||||
type Mapped = TypeParamTypeVarTuple<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self::Mapped, F::Error> {
|
||||
folder.fold_type_param_type_var_tuple(self)
|
||||
}
|
||||
}
|
||||
pub fn fold_type_param_type_var_tuple<U, F: Fold<U> + ?Sized>(
|
||||
#[allow(unused)] folder: &mut F,
|
||||
node: TypeParamTypeVarTuple<U>,
|
||||
) -> Result<TypeParamTypeVarTuple<F::TargetU>, F::Error> {
|
||||
let TypeParamTypeVarTuple { name, range } = node;
|
||||
let context = folder.will_map_user(&range);
|
||||
|
||||
let name = Foldable::fold(name, folder)?;
|
||||
let range = folder.map_user(range, context)?;
|
||||
Ok(TypeParamTypeVarTuple { name, range })
|
||||
}
|
||||
impl<T, U> Foldable<T, U> for ArgWithDefault<T> {
|
||||
type Mapped = ArgWithDefault<U>;
|
||||
fn fold<F: Fold<T, TargetU = U> + ?Sized>(
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// File automatically generated by ast/asdl_rs.py.
|
||||
|
||||
use crate::text_size::TextRange;
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[derive(is_macro::Is)]
|
||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
||||
pub enum Ast<R = TextRange> {
|
||||
#[is(name = "module")]
|
||||
Mod(Mod<R>),
|
||||
|
@ -23,6 +22,7 @@ pub enum Ast<R = TextRange> {
|
|||
MatchCase(MatchCase<R>),
|
||||
Pattern(Pattern<R>),
|
||||
TypeIgnore(TypeIgnore<R>),
|
||||
TypeParam(TypeParam<R>),
|
||||
}
|
||||
impl<R> Node for Ast<R> {
|
||||
const NAME: &'static str = "AST";
|
||||
|
@ -137,6 +137,12 @@ impl<R> From<TypeIgnore<R>> for Ast<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R> From<TypeParam<R>> for Ast<R> {
|
||||
fn from(node: TypeParam<R>) -> Self {
|
||||
Ast::TypeParam(node)
|
||||
}
|
||||
}
|
||||
|
||||
/// See also [mod](https://docs.python.org/3/library/ast.html#ast.mod)
|
||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
||||
pub enum Mod<R = TextRange> {
|
||||
|
@ -256,6 +262,8 @@ pub enum Stmt<R = TextRange> {
|
|||
Delete(StmtDelete<R>),
|
||||
#[is(name = "assign_stmt")]
|
||||
Assign(StmtAssign<R>),
|
||||
#[is(name = "type_alias_stmt")]
|
||||
TypeAlias(StmtTypeAlias<R>),
|
||||
#[is(name = "aug_assign_stmt")]
|
||||
AugAssign(StmtAugAssign<R>),
|
||||
#[is(name = "ann_assign_stmt")]
|
||||
|
@ -310,6 +318,7 @@ pub struct StmtFunctionDef<R = TextRange> {
|
|||
pub decorator_list: Vec<Expr<R>>,
|
||||
pub returns: Option<Box<Expr<R>>>,
|
||||
pub type_comment: Option<String>,
|
||||
pub type_params: Vec<TypeParam<R>>,
|
||||
}
|
||||
|
||||
impl<R> Node for StmtFunctionDef<R> {
|
||||
|
@ -321,6 +330,7 @@ impl<R> Node for StmtFunctionDef<R> {
|
|||
"decorator_list",
|
||||
"returns",
|
||||
"type_comment",
|
||||
"type_params",
|
||||
];
|
||||
}
|
||||
impl<R> From<StmtFunctionDef<R>> for Stmt<R> {
|
||||
|
@ -344,6 +354,7 @@ pub struct StmtAsyncFunctionDef<R = TextRange> {
|
|||
pub decorator_list: Vec<Expr<R>>,
|
||||
pub returns: Option<Box<Expr<R>>>,
|
||||
pub type_comment: Option<String>,
|
||||
pub type_params: Vec<TypeParam<R>>,
|
||||
}
|
||||
|
||||
impl<R> Node for StmtAsyncFunctionDef<R> {
|
||||
|
@ -355,6 +366,7 @@ impl<R> Node for StmtAsyncFunctionDef<R> {
|
|||
"decorator_list",
|
||||
"returns",
|
||||
"type_comment",
|
||||
"type_params",
|
||||
];
|
||||
}
|
||||
impl<R> From<StmtAsyncFunctionDef<R>> for Stmt<R> {
|
||||
|
@ -377,12 +389,19 @@ pub struct StmtClassDef<R = TextRange> {
|
|||
pub keywords: Vec<Keyword<R>>,
|
||||
pub body: Vec<Stmt<R>>,
|
||||
pub decorator_list: Vec<Expr<R>>,
|
||||
pub type_params: Vec<TypeParam<R>>,
|
||||
}
|
||||
|
||||
impl<R> Node for StmtClassDef<R> {
|
||||
const NAME: &'static str = "ClassDef";
|
||||
const FIELD_NAMES: &'static [&'static str] =
|
||||
&["name", "bases", "keywords", "body", "decorator_list"];
|
||||
const FIELD_NAMES: &'static [&'static str] = &[
|
||||
"name",
|
||||
"bases",
|
||||
"keywords",
|
||||
"body",
|
||||
"decorator_list",
|
||||
"type_params",
|
||||
];
|
||||
}
|
||||
impl<R> From<StmtClassDef<R>> for Stmt<R> {
|
||||
fn from(payload: StmtClassDef<R>) -> Self {
|
||||
|
@ -463,6 +482,30 @@ impl<R> From<StmtAssign<R>> for Ast<R> {
|
|||
}
|
||||
}
|
||||
|
||||
/// See also [TypeAlias](https://docs.python.org/3/library/ast.html#ast.TypeAlias)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct StmtTypeAlias<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Box<Expr<R>>,
|
||||
pub type_params: Vec<TypeParam<R>>,
|
||||
pub value: Box<Expr<R>>,
|
||||
}
|
||||
|
||||
impl<R> Node for StmtTypeAlias<R> {
|
||||
const NAME: &'static str = "TypeAlias";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name", "type_params", "value"];
|
||||
}
|
||||
impl<R> From<StmtTypeAlias<R>> for Stmt<R> {
|
||||
fn from(payload: StmtTypeAlias<R>) -> Self {
|
||||
Stmt::TypeAlias(payload)
|
||||
}
|
||||
}
|
||||
impl<R> From<StmtTypeAlias<R>> for Ast<R> {
|
||||
fn from(payload: StmtTypeAlias<R>) -> Self {
|
||||
Stmt::from(payload).into()
|
||||
}
|
||||
}
|
||||
|
||||
/// See also [AugAssign](https://docs.python.org/3/library/ast.html#ast.AugAssign)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct StmtAugAssign<R = TextRange> {
|
||||
|
@ -3074,6 +3117,86 @@ impl<R> Node for TypeIgnore<R> {
|
|||
const FIELD_NAMES: &'static [&'static str] = &[];
|
||||
}
|
||||
|
||||
/// See also [type_param](https://docs.python.org/3/library/ast.html#ast.type_param)
|
||||
#[derive(Clone, Debug, PartialEq, is_macro::Is)]
|
||||
pub enum TypeParam<R = TextRange> {
|
||||
TypeVar(TypeParamTypeVar<R>),
|
||||
ParamSpec(TypeParamParamSpec<R>),
|
||||
TypeVarTuple(TypeParamTypeVarTuple<R>),
|
||||
}
|
||||
|
||||
/// See also [TypeVar](https://docs.python.org/3/library/ast.html#ast.TypeVar)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct TypeParamTypeVar<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Identifier,
|
||||
pub bound: Option<Box<Expr<R>>>,
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParamTypeVar<R> {
|
||||
const NAME: &'static str = "TypeVar";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name", "bound"];
|
||||
}
|
||||
impl<R> From<TypeParamTypeVar<R>> for TypeParam<R> {
|
||||
fn from(payload: TypeParamTypeVar<R>) -> Self {
|
||||
TypeParam::TypeVar(payload)
|
||||
}
|
||||
}
|
||||
impl<R> From<TypeParamTypeVar<R>> for Ast<R> {
|
||||
fn from(payload: TypeParamTypeVar<R>) -> Self {
|
||||
TypeParam::from(payload).into()
|
||||
}
|
||||
}
|
||||
|
||||
/// See also [ParamSpec](https://docs.python.org/3/library/ast.html#ast.ParamSpec)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct TypeParamParamSpec<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Identifier,
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParamParamSpec<R> {
|
||||
const NAME: &'static str = "ParamSpec";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name"];
|
||||
}
|
||||
impl<R> From<TypeParamParamSpec<R>> for TypeParam<R> {
|
||||
fn from(payload: TypeParamParamSpec<R>) -> Self {
|
||||
TypeParam::ParamSpec(payload)
|
||||
}
|
||||
}
|
||||
impl<R> From<TypeParamParamSpec<R>> for Ast<R> {
|
||||
fn from(payload: TypeParamParamSpec<R>) -> Self {
|
||||
TypeParam::from(payload).into()
|
||||
}
|
||||
}
|
||||
|
||||
/// See also [TypeVarTuple](https://docs.python.org/3/library/ast.html#ast.TypeVarTuple)
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct TypeParamTypeVarTuple<R = TextRange> {
|
||||
pub range: R,
|
||||
pub name: Identifier,
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParamTypeVarTuple<R> {
|
||||
const NAME: &'static str = "TypeVarTuple";
|
||||
const FIELD_NAMES: &'static [&'static str] = &["name"];
|
||||
}
|
||||
impl<R> From<TypeParamTypeVarTuple<R>> for TypeParam<R> {
|
||||
fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
|
||||
TypeParam::TypeVarTuple(payload)
|
||||
}
|
||||
}
|
||||
impl<R> From<TypeParamTypeVarTuple<R>> for Ast<R> {
|
||||
fn from(payload: TypeParamTypeVarTuple<R>) -> Self {
|
||||
TypeParam::from(payload).into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<R> Node for TypeParam<R> {
|
||||
const NAME: &'static str = "type_param";
|
||||
const FIELD_NAMES: &'static [&'static str] = &[];
|
||||
}
|
||||
|
||||
/// An alternative type of AST `arguments`. This is parser-friendly and human-friendly definition of function arguments.
|
||||
/// This form also has advantage to implement pre-order traverse.
|
||||
/// `defaults` and `kw_defaults` fields are removed and the default values are placed under each `arg_with_default` typed argument.
|
||||
|
|
|
@ -171,6 +171,20 @@ impl LocatedMut for StmtAssign {
|
|||
}
|
||||
}
|
||||
|
||||
pub type StmtTypeAlias = crate::generic::StmtTypeAlias<SourceRange>;
|
||||
|
||||
impl Located for StmtTypeAlias {
|
||||
fn range(&self) -> SourceRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for StmtTypeAlias {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
&mut self.range
|
||||
}
|
||||
}
|
||||
|
||||
pub type StmtAugAssign = crate::generic::StmtAugAssign<SourceRange>;
|
||||
|
||||
impl Located for StmtAugAssign {
|
||||
|
@ -474,6 +488,7 @@ impl Located for Stmt {
|
|||
Self::Return(node) => node.range(),
|
||||
Self::Delete(node) => node.range(),
|
||||
Self::Assign(node) => node.range(),
|
||||
Self::TypeAlias(node) => node.range(),
|
||||
Self::AugAssign(node) => node.range(),
|
||||
Self::AnnAssign(node) => node.range(),
|
||||
Self::For(node) => node.range(),
|
||||
|
@ -508,6 +523,7 @@ impl LocatedMut for Stmt {
|
|||
Self::Return(node) => node.range_mut(),
|
||||
Self::Delete(node) => node.range_mut(),
|
||||
Self::Assign(node) => node.range_mut(),
|
||||
Self::TypeAlias(node) => node.range_mut(),
|
||||
Self::AugAssign(node) => node.range_mut(),
|
||||
Self::AnnAssign(node) => node.range_mut(),
|
||||
Self::For(node) => node.range_mut(),
|
||||
|
@ -1367,6 +1383,70 @@ impl LocatedMut for TypeIgnore {
|
|||
}
|
||||
}
|
||||
|
||||
pub type TypeParam = crate::generic::TypeParam<SourceRange>;
|
||||
|
||||
pub type TypeParamTypeVar = crate::generic::TypeParamTypeVar<SourceRange>;
|
||||
|
||||
impl Located for TypeParamTypeVar {
|
||||
fn range(&self) -> SourceRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for TypeParamTypeVar {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
&mut self.range
|
||||
}
|
||||
}
|
||||
|
||||
pub type TypeParamParamSpec = crate::generic::TypeParamParamSpec<SourceRange>;
|
||||
|
||||
impl Located for TypeParamParamSpec {
|
||||
fn range(&self) -> SourceRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for TypeParamParamSpec {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
&mut self.range
|
||||
}
|
||||
}
|
||||
|
||||
pub type TypeParamTypeVarTuple = crate::generic::TypeParamTypeVarTuple<SourceRange>;
|
||||
|
||||
impl Located for TypeParamTypeVarTuple {
|
||||
fn range(&self) -> SourceRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for TypeParamTypeVarTuple {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
&mut self.range
|
||||
}
|
||||
}
|
||||
|
||||
impl Located for TypeParam {
|
||||
fn range(&self) -> SourceRange {
|
||||
match self {
|
||||
Self::TypeVar(node) => node.range(),
|
||||
Self::ParamSpec(node) => node.range(),
|
||||
Self::TypeVarTuple(node) => node.range(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl LocatedMut for TypeParam {
|
||||
fn range_mut(&mut self) -> &mut SourceRange {
|
||||
match self {
|
||||
Self::TypeVar(node) => node.range_mut(),
|
||||
Self::ParamSpec(node) => node.range_mut(),
|
||||
Self::TypeVarTuple(node) => node.range_mut(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type Arguments = crate::generic::Arguments<SourceRange>;
|
||||
|
||||
#[cfg(feature = "all-nodes-with-ranges")]
|
||||
|
|
|
@ -66,6 +66,11 @@ impl Ranged for crate::generic::StmtAssign<TextRange> {
|
|||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::generic::StmtTypeAlias<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::generic::StmtAugAssign<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
|
@ -180,6 +185,7 @@ impl Ranged for crate::Stmt {
|
|||
Self::Return(node) => node.range(),
|
||||
Self::Delete(node) => node.range(),
|
||||
Self::Assign(node) => node.range(),
|
||||
Self::TypeAlias(node) => node.range(),
|
||||
Self::AugAssign(node) => node.range(),
|
||||
Self::AnnAssign(node) => node.range(),
|
||||
Self::For(node) => node.range(),
|
||||
|
@ -496,6 +502,31 @@ impl Ranged for crate::TypeIgnore {
|
|||
}
|
||||
}
|
||||
|
||||
impl Ranged for crate::generic::TypeParamTypeVar<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::generic::TypeParamParamSpec<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::generic::TypeParamTypeVarTuple<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
self.range
|
||||
}
|
||||
}
|
||||
impl Ranged for crate::TypeParam {
|
||||
fn range(&self) -> TextRange {
|
||||
match self {
|
||||
Self::TypeVar(node) => node.range(),
|
||||
Self::ParamSpec(node) => node.range(),
|
||||
Self::TypeVarTuple(node) => node.range(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "all-nodes-with-ranges")]
|
||||
impl Ranged for crate::generic::Arguments<TextRange> {
|
||||
fn range(&self) -> TextRange {
|
||||
|
|
|
@ -13,6 +13,7 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
Stmt::Return(data) => self.visit_stmt_return(data),
|
||||
Stmt::Delete(data) => self.visit_stmt_delete(data),
|
||||
Stmt::Assign(data) => self.visit_stmt_assign(data),
|
||||
Stmt::TypeAlias(data) => self.visit_stmt_type_alias(data),
|
||||
Stmt::AugAssign(data) => self.visit_stmt_aug_assign(data),
|
||||
Stmt::AnnAssign(data) => self.visit_stmt_ann_assign(data),
|
||||
Stmt::For(data) => self.visit_stmt_for(data),
|
||||
|
@ -53,6 +54,9 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
if let Some(value) = node.returns {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
for value in node.type_params {
|
||||
self.visit_type_param(value);
|
||||
}
|
||||
}
|
||||
fn visit_stmt_async_function_def(&mut self, node: StmtAsyncFunctionDef<R>) {
|
||||
self.generic_visit_stmt_async_function_def(node)
|
||||
|
@ -71,6 +75,9 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
if let Some(value) = node.returns {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
for value in node.type_params {
|
||||
self.visit_type_param(value);
|
||||
}
|
||||
}
|
||||
fn visit_stmt_class_def(&mut self, node: StmtClassDef<R>) {
|
||||
self.generic_visit_stmt_class_def(node)
|
||||
|
@ -88,6 +95,9 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
for value in node.decorator_list {
|
||||
self.visit_expr(value);
|
||||
}
|
||||
for value in node.type_params {
|
||||
self.visit_type_param(value);
|
||||
}
|
||||
}
|
||||
fn visit_stmt_return(&mut self, node: StmtReturn<R>) {
|
||||
self.generic_visit_stmt_return(node)
|
||||
|
@ -117,6 +127,22 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
self.visit_expr(*value);
|
||||
}
|
||||
}
|
||||
fn visit_stmt_type_alias(&mut self, node: StmtTypeAlias<R>) {
|
||||
self.generic_visit_stmt_type_alias(node)
|
||||
}
|
||||
fn generic_visit_stmt_type_alias(&mut self, node: StmtTypeAlias<R>) {
|
||||
{
|
||||
let value = node.name;
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
for value in node.type_params {
|
||||
self.visit_type_param(value);
|
||||
}
|
||||
{
|
||||
let value = node.value;
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
}
|
||||
fn visit_stmt_aug_assign(&mut self, node: StmtAugAssign<R>) {
|
||||
self.generic_visit_stmt_aug_assign(node)
|
||||
}
|
||||
|
@ -810,4 +836,30 @@ pub trait Visitor<R = crate::text_size::TextRange> {
|
|||
self.visit_pattern(value);
|
||||
}
|
||||
}
|
||||
fn visit_type_param(&mut self, node: TypeParam<R>) {
|
||||
self.generic_visit_type_param(node)
|
||||
}
|
||||
fn generic_visit_type_param(&mut self, node: TypeParam<R>) {
|
||||
match node {
|
||||
TypeParam::TypeVar(data) => self.visit_type_param_type_var(data),
|
||||
TypeParam::ParamSpec(data) => self.visit_type_param_param_spec(data),
|
||||
TypeParam::TypeVarTuple(data) => self.visit_type_param_type_var_tuple(data),
|
||||
}
|
||||
}
|
||||
fn visit_type_param_type_var(&mut self, node: TypeParamTypeVar<R>) {
|
||||
self.generic_visit_type_param_type_var(node)
|
||||
}
|
||||
fn generic_visit_type_param_type_var(&mut self, node: TypeParamTypeVar<R>) {
|
||||
if let Some(value) = node.bound {
|
||||
self.visit_expr(*value);
|
||||
}
|
||||
}
|
||||
fn visit_type_param_param_spec(&mut self, node: TypeParamParamSpec<R>) {
|
||||
self.generic_visit_type_param_param_spec(node)
|
||||
}
|
||||
fn generic_visit_type_param_param_spec(&mut self, node: TypeParamParamSpec<R>) {}
|
||||
fn visit_type_param_type_var_tuple(&mut self, node: TypeParamTypeVarTuple<R>) {
|
||||
self.generic_visit_type_param_type_var_tuple(node)
|
||||
}
|
||||
fn generic_visit_type_param_type_var_tuple(&mut self, node: TypeParamTypeVarTuple<R>) {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue