@@ -75,7 +75,7 @@ class CodeLens
7575 include Requests ::Support ::Common
7676 include ActiveSupportTestCaseHelper
7777
78- #: (RunnerClient client , GlobalState global_state , ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens] response_builder , URI::Generic uri , Prism::Dispatcher dispatcher ) -> void
78+ #: (RunnerClient, GlobalState, ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens], URI::Generic, Prism::Dispatcher) -> void
7979 def initialize ( client , global_state , response_builder , uri , dispatcher )
8080 @client = client
8181 @global_state = global_state
@@ -98,8 +98,10 @@ def initialize(client, global_state, response_builder, uri, dispatcher)
9898
9999 #: (Prism::CallNode node) -> void
100100 def on_call_node_enter ( node )
101- content = extract_test_case_name ( node )
101+ # Remove this method once the rollout is complete
102+ return if @global_state . enabled_feature? ( :fullTestDiscovery )
102103
104+ content = extract_test_case_name ( node )
103105 return unless content
104106
105107 line_number = node . location . start_line
@@ -110,12 +112,15 @@ def on_call_node_enter(node)
110112 # Although uncommon, Rails tests can be written with the classic "def test_name" syntax.
111113 #: (Prism::DefNode node) -> void
112114 def on_def_node_enter ( node )
113- method_name = node . name . to_s
114-
115- if method_name . start_with? ( "test_" )
116- line_number = node . location . start_line
117- command = "#{ test_command } #{ @path } :#{ line_number } "
118- add_test_code_lens ( node , name : method_name , command : command , kind : :example )
115+ # Remove this entire unless block once the rollout is complete
116+ unless @global_state . enabled_feature? ( :fullTestDiscovery )
117+ method_name = node . name . to_s
118+
119+ if method_name . start_with? ( "test_" )
120+ line_number = node . location . start_line
121+ command = "#{ test_command } #{ @path } :#{ line_number } "
122+ add_test_code_lens ( node , name : method_name , command : command , kind : :example )
123+ end
119124 end
120125
121126 if controller?
@@ -134,7 +139,8 @@ def on_class_node_enter(node)
134139 # back in a controller context. This part is used in other places in the LSP
135140 @constant_name_stack << [ class_name , superclass_name ]
136141
137- if class_name . end_with? ( "Test" )
142+ # Remove this entire if block once the rollout is complete
143+ if class_name . end_with? ( "Test" ) && !@global_state . enabled_feature? ( :fullTestDiscovery )
138144 fully_qualified_name = @constant_name_stack . map ( &:first ) . join ( "::" )
139145 command = "#{ test_command } #{ @path } --name \" /#{ Shellwords . escape ( fully_qualified_name ) } (#|::)/\" "
140146 add_test_code_lens ( node , name : class_name , command : command , kind : :group )
@@ -155,6 +161,8 @@ def on_class_node_leave(node)
155161 if class_name . end_with? ( "Test" )
156162 @group_id_stack . pop
157163 end
164+ # Remove everything but the `@constant_name_stack.pop` once the rollout is complete
165+ return if @global_state . enabled_feature? ( :fullTestDiscovery )
158166
159167 @constant_name_stack . pop
160168 end
0 commit comments