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

Function node_name

atomic-audit/src/extract/languages.rs:184–206  ·  view source on GitHub ↗
(node: Node<'_>, source: &str)

Source from the content-addressed store, hash-verified

182}
183
184pub(super) fn node_name(node: Node<'_>, source: &str) -> Option<String> {
185 if let Some(name) = node.child_by_field_name("name") {
186 return Some(text(name, source).into());
187 }
188 if let Some(function) = declarator(node) {
189 if let Some(name) = function.child_by_field_name("declarator") {
190 return Some(text(name, source).into());
191 }
192 }
193 if let Some(parent) = node.parent() {
194 if matches!(
195 parent.kind(),
196 "variable_declarator" | "public_field_definition" | "assignment" | "let_declaration"
197 ) {
198 return parent
199 .child_by_field_name("name")
200 .or_else(|| parent.child_by_field_name("left"))
201 .or_else(|| parent.child_by_field_name("pattern"))
202 .map(|name| text(name, source).into());
203 }
204 }
205 None
206}
207
208pub(crate) fn qualified(node: Node<'_>, source: &str, language: Language) -> (String, bool) {
209 let mut reliable = true;

Callers 2

qualifiedFunction · 0.85
public_surfaceFunction · 0.85

Calls 3

declaratorFunction · 0.85
parentMethod · 0.80
textFunction · 0.70

Tested by

no test coverage detected