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

Method signature_of

codegraph-kernel/src/kotlin.rs:581–608  ·  view source on GitHub ↗

`(params): ReturnType` — the positional read TreeSitterExtractor's kotlin getSignature does (#1495): the `function_value_parameters` child, then the type node that follows it before the body. Verbatim source text, so it round-trips through parity byte-for-byte.

(&self, node: Node)

Source from the content-addressed store, hash-verified

579 /// then the type node that follows it before the body. Verbatim source text,
580 /// so it round-trips through parity byte-for-byte.
581 fn signature_of(&self, node: Node) -> Option<String> {
582 let mut params: Option<Node> = None;
583 let mut return_type: Option<Node> = None;
584 for i in 0..node.named_child_count() {
585 let Some(child) = node.named_child(i) else { continue };
586 if child.kind() == "function_value_parameters" {
587 params = Some(child);
588 continue;
589 }
590 if params.is_none() {
591 continue;
592 }
593 if matches!(child.kind(), "function_body" | "type_constraints") {
594 break;
595 }
596 if matches!(child.kind(), "user_type" | "nullable_type" | "function_type") {
597 return_type = Some(child);
598 break;
599 }
600 }
601 let params = params?;
602 let mut sig = self.text(params).to_string();
603 if let Some(rt) = return_type {
604 sig.push_str(": ");
605 sig.push_str(self.text(rt));
606 }
607 Some(sig)
608 }
609
610 /// extractKotlinReturnType — positional: the first user_type/nullable_type
611 /// AFTER function_value_parameters; function_body/type_constraints first →

Callers 2

extract_functionMethod · 0.45
extract_methodMethod · 0.45

Calls 1

textMethod · 0.65

Tested by

no test coverage detected