Skip to content

Commit 959bf11

Browse files
Added iteration scope for csharp functions (#2665)
Fixes #2664 ## Checklist - [x] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [/] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [/] I have not broken the cheatsheet
1 parent 72c46b7 commit 959bf11

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class MyClass { }
2+
---
3+
4+
[Range] =
5+
[Domain] = 0:15-0:16
6+
>-<
7+
0| class MyClass { }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class MyClass { }
2+
---
3+
4+
[Range] =
5+
[Domain] = 0:15-0:16
6+
>-<
7+
0| class MyClass { }

packages/common/src/scopeSupportFacets/csharp.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = {
2828
namedFunction: supported,
2929
"namedFunction.constructor": supported,
3030
"namedFunction.method": supported,
31+
"namedFunction.method.iteration.class": supported,
3132

3233
functionName: supported,
3334
"functionName.constructor": supported,
3435
"functionName.method": supported,
36+
"functionName.method.iteration.class": supported,
3537

3638
"condition.for": supported,
3739
"condition.while": supported,

queries/csharp.scm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
(class_declaration
5454
name: (identifier) @className
5555
) @class @_.domain
56+
5657
(compilation_unit) @class.iteration @className.iteration
5758
;; Treat interior of all bodies as iteration scopes for class and classname, eg
5859
;;!! private static void foo() { }
@@ -89,6 +90,13 @@
8990
)
9091
] @namedFunction @functionName.domain
9192

93+
(class_declaration
94+
body: (_
95+
"{" @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf
96+
"}" @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf
97+
)
98+
)
99+
92100
[
93101
(invocation_expression)
94102
(object_creation_expression)

0 commit comments

Comments
 (0)