MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / visibility_of

Method visibility_of

codegraph-kernel/src/ruby.rs:385–401  ·  view source on GitHub ↗

rubyExtractor.getVisibility — walk the previousNamedSibling chain (unbounded, through non-matching siblings); the first `call` sibling whose `method` text is private/protected/public decides; else public. Bug-for-bug: a BARE `private` line parses as identifier (invisible), and a matching call poisons every later sibling def regardless of ruby's actual arg-scoped semantics.

(&self, node: Node)

Source from the content-addressed store, hash-verified

383 /// and a matching call poisons every later sibling def regardless of
384 /// ruby's actual arg-scoped semantics.
385 fn visibility_of(&self, node: Node) -> u8 {
386 let mut sibling = node.prev_named_sibling();
387 while let Some(s) = sibling {
388 if s.kind() == "call" {
389 if let Some(method) = s.child_by_field_name("method") {
390 match self.text(method) {
391 "private" => return 2,
392 "protected" => return 3,
393 "public" => return 1,
394 _ => {}
395 }
396 }
397 }
398 sibling = s.prev_named_sibling();
399 }
400 1 // public
401 }
402
403 // --- the visitNode hook (languages/ruby.ts:19-76) ---------------------------
404

Callers 3

extract_functionMethod · 0.45
extract_methodMethod · 0.45
extract_classMethod · 0.45

Calls 1

textMethod · 0.65

Tested by

no test coverage detected