Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .claude/settings.local.json
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
}
}
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ Codebook is in active development. As better dictionaries are added, words that
| C# | ⚠️ |
| C++ | ⚠️ |
| CSS | ⚠️ |
| Dart | ⚠️ |
| Elixir | ⚠️ |
| Erlang | ⚠️ |
| Go | ✅ |
Expand Down
1 change: 1 addition & 0 deletions crates/codebook/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions crates/codebook/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub enum LanguageType {
CSharp,
Cpp,
Css,
Dart,
Elixir,
Erlang,
Go,
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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()),
Expand Down
32 changes: 32 additions & 0 deletions crates/codebook/src/queries/dart.scm
Original file line number Diff line number Diff line change
@@ -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
37 changes: 37 additions & 0 deletions crates/codebook/tests/languages/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"#;
Expand All @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
"#;
Expand All @@ -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();
Expand All @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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"
Expand All @@ -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<std::string> mesages = { "Helo", "Wrold", "Cpp" };
"#;
Expand All @@ -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";
"#;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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();
Expand All @@ -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.

Expand All @@ -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();
Expand All @@ -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) {
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
Loading
Loading