MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / signature_of

Method signature_of

codegraph-kernel/src/dart.rs:621–653  ·  view source on GitHub ↗

getSignature (dart.ts:189-208).

(&self, node: Node<'t>)

Source from the content-addressed store, hash-verified

619
620 /// getSignature (dart.ts:189-208).
621 fn signature_of(&self, node: Node<'t>) -> Option<String> {
622 let sig = self.inner_signature(node);
623 let mut c1 = sig.walk();
624 let params = sig
625 .named_children(&mut c1)
626 .find(|c| c.kind() == "formal_parameter_list");
627 // A constructor has no return type: the type a redirecting factory
628 // names is its target (`= _Impl`).
629 let mut c2 = sig.walk();
630 let ret = if is_bodiless_ctor(sig.kind()) {
631 None
632 } else {
633 sig.named_children(&mut c2)
634 .find(|c| matches!(c.kind(), "type_identifier" | "void_type"))
635 };
636 if params.is_none() && ret.is_none() {
637 return None;
638 }
639 let mut result = String::new();
640 if let Some(r) = ret {
641 result.push_str(self.text(r));
642 result.push(' ');
643 }
644 if let Some(p) = params {
645 result.push_str(self.text(p));
646 }
647 let trimmed = result.trim();
648 if trimmed.is_empty() {
649 None
650 } else {
651 Some(trimmed.to_string())
652 }
653 }
654
655 /// getVisibility (dart.ts:209-222) — `_` prefix = private; every
656 /// constructor is public (the unwrap misses ctor signatures / the name

Callers 2

extract_functionMethod · 0.45
extract_methodMethod · 0.45

Calls 5

is_bodiless_ctorFunction · 0.85
inner_signatureMethod · 0.80
walkMethod · 0.80
pushMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected