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

Method has_modifier

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

Check if a node has a specific modifier (public, private, static, final, abstract, etc.).

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

Source from the content-addressed store, hash-verified

552
553 /// Check if a node has a specific modifier (public, private, static, final, abstract, etc.).
554 fn has_modifier(&self, node: &Node, source: &str, modifier: &str) -> bool {
555 let mut cursor = node.walk();
556 for child in node.children(&mut cursor) {
557 if child.kind() == "modifiers" {
558 let text = self.node_text(&child, source);
559 return text.contains(modifier);
560 }
561 // Also check direct modifier children (some tree-sitter versions)
562 if self.node_text(&child, source) == modifier {
563 return true;
564 }
565 // Stop once we hit the name/type — modifiers come before
566 if child.kind() == "identifier"
567 || child.kind() == "type_identifier"
568 || child.kind() == "void_type"
569 || child.kind() == "class"
570 || child.kind() == "interface"
571 || child.kind() == "enum"
572 {
573 break;
574 }
575 }
576 false
577 }
578
579 /// Get the visibility modifier as a string ("public ", "private ", "protected ", or "").
580 fn get_visibility(&self, node: &Node, source: &str) -> String {

Callers 11

extract_classMethod · 0.80
extract_interfaceMethod · 0.80
extract_enumMethod · 0.80
extract_recordMethod · 0.80
extract_methodMethod · 0.80
extract_constructorMethod · 0.80
extract_fieldsMethod · 0.80
build_class_signatureMethod · 0.80
get_visibilityMethod · 0.80

Calls 5

walkMethod · 0.80
childrenMethod · 0.80
kindMethod · 0.45
node_textMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected