Skip to content

Commit

Permalink
new: add get_description() to Node (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
KennedyTedesco committed Jan 15, 2023
1 parent 0363ecb commit d6adc0d
Show file tree
Hide file tree
Showing 35 changed files with 528 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tree/definition/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ impl Node for AttributeGroupDefinition {
.map(|member| member as &dyn Node)
.collect()
}

fn get_description(&self) -> String {
"attribute group definition".to_string()
}
}

impl Node for AttributeDefinition {
Expand All @@ -60,4 +64,8 @@ impl Node for AttributeDefinition {
vec![&self.name]
}
}

fn get_description(&self) -> String {
"attribute definition".to_string()
}
}
20 changes: 20 additions & 0 deletions src/tree/definition/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ impl Node for ClassDefinition {

children
}

fn get_description(&self) -> String {
"class definition".to_string()
}
}

impl Node for ClassDefinitionExtends {
Expand All @@ -130,6 +134,10 @@ impl Node for ClassDefinitionExtends {
fn children(&self) -> Vec<&dyn Node> {
vec![&self.extends, &self.parent]
}

fn get_description(&self) -> String {
"class extends definition".to_string()
}
}

impl Node for ClassDefinitionImplements {
Expand Down Expand Up @@ -162,6 +170,10 @@ impl Node for ClassDefinitionImplements {

children
}

fn get_description(&self) -> String {
"class implements definition".to_string()
}
}

impl Node for ClassDefinitionBody {
Expand All @@ -179,6 +191,10 @@ impl Node for ClassDefinitionBody {
.map(|member| member as &dyn Node)
.collect()
}

fn get_description(&self) -> String {
"class body definition".to_string()
}
}

impl Node for ClassDefinitionMember {
Expand Down Expand Up @@ -225,4 +241,8 @@ impl Node for ClassDefinitionMember {
Self::ConcreteConstructor(constructor) => vec![constructor],
}
}

fn get_description(&self) -> String {
"class member definition".to_string()
}
}
12 changes: 12 additions & 0 deletions src/tree/definition/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ impl Node for ConstantDefinitionEntry {
fn children(&self) -> Vec<&dyn Node> {
vec![&self.name, &self.value]
}

fn get_description(&self) -> String {
"constant entry definition".to_string()
}
}

impl Node for ConstantDefinition {
Expand All @@ -76,6 +80,10 @@ impl Node for ConstantDefinition {

children
}

fn get_description(&self) -> String {
"constant definition".to_string()
}
}

impl Node for ClassishConstantDefinition {
Expand Down Expand Up @@ -115,4 +123,8 @@ impl Node for ClassishConstantDefinition {

children
}

fn get_description(&self) -> String {
"classish constant definition".to_string()
}
}
44 changes: 44 additions & 0 deletions src/tree/definition/enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ impl Node for EnumDefinition {
EnumDefinition::Unit(definition) => vec![definition],
}
}

fn get_description(&self) -> String {
"enum definition".to_string()
}
}

impl Node for UnitEnumDefinition {
Expand Down Expand Up @@ -168,6 +172,10 @@ impl Node for UnitEnumDefinition {

children
}

fn get_description(&self) -> String {
"unit enum definition".to_string()
}
}

impl Node for EnumImplementsDefinition {
Expand Down Expand Up @@ -200,6 +208,10 @@ impl Node for EnumImplementsDefinition {

children
}

fn get_description(&self) -> String {
"enum implements definition".to_string()
}
}

impl Node for UnitEnumBodyDefinition {
Expand All @@ -217,6 +229,10 @@ impl Node for UnitEnumBodyDefinition {
.map(|member| member as &dyn Node)
.collect()
}

fn get_description(&self) -> String {
"unit enum body definition".to_string()
}
}

impl Node for UnitEnumMemberDefinition {
Expand All @@ -243,6 +259,10 @@ impl Node for UnitEnumMemberDefinition {
Self::Constant(constant) => vec![constant],
}
}

fn get_description(&self) -> String {
"unit enum member definition".to_string()
}
}

impl Node for UnitEnumCaseDefinition {
Expand All @@ -266,6 +286,10 @@ impl Node for UnitEnumCaseDefinition {

children
}

fn get_description(&self) -> String {
"unit enum case definition".to_string()
}
}

impl Node for BackedEnumDefinition {
Expand Down Expand Up @@ -299,6 +323,10 @@ impl Node for BackedEnumDefinition {

children
}

fn get_description(&self) -> String {
"backed enum definition".to_string()
}
}

impl Node for BackedEnumTypeDefinition {
Expand All @@ -319,6 +347,10 @@ impl Node for BackedEnumTypeDefinition {
Self::String(_, identifier) | Self::Int(_, identifier) => vec![identifier],
}
}

fn get_description(&self) -> String {
"backed enum type definition".to_string()
}
}

impl Node for BackedEnumBodyDefinition {
Expand All @@ -336,6 +368,10 @@ impl Node for BackedEnumBodyDefinition {
.map(|member| member as &dyn Node)
.collect()
}

fn get_description(&self) -> String {
"backed enum body definition".to_string()
}
}

impl Node for BackedEnumMemberDefinition {
Expand All @@ -362,6 +398,10 @@ impl Node for BackedEnumMemberDefinition {
Self::Constant(constant) => vec![constant],
}
}

fn get_description(&self) -> String {
"backed enum member definition".to_string()
}
}

impl Node for BackedEnumCaseDefinition {
Expand All @@ -380,4 +420,8 @@ impl Node for BackedEnumCaseDefinition {
fn children(&self) -> Vec<&dyn Node> {
vec![&self.case, &self.name, &self.value]
}

fn get_description(&self) -> String {
"backed enum case definition".to_string()
}
}
52 changes: 52 additions & 0 deletions src/tree/definition/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,10 @@ impl Node for FunctionLikeReturnTypeDefinition {
fn children(&self) -> Vec<&dyn Node> {
vec![&self.type_definition]
}

fn get_description(&self) -> String {
"function like return type definition".to_string()
}
}

impl Node for FunctionLikeParameterDefinition {
Expand Down Expand Up @@ -204,6 +208,10 @@ impl Node for FunctionLikeParameterDefinition {

children
}

fn get_description(&self) -> String {
"function like parameter definition".to_string()
}
}

impl Node for FunctionLikeParameterDefaultValueDefinition {
Expand All @@ -218,6 +226,10 @@ impl Node for FunctionLikeParameterDefaultValueDefinition {
fn children(&self) -> Vec<&dyn Node> {
vec![&self.value]
}

fn get_description(&self) -> String {
"function like parameter default value definition".to_string()
}
}

impl Node for FunctionLikeParameterListDefinition {
Expand All @@ -242,6 +254,10 @@ impl Node for FunctionLikeParameterListDefinition {

children
}

fn get_description(&self) -> String {
"function like parameter list definition".to_string()
}
}

impl Node for FunctionDefinition {
Expand Down Expand Up @@ -281,6 +297,10 @@ impl Node for FunctionDefinition {

children
}

fn get_description(&self) -> String {
"function definition".to_string()
}
}

impl Node for ConstructorParameterDefinition {
Expand Down Expand Up @@ -317,6 +337,10 @@ impl Node for ConstructorParameterDefinition {

children
}

fn get_description(&self) -> String {
"constructor parameter definition".to_string()
}
}

impl Node for ConstructorParameterListDefinition {
Expand All @@ -341,6 +365,10 @@ impl Node for ConstructorParameterListDefinition {

children
}

fn get_description(&self) -> String {
"constructor parameter list definition".to_string()
}
}

impl Node for AbstractConstructorDefinition {
Expand Down Expand Up @@ -381,6 +409,10 @@ impl Node for AbstractConstructorDefinition {

children
}

fn get_description(&self) -> String {
"abstract constructor definition".to_string()
}
}

impl Node for ConcreteConstructorDefinition {
Expand Down Expand Up @@ -422,6 +454,10 @@ impl Node for ConcreteConstructorDefinition {

children
}

fn get_description(&self) -> String {
"concrete constructor definition".to_string()
}
}

impl Node for AbstractMethodDefinition {
Expand Down Expand Up @@ -472,6 +508,10 @@ impl Node for AbstractMethodDefinition {

children
}

fn get_description(&self) -> String {
"abstract method definition".to_string()
}
}

impl Node for MethodTypeConstraintDefinition {
Expand All @@ -486,6 +526,10 @@ impl Node for MethodTypeConstraintDefinition {
fn children(&self) -> Vec<&dyn Node> {
vec![&self.identifier, &self.r#is, &self.type_definition]
}

fn get_description(&self) -> String {
"method type constraint definition".to_string()
}
}

impl Node for MethodTypeConstraintGroupDefinition {
Expand Down Expand Up @@ -522,6 +566,10 @@ impl Node for MethodTypeConstraintGroupDefinition {

children
}

fn get_description(&self) -> String {
"method type constraint group definition".to_string()
}
}

impl Node for ConcreteMethodDefinition {
Expand Down Expand Up @@ -574,4 +622,8 @@ impl Node for ConcreteMethodDefinition {

children
}

fn get_description(&self) -> String {
"concrete method definition".to_string()
}
}
Loading

0 comments on commit d6adc0d

Please sign in to comment.