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

Method signature_of

codegraph-kernel/src/kotlin.rs:580–607  ·  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

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