From b6f8ab0a1c99c21d2a75053971b65d7167eb089a Mon Sep 17 00:00:00 2001 From: rouzwelt Date: Fri, 14 Feb 2025 17:54:48 +0000 Subject: [PATCH] init --- .gitmodules | 4 - Cargo.lock | 9 ++- Cargo.toml | 8 +- crates/dotrain/Cargo.toml | 34 ++++---- crates/dotrain/src/composer/mod.rs | 81 ++++++++++++------- crates/dotrain/src/parser/mod.rs | 26 +++--- crates/dotrain/src/parser/raindocument/mod.rs | 28 ++----- .../src/parser/rainlangdocument/mod.rs | 30 +++---- crates/dotrain/src/types/patterns.rs | 4 +- crates/lsp/Cargo.toml | 11 ++- crates/lsp/src/lib.rs | 8 +- lib/magic-string | 1 - 12 files changed, 111 insertions(+), 133 deletions(-) delete mode 100644 .gitmodules delete mode 160000 lib/magic-string diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 91bc8b82..00000000 --- a/.gitmodules +++ /dev/null @@ -1,4 +0,0 @@ -[submodule "lib/magic-string"] - path = lib/magic-string - url = https://github.com/rouzwelt/magic-string-rs - branch = fix-memory-leak diff --git a/Cargo.lock b/Cargo.lock index a2cc6533..ff04bfcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -695,7 +695,7 @@ dependencies = [ "futures", "getrandom", "js-sys", - "magic_string", + "magic_string_rain", "once_cell", "proptest", "rain-metadata", @@ -718,7 +718,6 @@ name = "dotrain-lsp" version = "6.0.1-alpha.21" dependencies = [ "alloy-primitives 0.7.7", - "anyhow", "dotrain", "js-sys", "lsp-types", @@ -1390,8 +1389,10 @@ dependencies = [ ] [[package]] -name = "magic_string" -version = "0.3.4" +name = "magic_string_rain" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b14a99e25cbe68891c84655e1bc0181c72c270c07d89591954982c607c1d912a" dependencies = [ "base64 0.13.1", "regex", diff --git a/Cargo.toml b/Cargo.toml index 8d1904bd..e77a6c68 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,10 +10,10 @@ homepage = "https://github.com/rainlanguage/dotrain" repository = "https://github.com/rainlanguage/dotrain" [workspace.dependencies] -regex = "1.10.2" -anyhow = "1.0.75" -once_cell = "1.18.0" -alloy-primitives = "0.7.7" +regex = "1.10" +anyhow = "1" +once_cell = "1" +alloy-primitives = "0" rain-metadata = "0.0.2-alpha.2" [workspace.dependencies.dotrain] diff --git a/crates/dotrain/Cargo.toml b/crates/dotrain/Cargo.toml index f0667dbd..47fec435 100644 --- a/crates/dotrain/Cargo.toml +++ b/crates/dotrain/Cargo.toml @@ -21,14 +21,14 @@ path = "src/main.rs" required-features = ["cli"] [dependencies] -serde = "1.0.192" -serde_json = "1.0.108" -serde_repr = "0.1.17" -serde_bytes = "0.11.12" -futures = "0.3.29" -magic_string = { path = "../../lib/magic-string/core" } -async-recursion = "1.0.5" -getrandom = { version = "0.2.11", features = ["js", "js-sys"] } +serde = { version = "1.0", features = ["rc", "derive"] } +serde_json = "1.0" +serde_repr = "0.1" +serde_bytes = "0.11" +futures = "0.3" +magic_string_rain = "0.3.5" +async-recursion = "1" +getrandom = { version = "0", features = ["js", "js-sys"] } anyhow = { workspace = true } regex = { workspace = true } once_cell = { workspace = true } @@ -36,17 +36,17 @@ alloy-primitives = { workspace = true } rain-metadata = { workspace = true } # cli -tracing = { version = "0.1.37", optional = true } -tracing-subscriber = { version = "0.3.17", optional = true } -clap = { version = "4.4.8", features = ["cargo", "derive"], optional = true } -tokio = { version = "1.34.0", features = ["full"], optional = true } +tracing = { version = "0.1", optional = true } +tracing-subscriber = { version = "0.3", optional = true } +clap = { version = "4.4", features = ["cargo", "derive"], optional = true } +tokio = { version = "1", features = ["full"], optional = true } # js-api -js-sys = { version = "0.3.66", optional = true } -wasm-bindgen = { version = "0.2.89", optional = true } -serde-wasm-bindgen = { version = "0.6.1", optional = true } -wasm-bindgen-futures = { version = "0.4.39", optional = true } -tsify = { version = "0.4.5", default-features = false, features = ["js", "wasm-bindgen"], optional = true } +js-sys = { version = "0.3", optional = true } +wasm-bindgen = { version = "0.2", optional = true } +serde-wasm-bindgen = { version = "0.6", optional = true } +wasm-bindgen-futures = { version = "0.4", optional = true } +tsify = { version = "0.4", default-features = false, features = ["wasm-bindgen"], optional = true } [lints.clippy] all = "warn" diff --git a/crates/dotrain/src/composer/mod.rs b/crates/dotrain/src/composer/mod.rs index c2e86632..65aea9b3 100644 --- a/crates/dotrain/src/composer/mod.rs +++ b/crates/dotrain/src/composer/mod.rs @@ -3,7 +3,7 @@ use std::{ sync::{Arc, RwLock}, collections::VecDeque, }; -use magic_string::{MagicString, OverwriteOptions, GenerateDecodedMapOptions}; +use magic_string_rain::{MagicString, OverwriteOptions, GenerateDecodedMapOptions}; use crate::types::ast::PragmaStatement; use super::{ @@ -521,7 +521,7 @@ mod tests { }; #[test] - fn test_compose() -> anyhow::Result<()> { + fn test_compose() { let mut store = rain_metadata::Store::new(); let authoring_meta = AuthoringMeta(vec![ AuthoringMetaItem { @@ -564,7 +564,8 @@ _: opcode-1(0xabcd 456); &["exp-binding"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = "/* 0. exp-binding */ \n_: opcode-1(0xabcd 456);"; assert_eq!(rainlang_text, expected_rainlang); @@ -584,7 +585,8 @@ some-name _: opcode-2(opcode-1(1 2) const-binding) 0xab34; &["exp-binding"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = "/* 0. exp-binding */ _: opcode-1(0xabcd 456), some-name _: opcode-2(opcode-1(1 2) 4e18) 0xab34;"; @@ -608,7 +610,8 @@ _: opcode-2(0xabcd some-value); &["exp-binding-1"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = "/* 0. exp-binding-1 */ _: opcode-1<1>(0xabcd 456), some-name _: 0xab34; @@ -638,7 +641,8 @@ _: opcode-2(0xabcd some-value); &["exp-binding-1", "exp-binding-2"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = "/* 0. exp-binding-1 */ _: opcode-1(0xabcd 456), some-name _: 0xab34; @@ -669,7 +673,8 @@ _: opcode-2(some-name some-other-value); &["main", "exp-binding-1", "exp-binding-2"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = "/* 0. main */ _: opcode-1<2>(0xabcd 456); @@ -697,7 +702,8 @@ _: some-sub-parser-word<1 2>(some-value some-other-value); &["exp-binding-1"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = "/* 0. exp-binding-1 */ using-words-from 0x1234abced _: some-sub-parser-word<1 2>(4e18 0xabcdef1234);"; @@ -717,7 +723,8 @@ _: some-sub-parser-word<1 2>(some-value literal-binding); &["exp-binding-1"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ using-words-from 0x1234abced abcd: " this is literal string ", @@ -738,7 +745,8 @@ _: some-sub-parser-word(some-valu &["exp-binding-1"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ using-words-from 0x1234abced abcd: " this is literal string ", @@ -761,7 +769,8 @@ _: some-sub-parser-word<1 2>(some-value 44); &["exp-binding-1"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ /* some comment with quote: dont't */ using-words-from 0x1234abced @@ -785,7 +794,8 @@ _: opcode-1(0xabcd some-value---); &["exp-binding-1---"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r"/* 0. exp-binding-1--- */ /** some other comment with --- */ _: opcode-1(0xabcd 4e18);"; @@ -811,7 +821,8 @@ _: opcode-3(some-value some-other-value); &["exp-binding-1", "main"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r"/* 0. exp-binding-1 */ _: opcode-1<2>(0xabcd 456); @@ -842,7 +853,8 @@ _: opcode-3(some-value some-other-value); &["exp-binding-1", "main"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r"/* 0. exp-binding-1 */ _: opcode-1<2>(0xabcd 456); @@ -1070,7 +1082,8 @@ _: some-sub-parser-word<1 2>(4e18 literal-binding); &["exp-binding-1"], Some(meta_store.clone()), None, - )?; + ) + .unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ using-words-from 0x1234abcedf " some string literal " "abcd" abcd: " this is literal string ", @@ -1111,7 +1124,8 @@ _: some-sub-parser-word<1 2>(4e18 literal-binding); #exp-binding _: opcode-1(0xabcd "something.else"); "#; - let rainlang_text = RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None)?; + let rainlang_text = + RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None).unwrap(); let expected_rainlang = r#"/* 0. exp-binding */ _: opcode-1(0xabcd "something.else");"#; assert_eq!(rainlang_text, expected_rainlang); @@ -1126,7 +1140,8 @@ _: opcode-1(0xabcd "something.else");"#; #exp-binding _: opcode-1(12.34e6 123.123); "#; - let rainlang_text = RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None)?; + let rainlang_text = + RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None).unwrap(); let expected_rainlang = r#"/* 0. exp-binding */ _: opcode-1(12.34e6 123.123);"#; assert_eq!(rainlang_text, expected_rainlang); @@ -1141,7 +1156,8 @@ _some-lhs-word: opcode-1(12 123.456e123), _some-other-lhs-word: 1e18, _ _: opcode-1(_some-lhs-word _some-other-lhs-word) _some-other-lhs-word; "#; - let rainlang_text = RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None)?; + let rainlang_text = + RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None).unwrap(); let expected_rainlang = r#"/* 0. exp-binding */ _some-lhs-word: opcode-1(12 123.456e123), _some-other-lhs-word: 1e18, @@ -1173,7 +1189,8 @@ _some-lhs-word: opcode-1(12 _bad-binding-name); #exp-binding _: opcode-1(12.34e-6 1.234e-15); "#; - let rainlang_text = RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None)?; + let rainlang_text = + RainDocument::compose_text(dotrain_text, &["exp-binding"], None, None).unwrap(); let expected_rainlang = r#"/* 0. exp-binding */ _: opcode-1(12.34e-6 1.234e-15);"#; assert_eq!(rainlang_text, expected_rainlang); @@ -1193,12 +1210,10 @@ _some-lhs-word: opcode-1(12 1); ErrorCode::DuplicateIdentifier.to_problem(vec![], [64, 72]) ])); assert_eq!(result, expected_err); - - Ok(()) } #[test] - fn test_compose_with_rebinds() -> anyhow::Result<()> { + fn test_compose_with_rebinds() { let store = rain_metadata::Store::new(); let meta_store = Arc::new(RwLock::new(store)); @@ -1221,7 +1236,9 @@ _: opcode-2(some-name some-other-value); RainDocument::new(dotrain_text.to_owned(), Some(meta_store.clone()), 0, None); let rebinds = vec![Rebind("some-override-value".to_owned(), "567".to_owned())]; block_on(rain_document.parse(false, Some(rebinds))); - let rainlang_text = rain_document.compose(&["exp-binding-1", "exp-binding-2"])?; + let rainlang_text = rain_document + .compose(&["exp-binding-1", "exp-binding-2"]) + .unwrap(); let expected_rainlang = "/* 0. exp-binding-1 */ _: opcode-1(0xabcd 456); @@ -1255,7 +1272,9 @@ _: opcode-2(some-name some-other-value); Rebind("some-value".to_owned(), r#"0x123456"#.to_owned()), ]; block_on(rain_document.parse(false, Some(rebinds))); - let rainlang_text = rain_document.compose(&["exp-binding-1", "exp-binding-2"])?; + let rainlang_text = rain_document + .compose(&["exp-binding-1", "exp-binding-2"]) + .unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ _: opcode-1(0xabcd 456); @@ -1293,7 +1312,9 @@ _: opcode-2(some-name some-other-value); ), ]; block_on(rain_document.parse(false, Some(rebinds))); - let rainlang_text = rain_document.compose(&["exp-binding-1", "exp-binding-2"])?; + let rainlang_text = rain_document + .compose(&["exp-binding-1", "exp-binding-2"]) + .unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ _: opcode-1(0xabcd 456); @@ -1337,7 +1358,7 @@ _: opcode(1 2); ), ]; block_on(rain_document.parse(false, Some(rebinds))); - let rainlang_text = rain_document.compose(&["exp-binding-1"])?; + let rainlang_text = rain_document.compose(&["exp-binding-1"]).unwrap(); let expected_rainlang = r#"/* 0. exp-binding-1 */ _: opcode-1<1>(0xabcd 456); @@ -1412,7 +1433,7 @@ _: opcode-1(0xabcd 456); Rebind("rebind-item".to_owned(), "'another-binding".to_owned()), ]; block_on(rain_document.parse(false, Some(rebinds))); - let rainlang_text = rain_document.compose(&["e1", "e2"])?; + let rainlang_text = rain_document.compose(&["e1", "e2"]).unwrap(); let expected_rainlang = r#"/* 0. e1 */ _: opcode-3(1 call<2>()); @@ -1443,7 +1464,7 @@ _: opcode-2(1 0 [something]); Rebind("b".to_owned(), "'some-other-binding".to_owned()), ]; block_on(rain_document.parse(false, Some(rebinds))); - let rainlang_text = rain_document.compose(&["some-binding"])?; + let rainlang_text = rain_document.compose(&["some-binding"]).unwrap(); let expected_rainlang = "/* 0. some-binding */ _: opcode-2<0 1>(1 0 [something]); @@ -1465,8 +1486,6 @@ _: opcode-1(0xabcd 456); .to_problem(vec!["undefined binding: non-existant-binding"], [0, 0]), ])); assert_eq!(result, expected_err); - - Ok(()) } proptest! { @@ -1497,7 +1516,7 @@ matter #exp-binding _: opcode-1<{} literal-a>(literal-b {});", a[0], b[0], e1, e2); - let rainlang_text = RainDocument::compose_text(&dotrain_text, &["exp-binding"], None, None)?; + let rainlang_text = RainDocument::compose_text(&dotrain_text, &["exp-binding"], None, None).unwrap(); let expected_rainlang = format!("/* 0. exp-binding */ \n_: opcode-1<{} {}>({} {});", e1, a[0], b[0], e2); assert_eq!(rainlang_text, expected_rainlang); diff --git a/crates/dotrain/src/parser/mod.rs b/crates/dotrain/src/parser/mod.rs index 74b3ed75..aa25ebee 100644 --- a/crates/dotrain/src/parser/mod.rs +++ b/crates/dotrain/src/parser/mod.rs @@ -258,18 +258,16 @@ mod tests { use crate::parser::*; #[test] - fn test_parse_cli_key_val() -> anyhow::Result<()> { + fn test_parse_cli_key_val() { let key_value_pair = "key=value"; let result = parse_cli_key_val(key_value_pair).unwrap(); assert_eq!(result.0, "key"); assert_eq!(result.1, "value"); - - Ok(()) } #[test] - fn test_inclusive_parse() -> anyhow::Result<()> { + fn test_inclusive_parse() { let text = r"abcd eb qkbjh (aoib 124b)"; let pattern = Regex::new(r"b\s").unwrap(); @@ -281,11 +279,10 @@ mod tests { ]; assert_eq!(parsed_items, expected); - Ok(()) } #[test] - fn test_exclusive_parse() -> anyhow::Result<()> { + fn test_exclusive_parse() { let text = r"abcd eb qkbjh (aoib 124b)"; let pattern = Regex::new(r"b\s").unwrap(); @@ -298,50 +295,46 @@ mod tests { ]; assert_eq!(parsed_items, expected); - Ok(()) } #[test] - fn test_fill_in() -> anyhow::Result<()> { + fn test_fill_in() { let mut text = r"abcd eb qkbjh (aoib 124b)" .to_string(); - fill_in(&mut text, [23, 27])?; + fill_in(&mut text, [23, 27]).unwrap(); let expected = r"abcd eb qkbjh ( 124b)"; assert_eq!(text, expected); - Ok(()) } #[test] - fn test_fill_out() -> anyhow::Result<()> { + fn test_fill_out() { let mut text = r"abcd eb qkbjh (aoib 124b)" .to_string(); - fill_out(&mut text, [23, 27])?; + fill_out(&mut text, [23, 27]).unwrap(); let expected = r" aoib "; assert_eq!(text, expected); - Ok(()) } #[test] - fn test_tracked_trim() -> anyhow::Result<()> { + fn test_tracked_trim() { let text = " \n abcd \n\t"; let result = tracked_trim(text); let expected = ("abcd", 4, 5); assert_eq!(result, expected); - Ok(()) } #[test] - fn test_line_number() -> anyhow::Result<()> { + fn test_line_number() { let text = r"abcd efgh (123 876) @@ -349,6 +342,5 @@ mod tests { "; let result = line_number(text, 38); assert_eq!(result, 3); - Ok(()) } } diff --git a/crates/dotrain/src/parser/raindocument/mod.rs b/crates/dotrain/src/parser/raindocument/mod.rs index d0deabe4..0d56fa95 100644 --- a/crates/dotrain/src/parser/raindocument/mod.rs +++ b/crates/dotrain/src/parser/raindocument/mod.rs @@ -283,7 +283,7 @@ mod tests { use super::super::rainlangdocument::RainlangDocument; #[test] - fn test_is_constant_method() -> anyhow::Result<()> { + fn test_is_constant_method() { let text = " \n 1234 \n\t "; let result = RainDocument::is_literal(text); assert_eq!(result, Some(("1234".to_owned(), 2, false))); @@ -335,12 +335,10 @@ mod tests { let text = " \n 999 234 \n"; let result = RainDocument::is_literal(text); assert_eq!(result, None); - - Ok(()) } #[test] - fn test_is_elided_method() -> anyhow::Result<()> { + fn test_is_elided_method() { let text = " ! \n some msg \n msg continues \n\t"; let result = RainDocument::is_elided(text); assert_eq!(result, Some("some msg \n msg continues".to_owned())); @@ -352,12 +350,10 @@ mod tests { let text = "some msg"; let result = RainDocument::is_elided(text); assert_eq!(result, None); - - Ok(()) } #[test] - fn test_process_import_config_method() -> anyhow::Result<()> { + fn test_process_import_config_method() { let text = " 'item1 renamed-item1 \n \n\n\t item2 0x1234 \n"; let mut config_items = exclusive_parse(text, &WS_PATTERN, 0, false); let result = RainDocument::process_import_config(&mut config_items.iter_mut(), text); @@ -438,12 +434,10 @@ mod tests { problems: vec![ErrorCode::UnexpectedToken.to_problem(vec![], [0, 8])], }; assert_eq!(result, expected); - - Ok(()) } #[test] - fn test_process_import_method() -> anyhow::Result<()> { + fn test_process_import_method() { let mut meta_store = Store::new(); let hash = "0x6518ec1930d8846b093dcff41a6ee6f6352c72b82e48584cce741a9e8a6d6184"; let hash_bytes = alloy_primitives::hex::decode(hash).unwrap(); @@ -472,12 +466,10 @@ mod tests { sequence: None, }; assert_eq!(result, expected); - - Ok(()) } #[test] - fn test_check_namespace_method() -> anyhow::Result<()> { + fn test_check_namespace_method() { let mut main_namespace: Namespace = HashMap::new(); let mut new_namespace: Namespace = HashMap::new(); main_namespace.insert( @@ -563,12 +555,10 @@ mod tests { RainDocument::check_namespace(&new_namespace, &main_namespace), None ); - - Ok(()) } #[test] - fn test_merge_namespace_method() -> anyhow::Result<()> { + fn test_merge_namespace_method() { let mut main_namespace: Namespace = HashMap::new(); let mut new_namespace: Namespace = HashMap::new(); main_namespace.insert( @@ -654,12 +644,10 @@ mod tests { rain_document.problems, vec![ErrorCode::CollidingNamespaceNodes.to_problem(vec![], [0, 10])] ); - - Ok(()) } #[test] - fn test_parse_method() -> anyhow::Result<()> { + fn test_parse_method() { let store = Store::new(); let meta_store = Arc::new(RwLock::new(store)); @@ -798,7 +786,5 @@ _: opcode-1(0xabcd 456); known_words: None, }; assert_eq!(rain_document, expected_rain_document); - - Ok(()) } } diff --git a/crates/dotrain/src/parser/rainlangdocument/mod.rs b/crates/dotrain/src/parser/rainlangdocument/mod.rs index 7e5fd59f..f9dc220c 100644 --- a/crates/dotrain/src/parser/rainlangdocument/mod.rs +++ b/crates/dotrain/src/parser/rainlangdocument/mod.rs @@ -117,7 +117,7 @@ mod tests { use rain_metadata::types::authoring::v1::AuthoringMetaItem; #[test] - fn test_process_opcode_method() -> anyhow::Result<()> { + fn test_process_opcode_method() { let mut rl = RainlangDocument::new(); rl.state.depth = 1; rl.state.parens.close = vec![13]; @@ -155,7 +155,7 @@ mod tests { operand_args: None, }); rl.state.nodes = vec![value_node.clone(), op_node]; - rl.process_opcode()?; + rl.process_opcode().unwrap(); let expected_op_node = Node::Opcode(Opcode { opcode: OpcodeDetails { @@ -190,12 +190,10 @@ mod tests { ..Default::default() }; assert_eq!(rl.state, expected_state); - - Ok(()) } #[test] - fn test_process_operand_method() -> anyhow::Result<()> { + fn test_process_operand_method() { fn get_op() -> Opcode { Opcode { opcode: OpcodeDetails { @@ -462,12 +460,10 @@ mod tests { }; assert_eq!(consumed_count, exp.len()); assert_eq!(op, expected_op); - - Ok(()) } #[test] - fn test_consume_method() -> anyhow::Result<()> { + fn test_consume_method() { let mut rl = RainlangDocument::new(); let namespace = HashMap::new(); let authoring_meta = AuthoringMeta(vec![ @@ -489,7 +485,7 @@ mod tests { ]); let text = "opcode<12 56>("; - let consumed_count = rl.consume(text, 10, &namespace, &authoring_meta)?; + let consumed_count = rl.consume(text, 10, &namespace, &authoring_meta).unwrap(); let mut expected_state_nodes = vec![Node::Opcode(Opcode { opcode: OpcodeDetails { name: "opcode".to_owned(), @@ -527,7 +523,7 @@ mod tests { let text = "opcode<12.2 2.5e16>("; rl.state.depth -= 1; - let consumed_count = rl.consume(text, 10, &namespace, &authoring_meta)?; + let consumed_count = rl.consume(text, 10, &namespace, &authoring_meta).unwrap(); expected_state_nodes.push(Node::Opcode(Opcode { opcode: OpcodeDetails { name: "opcode".to_owned(), @@ -565,7 +561,7 @@ mod tests { let text = "another-opcode(12 0x123abced)"; rl.state.depth -= 1; - let consumed_count = rl.consume(text, 24, &namespace, &authoring_meta)?; + let consumed_count = rl.consume(text, 24, &namespace, &authoring_meta).unwrap(); expected_state_nodes.push(Node::Opcode(Opcode { opcode: OpcodeDetails { name: "another-opcode".to_owned(), @@ -585,7 +581,7 @@ mod tests { let text = "another-opcode-2<\n 0x1f\n 87>(\n 0xabcef1234\n)"; rl.state.depth -= 1; - let consumed_count = rl.consume(text, 77, &namespace, &authoring_meta)?; + let consumed_count = rl.consume(text, 77, &namespace, &authoring_meta).unwrap(); expected_state_nodes.push(Node::Opcode(Opcode { opcode: OpcodeDetails { name: "another-opcode-2".to_owned(), @@ -623,7 +619,7 @@ mod tests { let text = "another-opcode-2<\n 0x1f\n 87.3e2>(\n 0xabcef1234\n)"; rl.state.depth -= 1; - let consumed_count = rl.consume(text, 77, &namespace, &authoring_meta)?; + let consumed_count = rl.consume(text, 77, &namespace, &authoring_meta).unwrap(); expected_state_nodes.push(Node::Opcode(Opcode { opcode: OpcodeDetails { name: "another-opcode-2".to_owned(), @@ -664,7 +660,7 @@ mod tests { let text = "another-opcode-2<\n 0x1f\n 8.3e-2>(\n 0xabcef1234\n)"; rl.state.depth -= 1; - let consumed_count = rl.consume(text, 77, &namespace, &authoring_meta)?; + let consumed_count = rl.consume(text, 77, &namespace, &authoring_meta).unwrap(); expected_state_nodes.push(Node::Opcode(Opcode { opcode: OpcodeDetails { name: "another-opcode-2".to_owned(), @@ -702,12 +698,10 @@ mod tests { "another-opcode-2<\n 0x1f\n 8.3e-2>(".len() ); assert_eq!(rl.state.nodes, expected_state_nodes); - - Ok(()) } #[test] - fn test_search_namespace_method() -> anyhow::Result<()> { + fn test_search_namespace_method() { let mut rl = RainlangDocument::new(); let mut main_namespace: Namespace = HashMap::new(); let mut deep_namespace: Namespace = HashMap::new(); @@ -779,7 +773,5 @@ mod tests { &main_namespace, ); assert_eq!(None, result); - - Ok(()) } } diff --git a/crates/dotrain/src/types/patterns.rs b/crates/dotrain/src/types/patterns.rs index 08363fbd..0c2b7c08 100644 --- a/crates/dotrain/src/types/patterns.rs +++ b/crates/dotrain/src/types/patterns.rs @@ -141,7 +141,7 @@ mod tests { use super::*; #[test] - fn test_patterns() -> anyhow::Result<()> { + fn test_patterns() { // valids for i in [ "a", "aa", "aA", "aAa", "a0", "aa0", "aA0", "aA0a", "aA0a0", "", "a-", "a-a", "-", " ", @@ -421,7 +421,5 @@ mod tests { i ); } - - Ok(()) } } diff --git a/crates/lsp/Cargo.toml b/crates/lsp/Cargo.toml index 6156797f..226ec89e 100644 --- a/crates/lsp/Cargo.toml +++ b/crates/lsp/Cargo.toml @@ -22,18 +22,17 @@ crate-type = ["rlib", "cdylib"] [dependencies] lsp-types = "0.94.1" -anyhow = { workspace = true } dotrain = { workspace = true } regex = { workspace = true } once_cell = { workspace = true } alloy-primitives = { workspace = true } # js-api -js-sys = { version = "0.3.66", optional = true } -wasm-bindgen = { version = "0.2.89", optional = true } -serde-wasm-bindgen = { version = "0.6.1", optional = true } -wasm-bindgen-futures = { version = "0.4.39", optional = true } -tsify = { version = "0.4.5", default-features = false, features = ["js", "wasm-bindgen"], optional = true } +js-sys = { version = "0.3", optional = true } +wasm-bindgen = { version = "0.2", optional = true } +serde-wasm-bindgen = { version = "0.6", optional = true } +wasm-bindgen-futures = { version = "0.4", optional = true } +tsify = { version = "0.4", default-features = false, features = ["js", "wasm-bindgen"], optional = true } [lints.clippy] all = "warn" diff --git a/crates/lsp/src/lib.rs b/crates/lsp/src/lib.rs index 00d8ca1f..22ec6017 100644 --- a/crates/lsp/src/lib.rs +++ b/crates/lsp/src/lib.rs @@ -460,7 +460,7 @@ mod tests { use super::*; #[test] - fn test_position_at() -> anyhow::Result<()> { + fn test_position_at() { let text = r"abcd efgh ijkl"; @@ -478,12 +478,10 @@ mod tests { character: 10, }; assert_eq!(pos2, pos2_expected); - - Ok(()) } #[test] - fn test_offset_at() -> anyhow::Result<()> { + fn test_offset_at() { let text = r"abcd efgh ijkl"; @@ -501,7 +499,5 @@ mod tests { }); let expected_offset2 = 28; assert_eq!(offset2, expected_offset2); - - Ok(()) } } diff --git a/lib/magic-string b/lib/magic-string deleted file mode 160000 index 20da9e7d..00000000 --- a/lib/magic-string +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 20da9e7d9d65b12da5f80b54d72a528f37f9cceb