@@ -101,48 +101,6 @@ def _update_command(self, cmd: UpdateCommand):
101101 content = cmd .content or []
102102 file_path = os .path .join (self .root_path , target .file_path )
103103
104- # Example 1:
105- # UPDATE FILE "tmp.benchmarks/2024-10-04-22-59-58--CEDARScript-Gemini-small/bowling/bowling.py"
106- # INSERT INSIDE FUNCTION "__init__" TOP
107- # WITH CONTENT '''
108- # @0:print("This line will be inserted at the top")
109- # ''';
110- # After parsing ->
111- # UpdateCommand(
112- # type='update',
113- # target=SingleFileClause(file_path='tmp.benchmarks/2024-10-04-22-59-58--CEDARScript-Gemini-small/bowling
114- # /bowling.py'),
115- # action=InsertClause(insert_position=RelativeMarker(type=<MarkerType.FUNCTION: 'function'>,
116- # value='__init__',
117- # offset=None)),
118- # content='\n @0:print("This line will be inserted at the top")\n '
119- # )
120-
121- # Example 2:
122- # UPDATE FUNCTION
123- # FROM FILE "tmp.benchmarks/2024-10-04-22-59-58--CEDARScript-Gemini-small/bowling/bowling.py"
124- # WHERE NAME = "__init__"
125- # REPLACE SEGMENT
126- # STARTING AFTER LINE "def __init__(self):"
127- # ENDING AFTER LINE "def __init__(self):"
128- # WITH CONTENT '''
129- # @0:print("This line will be inserted at the top")
130- # ''';
131- # After parsing ->
132- # UpdateCommand(
133- # type='update',
134- # target=IdentifierFromFile(file_path='bowling.py',
135- # where_clause=WhereClause(field='NAME', operator='=', value='__init__'),
136- # identifier_type='FUNCTION', offset=None
137- # ),
138- # action=ReplaceClause(
139- # region=Segment(
140- # start=RelativeMarker(type=<MarkerType.LINE: 'line'>, value='def __init__(self):', offset=None),
141- # end=RelativeMarker(type=<MarkerType.LINE: 'line'>, value='def __init__(self):', offset=None)
142- # )),
143- # content='\n @0:print("This line will be inserted at the top")\n '
144- # )
145-
146104 src = read_file (file_path )
147105 lines = src .splitlines ()
148106
@@ -348,7 +306,7 @@ def restrict_search_range(action, target, identifier_finder: IdentifierFinder) -
348306 case BodyOrWhole () | RelativePositionType ():
349307 return identifier_boundaries .location_to_search_range (region )
350308 case Marker () as inner_marker :
351- match identifier_finder (inner_marker ):
309+ match identifier_finder (inner_marker , identifier_boundaries . whole ):
352310 case IdentifierBoundaries () as inner_boundaries :
353311 return inner_boundaries .whole
354312 case RangeSpec () as inner_range_spec :
0 commit comments