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

Method extract_method

atomic-semantic/src/parsers/java.rs:285–317  ·  view source on GitHub ↗

Extract a method declaration.

(
        &self,
        node: &Node,
        source: &str,
        file_path: &str,
        in_class: Option<&str>,
    )

Source from the content-addressed store, hash-verified

283
284 /// Extract a method declaration.
285 fn extract_method(
286 &self,
287 node: &Node,
288 source: &str,
289 file_path: &str,
290 in_class: Option<&str>,
291 ) -> Option<Entity> {
292 let name_node = node.child_by_field_name("name")?;
293 let name = self.node_text(&name_node, source);
294
295 let line = node.start_position().row as u32 + 1;
296 let end_line = node.end_position().row as u32 + 1;
297
298 let kind = if in_class.is_some() {
299 EntityKind::Method
300 } else {
301 EntityKind::Function
302 };
303
304 let exported = self.has_modifier(node, source, "public");
305
306 let signature = self.build_method_signature(node, source);
307
308 let mut entity = Entity::new(name, kind, file_path, line, end_line);
309 if let Some(sig) = signature {
310 entity = entity.with_signature(sig);
311 }
312 if exported {
313 entity.exported = true;
314 }
315
316 Some(entity)
317 }
318
319 /// Extract a constructor declaration.
320 fn extract_constructor(

Callers 1

walk_treeMethod · 0.45

Calls 4

has_modifierMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45

Tested by

no test coverage detected