Skip to content

Commit c06cced

Browse files
authored
C: don't spell-check type usages (#279)
Don't spell-check uses of C enums, structs, and unions.
1 parent a018baa commit c06cced

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

crates/codebook/src/queries/c.scm

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,20 @@
77
(type_definition
88
declarator: (type_identifier) @identifier.type)
99
(struct_specifier
10-
name: (type_identifier) @identifier.type)
10+
name: (type_identifier) @identifier.type
11+
body: _)
1112
(union_specifier
12-
name: (type_identifier) @identifier.type)
13+
name: (type_identifier) @identifier.type
14+
body: _)
1315
(field_declaration
1416
declarator: (field_identifier) @identifier.field)
1517
(pointer_declarator
1618
declarator: (field_identifier) @identifier.field)
1719
(array_declarator
1820
declarator: (field_identifier) @identifier.field)
1921
(enum_specifier
20-
name: (type_identifier) @identifier.type)
22+
name: (type_identifier) @identifier.type
23+
body: _)
2124
(enumerator
2225
name: (identifier) @identifier.constant)
2326
(init_declarator

crates/codebook/tests/languages/test_c.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,17 @@ fn test_c_enum() {
475475
misspelled.sort_by(|loc1, loc2| loc1.word.cmp(&loc2.word));
476476
assert_eq!(misspelled, expected);
477477
}
478+
479+
#[test]
480+
fn test_c_type_uses() {
481+
super::utils::init_logging();
482+
let sample_text = r#"
483+
enum Colorr color;
484+
union Dataa data;
485+
struct Userr user;
486+
"#;
487+
488+
let processor = super::utils::get_processor();
489+
let misspelled = processor.spell_check(sample_text, Some(LanguageType::C), None);
490+
assert_eq!(misspelled, []);
491+
}

0 commit comments

Comments
 (0)