diff --git a/data/fixtures/scopes/csharp/functionName.iteration.document.scope b/data/fixtures/scopes/csharp/functionName.iteration.document.scope new file mode 100644 index 0000000000..27476adbb1 --- /dev/null +++ b/data/fixtures/scopes/csharp/functionName.iteration.document.scope @@ -0,0 +1,12 @@ + +void Foo() { } + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| void Foo() { } +2| + < diff --git a/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope b/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope index 4eaba49f3c..a9bd7ec26f 100644 --- a/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope +++ b/data/fixtures/scopes/csharp/functionName.method.iteration.class.scope @@ -1,7 +1,13 @@ class MyClass { } --- -[Range] = -[Domain] = 0:15-0:16 +[#1 Range] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| class MyClass { } + + +[#2 Range] = +[#2 Domain] = 0:15-0:16 >-< 0| class MyClass { } diff --git a/data/fixtures/scopes/csharp/namedFunction.iteration.document.scope b/data/fixtures/scopes/csharp/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..27476adbb1 --- /dev/null +++ b/data/fixtures/scopes/csharp/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +void Foo() { } + +--- + +[Range] = +[Domain] = 0:0-2:0 + > +0| +1| void Foo() { } +2| + < diff --git a/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope b/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope index 4eaba49f3c..a9bd7ec26f 100644 --- a/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope +++ b/data/fixtures/scopes/csharp/namedFunction.method.iteration.class.scope @@ -1,7 +1,13 @@ class MyClass { } --- -[Range] = -[Domain] = 0:15-0:16 +[#1 Range] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| class MyClass { } + + +[#2 Range] = +[#2 Domain] = 0:15-0:16 >-< 0| class MyClass { } diff --git a/packages/common/src/scopeSupportFacets/c.ts b/packages/common/src/scopeSupportFacets/c.ts index f6f34dc8e4..2b9cfc5ff1 100644 --- a/packages/common/src/scopeSupportFacets/c.ts +++ b/packages/common/src/scopeSupportFacets/c.ts @@ -100,11 +100,11 @@ export const cCoreScopeSupport: LanguageScopeSupportFacetMap = { "interior.ternary": supported, "interior.loop": supported, - // Unsupported + /* UNSUPPORTED */ fieldAccess: unsupported, - // Not applicable (C and C++) + /* NOT APPLICABLE (C and C++) */ // Element and tags element: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/csharp.ts b/packages/common/src/scopeSupportFacets/csharp.ts index 0f5cb23cb6..867017c1e9 100644 --- a/packages/common/src/scopeSupportFacets/csharp.ts +++ b/packages/common/src/scopeSupportFacets/csharp.ts @@ -1,7 +1,7 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported, notApplicable } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const csharpScopeSupport: LanguageScopeSupportFacetMap = { switchStatementSubject: supported, @@ -28,11 +28,13 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "functionCallee.constructor": supported, namedFunction: supported, + "namedFunction.iteration.document": supported, "namedFunction.constructor": supported, "namedFunction.method": supported, "namedFunction.method.iteration.class": supported, functionName: supported, + "functionName.iteration.document": supported, "functionName.constructor": supported, "functionName.method": supported, "functionName.method.iteration.class": supported, @@ -169,46 +171,69 @@ export const csharpScopeSupport: LanguageScopeSupportFacetMap = { "interior.ternary": supported, "interior.try": supported, - // Not applicable + /* UNSUPPORTED */ - "collectionItem.unenclosed.iteration": notApplicable, - "collectionItem.unenclosed": notApplicable, - "functionName.iteration.block": notApplicable, - "functionName.iteration.document": notApplicable, - "interior.cell": notApplicable, - "interior.command": notApplicable, + fieldAccess: unsupported, + + /* NOT APPLICABLE */ + + // Element and tags + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, "interior.element": notApplicable, - "interior.resource": notApplicable, + "textFragment.element": notApplicable, "key.attribute": notApplicable, - "name.argument.actual.iteration": notApplicable, + "value.attribute": notApplicable, + + // Keyword argument "name.argument.actual": notApplicable, - "name.assignment.pattern": notApplicable, - "name.resource.iteration": notApplicable, - "name.resource": notApplicable, - "name.variable.pattern": notApplicable, + "name.argument.actual.iteration": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + + // Functions in blocks + "functionName.iteration.block": notApplicable, "namedFunction.iteration.block": notApplicable, - "namedFunction.iteration.document": notApplicable, - "section.iteration.document": notApplicable, - "section.iteration.parent": notApplicable, - "textFragment.element": notApplicable, - "type.resource.iteration": notApplicable, + + // Resource syntax + "interior.resource": notApplicable, "type.resource": notApplicable, - "type.alias": notApplicable, - "value.argument.actual.iteration": notApplicable, - "value.argument.actual": notApplicable, - "value.attribute": notApplicable, - "value.resource.iteration": notApplicable, + "type.resource.iteration": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, "value.resource": notApplicable, - "value.typeAlias": notApplicable, + "value.resource.iteration": notApplicable, + + // Pattern destructing + "name.assignment.pattern": notApplicable, + "name.variable.pattern": notApplicable, "value.variable.pattern": notApplicable, + + // Type alias + "type.alias": notApplicable, + "value.typeAlias": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Command command: notApplicable, - element: notApplicable, - endTag: notApplicable, - environment: notApplicable, + "interior.command": notApplicable, + + // Notebook cell notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Collection item + "collectionItem.unenclosed.iteration": notApplicable, + "collectionItem.unenclosed": notApplicable, + + // Miscellaneous + environment: notApplicable, pairDelimiter: notApplicable, regularExpression: notApplicable, - section: notApplicable, - startTag: notApplicable, - tags: notApplicable, }; diff --git a/queries/csharp.scm b/queries/csharp.scm index 326f17d4b3..8ce523b471 100644 --- a/queries/csharp.scm +++ b/queries/csharp.scm @@ -51,8 +51,13 @@ (if_statement) @ifStatement ( - (compilation_unit) @statement.iteration @name.iteration - (#document-range! @statement.iteration @name.iteration) + (compilation_unit) @statement.iteration @class.iteration @className.iteration + (#document-range! @statement.iteration @class.iteration @className.iteration) +) + +( + (compilation_unit) @name.iteration @namedFunction.iteration @functionName.iteration + (#document-range! @name.iteration @namedFunction.iteration @functionName.iteration) ) (_ @@ -175,11 +180,6 @@ ) ) @class @type @_.domain -( - (compilation_unit) @class.iteration @className.iteration - (#document-range! @class.iteration @className.iteration) -) - ;; Treat interior of all bodies as iteration scopes for class and classname, eg ;;!! private static void foo() { } ;;! ***