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

Function modifier

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

Source from the content-addressed store, hash-verified

637}
638
639fn modifier(node: Node<'_>, source: &str, expected: &str) -> bool {
640 let mut stack: Vec<_> = named(node)
641 .into_iter()
642 .filter(|child| {
643 matches!(
644 child.kind(),
645 "modifiers"
646 | "visibility_modifier"
647 | "accessibility_modifier"
648 | "storage_class_specifier"
649 )
650 })
651 .collect();
652 while let Some(item) = stack.pop() {
653 if item.kind() == "visibility_modifier" && expected == "pub" {
654 if text(item, source).trim() == "pub" {
655 return true;
656 }
657 continue;
658 }
659 if matches!(
660 item.kind(),
661 "annotation" | "marker_annotation" | "attribute" | "decorator"
662 ) || literal(item)
663 {
664 continue;
665 }
666 if text(item, source).trim() == expected {
667 return true;
668 }
669 stack.extend(children(item));
670 }
671 false
672}
673
674fn in_function(mut node: Node<'_>, language: Language) -> bool {
675 while let Some(parent) = node.parent() {

Callers 3

body_is_missingFunction · 0.85
exported_tsFunction · 0.85
public_surfaceFunction · 0.85

Calls 8

extendMethod · 0.80
namedFunction · 0.70
textFunction · 0.70
literalFunction · 0.70
childrenFunction · 0.70
collectMethod · 0.45
into_iterMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected