Skip to content

Commit c2a08f7

Browse files
authored
Fix #94: Add query for Ruby method names (#97)
1 parent 544eba3 commit c2a08f7

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

crates/codebook/src/queries/ruby.scm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
(method_parameters (keyword_parameter (identifier) @identifier)))
66
(method
77
(method_parameters (identifier) @identifier))
8+
(method name: (identifier) @identifier)
89
(heredoc_body
910
(heredoc_content) @string
1011
(heredoc_end) @language

crates/codebook/tests/test_ruby.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ fn test_ruby_simple() {
1515
# can be inented
1616
def bar
1717
end
18+
def opttions
19+
end
1820
end
1921
2022
=begin
@@ -35,7 +37,7 @@ fn test_ruby_simple() {
3537
symbol = :hello
3638
"#;
3739
let expected = vec![
38-
"comented", "helo", "inented", "lne", "lteral", "sepaate", "wors",
40+
"comented", "helo", "inented", "lne", "lteral", "opttions", "sepaate", "wors",
3941
];
4042
let binding = processor
4143
.spell_check(sample_text, Some(LanguageType::Ruby), None)
@@ -161,6 +163,14 @@ end
161163
line: 11,
162164
}],
163165
),
166+
WordLocation::new(
167+
"notfication".to_string(),
168+
vec![TextRange {
169+
start_char: 9,
170+
end_char: 20,
171+
line: 1,
172+
}],
173+
),
164174
WordLocation::new(
165175
"Regads".to_string(),
166176
vec![TextRange {
@@ -202,7 +212,7 @@ end
202212
}],
203213
),
204214
];
205-
let not_expected = vec!["finnished", "notfication"];
215+
let not_expected = vec!["finnished"];
206216
let processor = utils::get_processor();
207217
let misspelled = processor
208218
.spell_check(sample_ruby_code, Some(LanguageType::Ruby), None)

examples/example.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ class Foo # or at the end of the lne
33
# can be inented
44
def bar
55
end
6+
def opttions
7+
# opttions
8+
"opttions"
9+
end
610
end
711

812
=begin

0 commit comments

Comments
 (0)