From fe5bc47debb0963e2a79759c6c304ebd427ad0ec Mon Sep 17 00:00:00 2001 From: Kennedy Tedesco Date: Wed, 18 Jan 2023 20:13:46 -0300 Subject: [PATCH] chore: Node `get_description()` tweaks (#36) --- src/tree/definition/class.rs | 11 +- src/tree/definition/enum.rs | 19 +- src/tree/definition/interface.rs | 8 +- src/tree/definition/mod.rs | 13 +- src/tree/definition/modifier.rs | 10 +- src/tree/definition/property.rs | 7 +- src/tree/definition/type.rs | 27 ++- src/tree/definition/use.rs | 6 +- src/tree/expression/argument.rs | 9 +- src/tree/expression/class.rs | 9 +- src/tree/expression/literal.rs | 9 +- src/tree/expression/magic_constant.rs | 10 +- src/tree/expression/mod.rs | 32 ++- src/tree/expression/operator.rs | 296 ++++++++++++++++++++++++-- src/tree/statement/mod.rs | 16 +- src/tree/statement/return.rs | 5 +- 16 files changed, 448 insertions(+), 39 deletions(-) diff --git a/src/tree/definition/class.rs b/src/tree/definition/class.rs index 6065989..76fcde7 100644 --- a/src/tree/definition/class.rs +++ b/src/tree/definition/class.rs @@ -224,7 +224,7 @@ impl Node for ClassDefinitionMember { } fn children(&self) -> Vec<&dyn Node> { - match self { + match &self { Self::Constant(constant) => vec![constant], Self::Property(property) => vec![property], Self::AbstractMethod(method) => vec![method], @@ -235,6 +235,13 @@ impl Node for ClassDefinitionMember { } fn get_description(&self) -> String { - "class member definition".to_string() + match &self { + Self::Constant(constant) => constant.get_description(), + Self::Property(property) => property.get_description(), + Self::AbstractMethod(method) => method.get_description(), + Self::AbstractConstructor(constructor) => constructor.get_description(), + Self::ConcreteMethod(method) => method.get_description(), + Self::ConcreteConstructor(constructor) => constructor.get_description(), + } } } diff --git a/src/tree/definition/enum.rs b/src/tree/definition/enum.rs index 92bc717..d9d6a53 100644 --- a/src/tree/definition/enum.rs +++ b/src/tree/definition/enum.rs @@ -129,14 +129,17 @@ impl Node for EnumDefinition { } fn children(&self) -> Vec<&dyn Node> { - match self { + match &self { EnumDefinition::Backed(definition) => vec![definition], EnumDefinition::Unit(definition) => vec![definition], } } fn get_description(&self) -> String { - "enum definition".to_string() + match &self { + EnumDefinition::Backed(definition) => definition.get_description(), + EnumDefinition::Unit(definition) => definition.get_description(), + } } } @@ -261,7 +264,11 @@ impl Node for UnitEnumMemberDefinition { } fn get_description(&self) -> String { - "unit enum member definition".to_string() + match self { + Self::Case(case) => case.get_description(), + Self::Method(method) => method.get_description(), + Self::Constant(constant) => constant.get_description(), + } } } @@ -400,7 +407,11 @@ impl Node for BackedEnumMemberDefinition { } fn get_description(&self) -> String { - "backed enum member definition".to_string() + match &self { + Self::Case(case) => case.get_description(), + Self::Method(method) => method.get_description(), + Self::Constant(constant) => constant.get_description(), + } } } diff --git a/src/tree/definition/interface.rs b/src/tree/definition/interface.rs index abdc7fb..bc7857b 100644 --- a/src/tree/definition/interface.rs +++ b/src/tree/definition/interface.rs @@ -165,7 +165,7 @@ impl Node for InterfaceDefinitionMember { } fn children(&self) -> Vec<&dyn Node> { - match self { + match &self { Self::Constant(constant) => vec![constant], Self::Constructor(constructor) => vec![constructor], Self::Method(method) => vec![method], @@ -173,6 +173,10 @@ impl Node for InterfaceDefinitionMember { } fn get_description(&self) -> String { - "interface member definition".to_string() + match &self { + Self::Constant(constant) => constant.get_description(), + Self::Constructor(constructor) => constructor.get_description(), + Self::Method(method) => method.get_description(), + } } } diff --git a/src/tree/definition/mod.rs b/src/tree/definition/mod.rs index 71a1b62..7a8ac77 100644 --- a/src/tree/definition/mod.rs +++ b/src/tree/definition/mod.rs @@ -91,7 +91,7 @@ impl Node for Definition { } fn children(&self) -> Vec<&dyn Node> { - match self { + match &self { Definition::Namespace(definition) => vec![definition.as_ref()], Definition::Use(definition) => vec![definition.as_ref()], Definition::TypeAlias(definition) => vec![definition.as_ref()], @@ -104,6 +104,15 @@ impl Node for Definition { } fn get_description(&self) -> String { - "definition".to_string() + match &self { + Definition::Namespace(definition) => definition.get_description(), + Definition::Use(definition) => definition.get_description(), + Definition::TypeAlias(definition) => definition.get_description(), + Definition::Constant(definition) => definition.get_description(), + Definition::Function(definition) => definition.get_description(), + Definition::Interface(definition) => definition.get_description(), + Definition::Enum(definition) => definition.get_description(), + Definition::Class(definition) => definition.get_description(), + } } } diff --git a/src/tree/definition/modifier.rs b/src/tree/definition/modifier.rs index e205f7e..519bea9 100644 --- a/src/tree/definition/modifier.rs +++ b/src/tree/definition/modifier.rs @@ -89,7 +89,15 @@ impl Node for ModifierDefinition { } fn get_description(&self) -> String { - "modifier definition".to_string() + match &self { + ModifierDefinition::Public(_keyword) => "public modifier definition".to_string(), + ModifierDefinition::Protected(_keyword) => "protected modifier definition".to_string(), + ModifierDefinition::Private(_keyword) => "private modifier definition".to_string(), + ModifierDefinition::Readonly(_keyword) => "readonly modifier definition".to_string(), + ModifierDefinition::Static(_keyword) => "static modifier definition".to_string(), + ModifierDefinition::Abstract(_keyword) => "abstract modifier definition".to_string(), + ModifierDefinition::Final(_keyword) => "final modifier definition".to_string(), + } } } diff --git a/src/tree/definition/property.rs b/src/tree/definition/property.rs index 685ab12..d152765 100644 --- a/src/tree/definition/property.rs +++ b/src/tree/definition/property.rs @@ -102,6 +102,11 @@ impl Node for PropertyEntryDefinition { } fn get_description(&self) -> String { - "property entry definition".to_string() + match &self { + PropertyEntryDefinition::Uninitialized { .. } => { + "uninitialized property entry".to_string() + } + PropertyEntryDefinition::Initialized { .. } => "initialized property entry".to_string(), + } } } diff --git a/src/tree/definition/type.rs b/src/tree/definition/type.rs index dca34b9..3004af0 100644 --- a/src/tree/definition/type.rs +++ b/src/tree/definition/type.rs @@ -349,7 +349,32 @@ impl Node for TypeDefinition { } fn get_description(&self) -> String { - "type definition".to_string() + match &self { + // match &self and print all the variants: + TypeDefinition::Identifier(_) => "identifier type definition".to_string(), + TypeDefinition::Union(_) => "union type definition".to_string(), + TypeDefinition::Intersection(_) => "intersection type definition".to_string(), + TypeDefinition::Literal(literal) => literal.get_description(), + TypeDefinition::Nullable(_, _) => "nullable type definition".to_string(), + TypeDefinition::Void(_) => "void type definition".to_string(), + TypeDefinition::Never(_) => "never type definition".to_string(), + TypeDefinition::Boolean(_) => "boolean type definition".to_string(), + TypeDefinition::String(_) => "string type definition".to_string(), + TypeDefinition::Dict(_, _) => "dict type definition".to_string(), + TypeDefinition::Vec(_, _) => "vec type definition".to_string(), + TypeDefinition::Object(_) => "object type definition".to_string(), + TypeDefinition::Mixed(_) => "mixed type definition".to_string(), + TypeDefinition::NonNull(_) => "non-null type definition".to_string(), + TypeDefinition::Resource(_) => "resource type definition".to_string(), + TypeDefinition::Class(_, _) => "class type definition".to_string(), + TypeDefinition::Interface(_, _) => "interface type definition".to_string(), + TypeDefinition::Iterable(_, _) => "iterable type definition".to_string(), + TypeDefinition::SignedInteger(signed) => signed.get_description(), + TypeDefinition::UnsignedInteger(unsigned) => unsigned.get_description(), + TypeDefinition::FloatingPoint(floating) => floating.get_description(), + TypeDefinition::Tuple { .. } => "tuple type definition".to_string(), + TypeDefinition::Parenthesized { .. } => "parenthesized type definition".to_string(), + } } } diff --git a/src/tree/definition/use.rs b/src/tree/definition/use.rs index 7effcd1..a975544 100644 --- a/src/tree/definition/use.rs +++ b/src/tree/definition/use.rs @@ -95,7 +95,11 @@ impl Node for UseDefinition { } fn get_description(&self) -> String { - "use definition".to_string() + match &self { + UseDefinition::Default { .. } => "use definition".to_string(), + UseDefinition::Function { .. } => "use function definition".to_string(), + UseDefinition::Constant { .. } => "use constant definition".to_string(), + } } } diff --git a/src/tree/expression/argument.rs b/src/tree/expression/argument.rs index da26a44..668899c 100644 --- a/src/tree/expression/argument.rs +++ b/src/tree/expression/argument.rs @@ -90,7 +90,14 @@ impl Node for ArgumentExpression { } fn get_description(&self) -> String { - "argument expression".to_string() + match self { + ArgumentExpression::Value { .. } => "value argument expression".to_string(), + ArgumentExpression::Spread { .. } => "spread argument expression".to_string(), + ArgumentExpression::ReverseSpread { .. } => { + "reverse spread argument expression".to_string() + } + ArgumentExpression::Named { .. } => "named argument expression".to_string(), + } } } diff --git a/src/tree/expression/class.rs b/src/tree/expression/class.rs index 661de05..235da8c 100644 --- a/src/tree/expression/class.rs +++ b/src/tree/expression/class.rs @@ -120,7 +120,14 @@ impl Node for AnonymousClassExpressionMember { } fn get_description(&self) -> String { - "anonymous class expression member".to_string() + match &self { + AnonymousClassExpressionMember::Constant(constant) => constant.get_description(), + AnonymousClassExpressionMember::Property(property) => property.get_description(), + AnonymousClassExpressionMember::ConcreteMethod(method) => method.get_description(), + AnonymousClassExpressionMember::ConcreteConstructor(constructor) => { + constructor.get_description() + } + } } } diff --git a/src/tree/expression/literal.rs b/src/tree/expression/literal.rs index d0df133..ebd519f 100644 --- a/src/tree/expression/literal.rs +++ b/src/tree/expression/literal.rs @@ -109,7 +109,14 @@ impl Node for Literal { } fn get_description(&self) -> String { - "literal expression".to_string() + match &self { + Literal::String(literal) => literal.get_description(), + Literal::Integer(literal) => literal.get_description(), + Literal::Float(literal) => literal.get_description(), + Literal::Null(literal) => literal.get_description(), + Literal::True(literal) => literal.get_description(), + Literal::False(literal) => literal.get_description(), + } } } diff --git a/src/tree/expression/magic_constant.rs b/src/tree/expression/magic_constant.rs index 83c8020..6d9fef8 100644 --- a/src/tree/expression/magic_constant.rs +++ b/src/tree/expression/magic_constant.rs @@ -47,6 +47,14 @@ impl Node for MagicConstant { } fn get_description(&self) -> String { - "magic constant expression".to_string() + match self { + MagicConstant::Directory { .. } => "directory magic constant expression".to_string(), + MagicConstant::File { .. } => "file magic constant expression".to_string(), + MagicConstant::Line { .. } => "line magic constant expression".to_string(), + MagicConstant::Class { .. } => "class magic constant expression".to_string(), + MagicConstant::Function { .. } => "function magic constant expression".to_string(), + MagicConstant::Method { .. } => "method magic constant expression".to_string(), + MagicConstant::Namespace { .. } => "namespace magic constant expression".to_string(), + } } } diff --git a/src/tree/expression/mod.rs b/src/tree/expression/mod.rs index fab4846..ed3389e 100644 --- a/src/tree/expression/mod.rs +++ b/src/tree/expression/mod.rs @@ -393,6 +393,36 @@ impl Node for Expression { } fn get_description(&self) -> String { - "expression".to_string() + match &self { + Expression::Parenthesized(expression) => expression.get_description(), + Expression::ExitConstruct(expression) => expression.get_description(), + Expression::Literal(expression) => expression.get_description(), + Expression::ArithmeticOperation(expression) => expression.get_description(), + Expression::AsyncOperation(expression) => expression.get_description(), + Expression::ArrayOperation(expression) => expression.get_description(), + Expression::AssignmentOperation(expression) => expression.get_description(), + Expression::BitwiseOperation(expression) => expression.get_description(), + Expression::ClassOperation(expression) => expression.get_description(), + Expression::CoalesceOperation(expression) => expression.get_description(), + Expression::ComparisonOperation(expression) => expression.get_description(), + Expression::ExceptionOperation(expression) => expression.get_description(), + Expression::FunctionOperation(expression) => expression.get_description(), + Expression::GeneratorOperation(expression) => expression.get_description(), + Expression::LogicalOperation(expression) => expression.get_description(), + Expression::ObjectOperation(expression) => expression.get_description(), + Expression::RangeOperation(expression) => expression.get_description(), + Expression::StringOperation(expression) => expression.get_description(), + Expression::TypeOperation(expression) => expression.get_description(), + Expression::TernaryOperation(expression) => expression.get_description(), + Expression::Identifier(expression) => expression.get_description(), + Expression::Variable(expression) => expression.get_description(), + Expression::Match(expression) => expression.get_description(), + Expression::AnonymousFunction(expression) => expression.get_description(), + Expression::ArrowFunction(expression) => expression.get_description(), + Expression::Vec(expression) => expression.get_description(), + Expression::Dict(expression) => expression.get_description(), + Expression::Tuple(expression) => expression.get_description(), + Expression::MagicConstant(expression) => expression.get_description(), + } } } diff --git a/src/tree/expression/operator.rs b/src/tree/expression/operator.rs index e75270f..0bc8772 100644 --- a/src/tree/expression/operator.rs +++ b/src/tree/expression/operator.rs @@ -704,7 +704,44 @@ impl Node for ArithmeticOperationExpression { } fn get_description(&self) -> String { - "arithmetic operation expression".to_string() + match &self { + ArithmeticOperationExpression::Addition { .. } => { + "addition arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Subtraction { .. } => { + "subtraction arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Multiplication { .. } => { + "multiplication arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Division { .. } => { + "division arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Modulo { .. } => { + "modulo arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Exponentiation { .. } => { + "exponentiation arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Negative { .. } => { + "negative arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::Positive { .. } => { + "positive arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::PreIncrement { .. } => { + "pre-increment arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::PreDecrement { .. } => { + "pre-decrement arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::PostIncrement { .. } => { + "post-increment arithmetic operation expression".to_string() + } + ArithmeticOperationExpression::PostDecrement { .. } => { + "post-decrement arithmetic operation expression".to_string() + } + } } } @@ -788,7 +825,50 @@ impl Node for AssignmentOperationExpression { } fn get_description(&self) -> String { - "assignment operation expression".to_string() + match &self { + AssignmentOperationExpression::Assignment { .. } => { + "assignment operation expression".to_string() + } + AssignmentOperationExpression::Addition { .. } => { + "addition assignment operation expression".to_string() + } + AssignmentOperationExpression::Subtraction { .. } => { + "subtraction assignment operation expression".to_string() + } + AssignmentOperationExpression::Multiplication { .. } => { + "multiplication assignment operation expression".to_string() + } + AssignmentOperationExpression::Division { .. } => { + "division assignment operation expression".to_string() + } + AssignmentOperationExpression::Modulo { .. } => { + "modulo assignment operation expression".to_string() + } + AssignmentOperationExpression::Exponentiation { .. } => { + "exponentiation assignment operation expression".to_string() + } + AssignmentOperationExpression::BitwiseAnd { .. } => { + "bitwise AND assignment operation expression".to_string() + } + AssignmentOperationExpression::BitwiseOr { .. } => { + "bitwise OR assignment operation expression".to_string() + } + AssignmentOperationExpression::BitwiseXor { .. } => { + "bitwise XOR assignment operation expression".to_string() + } + AssignmentOperationExpression::LeftShift { .. } => { + "left shift assignment operation expression".to_string() + } + AssignmentOperationExpression::RightShift { .. } => { + "right shift assignment operation expression".to_string() + } + AssignmentOperationExpression::Coalesce { .. } => { + "coalesce assignment operation expression".to_string() + } + AssignmentOperationExpression::Concat { .. } => { + "concat assignment operation expression".to_string() + } + } } } @@ -840,7 +920,24 @@ impl Node for BitwiseOperationExpression { } fn get_description(&self) -> String { - "bitwise operation expression".to_string() + match &self { + BitwiseOperationExpression::And { .. } => { + "bitwise AND operation expression".to_string() + } + BitwiseOperationExpression::Or { .. } => "bitwise OR operation expression".to_string(), + BitwiseOperationExpression::Xor { .. } => { + "bitwise XOR operation expression".to_string() + } + BitwiseOperationExpression::LeftShift { .. } => { + "left shift operation expression".to_string() + } + BitwiseOperationExpression::RightShift { .. } => { + "right shift operation expression".to_string() + } + BitwiseOperationExpression::Not { .. } => { + "bitwise NOT operation expression".to_string() + } + } } } @@ -904,7 +1001,35 @@ impl Node for ComparisonOperationExpression { } fn get_description(&self) -> String { - "comparison operation expression".to_string() + match &self { + ComparisonOperationExpression::Equal { .. } => { + "equal comparison operation expression".to_string() + } + ComparisonOperationExpression::NotEqual { .. } => { + "not equal comparison operation expression".to_string() + } + ComparisonOperationExpression::Identical { .. } => { + "identical comparison operation expression".to_string() + } + ComparisonOperationExpression::NotIdentical { .. } => { + "not identical comparison operation expression".to_string() + } + ComparisonOperationExpression::LessThan { .. } => { + "less than comparison operation expression".to_string() + } + ComparisonOperationExpression::LessThanOrEqual { .. } => { + "less than or equal comparison operation expression".to_string() + } + ComparisonOperationExpression::GreaterThan { .. } => { + "greater than comparison operation expression".to_string() + } + ComparisonOperationExpression::GreaterThanOrEqual { .. } => { + "greater than or equal comparison operation expression".to_string() + } + ComparisonOperationExpression::Spaceship { .. } => { + "spaceship comparison operation expression".to_string() + } + } } } @@ -944,7 +1069,15 @@ impl Node for LogicalOperationExpression { } fn get_description(&self) -> String { - "logical operation expression".to_string() + match &self { + LogicalOperationExpression::And { .. } => { + "logical AND operation expression".to_string() + } + LogicalOperationExpression::Or { .. } => "logical OR operation expression".to_string(), + LogicalOperationExpression::Not { .. } => { + "logical NOT operation expression".to_string() + } + } } } @@ -976,7 +1109,11 @@ impl Node for StringOperationExpression { } fn get_description(&self) -> String { - "string operation expression".to_string() + match &self { + StringOperationExpression::Concat { .. } => { + "string concatenation operation expression".to_string() + } + } } } @@ -1040,7 +1177,19 @@ impl Node for ArrayOperationExpression { } fn get_description(&self) -> String { - "array operation expression".to_string() + match &self { + ArrayOperationExpression::Access { .. } => { + "array access operation expression".to_string() + } + ArrayOperationExpression::Push { .. } => "array push operation expression".to_string(), + ArrayOperationExpression::Isset { .. } => { + "array isset operation expression".to_string() + } + ArrayOperationExpression::Unset { .. } => { + "array unset operation expression".to_string() + } + ArrayOperationExpression::In { .. } => "array in operation expression".to_string(), + } } } @@ -1072,7 +1221,11 @@ impl Node for CoalesceOperationExpression { } fn get_description(&self) -> String { - "coalesce operation expression".to_string() + match &self { + CoalesceOperationExpression::Coalesce { .. } => { + "coalesce operation expression".to_string() + } + } } } @@ -1129,7 +1282,17 @@ impl Node for TernaryOperationExpression { } fn get_description(&self) -> String { - "ternary operation expression".to_string() + match &self { + TernaryOperationExpression::Ternary { .. } => { + "ternary operation expression".to_string() + } + TernaryOperationExpression::ShortTernary { .. } => { + "short ternary operation expression".to_string() + } + TernaryOperationExpression::ImplicitShortTernary { .. } => { + "implicit short ternary operation expression".to_string() + } + } } } @@ -1182,7 +1345,14 @@ impl Node for TypeOperationExpression { } fn get_description(&self) -> String { - "type operation expression".to_string() + match &self { + TypeOperationExpression::Instanceof { .. } => { + "instanceof type operation expression".to_string() + } + TypeOperationExpression::Is { .. } => "is type operation expression".to_string(), + TypeOperationExpression::Into { .. } => "into type operation expression".to_string(), + TypeOperationExpression::As { .. } => "as type operation expression".to_string(), + } } } @@ -1238,7 +1408,20 @@ impl Node for GeneratorOperationExpression { } fn get_description(&self) -> String { - "generator operation expression".to_string() + match &self { + GeneratorOperationExpression::Yield { .. } => { + "yield generator operation expression".to_string() + } + GeneratorOperationExpression::YieldValue { .. } => { + "yield value generator operation expression".to_string() + } + GeneratorOperationExpression::YieldKeyValue { .. } => { + "yield key value generator operation expression".to_string() + } + GeneratorOperationExpression::YieldFrom { .. } => { + "yield from generator operation expression".to_string() + } + } } } @@ -1268,7 +1451,11 @@ impl Node for ExceptionOperationExpression { } fn get_description(&self) -> String { - "exception operation expression".to_string() + match &self { + ExceptionOperationExpression::Throw { .. } => { + "throw exception operation expression".to_string() + } + } } } @@ -1372,7 +1559,26 @@ impl Node for ObjectOperationExpression { } fn get_description(&self) -> String { - "object operation expression".to_string() + match &self { + ObjectOperationExpression::Clone { .. } => { + "object clone operation expression".to_string() + } + ObjectOperationExpression::MethodCall { .. } => { + "object method call operation expression".to_string() + } + ObjectOperationExpression::NullsafeMethodCall { .. } => { + "object nullsafe method call operation expression".to_string() + } + ObjectOperationExpression::MethodClosureCreation { .. } => { + "object method closure creation operation expression".to_string() + } + ObjectOperationExpression::PropertyFetch { .. } => { + "object property fetch operation expression".to_string() + } + ObjectOperationExpression::NullsafePropertyFetch { .. } => { + "object nullsafe property fetch operation expression".to_string() + } + } } } @@ -1414,7 +1620,14 @@ impl Node for ClassOperationInitializationClassExpression { } fn get_description(&self) -> String { - "class operation initialization class expression".to_string() + match &self { + ClassOperationInitializationClassExpression::Identifier(identifier) => { + identifier.get_description() + } + ClassOperationInitializationClassExpression::Variable(variable) => { + variable.get_description() + } + } } } @@ -1535,7 +1748,26 @@ impl Node for ClassOperationExpression { } fn get_description(&self) -> String { - "class operation expression".to_string() + match &self { + ClassOperationExpression::Initialization { .. } => { + "class initialization operation expression".to_string() + } + ClassOperationExpression::AnonymousInitialization { .. } => { + "class anonymous initialization operation expression".to_string() + } + ClassOperationExpression::StaticMethodCall { .. } => { + "class static method call operation expression".to_string() + } + ClassOperationExpression::StaticMethodClosureCreation { .. } => { + "class static method closure creation operation expression".to_string() + } + ClassOperationExpression::StaticPropertyFetch { .. } => { + "class static property fetch operation expression".to_string() + } + ClassOperationExpression::ConstantFetch { .. } => { + "class constant fetch operation expression".to_string() + } + } } } @@ -1601,7 +1833,14 @@ impl Node for FunctionOperationExpression { } fn get_description(&self) -> String { - "function operation expression".to_string() + match &self { + FunctionOperationExpression::Call { .. } => { + "function call operation expression".to_string() + } + FunctionOperationExpression::ClosureCreation { .. } => { + "function closure creation operation expression".to_string() + } + } } } @@ -1660,7 +1899,15 @@ impl Node for AsyncOperationExpression { } fn get_description(&self) -> String { - "async operation expression".to_string() + match &self { + AsyncOperationExpression::Await { .. } => { + "async await operation expression".to_string() + } + AsyncOperationExpression::Async { .. } => "async operation expression".to_string(), + AsyncOperationExpression::Concurrently { .. } => { + "async concurrently operation expression".to_string() + } + } } } @@ -1714,6 +1961,19 @@ impl Node for RangeOperationExpression { } fn get_description(&self) -> String { - "range operation expression".to_string() + match &self { + RangeOperationExpression::Between { .. } => { + "range between operation expression".to_string() + } + RangeOperationExpression::BetweenInclusive { .. } => { + "range between inclusive operation expression".to_string() + } + RangeOperationExpression::To { .. } => "range to operation expression".to_string(), + RangeOperationExpression::ToInclusive { .. } => { + "range to inclusive operation expression".to_string() + } + RangeOperationExpression::From { .. } => "range from operation expression".to_string(), + RangeOperationExpression::Full { .. } => "range full operation expression".to_string(), + } } } diff --git a/src/tree/statement/mod.rs b/src/tree/statement/mod.rs index cca93c7..e6e2169 100644 --- a/src/tree/statement/mod.rs +++ b/src/tree/statement/mod.rs @@ -102,6 +102,20 @@ impl Node for Statement { } fn get_description(&self) -> String { - "statement".to_string() + match &self { + Statement::DoWhile(statement) => statement.get_description(), + Statement::While(statement) => statement.get_description(), + Statement::For(statement) => statement.get_description(), + Statement::Foreach(statement) => statement.get_description(), + Statement::Break(statement) => statement.get_description(), + Statement::Continue(statement) => statement.get_description(), + Statement::If(statement) => statement.get_description(), + Statement::Using(statement) => statement.get_description(), + Statement::Try(statement) => statement.get_description(), + Statement::Expression(statement) => statement.get_description(), + Statement::Return(statement) => statement.get_description(), + Statement::Block(statement) => statement.get_description(), + Statement::Empty(_) => "empty statement".to_string(), + } } } diff --git a/src/tree/statement/return.rs b/src/tree/statement/return.rs index 296a16c..0f4b060 100644 --- a/src/tree/statement/return.rs +++ b/src/tree/statement/return.rs @@ -62,6 +62,9 @@ impl Node for ReturnStatement { } fn get_description(&self) -> String { - "return statement".to_string() + match &self { + ReturnStatement::Explicit { .. } => "explicit return statement".to_string(), + ReturnStatement::Implicit { .. } => "implicit return statement".to_string(), + } } }