Skip to content

Commit 5175630

Browse files
committed
Initial support for keyword 'METHOD'
1 parent bb20071 commit 5175630

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
all: test version
44

55
version:
6+
git describe --tags
67
python -m setuptools_scm
78

89
test:

src/cedarscript_editor/tree_sitter_identifier_finder.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,16 @@ def _find_identifier(self,
7878
IdentifierBoundaries with identifier IdentifierBoundaries with identifier start, body start, and end lines of the identifier
7979
or None if not found
8080
"""
81+
query_info_key = marker.type
82+
match marker.type:
83+
case 'method':
84+
query_info_key = 'function'
8185
try:
82-
candidates = self.language.query(self.query_info[marker.type].format(name=marker.value)).captures(self.tree.root_node)
86+
candidates = (
87+
self.language.query(self.query_info[query_info_key].format(name=marker.value))
88+
.captures(self.tree.root_node)
89+
)
90+
# TODO discard candidates that aren't of type 'marker.type'
8391
candidates: list[IdentifierBoundaries] = [ib for ib in capture2identifier_boundaries(
8492
candidates,
8593
self.lines

tests/corpus/update.identifier.insert.inside.identifier/chat.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
```CEDARScript
33
UPDATE CLASS "A"
44
FROM FILE "1.py"
5-
INSERT INSIDE FUNCTION "__init__" BOTTOM
5+
INSERT INSIDE METHOD "__init__" BOTTOM
66
WITH CONTENT '''
77
@-1:def m1(self):
88
@0:pass

0 commit comments

Comments
 (0)