Skip to content

Commit

Permalink
Added iteration scope for csharp functions (#2665)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasArvidsson authored Oct 12, 2024
1 parent 72c46b7 commit 959bf11
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MyClass { }
---

[Range] =
[Domain] = 0:15-0:16
>-<
0| class MyClass { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class MyClass { }
---

[Range] =
[Domain] = 0:15-0:16
>-<
0| class MyClass { }
2 changes: 2 additions & 0 deletions packages/common/src/scopeSupportFacets/csharp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = {
namedFunction: supported,
"namedFunction.constructor": supported,
"namedFunction.method": supported,
"namedFunction.method.iteration.class": supported,

functionName: supported,
"functionName.constructor": supported,
"functionName.method": supported,
"functionName.method.iteration.class": supported,

"condition.for": supported,
"condition.while": supported,
Expand Down
8 changes: 8 additions & 0 deletions queries/csharp.scm
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
(class_declaration
name: (identifier) @className
) @class @_.domain

(compilation_unit) @class.iteration @className.iteration
;; Treat interior of all bodies as iteration scopes for class and classname, eg
;;!! private static void foo() { }
Expand Down Expand Up @@ -89,6 +90,13 @@
)
] @namedFunction @functionName.domain

(class_declaration
body: (_
"{" @namedFunction.iteration.start.endOf @functionName.iteration.start.endOf
"}" @namedFunction.iteration.end.startOf @functionName.iteration.end.startOf
)
)

[
(invocation_expression)
(object_creation_expression)
Expand Down

0 comments on commit 959bf11

Please sign in to comment.