cppExtractor.getVisibility: the FIRST access_specifier among the parent's children decides (document order, not nearest-preceding — bug-for-bug with the TS loop). The answer is the parent's, so it is read once for each parent and kept: read again for every member, a file of twenty thousand functions spent a minute on it, each one reading every sibling it has.
(&self, node: Node)
| 995 | /// kept: read again for every member, a file of twenty thousand functions |
| 996 | /// spent a minute on it, each one reading every sibling it has. |
| 997 | fn visibility_of(&self, node: Node) -> Option<u8> { |
| 998 | let parent = node.parent()?; |
| 999 | if let Some(known) = self.visibility_seen.borrow().get(&parent.id()) { |
| 1000 | return *known; |
| 1001 | } |
| 1002 | let mut found = None; |
| 1003 | let mut cursor = parent.walk(); |
| 1004 | for child in parent.children(&mut cursor) { |
| 1005 | if child.kind() == "access_specifier" { |
| 1006 | let text = self.text(child); |
| 1007 | if text.contains("public") { |
| 1008 | found = Some(1); |
| 1009 | } else if text.contains("private") { |
| 1010 | found = Some(2); |
| 1011 | } else if text.contains("protected") { |
| 1012 | found = Some(3); |
| 1013 | } |
| 1014 | if found.is_some() { |
| 1015 | break; |
| 1016 | } |
| 1017 | } |
| 1018 | } |
| 1019 | self.visibility_seen.borrow_mut().insert(parent.id(), found); |
| 1020 | found |
| 1021 | } |
| 1022 | |
| 1023 | /// cExtractor.isConst: any named `type_qualifier` child reading "const". |
| 1024 | fn is_const_declaration(&self, node: Node) -> bool { |
no test coverage detected