mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
simplification, stricter adherence to projectional editing approach
This commit is contained in:
parent
5374f6d6b8
commit
48d5775f62
19 changed files with 274 additions and 364 deletions
|
@ -64,13 +64,12 @@ pub fn expr2_to_markup<'a>(
|
|||
Expr2::Str(text) => {
|
||||
let content = format!("\"{}\"", text.as_str(env.pool));
|
||||
|
||||
new_markup_node(
|
||||
with_indent(indent_level, &content),
|
||||
ast_node_id,
|
||||
HighlightStyle::String,
|
||||
mark_node_pool,
|
||||
indent_level,
|
||||
)
|
||||
string_mark_node(&content, indent_level, ast_node_id, mark_node_pool)
|
||||
}
|
||||
Expr2::SmallStr(array_str) => {
|
||||
let content = format!("\"{}\"", array_str.as_str());
|
||||
|
||||
string_mark_node(&content, indent_level, ast_node_id, mark_node_pool)
|
||||
}
|
||||
Expr2::GlobalTag { name, .. } => new_markup_node(
|
||||
with_indent(indent_level, &get_string(env, name)),
|
||||
|
@ -387,3 +386,13 @@ fn with_indent(indent_level: usize, some_str: &str) -> String {
|
|||
|
||||
full_string
|
||||
}
|
||||
|
||||
fn string_mark_node(content: &str, indent_level: usize, ast_node_id: ASTNodeId, mark_node_pool: &mut SlowPool) -> MarkNodeId {
|
||||
new_markup_node(
|
||||
with_indent(indent_level, &content),
|
||||
ast_node_id,
|
||||
HighlightStyle::String,
|
||||
mark_node_pool,
|
||||
indent_level,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -468,3 +468,33 @@ pub fn join_mark_nodes_commas(
|
|||
|
||||
mark_nodes.into_iter().interleave(join_nodes).collect()
|
||||
}
|
||||
|
||||
pub fn mark_nodes_to_string(
|
||||
markup_node_ids: &[MarkNodeId],
|
||||
mark_node_pool: &SlowPool,
|
||||
) -> String {
|
||||
let mut all_code_string = String::new();
|
||||
|
||||
for mark_node_id in markup_node_ids.iter() {
|
||||
node_to_string_w_children(*mark_node_id, &mut all_code_string, mark_node_pool)
|
||||
}
|
||||
|
||||
all_code_string
|
||||
}
|
||||
|
||||
pub fn node_to_string_w_children(node_id: MarkNodeId, str_buffer: &mut String, mark_node_pool: &SlowPool) {
|
||||
let node = mark_node_pool.get(node_id);
|
||||
|
||||
if node.is_nested() {
|
||||
for child_id in node.get_children_ids() {
|
||||
node_to_string_w_children(child_id, str_buffer, mark_node_pool);
|
||||
}
|
||||
for _ in 0..node.get_newlines_at_end() {
|
||||
str_buffer.push('\n')
|
||||
}
|
||||
} else {
|
||||
let node_content_str = node.get_full_content();
|
||||
|
||||
str_buffer.push_str(&node_content_str);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue