Skip to content

Commit 94b92da

Browse files
committed
cedarscript-ast-parser>=0.5.1
1 parent 1bc498d commit 94b92da

File tree

7 files changed

+96
-10
lines changed

7 files changed

+96
-10
lines changed

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
.PHONY: all version test dist clean
1+
.PHONY: all version v test t dist d clean c
22

33
all: test version
44

5-
version:
5+
version v:
66
git describe --tags
77
python -m setuptools_scm
88

9-
test:
9+
test t:
1010
pytest --cov=src/cedarscript_editor --cov=src/text_manipulation tests/ --cov-report term-missing
1111

12-
dist: test
12+
dist d: test
1313
scripts/check-version.sh
1414
rm -rf dist/
1515
python -m build && twine upload dist/*
1616

17-
clean:
17+
clean c:
1818
rm -rfv out dist build/bdist.*

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ classifiers = [
2222
]
2323
keywords = ["cedarscript", "code-editing", "refactoring", "code-analysis", "sql-like", "ai-assisted-development"]
2424
dependencies = [
25-
"cedarscript-ast-parser>=0.4.4",
25+
"cedarscript-ast-parser>=0.5.1",
2626
"grep-ast==0.3.3",
2727
"tree-sitter-languages==1.10.2",
2828
]

src/cedarscript_editor/cedarscript_editor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ def apply_commands(self, commands: Sequence[Command]):
9797
raise ValueError(f"Unknown command '{type(invalid)}'")
9898
except Exception as e:
9999
print(f'[apply_commands] (command #{i+1}) Failed: {command}')
100-
if isinstance(command, UpdateCommand):
101-
print(f'CMD CONTENT: ***{command.content}***')
102100
raise CEDARScriptEditorException(i + 1, str(e)) from e
103101
return result
104102

@@ -176,7 +174,7 @@ def _update_command(self, cmd: UpdateCommand):
176174

177175
write_file(file_path, lines)
178176

179-
return f"Updated {target if target else 'file'} in {file_path}\n -> {action}"
177+
return f"Updated {target if target else 'file'}\n -> {action}"
180178

181179
@staticmethod
182180
def _apply_action(
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""CLI Backend for the Analyzer Part of the Debugger.
16+
17+
The analyzer performs post hoc analysis of dumped intermediate tensors and
18+
graph structure information from debugged Session.run() calls.
19+
"""
20+
21+
def _make_source_table(self, source_list, is_tf_py_library):
22+
lines=[]
23+
return debugger_cli_common.rich_text_lines_from_rich_line_list(lines)
24+
class DebugAnalyzer(object):
25+
def print_source(self, args, screen_info=None):
26+
pass
27+
def list_source(self, args, screen_info=None):
28+
output = []
29+
source_list = []
30+
output.extend(self._make_source_table(
31+
[item for item in source_list if not item[1]], False))
32+
output.extend(self._make_source_table(
33+
[item for item in source_list if item[1]], True))
34+
_add_main_menu(output, node_name=None)
35+
return output

tests/corpus/update.identifier.case-filter/chat.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,23 @@ REPLACE WHOLE WITH CASE
1919
r'self\.(convert)'
2020
r'\1'
2121
END;
22+
23+
-- Update the copied function to remove references to `self`
24+
UPDATE FUNCTION "_make_source_table"
25+
FROM FILE "analyzer_cli.py"
26+
REPLACE WHOLE WITH CASE
27+
WHEN PREFIX '''def _make_source_table(self''' THEN SUB
28+
r'''(def _make_source_table\()self, '''
29+
r'''\1'''
30+
END;
31+
32+
-- Update ALL call sites of the method `_make_source_table` to call the new top-level function with the same name
33+
UPDATE METHOD "DebugAnalyzer.list_source"
34+
FROM FILE "analyzer_cli.py"
35+
REPLACE BODY WITH CASE
36+
WHEN REGEX r'''self\._make_source_table''' THEN SUB
37+
r'''self\.(_make_source_table)'''
38+
r'''\1'''
39+
END;
2240
```
2341
</no-train>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
# ==============================================================================
15+
"""CLI Backend for the Analyzer Part of the Debugger.
16+
17+
The analyzer performs post hoc analysis of dumped intermediate tensors and
18+
graph structure information from debugged Session.run() calls.
19+
"""
20+
21+
def _make_source_table(source_list, is_tf_py_library):
22+
lines=[]
23+
return debugger_cli_common.rich_text_lines_from_rich_line_list(lines)
24+
class DebugAnalyzer(object):
25+
def print_source(self, args, screen_info=None):
26+
pass
27+
def list_source(self, args, screen_info=None):
28+
output = []
29+
source_list = []
30+
output.extend(_make_source_table(
31+
[item for item in source_list if not item[1]], False))
32+
output.extend(_make_source_table(
33+
[item for item in source_list if item[1]], True))
34+
_add_main_menu(output, node_name=None)
35+
return output

tests/corpus/update.identifier.ed-script-filter/chat.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ g/calc1(/s/\(calc1(\)/\1base_tax, /
2929

3030
''';
3131

32-
```
32+
```
3333
</no-train>

0 commit comments

Comments
 (0)