@@ -21,6 +21,7 @@ use cairo_lang_sierra::extensions::NamedType;
21
21
use cairo_lang_sierra:: ids:: GenericTypeId ;
22
22
use cairo_lang_sierra:: program:: { GenericArg , ProgramArtifact } ;
23
23
use cairo_lang_sierra_generator:: db:: SierraGenGroup ;
24
+ use cairo_lang_sierra_generator:: program_generator:: SierraProgramWithDebug ;
24
25
use cairo_lang_sierra_generator:: replace_ids:: replace_sierra_ids_in_program;
25
26
use cairo_lang_starknet:: starknet_plugin_suite;
26
27
use cairo_lang_test_plugin:: test_plugin_suite;
@@ -143,16 +144,9 @@ pub fn collect_tests(
143
144
. context ( "Compilation failed without any diagnostics" )
144
145
. context ( "Failed to get sierra program" ) ?;
145
146
146
- let debug_annotations = if compilation_unit. unstable_add_statements_functions_debug_info ( ) {
147
- Some ( Annotations :: from (
148
- sierra_program
149
- . debug_info
150
- . statements_locations
151
- . extract_statements_functions ( db) ,
152
- ) )
153
- } else {
154
- None
155
- } ;
147
+ let debug_annotations: Option < Annotations > =
148
+ maybe_build_debug_annotations ( compilation_unit, & sierra_program, db) ;
149
+
156
150
let debug_info = debug_annotations. map ( |annotations| DebugInfo {
157
151
type_names : Default :: default ( ) ,
158
152
executables : Default :: default ( ) ,
@@ -208,6 +202,36 @@ pub fn collect_tests(
208
202
) )
209
203
}
210
204
205
+ fn maybe_build_debug_annotations (
206
+ compilation_unit : & CompilationUnit ,
207
+ sierra_program : & Arc < SierraProgramWithDebug > ,
208
+ db : & mut RootDatabase ,
209
+ ) -> Option < Annotations > {
210
+ if !compilation_unit. unstable_add_statements_functions_debug_info ( )
211
+ && !compilation_unit. unstable_add_statements_code_locations_debug_info ( )
212
+ {
213
+ return None ;
214
+ } ;
215
+ let mut debug_annotations: Annotations = Annotations :: default ( ) ;
216
+ if compilation_unit. unstable_add_statements_functions_debug_info ( ) {
217
+ debug_annotations. extend ( Annotations :: from (
218
+ sierra_program
219
+ . debug_info
220
+ . statements_locations
221
+ . extract_statements_functions ( db) ,
222
+ ) ) ;
223
+ }
224
+ if compilation_unit. unstable_add_statements_code_locations_debug_info ( ) {
225
+ debug_annotations. extend ( Annotations :: from (
226
+ sierra_program
227
+ . debug_info
228
+ . statements_locations
229
+ . extract_statements_source_code_locations ( db) ,
230
+ ) ) ;
231
+ }
232
+ Some ( debug_annotations)
233
+ }
234
+
211
235
fn build_test_details ( function_finder : & FunctionFinder , test_name : & str ) -> Result < TestDetails > {
212
236
let func = function_finder. find_function ( test_name) ?;
213
237
0 commit comments