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

Method extract_method

atomic-semantic/src/parsers/go.rs:111–131  ·  view source on GitHub ↗

Extract a method declaration (function with receiver).

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

Source from the content-addressed store, hash-verified

109
110 /// Extract a method declaration (function with receiver).
111 fn extract_method(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
112 let name_node = node.child_by_field_name("name")?;
113 let name = self.node_text(&name_node, source);
114
115 let line = node.start_position().row as u32 + 1;
116 let end_line = node.end_position().row as u32 + 1;
117
118 let exported = name.starts_with(|c: char| c.is_uppercase());
119
120 let signature = self.build_method_signature(node, source);
121
122 let mut entity = Entity::new(name, EntityKind::Method, file_path, line, end_line);
123 if let Some(sig) = signature {
124 entity = entity.with_signature(sig);
125 }
126 if exported {
127 entity.exported = true;
128 }
129
130 Some(entity)
131 }
132
133 /// Extract a type specification (struct, interface, or type alias).
134 fn extract_type_spec(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {

Callers 1

walk_treeMethod · 0.45

Calls 3

with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected