mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-10 10:02:38 +03:00
minor cleanup
This commit is contained in:
parent
e7c5cc5664
commit
e156fbef03
@ -166,9 +166,9 @@ where
|
||||
p.build()?
|
||||
};
|
||||
|
||||
/*if DEBUG {
|
||||
if DEBUG {
|
||||
eprintln!("{}", program.to_source_string());
|
||||
}*/
|
||||
}
|
||||
|
||||
morphic_lib::solve(program)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ impl MarkupNode {
|
||||
}
|
||||
}
|
||||
|
||||
// return (index of child in list of children, index of child in list of children of ast node)
|
||||
// return (index of child in list of children, closest ast index of child corresponding to ast node)
|
||||
pub fn get_child_indices(
|
||||
&self,
|
||||
child_id: MarkNodeId,
|
||||
|
@ -135,7 +135,7 @@ impl<'a> EdModel<'a> {
|
||||
self.grid_node_map.node_exists_at_pos(self.get_caret())
|
||||
}
|
||||
|
||||
// return (index of child in list of children, index of child in list of children of ast node) of MarkupNode at current caret position
|
||||
// return (index of child in list of children, closest ast index of child corresponding to ast node) of MarkupNode at current caret position
|
||||
pub fn get_curr_child_indices(&self) -> EdResult<(usize, usize)> {
|
||||
if self.node_exists_at_caret() {
|
||||
let curr_mark_node_id = self.get_curr_mark_node_id()?;
|
||||
|
@ -696,16 +696,13 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||
Expr2::List{ elem_var: _, elems: _} => {
|
||||
let prev_mark_node = ed_model.markup_node_pool.get(prev_mark_node_id);
|
||||
|
||||
if prev_mark_node.get_content()? == nodes::LEFT_SQUARE_BR {
|
||||
if curr_mark_node.get_content()? == nodes::RIGHT_SQUARE_BR {
|
||||
// based on if, we are at the start of the list
|
||||
let new_child_index = 1;
|
||||
let new_ast_child_index = 0;
|
||||
add_blank_child(new_child_index, new_ast_child_index, ed_model)?; // insert a Blank first, this results in cleaner code
|
||||
handle_new_char(received_char, ed_model)?
|
||||
} else {
|
||||
InputOutcome::Ignored
|
||||
}
|
||||
if prev_mark_node.get_content()? == nodes::LEFT_SQUARE_BR && curr_mark_node.get_content()? == nodes::RIGHT_SQUARE_BR {
|
||||
// based on if, we are at the start of the list
|
||||
let new_child_index = 1;
|
||||
let new_ast_child_index = 0;
|
||||
// insert a Blank first, this results in cleaner code
|
||||
add_blank_child(new_child_index, new_ast_child_index, ed_model)?;
|
||||
handle_new_char(received_char, ed_model)?
|
||||
} else {
|
||||
InputOutcome::Ignored
|
||||
}
|
||||
@ -773,22 +770,19 @@ pub fn handle_new_char(received_char: &char, ed_model: &mut EdModel) -> EdResult
|
||||
} else if "\"{[".contains(*ch) {
|
||||
let prev_mark_node = ed_model.markup_node_pool.get(prev_mark_node_id);
|
||||
|
||||
if prev_mark_node.get_content()? == nodes::LEFT_SQUARE_BR {
|
||||
if curr_mark_node.get_content()? == nodes::RIGHT_SQUARE_BR {
|
||||
let (new_child_index, new_ast_child_index) = ed_model.get_curr_child_indices()?;
|
||||
// insert a Blank first, this results in cleaner code
|
||||
add_blank_child(
|
||||
new_child_index,
|
||||
new_ast_child_index,
|
||||
ed_model
|
||||
)?;
|
||||
handle_new_char(received_char, ed_model)?
|
||||
} else {
|
||||
InputOutcome::Ignored
|
||||
}
|
||||
if prev_mark_node.get_content()? == nodes::LEFT_SQUARE_BR && curr_mark_node.get_content()? == nodes::RIGHT_SQUARE_BR {
|
||||
let (new_child_index, new_ast_child_index) = ed_model.get_curr_child_indices()?;
|
||||
// insert a Blank first, this results in cleaner code
|
||||
add_blank_child(
|
||||
new_child_index,
|
||||
new_ast_child_index,
|
||||
ed_model
|
||||
)?;
|
||||
handle_new_char(received_char, ed_model)?
|
||||
} else {
|
||||
InputOutcome::Ignored
|
||||
}
|
||||
|
||||
} else {
|
||||
InputOutcome::Ignored
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ pub fn add_blank_child(
|
||||
.fail(),
|
||||
}?;
|
||||
|
||||
let new_mark_children = make_mark_children(
|
||||
let new_mark_children = update_mark_children(
|
||||
new_child_index,
|
||||
blank_elt_id,
|
||||
list_ast_node_id,
|
||||
@ -182,7 +182,8 @@ pub fn add_blank_child(
|
||||
Ok(InputOutcome::Accepted)
|
||||
}
|
||||
|
||||
pub fn make_mark_children(
|
||||
// add a Blank child to the Nested mark node and update the caret
|
||||
pub fn update_mark_children(
|
||||
new_child_index: usize,
|
||||
blank_elt_id: ExprId,
|
||||
list_ast_node_id: ExprId,
|
||||
|
Loading…
Reference in New Issue
Block a user