11from __future__ import annotations
22
33from dataclasses import dataclass
4+ from pathlib import Path
45from typing import TYPE_CHECKING
56
7+ from pygls import uris
8+
69from codeflash .lsp .server import CodeflashLanguageServer , CodeflashLanguageServerProtocol
710
811if TYPE_CHECKING :
@@ -25,10 +28,16 @@ class OptimizeFunctionParams:
2528
2629@server .feature ("getOptimizableFunctions" )
2730def get_optimizable_functions (
28- server : CodeflashLanguageServer , # noqa: ARG001
29- params : OptimizableFunctionsParams ,
31+ server : CodeflashLanguageServer , params : OptimizableFunctionsParams
3032) -> dict [str , list [str ]]:
31- return {params .textDocument .uri : ["example" ]}
33+ file_path = Path (uris .to_fs_path (params .textDocument .uri ))
34+ server .optimizer .args .file = file_path
35+ server .optimizer .args .previous_checkpoint_functions = False
36+ optimizable_funcs , _ = server .optimizer .get_optimizable_functions ()
37+ path_to_qualified_names = {}
38+ for path , functions in optimizable_funcs .items ():
39+ path_to_qualified_names [path .as_posix ()] = [func .qualified_name for func in functions ]
40+ return path_to_qualified_names
3241
3342
3443if __name__ == "__main__" :
0 commit comments