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

Method visibility_of

codegraph-kernel/src/csharp.rs:430–453  ·  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

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

childrenMethod · 0.80
mapMethod · 0.80
textMethod · 0.65
walkMethod · 0.45

Tested by

no test coverage detected