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

Method visibility_of

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

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