@@ -1230,17 +1230,18 @@ impl<'a> RubyIndexer<'a> {
12301230 }
12311231
12321232 fn handle_constant_visibility ( & mut self , node : & ruby_prism:: CallNode , visibility : Visibility ) {
1233+ if self . current_nesting_is_runtime_body ( ) {
1234+ self . visit_runtime_call_node ( node) ;
1235+ return ;
1236+ }
1237+
12331238 let receiver = node. receiver ( ) ;
12341239
12351240 let receiver_name_id = match receiver {
12361241 Some ( ruby_prism:: Node :: ConstantPathNode { .. } | ruby_prism:: Node :: ConstantReadNode { .. } ) => {
12371242 self . index_constant_reference ( & receiver. unwrap ( ) , true )
12381243 }
12391244 Some ( ruby_prism:: Node :: SelfNode { .. } ) | None => match self . nesting_stack . last ( ) {
1240- Some ( Nesting :: Method ( _) ) => {
1241- self . visit_call_node_parts ( node) ;
1242- return ;
1243- }
12441245 None => {
12451246 self . local_graph . add_diagnostic (
12461247 Rule :: InvalidPrivateConstant ,
@@ -1319,13 +1320,14 @@ impl<'a> RubyIndexer<'a> {
13191320 visibility : Visibility ,
13201321 call_name : & str ,
13211322 ) {
1323+ if self . current_nesting_is_runtime_body ( ) {
1324+ self . visit_runtime_call_node ( node) ;
1325+ return ;
1326+ }
1327+
13221328 match node. receiver ( ) {
1323- Some ( ruby_prism:: Node :: SelfNode { .. } ) | None => match self . nesting_stack . last ( ) {
1324- Some ( Nesting :: Method ( _) ) => {
1325- self . visit_call_node_parts ( node) ;
1326- return ;
1327- }
1328- None => {
1329+ Some ( ruby_prism:: Node :: SelfNode { .. } ) | None => {
1330+ if self . nesting_stack . last ( ) . is_none ( ) {
13291331 self . local_graph . add_diagnostic (
13301332 Rule :: InvalidMethodVisibility ,
13311333 Offset :: from_prism_location ( & node. location ( ) ) ,
@@ -1334,8 +1336,7 @@ impl<'a> RubyIndexer<'a> {
13341336 self . visit_call_node_parts ( node) ;
13351337 return ;
13361338 }
1337- _ => { }
1338- } ,
1339+ }
13391340 _ => {
13401341 self . visit_call_node_parts ( node) ;
13411342 return ;
@@ -2003,8 +2004,6 @@ impl Visit<'_> for RubyIndexer<'_> {
20032004 . unwrap_or_else ( || offset_for_comments. start ( ) ) ;
20042005
20052006 Self :: each_string_or_symbol_arg ( call, |name, location| {
2006- let reader_str_id = self . local_graph . intern_string ( format ! ( "{name}()" ) ) ;
2007- let writer_str_id = self . local_graph . intern_string ( format ! ( "{name}=()" ) ) ;
20082007 let parent_nesting_id = self . parent_nesting_id ( ) ;
20092008 let offset = Offset :: from_prism_location ( & location) ;
20102009
@@ -2018,6 +2017,9 @@ impl Visit<'_> for RubyIndexer<'_> {
20182017
20192018 match kind {
20202019 AttrKind :: Accessor => {
2020+ let reader_str_id = self . local_graph . intern_string ( format ! ( "{name}()" ) ) ;
2021+ let writer_str_id = self . local_graph . intern_string ( format ! ( "{name}=()" ) ) ;
2022+
20212023 let reader = Definition :: AttrAccessor ( Box :: new ( AttrAccessorDefinition :: new (
20222024 reader_str_id,
20232025 self . uri_id ,
@@ -2043,6 +2045,8 @@ impl Visit<'_> for RubyIndexer<'_> {
20432045 self . add_member_to_current_owner ( writer_id) ;
20442046 }
20452047 AttrKind :: Reader => {
2048+ let reader_str_id = self . local_graph . intern_string ( format ! ( "{name}()" ) ) ;
2049+
20462050 let definition = Definition :: AttrReader ( Box :: new ( AttrReaderDefinition :: new (
20472051 reader_str_id,
20482052 self . uri_id ,
@@ -2056,6 +2060,8 @@ impl Visit<'_> for RubyIndexer<'_> {
20562060 self . add_member_to_current_owner ( definition_id) ;
20572061 }
20582062 AttrKind :: Writer => {
2063+ let writer_str_id = self . local_graph . intern_string ( format ! ( "{name}=()" ) ) ;
2064+
20592065 let definition = Definition :: AttrWriter ( Box :: new ( AttrWriterDefinition :: new (
20602066 writer_str_id,
20612067 self . uri_id ,
@@ -2199,7 +2205,7 @@ impl Visit<'_> for RubyIndexer<'_> {
21992205 "private" | "protected" | "public" | "module_function" => {
22002206 let visibility = Visibility :: from_string ( message. as_str ( ) ) ;
22012207
2202- if visibility == Visibility :: ModuleFunction && self . current_nesting_is_runtime_body ( ) {
2208+ if self . current_nesting_is_runtime_body ( ) {
22032209 self . visit_runtime_call_node ( node) ;
22042210 return ;
22052211 }
0 commit comments