Skip to content

Commit caadf07

Browse files
unhappychoiceclaude
andcommitted
fix: resolve clippy warnings in Haskell extractor
- Extract recursive helper functions to avoid 'only_used_in_recursion' warnings - Move find_child_by_kind_impl and extract_name_from_node_impl to module level - Maintain same functionality while satisfying clippy requirements 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a224121 commit caadf07

File tree

1 file changed

+52
-44
lines changed

1 file changed

+52
-44
lines changed

src/extractor/parsers/haskell.rs

Lines changed: 52 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -128,53 +128,11 @@ impl HaskellExtractor {
128128
}
129129

130130
fn find_child_by_kind(&self, node: Node, source_code: &str, kind: &str) -> Option<String> {
131-
let mut cursor = node.walk();
132-
if cursor.goto_first_child() {
133-
loop {
134-
let child = cursor.node();
135-
if child.kind() == kind {
136-
return child
137-
.utf8_text(source_code.as_bytes())
138-
.ok()
139-
.map(|s| s.to_string());
140-
}
141-
// Recursively search in child nodes
142-
if let Some(name) = self.find_child_by_kind(child, source_code, kind) {
143-
return Some(name);
144-
}
145-
if !cursor.goto_next_sibling() {
146-
break;
147-
}
148-
}
149-
}
150-
None
131+
find_child_by_kind_impl(node, source_code, kind)
151132
}
152133

153134
fn extract_name_from_node(&self, node: Node, source_code: &str) -> Option<String> {
154-
let mut cursor = node.walk();
155-
if cursor.goto_first_child() {
156-
loop {
157-
let child = cursor.node();
158-
match child.kind() {
159-
"variable" | "type" | "module_name" | "constructor" => {
160-
return child
161-
.utf8_text(source_code.as_bytes())
162-
.ok()
163-
.map(|s| s.to_string());
164-
}
165-
_ => {
166-
// Recursively search in child nodes
167-
if let Some(name) = self.extract_name_from_node(child, source_code) {
168-
return Some(name);
169-
}
170-
}
171-
}
172-
if !cursor.goto_next_sibling() {
173-
break;
174-
}
175-
}
176-
}
177-
None
135+
extract_name_from_node_impl(node, source_code)
178136
}
179137

180138
pub fn create_parser() -> Result<Parser> {
@@ -187,3 +145,53 @@ impl HaskellExtractor {
187145
Ok(parser)
188146
}
189147
}
148+
149+
fn find_child_by_kind_impl(node: Node, source_code: &str, kind: &str) -> Option<String> {
150+
let mut cursor = node.walk();
151+
if cursor.goto_first_child() {
152+
loop {
153+
let child = cursor.node();
154+
if child.kind() == kind {
155+
return child
156+
.utf8_text(source_code.as_bytes())
157+
.ok()
158+
.map(|s| s.to_string());
159+
}
160+
// Recursively search in child nodes
161+
if let Some(name) = find_child_by_kind_impl(child, source_code, kind) {
162+
return Some(name);
163+
}
164+
if !cursor.goto_next_sibling() {
165+
break;
166+
}
167+
}
168+
}
169+
None
170+
}
171+
172+
fn extract_name_from_node_impl(node: Node, source_code: &str) -> Option<String> {
173+
let mut cursor = node.walk();
174+
if cursor.goto_first_child() {
175+
loop {
176+
let child = cursor.node();
177+
match child.kind() {
178+
"variable" | "type" | "module_name" | "constructor" => {
179+
return child
180+
.utf8_text(source_code.as_bytes())
181+
.ok()
182+
.map(|s| s.to_string());
183+
}
184+
_ => {
185+
// Recursively search in child nodes
186+
if let Some(name) = extract_name_from_node_impl(child, source_code) {
187+
return Some(name);
188+
}
189+
}
190+
}
191+
if !cursor.goto_next_sibling() {
192+
break;
193+
}
194+
}
195+
}
196+
None
197+
}

0 commit comments

Comments
 (0)