From 42dff3c441c061c3f3e40ca74716fda7dd9ec274 Mon Sep 17 00:00:00 2001 From: Zach Breit Date: Sat, 23 May 2026 13:44:34 -0400 Subject: [PATCH] C: don't spell-check type usages Don't spell-check uses of C enums, structs, and unions. --- crates/codebook/src/queries/c.scm | 9 ++++++--- crates/codebook/tests/languages/test_c.rs | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/crates/codebook/src/queries/c.scm b/crates/codebook/src/queries/c.scm index 9780926..578065f 100644 --- a/crates/codebook/src/queries/c.scm +++ b/crates/codebook/src/queries/c.scm @@ -7,9 +7,11 @@ (type_definition declarator: (type_identifier) @identifier.type) (struct_specifier - name: (type_identifier) @identifier.type) + name: (type_identifier) @identifier.type + body: _) (union_specifier - name: (type_identifier) @identifier.type) + name: (type_identifier) @identifier.type + body: _) (field_declaration declarator: (field_identifier) @identifier.field) (pointer_declarator @@ -17,7 +19,8 @@ (array_declarator declarator: (field_identifier) @identifier.field) (enum_specifier - name: (type_identifier) @identifier.type) + name: (type_identifier) @identifier.type + body: _) (enumerator name: (identifier) @identifier.constant) (init_declarator diff --git a/crates/codebook/tests/languages/test_c.rs b/crates/codebook/tests/languages/test_c.rs index d231e0e..a1b345c 100644 --- a/crates/codebook/tests/languages/test_c.rs +++ b/crates/codebook/tests/languages/test_c.rs @@ -475,3 +475,17 @@ fn test_c_enum() { misspelled.sort_by(|loc1, loc2| loc1.word.cmp(&loc2.word)); assert_eq!(misspelled, expected); } + +#[test] +fn test_c_type_uses() { + super::utils::init_logging(); + let sample_text = r#" + enum Colorr color; + union Dataa data; + struct Userr user; + "#; + + let processor = super::utils::get_processor(); + let misspelled = processor.spell_check(sample_text, Some(LanguageType::C), None); + assert_eq!(misspelled, []); +}