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

Method extract_property

atomic-semantic/src/parsers/swift.rs:307–326  ·  view source on GitHub ↗

Extract a top-level property declaration (`var` / `let`).

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

Source from the content-addressed store, hash-verified

305
306 /// Extract a top-level property declaration (`var` / `let`).
307 fn extract_property(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {
308 let name = self.find_property_name(node, source)?;
309
310 let line = node.start_position().row as u32 + 1;
311 let end_line = node.end_position().row as u32 + 1;
312
313 let exported = self.is_exported(node, source);
314
315 // Use the first line as the signature
316 let full_text = self.node_text(node, source);
317 let signature = full_text.lines().next().map(|l| l.trim().to_string());
318
319 let mut entity = Entity::new(name, EntityKind::Variable, file_path, line, end_line);
320 if let Some(sig) = signature {
321 entity = entity.with_signature(sig);
322 }
323 entity.exported = exported;
324
325 Some(entity)
326 }
327
328 /// Extract an import declaration.
329 fn extract_import(&self, node: &Node, source: &str, file_path: &str) -> Option<Entity> {

Callers 1

walk_treeMethod · 0.80

Calls 6

find_property_nameMethod · 0.80
is_exportedMethod · 0.80
with_signatureMethod · 0.80
node_textMethod · 0.45
nextMethod · 0.45
linesMethod · 0.45

Tested by

no test coverage detected