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

Method extract_constructor

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

Extract a constructor declaration.

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

Source from the content-addressed store, hash-verified

318
319 /// Extract a constructor declaration.
320 fn extract_constructor(
321 &self,
322 node: &Node,
323 source: &str,
324 file_path: &str,
325 _in_class: Option<&str>,
326 ) -> Option<Entity> {
327 let name_node = node.child_by_field_name("name")?;
328 let name = self.node_text(&name_node, source);
329
330 let line = node.start_position().row as u32 + 1;
331 let end_line = node.end_position().row as u32 + 1;
332
333 let exported = self.has_modifier(node, source, "public");
334
335 let params = node
336 .child_by_field_name("parameters")
337 .map(|n| self.node_text(&n, source))
338 .unwrap_or_else(|| "()".to_string());
339
340 let vis = self.get_visibility(node, source);
341
342 let mut entity = Entity::new(name.clone(), EntityKind::Method, file_path, line, end_line);
343 entity = entity.with_signature(format!("{}{}{}", vis, name, params));
344 if exported {
345 entity.exported = true;
346 }
347
348 Some(entity)
349 }
350
351 /// Extract field declarations from a class body.
352 ///

Callers 1

walk_treeMethod · 0.80

Calls 5

has_modifierMethod · 0.80
get_visibilityMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected