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

Method extract_name

codegraph-kernel/src/tsjs/mod.rs:739–761  ·  view source on GitHub ↗

extractName / extractNameRaw for the TS/JS configs.

(&self, node: Node)

Source from the content-addressed store, hash-verified

737
738 /// extractName / extractNameRaw for the TS/JS configs.
739 fn extract_name(&self, node: Node) -> String {
740 // javascriptExtractor.resolveName: field_definition names its key the
741 // `property` field.
742 if !self.variant.is_ts() && node.kind() == "field_definition" {
743 if let Some(prop) = node.child_by_field_name("property") {
744 return self.text(prop).to_string();
745 }
746 }
747 if let Some(name_node) = node.child_by_field_name("name") {
748 return self.text(name_node).to_string();
749 }
750 if matches!(node.kind(), "arrow_function" | "function_expression") {
751 return "<anonymous>".to_string();
752 }
753 for i in 0..node.named_child_count() {
754 if let Some(c) = node.named_child(i) {
755 if matches!(c.kind(), "identifier" | "type_identifier" | "simple_identifier" | "constant") {
756 return self.text(c).to_string();
757 }
758 }
759 }
760 "<anonymous>".to_string()
761 }
762
763 /// typescriptExtractor.getSignature / javascriptExtractor.getSignature.
764 fn signature_of(&self, node: Node) -> Option<String> {

Callers 7

extract_functionMethod · 0.45
extract_classMethod · 0.45
extract_methodMethod · 0.45
extract_interfaceMethod · 0.45
extract_enumMethod · 0.45
extract_type_aliasMethod · 0.45

Calls 2

is_tsMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected