@@ -75,7 +75,7 @@ class CodeLens
75
75
include Requests ::Support ::Common
76
76
include ActiveSupportTestCaseHelper
77
77
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
79
79
def initialize ( client , global_state , response_builder , uri , dispatcher )
80
80
@client = client
81
81
@global_state = global_state
@@ -98,8 +98,10 @@ def initialize(client, global_state, response_builder, uri, dispatcher)
98
98
99
99
#: (Prism::CallNode node) -> void
100
100
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 )
102
103
104
+ content = extract_test_case_name ( node )
103
105
return unless content
104
106
105
107
line_number = node . location . start_line
@@ -110,12 +112,15 @@ def on_call_node_enter(node)
110
112
# Although uncommon, Rails tests can be written with the classic "def test_name" syntax.
111
113
#: (Prism::DefNode node) -> void
112
114
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
119
124
end
120
125
121
126
if controller?
@@ -134,7 +139,8 @@ def on_class_node_enter(node)
134
139
# back in a controller context. This part is used in other places in the LSP
135
140
@constant_name_stack << [ class_name , superclass_name ]
136
141
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 )
138
144
fully_qualified_name = @constant_name_stack . map ( &:first ) . join ( "::" )
139
145
command = "#{ test_command } #{ @path } --name \" /#{ Shellwords . escape ( fully_qualified_name ) } (#|::)/\" "
140
146
add_test_code_lens ( node , name : class_name , command : command , kind : :group )
@@ -155,6 +161,8 @@ def on_class_node_leave(node)
155
161
if class_name . end_with? ( "Test" )
156
162
@group_id_stack . pop
157
163
end
164
+ # Remove everything but the `@constant_name_stack.pop` once the rollout is complete
165
+ return if @global_state . enabled_feature? ( :fullTestDiscovery )
158
166
159
167
@constant_name_stack . pop
160
168
end
0 commit comments