refactor: remove unsued vaules defs

上级 feac0f7c
......@@ -133,7 +133,7 @@ impl Grammar {
}
let scope_list = ScopeListElement::new(None, root_scope_name);
let mut state = StackElement::new(
let state = StackElement::new(
None,
self.root_id.clone(),
-1,
......@@ -176,7 +176,7 @@ impl Grammar {
) -> Option<StackElement> {
let _line_length = line_text.len();
let mut _stop = false;
let mut anchor_position = -1;
let anchor_position = -1;
if check_while_conditions {
// todo: add realy logic
......@@ -189,8 +189,8 @@ impl Grammar {
);
}
let mut line_pos = origin_line_pos.clone();
let mut is_first_line = origin_is_first.clone();
let line_pos = origin_line_pos.clone();
let is_first_line = origin_is_first.clone();
while !_stop {
let r = self.match_rule(
line_text.clone(),
......@@ -225,7 +225,7 @@ impl Grammar {
if capture_indices[0].end == _line_length {
begin_rule_capture_eol = true;
}
let mut new_stack = stack.clone().push(
let new_stack = stack.clone().push(
matched_rule_id,
line_pos,
anchor_position,
......@@ -247,17 +247,16 @@ impl Grammar {
return None;
}
_ => {
_stop = true;
return None;
}
}
}
if capture_indices[0].end > line_pos as usize {
line_pos = capture_indices[0].end as i32;
is_first_line = false;
}
//
// if capture_indices[0].end > line_pos as usize {
// line_pos = capture_indices[0].end as i32;
// is_first_line = false;
// }
}
Some(stack.clone())
}
......
......@@ -17,7 +17,7 @@ pub use self::raw_rule::IRawRule;
#[cfg(test)]
mod tests {
use crate::inter::{IRawCaptures, IRawGrammar, IRawRule, InjectionMap};
use crate::inter::{IRawCaptures, IRawGrammar, IRawRule};
use serde::{Deserialize, Serialize};
use std::fs;
use std::fs::File;
......@@ -53,42 +53,6 @@ mod tests {
assert_eq!("punctuation.definition.item.text", name.unwrap())
}
#[test]
fn should_convert_injections() {
let data = r#"
"injections": {
"R:text.html - comment.block": {
"comment": "Use R: to ensure this matches after any other injections.",
"patterns": [
{
"match": "<",
"name": "invalid.illegal.bad-angle-bracket.html"
}
]
}
}"#;
let p: InjectionMap = serde_json::from_str(data).unwrap();
let pattern = p
.map
.get("R:text.html - comment.block")
.unwrap()
.patterns
.clone();
assert_eq!(1, pattern.clone().unwrap().len());
assert_eq!(
"<",
pattern
.clone()
.unwrap()
.first()
.unwrap()
.match_s
.clone()
.unwrap()
)
}
#[test]
fn should_convert_rawrule() {
let data = r#"
......
......@@ -3,19 +3,19 @@ use crate::rule::CompiledRule;
#[derive(Clone, Debug, Serialize)]
pub struct AnchorCache {
A0_G0: Option<String>,
A0_G1: Option<String>,
A1_G0: Option<String>,
A1_G1: Option<String>,
a0_g0: Option<String>,
a0_g1: Option<String>,
a1_g0: Option<String>,
a1_g1: Option<String>,
}
impl Default for AnchorCache {
fn default() -> Self {
AnchorCache {
A0_G0: None,
A0_G1: None,
A1_G0: None,
A1_G1: None,
a0_g0: None,
a0_g1: None,
a1_g0: None,
a1_g1: None,
}
}
}
......
use scie_grammar::inter::{ILocatable, ILocation, IRawCaptures};
use std::collections::HashMap;
fn main() {
let location = ILocation {
filename: "".to_string(),
line: "".to_string(),
chart: "".to_string(),
};
println!("{:?}", location)
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册