Skip to content

Commit 9c1d031

Browse files
committed
restore getOptimizableFunctions
1 parent 82db74a commit 9c1d031

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

codeflash/lsp/beta.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4+
from pathlib import Path
45
from typing import TYPE_CHECKING
56

7+
from pygls import uris
8+
69
from codeflash.lsp.server import CodeflashLanguageServer, CodeflashLanguageServerProtocol
710

811
if TYPE_CHECKING:
@@ -25,10 +28,16 @@ class OptimizeFunctionParams:
2528

2629
@server.feature("getOptimizableFunctions")
2730
def 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

3443
if __name__ == "__main__":

0 commit comments

Comments
 (0)