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

Method visibility_of

codegraph-kernel/src/ruby.rs:387–403  ·  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

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

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