@@ -54,12 +54,38 @@ def optimize_function(server: CodeflashLanguageServer, params: OptimizeFunctionP
5454
5555
5656@server .feature ("second_step_in_optimize_function" )
57- def second_step_in_optimize_function (server : CodeflashLanguageServer , params : OptimizeFunctionParams ) -> dict [str , str ]: # noqa: ARG001
57+ def second_step_in_optimize_function (server : CodeflashLanguageServer , params : OptimizeFunctionParams ) -> dict [str , str ]:
58+ current_function = server .optimizer .current_function_being_optimized
59+
60+ optimizable_funcs = {current_function .file_path : [current_function ]}
61+
62+ function_to_tests , num_discovered_tests = server .optimizer .discover_tests (optimizable_funcs )
63+ # mocking in order to get things going
64+ return {"functionName" : params .functionName , "status" : "success" , "generated_tests" : str (num_discovered_tests )}
65+
66+
67+ @server .feature ("third_step_in_optimize_function" )
68+ def third_step_in_optimize_function (server : CodeflashLanguageServer , params : OptimizeFunctionParams ) -> dict [str , str ]:
69+ current_function = server .optimizer .current_function_being_optimized
70+
71+ module_prep_result = server .optimizer .prepare_module_for_optimization (current_function .file_path )
72+
73+ validated_original_code , original_module_ast = module_prep_result
74+
75+ function_optimizer = server .optimizer .create_function_optimizer (
76+ current_function ,
77+ function_to_optimize_source_code = validated_original_code [current_function .file_path ].source_code ,
78+ original_module_ast = original_module_ast ,
79+ original_module_path = current_function .file_path ,
80+ )
81+
82+ server .optimizer .current_function_optimizer = function_optimizer
83+
5884 return {
5985 "functionName" : params .functionName ,
6086 "status" : "success" ,
61- "generated_tests " : "5 " ,
62- "generated_optimizations " : "3" ,
87+ "message " : "Function optimizer created successfully " ,
88+ "extra " : function_optimizer . function_to_tests ,
6389 }
6490
6591
0 commit comments