Skip to content

Commit 6e2f014

Browse files
committed
Small improvements
1 parent 4df5742 commit 6e2f014

21 files changed

+10871
-9
lines changed

src/cedarscript_editor/cedarscript_editor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _update_command(self, cmd: UpdateCommand):
122122
case RegionClause(region=region) | InsertClause(insert_position=region):
123123
search_range = restrict_search_range(region, target, identifier_finder, lines)
124124

125-
if search_range.line_count:
125+
if search_range and search_range.line_count:
126126
match action:
127127
case RegionClause(region=Segment()):
128128
pass

tests/corpus/.x.refactoring-benchmark/chat.xml renamed to tests/corpus/.refactoring-benchmark/chat.xml

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,84 @@
1-
<no-train>
2-
```CEDARScript
1+
<report>
2+
3+
# CEDARScript 1.1.2 + 1.1.6
4+
# gemini-1.5-flash-latest
5+
# pass_rate_1: 74.2
6+
# pass_rate_2: 75.3
7+
# pass_rate_3: 75.3
8+
# percent_cases_well_formed: 89.9
9+
# total_cost: 1.2366
10+
11+
12+
@@ Worsened, now FAILED (5) @@
13+
The class identifier named `FxGraphDrawer`: 4 matches
14+
-- [0 -> -4] (--------------------) (++++++++++++++++++++) graph_drawer_FxGraphDrawer__stringify_tensor_meta
315

4-
/*
516
Moved method now at 2-char indent:
6-
-- [0 -> -4] ( --) (++++++++++++++++++++) autosave_AutosaveForPlugin_get_files_to_recover
7-
-- [0 -> -4] (--------------------) (++++++++++++++++++++) base_BaseHandler_adapt_method_mode
817
-- [0 -> -4] ( -) (++++++++++++++++++++) gradient_checker_GradientChecker__assertInferTensorChecks
918
-- [0 -> -4] ( -------) (++++++++++++++++++++) i18n_JavaScriptCatalog_get_paths
10-
@ Stable: FAILED (15) @@
11-
=- [-4 -> -4] ( -------------------) (++++++++++++++++++++) common_methods_invocations_foreach_inputs_sample_func__sample_rightmost_arg
19+
POSTPONED =- [-4 -> -4] ( ------------------) (++++++++++++++++++++) codeeditor_CodeEditor___get_brackets
1220

21+
> makemessages.py:208:20: E999 SyntaxError: unexpected character after line continuation character
22+
-- [0 -> -3] ( ---------------) (++++++++++++++++++++) makemessages_Command_add_arguments
23+
24+
-- [0 -> -3] ( --------) (++++++++++++++++++++) weather_NWSWeather__forecast
25+
26+
@@ Stable: FAILED (17) @@
27+
=- [-4 -> -3] ( -------------------) (+++++++ ) builtin_BuiltinVariable_call_setattr
28+
=- [-4 -> -3] ( ----------------) (++++++++++++++++++++) common_methods_invocations_foreach_inputs_sample_func__sample_rightmost_arg
29+
=- [-4 -> -3] ( -------------------) (++++++++++++++++++++) common_utils_TestCase_genSparseTensor
30+
=- [-4 -> -3] ( -------------------) (++++++++++++++++ ) dataframeeditor_DataFrameView_next_index_name
31+
=- [-4 -> -3] ( -------------------) (++++++++++++++++++++) doc_DocCLI_display_plugin_list
32+
=- [-4 -> -3] ( -------------------) (+++++++ ) doc_DocCLI_get_role_man_text
33+
=- [-4 -> -3] ( -------------------) (++++++++++++++++++++) figure_FigureBase_colorbar
34+
=- [-4 -> -3] ( -------------------) (++++++++++++ ) galaxy_GalaxyCLI_execute_list_collection
35+
=- [-4 -> -3] ( ------------------) (++++++++++++++++++++) generator_GenOpTestCase_out_variant_op_test_case_generator
36+
=- [-4 -> -3] ( -------------------) (+++++++++++ ) kernel_SpyderKernel_get_fault_text
37+
=- [-4 -> -3] ( -------------------) (++++ ) main_widget_PylintWidget_parse_output
38+
=- [-4 -> -3] ( -------------------) (+ ) patches__Curve__get_arrow_wedge
39+
=- [-4 -> -3] ( -------------------) (++++++ ) polar_RadialTick__determine_anchor
40+
=- [-4 -> -3] (--------------------) (++++++++++++++++++++) sharding_policies_MaxShardSizePolicy__add_partition
41+
=- [-4 -> -3] ( -------------------) (++++++++++++++++++++) symbolic_shapes_ShapeEnv_bind_symbols
42+
=- [-4 -> -3] ( -------------------) (++++++++++++ ) text_CountVectorizer__limit_features
43+
</report>
44+
45+
<no-train>
46+
```CEDARScript
47+
48+
/* makemessages.py
49+
#### # Refactor Command.add_arguments
50+
####
51+
#### Refactor the `add_arguments` method in the `Command` class to be a stand alone, top level function.
52+
#### Name the new function `add_arguments`, exactly the same name as the existing method.
53+
#### Update any existing `self.add_arguments` calls to work with the new `add_arguments` function.
1354
*/
1455

56+
-- 1. Move the `add_arguments` method from the `Command` class, placing it at the top level, just before the line where its class starts
57+
UPDATE CLASS "Command"
58+
FROM FILE "makemessages.py"
59+
MOVE METHOD "add_arguments"
60+
INSERT BEFORE CLASS "Command"
61+
RELATIVE INDENTATION 0;
62+
63+
-- 2. Update the copied function to remove references to `self`
64+
UPDATE FUNCTION "add_arguments"
65+
FROM FILE "makemessages.py"
66+
REPLACE WHOLE WITH CASE
67+
WHEN REGEX r'''def add_arguments\(''' THEN SUB
68+
r'''def add_arguments\(self,'''
69+
r'''def add_arguments(parser)'''
70+
END;
71+
72+
-- 3. Update ALL call sites of the method `add_arguments` to call the new top-level function with the same name
73+
UPDATE CLASS "Command"
74+
FROM FILE "makemessages.py"
75+
REPLACE BODY WITH CASE
76+
WHEN REGEX r'''self\.add_arguments\(''' THEN SUB
77+
r'''self\.(add_arguments\()'''
78+
r'''\1'''
79+
END;
80+
```
81+
1582
/* config.py
1683
Doubled fun signature:
1784
-- [0 -> -4] ( ------------) (++++++++++++++++++++) config_NetworkConfig_parse

0 commit comments

Comments
 (0)