Revert "refactor: remove unused stringify"

This reverts commit 351b81f4.
上级 88152fdc
...@@ -4,11 +4,20 @@ use crate::grammar::Grammar; ...@@ -4,11 +4,20 @@ use crate::grammar::Grammar;
pub struct ScopeListElement { pub struct ScopeListElement {
pub parent: Option<Box<ScopeListElement>>, pub parent: Option<Box<ScopeListElement>>,
pub scope: String, pub scope: String,
// todo: remove stringify
pub stringify: String,
// pub metadata: i32,
} }
impl ScopeListElement { impl ScopeListElement {
pub fn new(parent: Option<Box<ScopeListElement>>, scope: String) -> Self { pub fn new(parent: Option<Box<ScopeListElement>>, 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 { pub fn stringify(self) -> String {
...@@ -66,6 +75,7 @@ impl Default for ScopeListElement { ...@@ -66,6 +75,7 @@ impl Default for ScopeListElement {
ScopeListElement { ScopeListElement {
parent: None, parent: None,
scope: "".to_string(), scope: "".to_string(),
stringify: "".to_string(),
} }
} }
} }
...@@ -13,6 +13,8 @@ pub struct StackElement { ...@@ -13,6 +13,8 @@ pub struct StackElement {
pub end_rule: Option<String>, pub end_rule: Option<String>,
pub name_scopes_list: ScopeListElement, pub name_scopes_list: ScopeListElement,
pub content_name_scopes_list: ScopeListElement, pub content_name_scopes_list: ScopeListElement,
// todo: remove stringify
pub stringify: String,
} }
impl StackElement { impl StackElement {
...@@ -27,6 +29,7 @@ impl StackElement { ...@@ -27,6 +29,7 @@ impl StackElement {
end_rule: None, end_rule: None,
name_scopes_list: Default::default(), name_scopes_list: Default::default(),
content_name_scopes_list: Default::default(), content_name_scopes_list: Default::default(),
stringify: "".to_string(),
} }
} }
...@@ -53,8 +56,7 @@ impl StackElement { ...@@ -53,8 +56,7 @@ impl StackElement {
if let Some(iparent) = parent.clone() { if let Some(iparent) = parent.clone() {
depth = iparent.depth + 1 depth = iparent.depth + 1
} }
let mut element = StackElement {
StackElement {
parent, parent,
depth, depth,
rule_id, rule_id,
...@@ -64,7 +66,11 @@ impl StackElement { ...@@ -64,7 +66,11 @@ impl StackElement {
end_rule, end_rule,
name_scopes_list, name_scopes_list,
content_name_scopes_list, content_name_scopes_list,
} stringify: "".to_string(),
};
element.stringify = element.clone().stringify();
element
} }
pub fn stringify(self) -> String { pub fn stringify(self) -> String {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册