diff --git a/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope b/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope new file mode 100644 index 0000000000..4eaba49f3c --- /dev/null +++ b/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope @@ -0,0 +1,7 @@ +class MyClass { } +--- + +[Range] = +[Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope b/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope new file mode 100644 index 0000000000..4eaba49f3c --- /dev/null +++ b/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope @@ -0,0 +1,7 @@ +class MyClass { } +--- + +[Range] = +[Domain] = 0:15-0:16 + >-< +0| class MyClass { } diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 3461d7cf0c..26b424df70 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -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, diff --git a/queries/csharp.scm b/queries/csharp.scm index 33ad4ab93e..6fb98dd4a9 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -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() { } @@ -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)