MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / build_method_signature

Method build_method_signature

atomic-semantic/src/parsers/java.rs:502–549  ·  view source on GitHub ↗

Build a method signature string.

(&self, node: &Node, source: &str)

Source from the content-addressed store, hash-verified

500
501 /// Build a method signature string.
502 fn build_method_signature(&self, node: &Node, source: &str) -> Option<String> {
503 let name_node = node.child_by_field_name("name")?;
504 let name = self.node_text(&name_node, source);
505
506 let vis = self.get_visibility(node, source);
507 let is_static = self.has_modifier(node, source, "static");
508 let is_abstract = self.has_modifier(node, source, "abstract");
509
510 let return_type = node
511 .child_by_field_name("type")
512 .map(|n| self.node_text(&n, source))
513 .unwrap_or_else(|| "void".to_string());
514
515 let params = node
516 .child_by_field_name("parameters")
517 .map(|n| self.node_text(&n, source))
518 .unwrap_or_else(|| "()".to_string());
519
520 // Check for type parameters on the method itself
521 let type_params = node
522 .child_by_field_name("type_parameters")
523 .map(|n| format!("{} ", self.node_text(&n, source)))
524 .unwrap_or_default();
525
526 let mut parts = Vec::new();
527 if !vis.is_empty() {
528 parts.push(vis.trim().to_string());
529 }
530 if is_static {
531 parts.push("static".to_string());
532 }
533 if is_abstract {
534 parts.push("abstract".to_string());
535 }
536 parts.push(format!("{}{}", type_params, return_type));
537 parts.push(format!("{}{}", name, params));
538
539 // Check for throws
540 let mut cursor = node.walk();
541 for child in node.children(&mut cursor) {
542 if child.kind() == "throws" {
543 parts.push(format!("throws {}", self.node_text(&child, source)));
544 break;
545 }
546 }
547
548 Some(parts.join(" "))
549 }
550
551 // ── Helpers ─────────────────────────────────────────────────────
552

Callers 1

extract_methodMethod · 0.45

Calls 8

get_visibilityMethod · 0.80
has_modifierMethod · 0.80
walkMethod · 0.80
childrenMethod · 0.80
node_textMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected