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

Method visibility_of

codegraph-kernel/src/csharp.rs:431–455  ·  view source on GitHub ↗

getVisibility: FIRST `modifier` child whose text is one of the four levels wins; none → public in an interface, internal in a namespace or the file, private in a class or struct (the C# defaults).

(&self, node: Node)

Source from the content-addressed store, hash-verified

429 /// levels wins; none → public in an interface, internal in a namespace
430 /// or the file, private in a class or struct (the C# defaults).
431 fn visibility_of(&self, node: Node) -> u8 {
432 for i in 0..node.child_count() {
433 let Some(child) = node.child(i) else { continue };
434 if child.kind() == "modifier" {
435 match self.text(child) {
436 "public" => return 1,
437 "private" => return 2,
438 "protected" => return 3,
439 "internal" => return 4,
440 _ => {}
441 }
442 }
443 }
444 let parent = node.parent();
445 let container = match parent {
446 Some(p) if p.kind() == "declaration_list" => p.parent(),
447 other => other,
448 };
449 match container.map(|c| c.kind()) {
450 Some("interface_declaration") => 1,
451 None | Some("compilation_unit") | Some("namespace_declaration")
452 | Some("file_scoped_namespace_declaration") => 4,
453 _ => 2,
454 }
455 }
456
457 fn is_static(&self, node: Node) -> bool {
458 (0..node.child_count())

Callers 7

extract_classMethod · 0.45
extract_structMethod · 0.45
extract_enumMethod · 0.45
extract_propertyMethod · 0.45
extract_fieldMethod · 0.45
extract_methodMethod · 0.45
extract_functionMethod · 0.45

Calls 2

mapMethod · 0.80
textMethod · 0.65

Tested by

no test coverage detected