From 3b5c570bacc33825a99597f41fe2ab5d62a08b3a Mon Sep 17 00:00:00 2001 From: Phodal Huang Date: Wed, 9 Sep 2020 07:36:42 +0800 Subject: [PATCH] Revert "refactor: remove unused stringify" This reverts commit 351b81f40cae24f5f480afa980bf3ba57c18f3d4. --- scie-grammar/src/grammar/scope_list_element.rs | 12 +++++++++++- scie-grammar/src/grammar/stack_element.rs | 12 +++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scie-grammar/src/grammar/scope_list_element.rs b/scie-grammar/src/grammar/scope_list_element.rs index 90508e4..b947ed4 100644 --- a/scie-grammar/src/grammar/scope_list_element.rs +++ b/scie-grammar/src/grammar/scope_list_element.rs @@ -4,11 +4,20 @@ use crate::grammar::Grammar; pub struct ScopeListElement { pub parent: Option>, pub scope: String, + // todo: remove stringify + pub stringify: String, + // pub metadata: i32, } impl ScopeListElement { pub fn new(parent: Option>, scope: String) -> Self { - ScopeListElement { parent, scope } + let mut list_element = ScopeListElement { + parent, + scope, + stringify: String::from(""), + }; + list_element.stringify = list_element.clone().stringify(); + list_element } pub fn stringify(self) -> String { @@ -66,6 +75,7 @@ impl Default for ScopeListElement { ScopeListElement { parent: None, scope: "".to_string(), + stringify: "".to_string(), } } } diff --git a/scie-grammar/src/grammar/stack_element.rs b/scie-grammar/src/grammar/stack_element.rs index 9325340..98247a8 100644 --- a/scie-grammar/src/grammar/stack_element.rs +++ b/scie-grammar/src/grammar/stack_element.rs @@ -13,6 +13,8 @@ pub struct StackElement { pub end_rule: Option, pub name_scopes_list: ScopeListElement, pub content_name_scopes_list: ScopeListElement, + // todo: remove stringify + pub stringify: String, } impl StackElement { @@ -27,6 +29,7 @@ impl StackElement { end_rule: None, name_scopes_list: Default::default(), content_name_scopes_list: Default::default(), + stringify: "".to_string(), } } @@ -53,8 +56,7 @@ impl StackElement { if let Some(iparent) = parent.clone() { depth = iparent.depth + 1 } - - StackElement { + let mut element = StackElement { parent, depth, rule_id, @@ -64,7 +66,11 @@ impl StackElement { end_rule, name_scopes_list, content_name_scopes_list, - } + stringify: "".to_string(), + }; + + element.stringify = element.clone().stringify(); + element } pub fn stringify(self) -> String { -- GitLab