@@ -1577,9 +1577,11 @@ def get_opt_review_metrics(
15771577
15781578 Returns:
15791579 Markdown-formatted string with code blocks showing calling functions.
1580+
15801581 """
1581- from codeflash .languages . base import FunctionInfo , ParentInfo , ReferenceInfo
1582+ from codeflash .discovery . functions_to_optimize import FunctionToOptimize
15821583 from codeflash .languages .registry import get_language_support
1584+ from codeflash .models .models import FunctionParent
15831585
15841586 start_time = time .perf_counter ()
15851587
@@ -1596,19 +1598,19 @@ def get_opt_review_metrics(
15961598 else :
15971599 function_name , class_name = qualified_name_split [1 ], qualified_name_split [0 ]
15981600
1599- # Create a FunctionInfo for the function
1601+ # Create a FunctionToOptimize for the function
16001602 # We don't have full line info here, so we'll use defaults
1601- parents = ()
1603+ parents : list [ FunctionParent ] = []
16021604 if class_name :
1603- parents = ( ParentInfo ( name = class_name , type = "ClassDef" ),)
1605+ parents = [ FunctionParent ( name = class_name , type = "ClassDef" )]
16041606
1605- func_info = FunctionInfo (
1606- name = function_name ,
1607+ func_info = FunctionToOptimize (
1608+ function_name = function_name ,
16071609 file_path = file_path ,
1608- start_line = 1 ,
1609- end_line = 1 ,
16101610 parents = parents ,
1611- language = language ,
1611+ starting_line = 1 ,
1612+ ending_line = 1 ,
1613+ language = str (language ),
16121614 )
16131615
16141616 # Find references using language support
@@ -1618,9 +1620,7 @@ def get_opt_review_metrics(
16181620 return ""
16191621
16201622 # Format references as markdown code blocks
1621- calling_fns_details = _format_references_as_markdown (
1622- references , file_path , project_root , language
1623- )
1623+ calling_fns_details = _format_references_as_markdown (references , file_path , project_root , language )
16241624
16251625 except Exception as e :
16261626 logger .debug (f"Error getting function references: { e } " )
@@ -1631,9 +1631,7 @@ def get_opt_review_metrics(
16311631 return calling_fns_details
16321632
16331633
1634- def _format_references_as_markdown (
1635- references : list , file_path : Path , project_root : Path , language : Language
1636- ) -> str :
1634+ def _format_references_as_markdown (references : list , file_path : Path , project_root : Path , language : Language ) -> str :
16371635 """Format references as markdown code blocks with calling function code.
16381636
16391637 Args:
@@ -1644,6 +1642,7 @@ def _format_references_as_markdown(
16441642
16451643 Returns:
16461644 Markdown-formatted string.
1645+
16471646 """
16481647 # Group references by file
16491648 refs_by_file : dict [Path , list ] = {}
@@ -1710,7 +1709,7 @@ def _format_references_as_markdown(
17101709 context_len += len (context_code )
17111710
17121711 if caller_contexts :
1713- fn_call_context += f"```{ lang_hint } :{ path_relative } \n "
1712+ fn_call_context += f"```{ lang_hint } :{ path_relative . as_posix () } \n "
17141713 fn_call_context += "\n " .join (caller_contexts )
17151714 fn_call_context += "\n ```\n "
17161715
@@ -1728,11 +1727,11 @@ def _extract_calling_function(source_code: str, function_name: str, ref_line: in
17281727
17291728 Returns:
17301729 Source code of the function, or None if not found.
1730+
17311731 """
17321732 if language == Language .PYTHON :
17331733 return _extract_calling_function_python (source_code , function_name , ref_line )
1734- else :
1735- return _extract_calling_function_js (source_code , function_name , ref_line )
1734+ return _extract_calling_function_js (source_code , function_name , ref_line )
17361735
17371736
17381737def _extract_calling_function_python (source_code : str , function_name : str , ref_line : int ) -> str | None :
@@ -1766,6 +1765,7 @@ def _extract_calling_function_js(source_code: str, function_name: str, ref_line:
17661765
17671766 Returns:
17681767 Source code of the function, or None if not found.
1768+
17691769 """
17701770 try :
17711771 from codeflash .languages .treesitter_utils import TreeSitterAnalyzer , TreeSitterLanguage
0 commit comments