diff --git a/.claude/settings.local.json b/.claude/settings.local.json index c62b52d4..b71dc973 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -16,7 +16,10 @@ "Bash(gh repo view:*)", "Bash(cargo build:*)", "Bash(cargo search:*)", - "WebFetch(domain:docs.rs)" + "WebFetch(domain:docs.rs)", + "WebFetch(domain:github.com)", + "WebFetch(domain:raw.githubusercontent.com)", + "WebFetch(domain:index.crates.io)" ] } } diff --git a/Cargo.lock b/Cargo.lock index 761038d6..5451fba7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -419,6 +419,7 @@ dependencies = [ "tree-sitter-c-sharp", "tree-sitter-cpp", "tree-sitter-css", + "tree-sitter-dart", "tree-sitter-elixir", "tree-sitter-erlang", "tree-sitter-go", @@ -3058,6 +3059,16 @@ dependencies = [ "tree-sitter-language", ] +[[package]] +name = "tree-sitter-dart" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bba6bf8675e6fe92ba6da371a5497ee5df2a04d2c503e3599c8ad771f6f1faec" +dependencies = [ + "cc", + "tree-sitter-language", +] + [[package]] name = "tree-sitter-elixir" version = "0.3.5" diff --git a/Cargo.toml b/Cargo.toml index 880f8780..e1203031 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,6 +64,7 @@ tree-sitter-c = "<0.25.0" tree-sitter-c-sharp = "<0.24.0" tree-sitter-cpp = "<0.25.0" tree-sitter-css = "<0.26.0" +tree-sitter-dart = "<1" tree-sitter-elixir = "<0.4.0" tree-sitter-erlang = "<0.16.0" tree-sitter-go = "<0.26.0" diff --git a/README.md b/README.md index 60ef9c17..d3f9e96a 100644 --- a/README.md +++ b/README.md @@ -159,6 +159,7 @@ Codebook is in active development. As better dictionaries are added, words that | C# | ⚠️ | | C++ | ⚠️ | | CSS | ⚠️ | +| Dart | ⚠️ | | Elixir | ⚠️ | | Erlang | ⚠️ | | Go | ✅ | diff --git a/crates/codebook/Cargo.toml b/crates/codebook/Cargo.toml index 99d4b86f..81273b5f 100644 --- a/crates/codebook/Cargo.toml +++ b/crates/codebook/Cargo.toml @@ -33,6 +33,7 @@ tree-sitter-bash.workspace = true tree-sitter-c.workspace = true tree-sitter-cpp.workspace = true tree-sitter-css.workspace = true +tree-sitter-dart.workspace = true tree-sitter-elixir.workspace = true tree-sitter-erlang.workspace = true tree-sitter-go.workspace = true diff --git a/crates/codebook/src/queries.rs b/crates/codebook/src/queries.rs index 52cdcbdc..00efa960 100644 --- a/crates/codebook/src/queries.rs +++ b/crates/codebook/src/queries.rs @@ -9,6 +9,7 @@ pub enum LanguageType { CSharp, Cpp, Css, + Dart, Elixir, Erlang, Go, @@ -171,6 +172,13 @@ pub static LANGUAGE_SETTINGS: &[LanguageSetting] = &[ query: include_str!("queries/css.scm"), extensions: &["css"], }, + LanguageSetting { + type_: LanguageType::Dart, + ids: &["dart"], + dictionary_ids: &["dart"], + query: include_str!("queries/dart.scm"), + extensions: &["dart"], + }, LanguageSetting { type_: LanguageType::Go, ids: &["go"], @@ -311,6 +319,7 @@ impl LanguageSetting { LanguageType::CSharp => Some(tree_sitter_c_sharp::LANGUAGE.into()), LanguageType::Cpp => Some(tree_sitter_cpp::LANGUAGE.into()), LanguageType::Css => Some(tree_sitter_css::LANGUAGE.into()), + LanguageType::Dart => Some(tree_sitter_dart::LANGUAGE.into()), LanguageType::Elixir => Some(tree_sitter_elixir::LANGUAGE.into()), LanguageType::Erlang => Some(tree_sitter_erlang::LANGUAGE.into()), LanguageType::Go => Some(tree_sitter_go::LANGUAGE.into()), diff --git a/crates/codebook/src/queries/dart.scm b/crates/codebook/src/queries/dart.scm new file mode 100644 index 00000000..c114dfef --- /dev/null +++ b/crates/codebook/src/queries/dart.scm @@ -0,0 +1,32 @@ +(comment) @comment + +; Types +(class_declaration name: (identifier) @identifier.type) +(enum_declaration name: (identifier) @identifier.type) +(mixin_declaration name: (identifier) @identifier.type) +(type_alias . _ . (type_identifier) @identifier.type) + +; Functions +(function_signature name: (identifier) @identifier.function) +(getter_signature name: (identifier) @identifier.function) +(setter_signature name: (identifier) @identifier.function) + +; Variables (local) +(initialized_variable_definition name: (identifier) @identifier.variable) +(static_final_declaration name: (identifier) @identifier.variable) +(enum_constant name: (identifier) @identifier.constant) + +; Fields (class/mixin instance variables) +(initialized_identifier (identifier) @identifier.field) + +; Parameters +(formal_parameter name: (identifier) @identifier.parameter) + +; Import aliases +(import_specification alias: (identifier) @identifier.module) + +; String content (excludes interpolation expressions) +(template_chars_single_single) @string +(template_chars_double_single) @string +(template_chars_single) @string +(template_chars_double) @string diff --git a/crates/codebook/tests/languages/main.rs b/crates/codebook/tests/languages/main.rs new file mode 100644 index 00000000..f3a1daed --- /dev/null +++ b/crates/codebook/tests/languages/main.rs @@ -0,0 +1,37 @@ +mod utils; + +mod test_c; +mod test_config; +mod test_cpp; +mod test_csharp; +mod test_css; +mod test_dart; +mod test_elixir; +mod test_erlang; +mod test_files; +mod test_go; +mod test_haskell; +mod test_java; +mod test_javascript; +mod test_latex; +mod test_lua; +mod test_markdown; +mod test_ocaml; +mod test_odin; +mod test_php; +mod test_python; +mod test_r; +mod test_regex; +mod test_ruby; +mod test_rust; +mod test_suggestions; +mod test_svelte; +mod test_swift; +mod test_tags; +mod test_text; +mod test_toml; +mod test_typescript; +mod test_typst; +mod test_vhdl; +mod test_yaml; +mod test_zig; diff --git a/crates/codebook/tests/test_c.rs b/crates/codebook/tests/languages/test_c.rs similarity index 91% rename from crates/codebook/tests/test_c.rs rename to crates/codebook/tests/languages/test_c.rs index e247625d..857eed88 100644 --- a/crates/codebook/tests/test_c.rs +++ b/crates/codebook/tests/languages/test_c.rs @@ -2,12 +2,11 @@ use codebook::{ parser::{TextRange, WordLocation}, queries::LanguageType, }; -mod utils; #[test] fn test_c_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" int calculatr(int numbr1, int numbr2, char operashun) { // This is an exampl function that performz calculashuns @@ -38,7 +37,7 @@ fn test_c_simple() { #[test] fn test_c_comment_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_c = r#" // Structur definition with misspellings "#; @@ -49,7 +48,7 @@ fn test_c_comment_location() { end_byte: 20, }], )]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_c, Some(LanguageType::C), None) .to_vec(); @@ -60,7 +59,7 @@ fn test_c_comment_location() { #[test] fn test_c_struct() { - utils::init_logging(); + super::utils::init_logging(); let sample_c = r#" struct UserAccaunt { char* usrrnamee; @@ -98,7 +97,7 @@ fn test_c_struct() { }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_c, Some(LanguageType::C), None) .to_vec(); diff --git a/crates/codebook/tests/test_config.rs b/crates/codebook/tests/languages/test_config.rs similarity index 100% rename from crates/codebook/tests/test_config.rs rename to crates/codebook/tests/languages/test_config.rs diff --git a/crates/codebook/tests/test_cpp.rs b/crates/codebook/tests/languages/test_cpp.rs similarity index 89% rename from crates/codebook/tests/test_cpp.rs rename to crates/codebook/tests/languages/test_cpp.rs index 3125931b..8b99bd45 100644 --- a/crates/codebook/tests/test_cpp.rs +++ b/crates/codebook/tests/languages/test_cpp.rs @@ -2,12 +2,11 @@ use codebook::{ parser::{TextRange, WordLocation}, queries::LanguageType, }; -mod utils; #[test] fn test_cpp_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" int calculatr(int numbr1, int numbr2, char operashun) { // This is an exampl function that performz calculashuns @@ -38,7 +37,7 @@ fn test_cpp_simple() { #[test] fn test_cpp_comment_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_cpp = r#" // Structur definition with misspellings "#; @@ -49,7 +48,7 @@ fn test_cpp_comment_location() { end_byte: 20, }], )]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_cpp, Some(LanguageType::Cpp), None) .to_vec(); @@ -60,7 +59,7 @@ fn test_cpp_comment_location() { #[test] fn test_cpp_class() { - utils::init_logging(); + super::utils::init_logging(); let sample_cpp = r#" class UserAccaunt { std::string usrrnamee; @@ -98,7 +97,7 @@ fn test_cpp_class() { }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_cpp, Some(LanguageType::Cpp), None) .to_vec(); @@ -113,8 +112,8 @@ fn test_cpp_class() { #[test] fn test_cpp_multiline_string_concat() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" const char* message = "This is a verry long string\n" @@ -136,8 +135,8 @@ fn test_cpp_multiline_string_concat() { #[test] fn test_cpp_vector_string_literals() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" std::vector mesages = { "Helo", "Wrold", "Cpp" }; "#; @@ -156,8 +155,8 @@ fn test_cpp_vector_string_literals() { #[test] fn test_cpp_stream_string_literal() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" std::cout << "Currect anser!\n youu best"; "#; diff --git a/crates/codebook/tests/test_csharp.rs b/crates/codebook/tests/languages/test_csharp.rs similarity index 89% rename from crates/codebook/tests/test_csharp.rs rename to crates/codebook/tests/languages/test_csharp.rs index 38550dd9..cc2ee5a9 100644 --- a/crates/codebook/tests/test_csharp.rs +++ b/crates/codebook/tests/languages/test_csharp.rs @@ -1,10 +1,9 @@ use codebook::queries::LanguageType; -mod utils; #[test] fn test_csharp_simple() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" class Demo { const int tesst = 5; @@ -15,7 +14,7 @@ class Demo { } "#; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::CSharp), None) .to_vec(); @@ -28,7 +27,7 @@ class Demo { #[test] fn test_csharp_strings_and_comments() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" // Comment with speling error. @@ -51,7 +50,7 @@ class DemoStrings { } "#; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::CSharp), None) .to_vec(); @@ -70,7 +69,7 @@ class DemoStrings { #[test] fn test_csharp_functions() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" class MathUtil { static int AddNumberrs(int firstt, int seconnd) { @@ -80,7 +79,7 @@ class MathUtil { } "#; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::CSharp), None) .to_vec(); diff --git a/crates/codebook/tests/test_css.rs b/crates/codebook/tests/languages/test_css.rs similarity index 88% rename from crates/codebook/tests/test_css.rs rename to crates/codebook/tests/languages/test_css.rs index b78cacad..9b229549 100644 --- a/crates/codebook/tests/test_css.rs +++ b/crates/codebook/tests/languages/test_css.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_css_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_css = r#" .test { color: red; @@ -23,7 +22,7 @@ fn test_css_location() { end_byte: 65, }], )]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_css, Some(LanguageType::Css), None) .to_vec(); diff --git a/crates/codebook/tests/languages/test_dart.rs b/crates/codebook/tests/languages/test_dart.rs new file mode 100644 index 00000000..73afe5ab --- /dev/null +++ b/crates/codebook/tests/languages/test_dart.rs @@ -0,0 +1,239 @@ +use codebook::queries::LanguageType; + +#[test] +fn test_dart_simple() { + super::utils::init_logging(); + let processor = super::utils::get_processor(); + let sample_text = r#" +import 'dart:math'; +import 'package:flutter/materail.dart'; + +/// A documntation comment +class MyWidgett extends StatelessWidget { + final String titlee; + final int countr; + + const MyWidgett({required this.titlee, required this.countr}); + + // Regular coment with misspeling + String getMessge() { + var greting = "Helllo Worlld"; + if (countr == 0) { + return "No itemms"; + } + return greting + " numbr $countr"; + } + + /* Block coment + * with misspeled words + */ + List getItemms() { + return ["firstt", "seconnd", "thirdd"]; + } +} + +enum Statuss { + activve, + inacive, +} + "#; + let expected = vec![ + "Helllo", + "Itemms", + "Messge", + "Statuss", + "Widgett", + "Worlld", + "activve", + "coment", + "countr", + "documntation", + "firstt", + "greting", + "inacive", + "itemms", + "misspeled", + "misspeling", + "numbr", + "seconnd", + "thirdd", + "titlee", + ]; + let not_expected = vec![ + "dart", // import URI content + "flutter", // import URI content + "materail", // import URI content (misspelled but in import) + "package", // import URI content + ]; + let binding = processor + .spell_check(sample_text, Some(LanguageType::Dart), None) + .to_vec(); + let mut misspelled = binding + .iter() + .map(|r| r.word.as_str()) + .collect::>(); + misspelled.sort(); + println!("Misspelled words: {misspelled:?}"); + assert_eq!(misspelled, expected); + for word in ¬_expected { + assert!( + !misspelled.contains(word), + "'{word}' should not be spell-checked (import URI)" + ); + } +} + +#[test] +fn test_dart_string_interpolation() { + super::utils::init_logging(); + let processor = super::utils::get_processor(); + let sample_text = r#" +class Foo { + String usrname = "bob"; + + void doStuff() { + var greting = "Helllo"; + logg('Deleeted accaunt for $usrname'); + print("Greting is $greting and numbr ${usrname.length}"); + } +} + "#; + let binding = processor + .spell_check(sample_text, Some(LanguageType::Dart), None) + .to_vec(); + let mut misspelled: Vec<&str> = binding.iter().map(|r| r.word.as_str()).collect(); + misspelled.sort(); + println!("Misspelled words: {misspelled:?}"); + + let expected = vec![ + "Deleeted", + "Greting", + "Helllo", + "accaunt", + "greting", + "numbr", + "usrname", + ]; + let not_expected = vec![ + "bob", // string content, valid word + "logg", // function call (reference, not definition) + "length", // interpolation expression member + ]; + assert_eq!(misspelled, expected); + for word in ¬_expected { + assert!( + !misspelled.contains(word), + "'{word}' should not be spell-checked (interpolation)" + ); + } +} + +#[test] +fn test_dart_class_fields() { + super::utils::init_logging(); + let processor = super::utils::get_processor(); + let sample_text = r#" +class UserAccaunt { + final String usrname; + final Map _accaunts = {}; + int _balanse = 0; +} + "#; + let binding = processor + .spell_check(sample_text, Some(LanguageType::Dart), None) + .to_vec(); + let mut misspelled: Vec<&str> = binding.iter().map(|r| r.word.as_str()).collect(); + misspelled.sort(); + println!("Misspelled words: {misspelled:?}"); + + // Class fields should be flagged at definitions + assert!(misspelled.contains(&"usrname"), "class field 'usrname' should be flagged"); + assert!(misspelled.contains(&"accaunts"), "class field '_accaunts' should be flagged"); + assert!(misspelled.contains(&"balanse"), "class field '_balanse' should be flagged"); + assert!(misspelled.contains(&"Accaunt"), "class name 'UserAccaunt' should be flagged at definition"); + + // Type references should NOT be flagged + let type_ref_words = vec!["String", "Map", "int"]; + for word in &type_ref_words { + assert!( + !misspelled.contains(word), + "type reference '{word}' should not be spell-checked" + ); + } +} + +#[test] +fn test_dart_arrow_body_strings() { + super::utils::init_logging(); + let processor = super::utils::get_processor(); + let sample_text = r#" +class Foo { + String usrname = "bob"; + int _balanse = 0; + + @override + String toString() => 'Accaunt(usrname: $usrname, balanse: $_balanse)'; +} + "#; + let binding = processor + .spell_check(sample_text, Some(LanguageType::Dart), None) + .to_vec(); + let mut misspelled: Vec<&str> = binding.iter().map(|r| r.word.as_str()).collect(); + misspelled.sort(); + println!("Misspelled words: {misspelled:?}"); + + // Arrow body string content should be checked + assert!(misspelled.contains(&"Accaunt"), "string in arrow body should be checked"); + assert!(misspelled.contains(&"balanse"), "field definition should be flagged"); + assert!(misspelled.contains(&"usrname"), "field definition should be flagged"); +} + +#[test] +fn test_dart_type_references_not_flagged() { + super::utils::init_logging(); + let processor = super::utils::get_processor(); + let sample_text = r#" +typedef MyCallbak = void Function(int); + +mixin Loggabel {} + +class Foo with Loggabel { + final Map> dataa = {}; + final MyCallbak? callbak; + + Foo({required this.dataa, this.callbak}); + + Future> fetchStuf() async { + return []; + } +} + "#; + let binding = processor + .spell_check(sample_text, Some(LanguageType::Dart), None) + .to_vec(); + let mut misspelled: Vec<&str> = binding.iter().map(|r| r.word.as_str()).collect(); + misspelled.sort(); + println!("Misspelled words: {misspelled:?}"); + + // Definitions should be flagged + assert!(misspelled.contains(&"Callbak"), "typedef name should be flagged"); + assert!(misspelled.contains(&"Loggabel"), "mixin name should be flagged"); + assert!(misspelled.contains(&"dataa"), "field name should be flagged"); + assert!(misspelled.contains(&"callbak"), "field name should be flagged"); + assert!(misspelled.contains(&"Stuf"), "method name should be flagged"); + + // Type references should NOT be flagged + let not_expected = vec![ + "Map", "String", "List", "int", "Future", "Loggabel", "MyCallbak", + ]; + for word in ¬_expected { + // Skip words that are also flagged as definitions + if *word == "Loggabel" || *word == "MyCallbak" { + continue; + } + assert!( + !misspelled.contains(word), + "type reference '{word}' should not be spell-checked" + ); + } +} diff --git a/crates/codebook/tests/test_elixir.rs b/crates/codebook/tests/languages/test_elixir.rs similarity index 93% rename from crates/codebook/tests/test_elixir.rs rename to crates/codebook/tests/languages/test_elixir.rs index 0ee2d863..f1187ac8 100644 --- a/crates/codebook/tests/test_elixir.rs +++ b/crates/codebook/tests/languages/test_elixir.rs @@ -2,12 +2,11 @@ use codebook::{ parser::{TextRange, WordLocation}, queries::LanguageType, }; -mod utils; #[test] fn test_elixir_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" defmodule Calculatr do # This is an exampl module that performz calculashuns @@ -39,7 +38,7 @@ fn test_elixir_simple() { #[test] fn test_elixir_comment_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_elixir = r#" # Structur definition with misspellings "#; @@ -50,7 +49,7 @@ fn test_elixir_comment_location() { end_byte: 19, }], )]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_elixir, Some(LanguageType::Elixir), None) .to_vec(); @@ -61,7 +60,7 @@ fn test_elixir_comment_location() { #[test] fn test_elixir_module() { - utils::init_logging(); + super::utils::init_logging(); let sample_elixir = r#" defmodule UserAccaunt do @moduledoc """ @@ -154,7 +153,7 @@ fn test_elixir_module() { }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_elixir, Some(LanguageType::Elixir), None) .to_vec(); @@ -172,7 +171,7 @@ fn test_elixir_module() { #[test] fn test_elixir_functions() { - utils::init_logging(); + super::utils::init_logging(); let sample_elixir = r#" defmodule ProcessingPipeline do # Handles incomming data procesing @@ -213,7 +212,7 @@ fn test_elixir_functions() { "transfrom", "validatte", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_elixir, Some(LanguageType::Elixir), None) .to_vec(); @@ -228,7 +227,7 @@ fn test_elixir_functions() { #[test] fn test_elixir_pattern_matching() { - utils::init_logging(); + super::utils::init_logging(); let sample_elixir = r#" defmodule PatternMatcher do def handle_responce({:ok, resalt}) do @@ -252,7 +251,7 @@ fn test_elixir_pattern_matching() { "responce", "succes", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_elixir, Some(LanguageType::Elixir), None) .to_vec(); diff --git a/crates/codebook/tests/test_erlang.rs b/crates/codebook/tests/languages/test_erlang.rs similarity index 90% rename from crates/codebook/tests/test_erlang.rs rename to crates/codebook/tests/languages/test_erlang.rs index d485ab11..d28d8e0a 100644 --- a/crates/codebook/tests/test_erlang.rs +++ b/crates/codebook/tests/languages/test_erlang.rs @@ -2,12 +2,11 @@ use codebook::{ parser::{TextRange, WordLocation}, queries::LanguageType, }; -mod utils; #[test] fn test_erlang_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" -module(calculatr). % This is an exampl module that performz calculashuns @@ -39,7 +38,7 @@ fn test_erlang_simple() { #[test] fn test_erlang_comment_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_erlang = r#" % Structur definition with misspellings "#; @@ -50,7 +49,7 @@ fn test_erlang_comment_location() { end_byte: 19, }], )]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_erlang, Some(LanguageType::Erlang), None) .to_vec(); @@ -61,7 +60,7 @@ fn test_erlang_comment_location() { #[test] fn test_erlang_pattern_matching() { - utils::init_logging(); + super::utils::init_logging(); let sample_erlang = r#" -module(example). -export([handle_response/1]). @@ -83,7 +82,7 @@ fn test_erlang_pattern_matching() { "notfication", "succes", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_erlang, Some(LanguageType::Erlang), None) .to_vec(); diff --git a/crates/codebook/tests/test_files.rs b/crates/codebook/tests/languages/test_files.rs similarity index 90% rename from crates/codebook/tests/test_files.rs rename to crates/codebook/tests/languages/test_files.rs index 7acafa13..192a081f 100644 --- a/crates/codebook/tests/test_files.rs +++ b/crates/codebook/tests/languages/test_files.rs @@ -3,7 +3,6 @@ use codebook::{ queries::LanguageType, }; -mod utils; fn example_file_path(file: &str) -> String { // get root of the project through CARGO_MANIFEST_DIR @@ -12,16 +11,16 @@ fn example_file_path(file: &str) -> String { #[test] fn test_ignore_file() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let results = processor.spell_check("badword", None, Some("ignore.txt")); assert_eq!(results.len(), 0); } #[test] fn test_include_paths_allowlist() { - utils::init_logging(); - let processor = utils::get_processor_with_include("**/*.rs"); + super::utils::init_logging(); + let processor = super::utils::get_processor_with_include("**/*.rs"); assert!( !processor .spell_check("badword", Some(LanguageType::Text), Some("src/main.rs")) @@ -36,8 +35,8 @@ fn test_include_paths_allowlist() { #[test] fn test_include_paths_empty_includes_everything() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); assert!( !processor .spell_check("badword", Some(LanguageType::Text), Some("src/main.rs")) @@ -52,8 +51,8 @@ fn test_include_paths_empty_includes_everything() { #[test] fn test_ignore_paths_takes_precedence_over_include_paths() { - utils::init_logging(); - let processor = utils::get_processor_with_include_and_ignore("**/*.rs", "**/*.rs"); + super::utils::init_logging(); + let processor = super::utils::get_processor_with_include_and_ignore("**/*.rs", "**/*.rs"); assert_eq!( processor .spell_check("badword", Some(LanguageType::Text), Some("src/main.rs")) @@ -64,7 +63,7 @@ fn test_ignore_paths_takes_precedence_over_include_paths() { #[test] fn test_example_files_word_locations() { - utils::init_logging(); + super::utils::init_logging(); let files: Vec<(&str, Vec)> = vec![ ( "example.py", @@ -128,7 +127,7 @@ fn test_example_files_word_locations() { let path = example_file_path(file.0); println!("Checking file: {path:?}"); let text = std::fs::read_to_string(path).unwrap(); - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let results = processor.spell_check(&text, Some(LanguageType::Text), None); println!("Misspelled words: {results:?}"); for expected in file.1 { @@ -140,7 +139,7 @@ fn test_example_files_word_locations() { #[test] fn test_example_files() { - utils::init_logging(); + super::utils::init_logging(); let files = [ ("example.html", vec!["Spelin", "Wolrd", "sor"]), ("example.py", vec!["Pthon", "Wolrd"]), @@ -196,7 +195,7 @@ fn test_example_files() { for mut file in files { let path = example_file_path(file.0); println!("---------- Checking file: {path:?} ----------"); - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let results = processor.spell_check_file(&path); let mut misspelled = results .iter() diff --git a/crates/codebook/tests/test_go.rs b/crates/codebook/tests/languages/test_go.rs similarity index 97% rename from crates/codebook/tests/test_go.rs rename to crates/codebook/tests/languages/test_go.rs index 1b8bff7f..53e4dd6f 100644 --- a/crates/codebook/tests/test_go.rs +++ b/crates/codebook/tests/languages/test_go.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_go_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" package pacagename import myfmt "fmt" @@ -237,7 +236,7 @@ fn test_go_location() { ), ]; let not_expected = ["fmt"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Go), None) .to_vec(); @@ -258,7 +257,7 @@ fn test_go_location() { #[test] fn test_go_imports_not_checked() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" package main @@ -272,7 +271,7 @@ fn test_go_imports_not_checked() { func main() { fmt.Println("hello") }"#; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Go), None) .to_vec(); diff --git a/crates/codebook/tests/test_haskell.rs b/crates/codebook/tests/languages/test_haskell.rs similarity index 85% rename from crates/codebook/tests/test_haskell.rs rename to crates/codebook/tests/languages/test_haskell.rs index bffe8517..7a52abbf 100644 --- a/crates/codebook/tests/test_haskell.rs +++ b/crates/codebook/tests/languages/test_haskell.rs @@ -1,10 +1,9 @@ use codebook::queries::LanguageType; -mod utils; #[test] fn test_haskell_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" func myArrg = do calculatr <- makeCowculator @@ -24,8 +23,8 @@ fn test_haskell_simple() { #[test] fn test_haskell_string() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" let str = "herlo, world" in str @@ -44,8 +43,8 @@ fn test_haskell_string() { #[test] fn test_haskell_module() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" import Data.Functoin as Func import Data.Function qualified as D.Funcc @@ -64,8 +63,8 @@ fn test_haskell_module() { #[test] fn test_haskell_types() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" func :: forall badd . (MyTypeeClass var) => varr -> Intt func = varToInt diff --git a/crates/codebook/tests/test_java.rs b/crates/codebook/tests/languages/test_java.rs similarity index 97% rename from crates/codebook/tests/test_java.rs rename to crates/codebook/tests/languages/test_java.rs index b82c5a2e..4642095b 100644 --- a/crates/codebook/tests/test_java.rs +++ b/crates/codebook/tests/languages/test_java.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_java_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" // Singl-line comment /* Blck comment */ @@ -137,7 +136,7 @@ fn test_java_location() { "Mthod", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Java), None) .to_vec(); diff --git a/crates/codebook/tests/test_javascript.rs b/crates/codebook/tests/languages/test_javascript.rs similarity index 96% rename from crates/codebook/tests/test_javascript.rs rename to crates/codebook/tests/languages/test_javascript.rs index f43e19e0..c553e82e 100644 --- a/crates/codebook/tests/test_javascript.rs +++ b/crates/codebook/tests/languages/test_javascript.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_javascript_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" import { useState } from 'react'; @@ -98,7 +97,7 @@ fn test_javascript_location() { "incluudes", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Javascript), None) .to_vec(); diff --git a/crates/codebook/tests/test_latex.rs b/crates/codebook/tests/languages/test_latex.rs similarity index 91% rename from crates/codebook/tests/test_latex.rs rename to crates/codebook/tests/languages/test_latex.rs index 1601ae15..fd139b51 100644 --- a/crates/codebook/tests/test_latex.rs +++ b/crates/codebook/tests/languages/test_latex.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_latex_comments() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" % This is a coment with a typo % Another commnet with wrng spelling @@ -37,7 +36,7 @@ fn test_latex_comments() { ), ]; let not_expected = vec!["documentclass", "article"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Latex), None) .to_vec(); @@ -57,14 +56,14 @@ fn test_latex_comments() { #[test] fn test_latex_text_content() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" \section{Introducton} This is an exampl of text with speling errors. "#; let expected = vec!["Introducton", "exampl", "speling"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_text, Some(LanguageType::Latex), None) .to_vec(); @@ -79,7 +78,7 @@ This is an exampl of text with speling errors. #[test] fn test_latex_sections_and_text() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" \section{Methology} @@ -97,7 +96,7 @@ In this secion we discuss importnt concepts. "methology", "secion", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_text, Some(LanguageType::Latex), None) .to_vec(); @@ -112,7 +111,7 @@ In this secion we discuss importnt concepts. #[test] fn test_latex_itemize() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" \begin{itemize} \item First itm with algoritm @@ -120,7 +119,7 @@ fn test_latex_itemize() { \end{itemize} "#; let expected = vec!["algoritm", "itm"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_text, Some(LanguageType::Latex), None) .to_vec(); @@ -135,7 +134,7 @@ fn test_latex_itemize() { #[test] fn test_latex_mixed_content() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" % Comment: calcuate the result \section{Resuts} @@ -158,7 +157,7 @@ As shown in Equation~\ref{eq:enrgy}, the relatioship is clear. "resuts", ]; let not_expected = vec!["equation", "label", "ref", "begin", "end", "section"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_text, Some(LanguageType::Latex), None) .to_vec(); @@ -176,7 +175,7 @@ As shown in Equation~\ref{eq:enrgy}, the relatioship is clear. #[test] fn test_latex_comprehensive() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" \documentclass{article} @@ -217,7 +216,7 @@ The analyss reveals paterns in the data. "section", "subsection", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let binding = processor .spell_check(sample_text, Some(LanguageType::Latex), None) .to_vec(); diff --git a/crates/codebook/tests/test_lua.rs b/crates/codebook/tests/languages/test_lua.rs similarity index 90% rename from crates/codebook/tests/test_lua.rs rename to crates/codebook/tests/languages/test_lua.rs index 8c8bcd51..605c57a4 100644 --- a/crates/codebook/tests/test_lua.rs +++ b/crates/codebook/tests/languages/test_lua.rs @@ -1,11 +1,10 @@ use codebook::queries::LanguageType; -mod utils; #[test] fn test_lua_spell_check() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" -- This is a commet with a misspelling @@ -50,8 +49,8 @@ local data = { #[test] fn test_lua_word_locations() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#"-- Simple commet local function test_func() @@ -74,8 +73,8 @@ end"#; #[test] fn test_lua_comments() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" -- This is a coment with misspeling @@ -96,8 +95,8 @@ local x = 1 -- inline coment #[test] fn test_lua_strings() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" local single = 'This is a strng with misspeling' @@ -119,8 +118,8 @@ local multi = [[ #[test] fn test_lua_identifiers() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" local functoin = function() end @@ -154,8 +153,8 @@ end #[test] fn test_lua_tables() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" local config = { @@ -183,8 +182,8 @@ local config = { #[test] fn test_lua_camel_case() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" local myVaribleNam = 1 @@ -206,8 +205,8 @@ local getUserInformaton = function() end #[test] fn test_lua_snake_case() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let lua_code = r#" local my_varible_nam = 1 @@ -227,8 +226,8 @@ local calculat_reslt = function() end #[test] fn test_lua_no_false_positives() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Code with correct spelling - should not produce any results let lua_code = r#" diff --git a/crates/codebook/tests/test_markdown.rs b/crates/codebook/tests/languages/test_markdown.rs similarity index 89% rename from crates/codebook/tests/test_markdown.rs rename to crates/codebook/tests/languages/test_markdown.rs index 93ba8362..4b25b60e 100644 --- a/crates/codebook/tests/test_markdown.rs +++ b/crates/codebook/tests/languages/test_markdown.rs @@ -3,12 +3,11 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_markdown_paragraph() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = "Some paragraph text with a misspeled word.\n"; let expected = [WordLocation::new( "misspeled".to_string(), @@ -28,8 +27,8 @@ fn test_markdown_paragraph() { #[test] fn test_markdown_heading() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = "# A headng with a tyypo\n"; let misspelled = processor .spell_check(sample_text, Some(LanguageType::Markdown), None) @@ -42,8 +41,8 @@ fn test_markdown_heading() { #[test] fn test_markdown_fenced_code_block_known_lang() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Note: bash.scm only captures comments, strings, function names, // heredocs, and variable names, NOT command invocations. // So mkdir/some_dir are not checked because bash.scm doesn't capture them, @@ -70,8 +69,8 @@ More correct text here. #[test] fn test_markdown_fenced_code_block_unknown_lang_skipped() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#"Some text. ```unknownlang @@ -91,8 +90,8 @@ More text. #[test] fn test_markdown_fenced_code_block_no_lang_skipped() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#"Some text. ``` @@ -112,8 +111,8 @@ More text. #[test] fn test_markdown_code_block_uses_language_grammar() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // In Python grammar, function names are checked as identifiers let sample_text = r#"A paragrap with a tyypo. @@ -138,8 +137,8 @@ Another paragrap with a tyypo. #[test] fn test_markdown_multiple_code_blocks() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#"Some text with a tyypo. ```bash @@ -169,8 +168,8 @@ End text is also corect. #[test] fn test_markdown_block_quote() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = "> A block quoet with a tyypo.\n"; let misspelled = processor .spell_check(sample_text, Some(LanguageType::Markdown), None) @@ -183,8 +182,8 @@ fn test_markdown_block_quote() { #[test] fn test_markdown_code_block_alias_resolution() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Test that common aliases work (py -> Python, js -> Javascript, etc.) let sample_text = r#"Some text. @@ -215,8 +214,8 @@ More text. #[test] fn test_markdown_injected_region_byte_offsets() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Verify that byte offsets from injected regions map back correctly // to the original document coordinates. // 0 1 2 3 @@ -243,8 +242,8 @@ fn test_markdown_injected_region_byte_offsets() { #[test] fn test_markdown_no_duplicate_spans() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Block quotes contain paragraphs. Make sure the inline content // isn't captured twice (once for the paragraph, once for the block quote) let sample_text = "> A tyypo in a block quoet.\n"; diff --git a/crates/codebook/tests/test_ocaml.rs b/crates/codebook/tests/languages/test_ocaml.rs similarity index 97% rename from crates/codebook/tests/test_ocaml.rs rename to crates/codebook/tests/languages/test_ocaml.rs index f64b79cd..a0f8dd69 100644 --- a/crates/codebook/tests/test_ocaml.rs +++ b/crates/codebook/tests/languages/test_ocaml.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_ocaml_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#" (* Commment with a typo *) type usr_recrod = { @@ -140,7 +139,7 @@ let () = "with", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::OCaml), None) .to_vec(); diff --git a/crates/codebook/tests/test_odin.rs b/crates/codebook/tests/languages/test_odin.rs similarity index 98% rename from crates/codebook/tests/test_odin.rs rename to crates/codebook/tests/languages/test_odin.rs index 9d8777f9..3dc10843 100644 --- a/crates/codebook/tests/test_odin.rs +++ b/crates/codebook/tests/languages/test_odin.rs @@ -3,12 +3,11 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_odin_location() { - utils::init_logging(); - let sample_text = include_str!("./examples/example.odin"); + super::utils::init_logging(); + let sample_text = include_str!("../examples/example.odin"); let expected = vec![ // Comments WordLocation::new( @@ -300,7 +299,7 @@ fn test_odin_location() { ), ]; let not_expected = ["fmt", "println"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Odin), None) .to_vec(); diff --git a/crates/codebook/tests/test_php.rs b/crates/codebook/tests/languages/test_php.rs similarity index 98% rename from crates/codebook/tests/test_php.rs rename to crates/codebook/tests/languages/test_php.rs index 166fcdf0..f6491986 100644 --- a/crates/codebook/tests/test_php.rs +++ b/crates/codebook/tests/languages/test_php.rs @@ -3,11 +3,10 @@ use codebook::{ queries::LanguageType, }; -mod utils; // WIP PHP Support #[test] fn test_php_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_text = r#"getUserDeetails(); "empty", ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_text, Some(LanguageType::Php), None) .to_vec(); diff --git a/crates/codebook/tests/test_python.rs b/crates/codebook/tests/languages/test_python.rs similarity index 95% rename from crates/codebook/tests/test_python.rs rename to crates/codebook/tests/languages/test_python.rs index 7cbef746..787872ab 100644 --- a/crates/codebook/tests/test_python.rs +++ b/crates/codebook/tests/languages/test_python.rs @@ -3,7 +3,6 @@ use codebook::{ queries::LanguageType, }; -mod utils; /// Strategy: /// Use distinct misspellings to test location sensitive checking. @@ -53,8 +52,8 @@ fn assert_simple_misspellings( #[test] fn test_python_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" def calculat_user_age(bithDate) -> int: # This is an examle_function that calculates age @@ -76,7 +75,7 @@ fn test_python_simple() { #[test] fn test_python_multi_line_comment() { - utils::init_logging(); + super::utils::init_logging(); let sample_python = r#" multi_line_comment = ''' This is a multi line comment with a typo: mment @@ -99,7 +98,7 @@ multi_line_comment = ''' }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_python, Some(LanguageType::Python), None) .to_vec(); @@ -113,7 +112,7 @@ multi_line_comment = ''' #[test] fn test_python_class() { - utils::init_logging(); + super::utils::init_logging(); let sample_python = r#" class BadSpelin: def nospel(self): @@ -157,7 +156,7 @@ def constructor(): ), ]; let not_expected = vec!["zzzznomethod", "hardx", "hardd"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_python, Some(LanguageType::Python), None) .to_vec(); @@ -175,8 +174,8 @@ def constructor(): #[test] fn test_python_global_variables() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" # Globul variables globalCountr = 0 @@ -237,8 +236,8 @@ mesage = "Helllo Wolrd!" #[test] fn test_python_f_strings() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" name = "John" age = 25 @@ -316,8 +315,8 @@ simple = f'check these wordz {but} {not} {the} {variables}' #[test] fn test_python_import_statements() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" import no_typpoa import no_typpob.no_typpoc @@ -347,8 +346,8 @@ fn test_python_import_statements() { #[test] fn test_python_functions() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Test simple function - function name and parameter names should be checked let simple_function = r#" diff --git a/crates/codebook/tests/test_r.rs b/crates/codebook/tests/languages/test_r.rs similarity index 86% rename from crates/codebook/tests/test_r.rs rename to crates/codebook/tests/languages/test_r.rs index 97c0ab7d..eff7ebd1 100644 --- a/crates/codebook/tests/test_r.rs +++ b/crates/codebook/tests/languages/test_r.rs @@ -1,10 +1,9 @@ use codebook::queries::LanguageType; -mod utils; #[test] fn test_r_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" calculatr <- function(numbr1, argumnt2=3) { # This is an exampl function @@ -25,8 +24,8 @@ fn test_r_simple() { #[test] fn test_r_string() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" my_var <- "herlo, world" "#; @@ -44,8 +43,8 @@ fn test_r_string() { #[test] fn test_r_kwarg() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" table2 <- dplyr::mutate(table1, mispell=nmae1 + name2, bad_spelin, olny_named_cols=3) "#; @@ -63,8 +62,8 @@ fn test_r_kwarg() { #[test] fn test_r_assign() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" list$miispell = list() list$mispell$chiian <- 1 diff --git a/crates/codebook/tests/test_regex.rs b/crates/codebook/tests/languages/test_regex.rs similarity index 93% rename from crates/codebook/tests/test_regex.rs rename to crates/codebook/tests/languages/test_regex.rs index 76f58ca2..5b26633a 100644 --- a/crates/codebook/tests/test_regex.rs +++ b/crates/codebook/tests/languages/test_regex.rs @@ -1,11 +1,10 @@ use codebook::queries::LanguageType; -mod utils; #[test] fn test_text_with_urls_should_skip_misspelled_words_in_urls() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // URLs contain "misspelled" words like "exampl", "badspeling" that should be ignored let sample_text = r#" @@ -36,8 +35,8 @@ fn test_text_with_urls_should_skip_misspelled_words_in_urls() { #[test] fn test_text_with_hex_colors_should_skip() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); // Hex colors that might contain letter patterns that look like words let sample_text = r#" @@ -68,8 +67,8 @@ fn test_text_with_hex_colors_should_skip() { #[test] fn test_text_with_emails_should_skip() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" Contact usr@exampl.com or admin@badspeling.org @@ -92,8 +91,8 @@ fn test_text_with_emails_should_skip() { #[test] fn test_python_with_urls_in_strings_should_skip() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" def fetch_data(): @@ -126,8 +125,8 @@ fn test_python_with_urls_in_strings_should_skip() { #[test] fn test_python_with_hex_colors_should_skip() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r##" def set_colors(): @@ -155,8 +154,8 @@ fn test_python_with_hex_colors_should_skip() { #[test] fn test_multiple_patterns_combined() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" Visit https://exampl.com/badspeling @@ -182,7 +181,7 @@ fn test_multiple_patterns_combined() { #[test] fn test_user_defined_regex_patterns() { - utils::init_logging(); + super::utils::init_logging(); // Create a temporary config with user-defined patterns let temp_dir = tempfile::TempDir::new().unwrap(); @@ -254,7 +253,7 @@ fn test_user_defined_regex_patterns() { #[test] fn test_pattern_matching_against_full_source() { - utils::init_logging(); + super::utils::init_logging(); // Create a temporary config with a pattern that matches vim.opt.* expressions let temp_dir = tempfile::TempDir::new().unwrap(); diff --git a/crates/codebook/tests/test_ruby.rs b/crates/codebook/tests/languages/test_ruby.rs similarity index 95% rename from crates/codebook/tests/test_ruby.rs rename to crates/codebook/tests/languages/test_ruby.rs index 2be49c92..308d38b6 100644 --- a/crates/codebook/tests/test_ruby.rs +++ b/crates/codebook/tests/languages/test_ruby.rs @@ -3,12 +3,11 @@ use codebook::{ queries::LanguageType, }; -mod utils; #[test] fn test_ruby_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" # On a sepaate line class Foo # or at the end of the lne @@ -53,7 +52,7 @@ fn test_ruby_simple() { #[test] fn test_ruby_heredoc() { - utils::init_logging(); + super::utils::init_logging(); let sample_ruby_heredocs = r#" instructions = %Q{ 1. Clickk on the "Forgot Password" link @@ -109,7 +108,7 @@ HTML }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_ruby_heredocs, Some(LanguageType::Ruby), None) .to_vec(); @@ -124,7 +123,7 @@ HTML #[test] fn test_ruby_code() { - utils::init_logging(); + super::utils::init_logging(); let sample_ruby_code = r#" def send_notfication(recipient, subject, body) # This method sends an email with potentialy misspelled content @@ -200,7 +199,7 @@ end ), ]; let not_expected = vec!["finnished"]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_ruby_code, Some(LanguageType::Ruby), None) .to_vec(); diff --git a/crates/codebook/tests/test_rust.rs b/crates/codebook/tests/languages/test_rust.rs similarity index 92% rename from crates/codebook/tests/test_rust.rs rename to crates/codebook/tests/languages/test_rust.rs index c70ba702..aa01dff1 100644 --- a/crates/codebook/tests/test_rust.rs +++ b/crates/codebook/tests/languages/test_rust.rs @@ -2,12 +2,11 @@ use codebook::{ parser::{TextRange, WordLocation}, queries::LanguageType, }; -mod utils; #[test] fn test_rust_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" fn calculat_user_age(bithDate: String) -> u32 { // This is an examle_function that calculates age @@ -30,7 +29,7 @@ fn test_rust_simple() { #[test] fn test_rust_comment_location() { - utils::init_logging(); + super::utils::init_logging(); let sample_rust = r#" // Comment with a typo: mment "#; @@ -41,7 +40,7 @@ fn test_rust_comment_location() { end_byte: 38, }], )]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_rust, Some(LanguageType::Rust), None) .to_vec(); @@ -52,7 +51,7 @@ fn test_rust_comment_location() { #[test] fn test_rust_block_comments() { - utils::init_logging(); + super::utils::init_logging(); let sample_rust = r#" /* Comment with a typos on multiple lines: mment @@ -97,7 +96,7 @@ fn test_rust_block_comments() { }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_rust, Some(LanguageType::Rust), None) .to_vec(); @@ -112,7 +111,7 @@ fn test_rust_block_comments() { #[test] fn test_rust_struct() { - utils::init_logging(); + super::utils::init_logging(); let sample_rust = r#" pub struct BadSpeler { /// Terrible spelling: dwnloader @@ -142,7 +141,7 @@ fn test_rust_struct() { }], ), ]; - let processor = utils::get_processor(); + let processor = super::utils::get_processor(); let misspelled = processor .spell_check(sample_rust, Some(LanguageType::Rust), None) .to_vec(); @@ -160,8 +159,8 @@ fn test_rust_trait_impl_function_names_not_checked() { // https://github.com/blopker/codebook/issues/225 // Function names in `impl Trait for Type` blocks should not be spell-checked // because the names are dictated by the trait, not the implementor. - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" struct MyType; @@ -191,8 +190,8 @@ fn test_rust_trait_impl_function_names_not_checked() { #[test] fn test_rust_regular_impl_function_names_checked() { // Regular impl blocks (not trait implementations) should still be spell-checked - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#" struct MyType; diff --git a/crates/codebook/tests/test_suggestions.rs b/crates/codebook/tests/languages/test_suggestions.rs similarity index 100% rename from crates/codebook/tests/test_suggestions.rs rename to crates/codebook/tests/languages/test_suggestions.rs diff --git a/crates/codebook/tests/test_svelte.rs b/crates/codebook/tests/languages/test_svelte.rs similarity index 90% rename from crates/codebook/tests/test_svelte.rs rename to crates/codebook/tests/languages/test_svelte.rs index 168fe804..010b505d 100644 --- a/crates/codebook/tests/test_svelte.rs +++ b/crates/codebook/tests/languages/test_svelte.rs @@ -1,11 +1,10 @@ use codebook::queries::LanguageType; -mod utils; #[test] fn test_svelte_simple() { - utils::init_logging(); - let processor = utils::get_processor(); + super::utils::init_logging(); + let processor = super::utils::get_processor(); let sample_text = r#"