mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
fmt+clippy
This commit is contained in:
parent
cd2b83c503
commit
272e6f9ca0
15 changed files with 155 additions and 283 deletions
|
@ -155,20 +155,16 @@ fn canonicalize_field<'a>(
|
||||||
expr_to_expr2(env, scope, &loc_expr.value, loc_expr.region);
|
expr_to_expr2(env, scope, &loc_expr.value, loc_expr.region);
|
||||||
|
|
||||||
match loc_can_expr {
|
match loc_can_expr {
|
||||||
Expr2::RuntimeError() => {
|
Expr2::RuntimeError() => Ok(CanonicalField::InvalidLabelOnly {
|
||||||
Ok(CanonicalField::InvalidLabelOnly {
|
|
||||||
label: label.value,
|
label: label.value,
|
||||||
var: field_var,
|
var: field_var,
|
||||||
})
|
}),
|
||||||
}
|
_ => Ok(CanonicalField::LabelAndValue {
|
||||||
_ => {
|
|
||||||
Ok(CanonicalField::LabelAndValue {
|
|
||||||
label: label.value,
|
label: label.value,
|
||||||
value_expr: loc_can_expr,
|
value_expr: loc_can_expr,
|
||||||
value_output: output,
|
value_output: output,
|
||||||
var: field_var,
|
var: field_var,
|
||||||
})
|
}),
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,6 @@ impl AST {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Copy, Clone)]
|
#[derive(Debug, PartialEq, Copy, Clone)]
|
||||||
pub enum ASTNodeId {
|
pub enum ASTNodeId {
|
||||||
ADefId(DefId),
|
ADefId(DefId),
|
||||||
|
|
35
cli_utils/Cargo.lock
generated
35
cli_utils/Cargo.lock
generated
|
@ -964,12 +964,6 @@ dependencies = [
|
||||||
"toml",
|
"toml",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "fixedbitset"
|
|
||||||
version = "0.2.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "flate2"
|
name = "flate2"
|
||||||
version = "1.0.22"
|
version = "1.0.22"
|
||||||
|
@ -2047,14 +2041,11 @@ version = "0.8.5"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"instant",
|
"instant",
|
||||||
"libc",
|
"libc",
|
||||||
"petgraph",
|
|
||||||
"redox_syscall",
|
"redox_syscall",
|
||||||
"smallvec",
|
"smallvec",
|
||||||
"thread-id",
|
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -2107,16 +2098,6 @@ dependencies = [
|
||||||
"sha-1",
|
"sha-1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "petgraph"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7"
|
|
||||||
dependencies = [
|
|
||||||
"fixedbitset",
|
|
||||||
"indexmap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "phf"
|
name = "phf"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -2799,6 +2780,7 @@ dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
|
"roc_error_macros",
|
||||||
"roc_ident",
|
"roc_ident",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
"snafu",
|
"snafu",
|
||||||
|
@ -2815,6 +2797,7 @@ dependencies = [
|
||||||
"roc_builtins",
|
"roc_builtins",
|
||||||
"roc_can",
|
"roc_can",
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
|
"roc_error_macros",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_problem",
|
"roc_problem",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
|
@ -2865,6 +2848,7 @@ dependencies = [
|
||||||
"inkwell 0.1.0",
|
"inkwell 0.1.0",
|
||||||
"libloading 0.7.1",
|
"libloading 0.7.1",
|
||||||
"roc_build",
|
"roc_build",
|
||||||
|
"roc_builtins",
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
"roc_gen_llvm",
|
"roc_gen_llvm",
|
||||||
"roc_load",
|
"roc_load",
|
||||||
|
@ -2946,6 +2930,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bumpalo",
|
"bumpalo",
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
|
"roc_error_macros",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_region",
|
"roc_region",
|
||||||
"static_assertions",
|
"static_assertions",
|
||||||
|
@ -2956,6 +2941,7 @@ dependencies = [
|
||||||
name = "roc_unify"
|
name = "roc_unify"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
"roc_collections",
|
"roc_collections",
|
||||||
"roc_module",
|
"roc_module",
|
||||||
"roc_types",
|
"roc_types",
|
||||||
|
@ -3402,17 +3388,6 @@ dependencies = [
|
||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "thread-id"
|
|
||||||
version = "4.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5fdfe0627923f7411a43ec9ec9c39c3a9b4151be313e0922042581fb6c9b717f"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
"redox_syscall",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "threadpool"
|
name = "threadpool"
|
||||||
version = "1.8.1"
|
version = "1.8.1"
|
||||||
|
|
|
@ -387,9 +387,14 @@ fn with_indent(indent_level: usize, some_str: &str) -> String {
|
||||||
full_string
|
full_string
|
||||||
}
|
}
|
||||||
|
|
||||||
fn string_mark_node(content: &str, indent_level: usize, ast_node_id: ASTNodeId, mark_node_pool: &mut SlowPool) -> MarkNodeId {
|
fn string_mark_node(
|
||||||
|
content: &str,
|
||||||
|
indent_level: usize,
|
||||||
|
ast_node_id: ASTNodeId,
|
||||||
|
mark_node_pool: &mut SlowPool,
|
||||||
|
) -> MarkNodeId {
|
||||||
new_markup_node(
|
new_markup_node(
|
||||||
with_indent(indent_level, &content),
|
with_indent(indent_level, content),
|
||||||
ast_node_id,
|
ast_node_id,
|
||||||
HighlightStyle::String,
|
HighlightStyle::String,
|
||||||
mark_node_pool,
|
mark_node_pool,
|
||||||
|
|
|
@ -469,10 +469,7 @@ pub fn join_mark_nodes_commas(
|
||||||
mark_nodes.into_iter().interleave(join_nodes).collect()
|
mark_nodes.into_iter().interleave(join_nodes).collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn mark_nodes_to_string(
|
pub fn mark_nodes_to_string(markup_node_ids: &[MarkNodeId], mark_node_pool: &SlowPool) -> String {
|
||||||
markup_node_ids: &[MarkNodeId],
|
|
||||||
mark_node_pool: &SlowPool,
|
|
||||||
) -> String {
|
|
||||||
let mut all_code_string = String::new();
|
let mut all_code_string = String::new();
|
||||||
|
|
||||||
for mark_node_id in markup_node_ids.iter() {
|
for mark_node_id in markup_node_ids.iter() {
|
||||||
|
@ -482,7 +479,11 @@ pub fn mark_nodes_to_string(
|
||||||
all_code_string
|
all_code_string
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn node_to_string_w_children(node_id: MarkNodeId, str_buffer: &mut String, mark_node_pool: &SlowPool) {
|
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);
|
let node = mark_node_pool.get(node_id);
|
||||||
|
|
||||||
if node.is_nested() {
|
if node.is_nested() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::ui::text::lines::Lines;
|
use crate::ui::text::lines::Lines;
|
||||||
use crate::ui::text::text_pos::TextPos;
|
use crate::ui::text::text_pos::TextPos;
|
||||||
use crate::ui::ui_error::{ UIResult};
|
use crate::ui::ui_error::UIResult;
|
||||||
use crate::ui::util::slice_get;
|
use crate::ui::util::slice_get;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
|
@ -13,10 +13,7 @@ pub struct CodeLines {
|
||||||
impl CodeLines {
|
impl CodeLines {
|
||||||
pub fn from_str(code_str: &str) -> CodeLines {
|
pub fn from_str(code_str: &str) -> CodeLines {
|
||||||
CodeLines {
|
CodeLines {
|
||||||
lines: code_str
|
lines: code_str.split('\n').map(|s| s.to_owned()).collect(),
|
||||||
.split('\n')
|
|
||||||
.map(|s| s.to_owned())
|
|
||||||
.collect(),
|
|
||||||
nr_of_chars: code_str.len(),
|
nr_of_chars: code_str.len(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,19 +28,10 @@ pub fn break_line(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
&& ed_model.code_lines.line_len(new_blank_line_nr).unwrap() == 0)
|
&& ed_model.code_lines.line_len(new_blank_line_nr).unwrap() == 0)
|
||||||
{
|
{
|
||||||
// two blank lines between top level definitions
|
// two blank lines between top level definitions
|
||||||
EdModel::insert_empty_line(
|
EdModel::insert_empty_line(caret_line_nr + 1, &mut ed_model.grid_node_map)?;
|
||||||
caret_line_nr + 1,
|
EdModel::insert_empty_line(caret_line_nr + 2, &mut ed_model.grid_node_map)?;
|
||||||
&mut ed_model.grid_node_map,
|
|
||||||
)?;
|
|
||||||
EdModel::insert_empty_line(
|
|
||||||
caret_line_nr + 2,
|
|
||||||
&mut ed_model.grid_node_map,
|
|
||||||
)?;
|
|
||||||
// third "empty" line will be filled by the blank
|
// third "empty" line will be filled by the blank
|
||||||
EdModel::insert_empty_line(
|
EdModel::insert_empty_line(caret_line_nr + 3, &mut ed_model.grid_node_map)?;
|
||||||
caret_line_nr + 3,
|
|
||||||
&mut ed_model.grid_node_map,
|
|
||||||
)?;
|
|
||||||
|
|
||||||
insert_new_blank(ed_model, caret_pos.line + 3)?;
|
insert_new_blank(ed_model, caret_pos.line + 3)?;
|
||||||
}
|
}
|
||||||
|
@ -52,24 +43,25 @@ pub fn break_line(ed_model: &mut EdModel) -> EdResult<InputOutcome> {
|
||||||
Ok(InputOutcome::Accepted)
|
Ok(InputOutcome::Accepted)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_new_blank(
|
pub fn insert_new_blank(ed_model: &mut EdModel, insert_on_line_nr: usize) -> EdResult<()> {
|
||||||
ed_model: &mut EdModel,
|
println!(
|
||||||
insert_on_line_nr: usize,
|
"{}",
|
||||||
) -> EdResult<()> {
|
ed_model.module.ast.ast_to_string(ed_model.module.env.pool)
|
||||||
println!("{}", ed_model.module.ast.ast_to_string(ed_model.module.env.pool));
|
);
|
||||||
|
|
||||||
// find position of the previous ASTNode to figure out where to add this new Blank ASTNode
|
// find position of the previous ASTNode to figure out where to add this new Blank ASTNode
|
||||||
let def_mark_node_id = ed_model.grid_node_map.get_def_mark_node_id_before_line(
|
let def_mark_node_id = ed_model
|
||||||
insert_on_line_nr,
|
.grid_node_map
|
||||||
&ed_model.mark_node_pool,
|
.get_def_mark_node_id_before_line(insert_on_line_nr, &ed_model.mark_node_pool)?;
|
||||||
)?;
|
|
||||||
|
|
||||||
let new_line_blank = Def2::Blank;
|
let new_line_blank = Def2::Blank;
|
||||||
let new_line_blank_id = ed_model.module.env.pool.add(new_line_blank);
|
let new_line_blank_id = ed_model.module.env.pool.add(new_line_blank);
|
||||||
|
|
||||||
let insertion_index = index_of(def_mark_node_id, &ed_model.markup_ids)?;
|
let insertion_index = index_of(def_mark_node_id, &ed_model.markup_ids)?;
|
||||||
ed_model.module.ast.insert_def_at_index(new_line_blank_id, insertion_index);
|
ed_model
|
||||||
|
.module
|
||||||
|
.ast
|
||||||
|
.insert_def_at_index(new_line_blank_id, insertion_index);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,10 +75,8 @@ pub fn init_model<'a>(
|
||||||
)?)
|
)?)
|
||||||
}?;
|
}?;
|
||||||
|
|
||||||
|
let code_lines =
|
||||||
let code_lines = CodeLines::from_str(
|
CodeLines::from_str(&nodes::mark_nodes_to_string(&markup_ids, &mark_node_pool));
|
||||||
&nodes::mark_nodes_to_string(&markup_ids, &mark_node_pool)
|
|
||||||
);
|
|
||||||
let mut grid_node_map = GridNodeMap::default();
|
let mut grid_node_map = GridNodeMap::default();
|
||||||
|
|
||||||
let mut line_nr = 0;
|
let mut line_nr = 0;
|
||||||
|
|
|
@ -300,10 +300,7 @@ impl<'a> EdModel<'a> {
|
||||||
grid_node_map.break_line(line_nr, col_nr)
|
grid_node_map.break_line(line_nr, col_nr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn insert_empty_line(
|
pub fn insert_empty_line(line_nr: usize, grid_node_map: &mut GridNodeMap) -> UIResult<()> {
|
||||||
line_nr: usize,
|
|
||||||
grid_node_map: &mut GridNodeMap,
|
|
||||||
) -> UIResult<()> {
|
|
||||||
grid_node_map.insert_empty_line(line_nr)
|
grid_node_map.insert_empty_line(line_nr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -330,7 +327,7 @@ impl<'a> EdModel<'a> {
|
||||||
col_range: std::ops::Range<usize>,
|
col_range: std::ops::Range<usize>,
|
||||||
) -> UIResult<()> {
|
) -> UIResult<()> {
|
||||||
self.grid_node_map
|
self.grid_node_map
|
||||||
.del_range_at_line(line_nr, col_range.clone())
|
.del_range_at_line(line_nr, col_range)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn del_blank_expr_node(&mut self, txt_pos: TextPos) -> UIResult<()> {
|
pub fn del_blank_expr_node(&mut self, txt_pos: TextPos) -> UIResult<()> {
|
||||||
|
@ -669,9 +666,10 @@ impl<'a> EdModel<'a> {
|
||||||
&self.loaded_module.interns,
|
&self.loaded_module.interns,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.code_lines = CodeLines::from_str(
|
self.code_lines = CodeLines::from_str(&nodes::mark_nodes_to_string(
|
||||||
&nodes::mark_nodes_to_string(&self.markup_ids, &self.mark_node_pool)
|
&self.markup_ids,
|
||||||
);
|
&self.mark_node_pool,
|
||||||
|
));
|
||||||
self.grid_node_map = GridNodeMap::default();
|
self.grid_node_map = GridNodeMap::default();
|
||||||
|
|
||||||
let mut line_nr = 0;
|
let mut line_nr = 0;
|
||||||
|
@ -1703,89 +1701,29 @@ pub mod test_ed_update {
|
||||||
fn test_record() -> Result<(), String> {
|
fn test_record() -> Result<(), String> {
|
||||||
assert_insert_in_def_nls(ovec!["{ ┃ }"], '{')?;
|
assert_insert_in_def_nls(ovec!["{ ┃ }"], '{')?;
|
||||||
assert_insert_nls(ovec!["val = { ┃ }"], ovec!["val = { a┃ }"], 'a')?;
|
assert_insert_nls(ovec!["val = { ┃ }"], ovec!["val = { a┃ }"], 'a')?;
|
||||||
assert_insert_nls(
|
assert_insert_nls(ovec!["val = { a┃ }"], ovec!["val = { ab┃ }"], 'b')?;
|
||||||
ovec!["val = { a┃ }"],
|
assert_insert_nls(ovec!["val = { a┃ }"], ovec!["val = { a1┃ }"], '1')?;
|
||||||
ovec!["val = { ab┃ }"],
|
assert_insert_nls(ovec!["val = { a1┃ }"], ovec!["val = { a1z┃ }"], 'z')?;
|
||||||
'b',
|
assert_insert_nls(ovec!["val = { a1┃ }"], ovec!["val = { a15┃ }"], '5')?;
|
||||||
)?;
|
assert_insert_nls(ovec!["val = { ab┃ }"], ovec!["val = { abc┃ }"], 'c')?;
|
||||||
assert_insert_nls(
|
assert_insert_nls(ovec!["val = { ┃abc }"], ovec!["val = { z┃abc }"], 'z')?;
|
||||||
ovec!["val = { a┃ }"],
|
assert_insert_nls(ovec!["val = { a┃b }"], ovec!["val = { az┃b }"], 'z')?;
|
||||||
ovec!["val = { a1┃ }"],
|
assert_insert_nls(ovec!["val = { a┃b }"], ovec!["val = { a9┃b }"], '9')?;
|
||||||
'1',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { a1┃ }"],
|
|
||||||
ovec!["val = { a1z┃ }"],
|
|
||||||
'z',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { a1┃ }"],
|
|
||||||
ovec!["val = { a15┃ }"],
|
|
||||||
'5',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { ab┃ }"],
|
|
||||||
ovec!["val = { abc┃ }"],
|
|
||||||
'c',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { ┃abc }"],
|
|
||||||
ovec!["val = { z┃abc }"],
|
|
||||||
'z',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { a┃b }"],
|
|
||||||
ovec!["val = { az┃b }"],
|
|
||||||
'z',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { a┃b }"],
|
|
||||||
ovec!["val = { a9┃b }"],
|
|
||||||
'9',
|
|
||||||
)?;
|
|
||||||
|
|
||||||
assert_insert_nls(
|
assert_insert_nls(ovec!["val = { a┃ }"], ovec!["val = { a: ┃ }"], ':')?;
|
||||||
ovec!["val = { a┃ }"],
|
assert_insert_nls(ovec!["val = { abc┃ }"], ovec!["val = { abc: ┃ }"], ':')?;
|
||||||
ovec!["val = { a: ┃ }"],
|
assert_insert_nls(ovec!["val = { aBc┃ }"], ovec!["val = { aBc: ┃ }"], ':')?;
|
||||||
':',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { abc┃ }"],
|
|
||||||
ovec!["val = { abc: ┃ }"],
|
|
||||||
':',
|
|
||||||
)?;
|
|
||||||
assert_insert_nls(
|
|
||||||
ovec!["val = { aBc┃ }"],
|
|
||||||
ovec!["val = { aBc: ┃ }"],
|
|
||||||
':',
|
|
||||||
)?;
|
|
||||||
|
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(ovec!["val = { a┃ }"], ovec!["val = { a: \"┃\" }"], ":\"")?;
|
||||||
ovec!["val = { a┃ }"],
|
|
||||||
ovec!["val = { a: \"┃\" }"],
|
|
||||||
":\"",
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(
|
||||||
ovec!["val = { abc┃ }"],
|
ovec!["val = { abc┃ }"],
|
||||||
ovec!["val = { abc: \"┃\" }"],
|
ovec!["val = { abc: \"┃\" }"],
|
||||||
":\"",
|
":\"",
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(ovec!["val = { a┃ }"], ovec!["val = { a: 0┃ }"], ":0")?;
|
||||||
ovec!["val = { a┃ }"],
|
assert_insert_seq_nls(ovec!["val = { abc┃ }"], ovec!["val = { abc: 9┃ }"], ":9")?;
|
||||||
ovec!["val = { a: 0┃ }"],
|
assert_insert_seq_nls(ovec!["val = { a┃ }"], ovec!["val = { a: 1000┃ }"], ":1000")?;
|
||||||
":0",
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
|
||||||
ovec!["val = { abc┃ }"],
|
|
||||||
ovec!["val = { abc: 9┃ }"],
|
|
||||||
":9",
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
|
||||||
ovec!["val = { a┃ }"],
|
|
||||||
ovec!["val = { a: 1000┃ }"],
|
|
||||||
":1000",
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(
|
||||||
ovec!["val = { abc┃ }"],
|
ovec!["val = { abc┃ }"],
|
||||||
ovec!["val = { abc: 98761┃ }"],
|
ovec!["val = { abc: 98761┃ }"],
|
||||||
|
@ -1938,16 +1876,8 @@ pub mod test_ed_update {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_nested_record() -> Result<(), String> {
|
fn test_nested_record() -> Result<(), String> {
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(ovec!["val = { a┃ }"], ovec!["val = { a: { ┃ } }"], ":{")?;
|
||||||
ovec!["val = { a┃ }"],
|
assert_insert_seq_nls(ovec!["val = { abc┃ }"], ovec!["val = { abc: { ┃ } }"], ":{")?;
|
||||||
ovec!["val = { a: { ┃ } }"],
|
|
||||||
":{",
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
|
||||||
ovec!["val = { abc┃ }"],
|
|
||||||
ovec!["val = { abc: { ┃ } }"],
|
|
||||||
":{",
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(
|
||||||
ovec!["val = { camelCase┃ }"],
|
ovec!["val = { camelCase┃ }"],
|
||||||
ovec!["val = { camelCase: { ┃ } }"],
|
ovec!["val = { camelCase: { ┃ } }"],
|
||||||
|
@ -2239,14 +2169,8 @@ pub mod test_ed_update {
|
||||||
assert_insert_seq_ignore_nls(ovec!["val = ┃{ a: { } }"], IGNORE_NO_LTR)?;
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ a: { } }"], IGNORE_NO_LTR)?;
|
||||||
assert_insert_seq_ignore_nls(ovec!["val = { ┃a: { } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { ┃a: { } }"], "1")?;
|
||||||
|
|
||||||
assert_insert_seq_ignore_nls(
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: {┃ z15a } }"], IGNORE_NO_LTR)?;
|
||||||
ovec!["val = { camelCaseB1: {┃ z15a } }"],
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: ┃{ z15a } }"], IGNORE_NO_LTR)?;
|
||||||
IGNORE_NO_LTR,
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_ignore_nls(
|
|
||||||
ovec!["val = { camelCaseB1: ┃{ z15a } }"],
|
|
||||||
IGNORE_NO_LTR,
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_nls(
|
assert_insert_seq_nls(
|
||||||
ovec!["val = { camelCaseB1: { z15a┃ } }"],
|
ovec!["val = { camelCaseB1: { z15a┃ } }"],
|
||||||
ovec!["val = { camelCaseB1: { z15a:┃ } }"],
|
ovec!["val = { camelCaseB1: { z15a:┃ } }"],
|
||||||
|
@ -2257,18 +2181,9 @@ pub mod test_ed_update {
|
||||||
ovec!["val = { camelCaseB1: { z15a: ┃ } }"],
|
ovec!["val = { camelCaseB1: { z15a: ┃ } }"],
|
||||||
&concat_strings(":🡲", IGNORE_CHARS),
|
&concat_strings(":🡲", IGNORE_CHARS),
|
||||||
)?;
|
)?;
|
||||||
assert_insert_seq_ignore_nls(
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1:┃ { z15a } }"], IGNORE_NO_LTR)?;
|
||||||
ovec!["val = { camelCaseB1:┃ { z15a } }"],
|
assert_insert_seq_ignore_nls(ovec!["val = {┃ camelCaseB1: { z15a } }"], IGNORE_NO_LTR)?;
|
||||||
IGNORE_NO_LTR,
|
assert_insert_seq_ignore_nls(ovec!["val = ┃{ camelCaseB1: { z15a } }"], IGNORE_NO_LTR)?;
|
||||||
)?;
|
|
||||||
assert_insert_seq_ignore_nls(
|
|
||||||
ovec!["val = {┃ camelCaseB1: { z15a } }"],
|
|
||||||
IGNORE_NO_LTR,
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_ignore_nls(
|
|
||||||
ovec!["val = ┃{ camelCaseB1: { z15a } }"],
|
|
||||||
IGNORE_NO_LTR,
|
|
||||||
)?;
|
|
||||||
assert_insert_seq_ignore_nls(ovec!["val = { ┃camelCaseB1: { z15a } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { ┃camelCaseB1: { z15a } }"], "1")?;
|
||||||
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { ┃z15a } }"], "1")?;
|
assert_insert_seq_ignore_nls(ovec!["val = { camelCaseB1: { ┃z15a } }"], "1")?;
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ pub fn start_new_let_value(ed_model: &mut EdModel, new_char: &char) -> EdResult<
|
||||||
.module
|
.module
|
||||||
.env
|
.env
|
||||||
.ident_ids
|
.ident_ids
|
||||||
.add(val_name_string.clone().into());
|
.add(val_name_string.into());
|
||||||
let var_symbol = Symbol::new(ed_model.module.env.home, ident_id);
|
let var_symbol = Symbol::new(ed_model.module.env.home, ident_id);
|
||||||
let body = Expr2::Var(var_symbol);
|
let body = Expr2::Var(var_symbol);
|
||||||
let body_id = ed_model.module.env.pool.add(body);
|
let body_id = ed_model.module.env.pool.add(body);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use roc_ast::lang::core::ast::{ast_node_to_string};
|
use roc_ast::lang::core::ast::ast_node_to_string;
|
||||||
use roc_ast::lang::core::expr::expr2::{Expr2, ExprId};
|
use roc_ast::lang::core::expr::expr2::{Expr2, ExprId};
|
||||||
use roc_ast::mem_pool::pool_vec::PoolVec;
|
use roc_ast::mem_pool::pool_vec::PoolVec;
|
||||||
use roc_code_markup::markup::nodes::{self};
|
use roc_code_markup::markup::nodes::{self};
|
||||||
|
|
|
@ -15,8 +15,8 @@ use roc_ast::mem_pool::pool_str::PoolStr;
|
||||||
use roc_ast::mem_pool::pool_vec::PoolVec;
|
use roc_ast::mem_pool::pool_vec::PoolVec;
|
||||||
use roc_code_markup::markup::attribute::Attributes;
|
use roc_code_markup::markup::attribute::Attributes;
|
||||||
use roc_code_markup::markup::nodes;
|
use roc_code_markup::markup::nodes;
|
||||||
use roc_code_markup::markup::nodes::COLON;
|
|
||||||
use roc_code_markup::markup::nodes::MarkupNode;
|
use roc_code_markup::markup::nodes::MarkupNode;
|
||||||
|
use roc_code_markup::markup::nodes::COLON;
|
||||||
use roc_code_markup::slow_pool::MarkNodeId;
|
use roc_code_markup::slow_pool::MarkNodeId;
|
||||||
use roc_code_markup::syntax_highlight::HighlightStyle;
|
use roc_code_markup::syntax_highlight::HighlightStyle;
|
||||||
use snafu::OptionExt;
|
use snafu::OptionExt;
|
||||||
|
@ -160,7 +160,6 @@ pub fn update_record_colon(
|
||||||
if matches!(prev_expr, Expr2::Record { .. })
|
if matches!(prev_expr, Expr2::Record { .. })
|
||||||
&& matches!(curr_ast_node, Expr2::Record { .. })
|
&& matches!(curr_ast_node, Expr2::Record { .. })
|
||||||
{
|
{
|
||||||
|
|
||||||
let ast_node_ref = ed_model.module.env.pool.get(record_ast_node_id);
|
let ast_node_ref = ed_model.module.env.pool.get(record_ast_node_id);
|
||||||
|
|
||||||
match ast_node_ref {
|
match ast_node_ref {
|
||||||
|
@ -171,8 +170,7 @@ pub fn update_record_colon(
|
||||||
if ed_model.node_exists_at_caret() {
|
if ed_model.node_exists_at_caret() {
|
||||||
let next_mark_node_id =
|
let next_mark_node_id =
|
||||||
ed_model.grid_node_map.get_id_at_row_col(old_caret_pos)?;
|
ed_model.grid_node_map.get_id_at_row_col(old_caret_pos)?;
|
||||||
let next_mark_node =
|
let next_mark_node = ed_model.mark_node_pool.get(next_mark_node_id);
|
||||||
ed_model.mark_node_pool.get(next_mark_node_id);
|
|
||||||
if next_mark_node.get_content() == nodes::RIGHT_ACCOLADE {
|
if next_mark_node.get_content() == nodes::RIGHT_ACCOLADE {
|
||||||
// update AST node
|
// update AST node
|
||||||
let new_field_val = Expr2::Blank;
|
let new_field_val = Expr2::Blank;
|
||||||
|
|
|
@ -76,7 +76,6 @@ pub fn update_string(new_char: char, ed_model: &mut EdModel) -> EdResult<InputOu
|
||||||
.get_offset_to_node_id(old_caret_pos, curr_mark_node_id)?;
|
.get_offset_to_node_id(old_caret_pos, curr_mark_node_id)?;
|
||||||
|
|
||||||
if node_caret_offset != 0 && node_caret_offset < content_str.len() {
|
if node_caret_offset != 0 && node_caret_offset < content_str.len() {
|
||||||
|
|
||||||
// update ast
|
// update ast
|
||||||
update_str_expr(
|
update_str_expr(
|
||||||
ast_node_id.to_expr_id()?,
|
ast_node_id.to_expr_id()?,
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
use roc_ast::lang::core::{def::def2::Def2, expr::expr2::Expr2};
|
use roc_ast::lang::core::{def::def2::Def2, expr::expr2::Expr2};
|
||||||
use roc_code_markup::{
|
use roc_code_markup::slow_pool::MarkNodeId;
|
||||||
slow_pool::MarkNodeId,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
editor::ed_error::{EdResult, FailedToUpdateIdentIdName, KeyNotFound},
|
editor::ed_error::{EdResult, FailedToUpdateIdentIdName, KeyNotFound},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue