From 8057b8e3023aea22914c7793da6e052590cafbbf Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 10:13:49 +0100 Subject: [PATCH 01/20] Started working on dart support --- data/fixtures/scopes/dart/comment.block.scope | 10 + data/fixtures/scopes/dart/comment.line.scope | 10 + .../scopes/dart/string.multiLine.scope | 13 + .../scopes/dart/string.singleLine.scope | 10 + .../dart/textFragment.comment.block.scope | 10 + .../dart/textFragment.comment.line.scope | 10 + .../dart/textFragment.string.multiLine.scope | 13 + .../dart/textFragment.string.singleLine.scope | 10 + .../common/src/scopeSupportFacets/dart.ts | 311 +++++++++++++++++- queries/dart.scm | 12 + 10 files changed, 406 insertions(+), 3 deletions(-) create mode 100644 data/fixtures/scopes/dart/comment.block.scope create mode 100644 data/fixtures/scopes/dart/comment.line.scope create mode 100644 data/fixtures/scopes/dart/string.multiLine.scope create mode 100644 data/fixtures/scopes/dart/string.singleLine.scope create mode 100644 data/fixtures/scopes/dart/textFragment.comment.block.scope create mode 100644 data/fixtures/scopes/dart/textFragment.comment.line.scope create mode 100644 data/fixtures/scopes/dart/textFragment.string.multiLine.scope create mode 100644 data/fixtures/scopes/dart/textFragment.string.singleLine.scope diff --git a/data/fixtures/scopes/dart/comment.block.scope b/data/fixtures/scopes/dart/comment.block.scope new file mode 100644 index 0000000000..5e8b51111c --- /dev/null +++ b/data/fixtures/scopes/dart/comment.block.scope @@ -0,0 +1,10 @@ +/* Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/comment.line.scope b/data/fixtures/scopes/dart/comment.line.scope new file mode 100644 index 0000000000..7d1477b8a1 --- /dev/null +++ b/data/fixtures/scopes/dart/comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/string.multiLine.scope b/data/fixtures/scopes/dart/string.multiLine.scope new file mode 100644 index 0000000000..80dbca0966 --- /dev/null +++ b/data/fixtures/scopes/dart/string.multiLine.scope @@ -0,0 +1,13 @@ +"""Hello +world""" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:8 + >-------- +0| """Hello +1| world""" + --------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/string.singleLine.scope b/data/fixtures/scopes/dart/string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/data/fixtures/scopes/dart/string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/textFragment.comment.block.scope b/data/fixtures/scopes/dart/textFragment.comment.block.scope new file mode 100644 index 0000000000..af33f95d00 --- /dev/null +++ b/data/fixtures/scopes/dart/textFragment.comment.block.scope @@ -0,0 +1,10 @@ +/* Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/textFragment.comment.line.scope b/data/fixtures/scopes/dart/textFragment.comment.line.scope new file mode 100644 index 0000000000..6758f81490 --- /dev/null +++ b/data/fixtures/scopes/dart/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/textFragment.string.multiLine.scope b/data/fixtures/scopes/dart/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..32632a1b32 --- /dev/null +++ b/data/fixtures/scopes/dart/textFragment.string.multiLine.scope @@ -0,0 +1,13 @@ +"""Hello +world""" +--- + +[Content] = +[Removal] = +[Domain] = 0:3-1:5 + >----- +0| """Hello +1| world""" + -----< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/textFragment.string.singleLine.scope b/data/fixtures/scopes/dart/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..85dcf5fa7f --- /dev/null +++ b/data/fixtures/scopes/dart/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:12 + >-----------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index 9a6d3b1760..b7317d80dc 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -1,13 +1,318 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; +const { supported, notApplicable } = ScopeSupportFacetLevel; export const dartScopeSupport: LanguageScopeSupportFacetMap = { - ifStatement: supported, + disqualifyDelimiter: supported, + pairDelimiter: supported, list: supported, map: supported, + fieldAccess: supported, + ifStatement: supported, + anonymousFunction: supported, + class: supported, + "class.iteration.document": supported, + + namedFunction: supported, + "namedFunction.constructor": supported, + "namedFunction.method": supported, + "namedFunction.iteration.document": supported, + "namedFunction.iteration.class": supported, + + functionCall: supported, + "functionCall.constructor": supported, + "functionCall.method": supported, + "functionCall.chain": supported, + "functionCall.generic": supported, + functionCallee: supported, + "functionCallee.constructor": supported, + "functionCallee.method": supported, + "functionCallee.chain": supported, + "functionCallee.generic": supported, + + "argument.actual.singleLine": supported, + "argument.actual.multiLine": supported, + "argument.actual.iteration": supported, + "argument.actual.constructor.singleLine": supported, + "argument.actual.constructor.multiLine": supported, + "argument.actual.constructor.iteration": supported, + "argument.actual.method.singleLine": supported, + "argument.actual.method.multiLine": supported, + "argument.actual.method.iteration": supported, + "argument.formal.singleLine": supported, + "argument.formal.multiLine": supported, + "argument.formal.iteration": supported, + "argument.formal.constructor.singleLine": supported, + "argument.formal.constructor.multiLine": supported, + "argument.formal.constructor.iteration": supported, + "argument.formal.method.singleLine": supported, + "argument.formal.method.multiLine": supported, + "argument.formal.method.iteration": supported, + "argument.formal.lambda.singleLine": supported, + "argument.formal.lambda.multiLine": supported, + "argument.formal.lambda.iteration": supported, + "argument.catch": supported, + + "argumentList.actual.empty": supported, + "argumentList.actual.singleLine": supported, + "argumentList.actual.multiLine": supported, + "argumentList.actual.constructor.empty": supported, + "argumentList.actual.constructor.singleLine": supported, + "argumentList.actual.constructor.multiLine": supported, + "argumentList.actual.method.empty": supported, + "argumentList.actual.method.singleLine": supported, + "argumentList.actual.method.multiLine": supported, + "argumentList.formal.empty": supported, + "argumentList.formal.singleLine": supported, + "argumentList.formal.multiLine": supported, + "argumentList.formal.constructor.empty": supported, + "argumentList.formal.constructor.singleLine": supported, + "argumentList.formal.constructor.multiLine": supported, + "argumentList.formal.method.empty": supported, + "argumentList.formal.method.singleLine": supported, + "argumentList.formal.method.multiLine": supported, + "argumentList.formal.lambda.empty": supported, + "argumentList.formal.lambda.singleLine": supported, + "argumentList.formal.lambda.multiLine": supported, + + "collectionItem.unenclosed.singleLine": supported, + "collectionItem.unenclosed.multiLine": supported, + "collectionItem.unenclosed.iteration": supported, + + "branch.if": supported, + "branch.if.elif.else": supported, + "branch.if.else": supported, + "branch.if.iteration": supported, + "branch.try": supported, + "branch.try.iteration": supported, + "branch.switchCase": supported, + "branch.switchCase.iteration": supported, + "branch.ternary": supported, + "branch.ternary.iteration": supported, + + "comment.block": supported, + "comment.line": supported, + + "condition.if": supported, + "condition.while": supported, + "condition.doWhile": supported, + "condition.for": supported, + "condition.switchCase": supported, + "condition.switchCase.iteration": supported, + "condition.ternary": supported, + + "statement.class": supported, + "statement.enum": supported, + "statement.field.class": supported, + "statement.function": supported, + "statement.constructor": supported, + "statement.method": supported, + "statement.functionCall": supported, + "statement.if": supported, + "statement.try": supported, + "statement.switch": supported, + "statement.for": supported, + "statement.foreach": supported, + "statement.while": supported, + "statement.doWhile": supported, + "statement.assignment": supported, + "statement.assignment.compound": supported, + "statement.constant": supported, + "statement.variable.uninitialized": supported, + "statement.variable.initialized": supported, + "statement.typeAlias": supported, + "statement.update": supported, + "statement.return": supported, + "statement.yield": supported, + "statement.throw": supported, + "statement.break": supported, + "statement.continue": supported, + "statement.static": supported, + "statement.import": supported, + "statement.misc": supported, + "statement.iteration.document": supported, + "statement.iteration.class": supported, + "statement.iteration.block": supported, + + "string.singleLine": supported, + "string.multiLine": supported, + + "textFragment.comment.block": supported, + "textFragment.comment.line": supported, + "textFragment.string.singleLine": supported, + "textFragment.string.multiLine": supported, + + "name.argument.actual": supported, + "name.argument.actual.iteration": supported, + "name.argument.formal": supported, + "name.argument.formal.iteration": supported, + "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, + "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, + "name.argument.formal.lambda": supported, + "name.argument.formal.lambda.iteration": supported, + "name.argument.catch": supported, + "name.assignment": supported, + "name.assignment.compound": supported, + "name.constant": supported, + "name.variable.uninitialized": supported, + "name.variable.initialized": supported, + "name.foreach": supported, + "name.function": supported, + "name.constructor": supported, + "name.method": supported, "name.class": supported, + "name.enum": supported, + "name.field.class": supported, + "name.field.enum": supported, + "name.typeAlias": supported, + "name.iteration.document": supported, + "name.iteration.class": supported, + "name.iteration.enum": supported, + "name.iteration.block": supported, + + "key.mapPair": supported, + "key.mapPair.iteration": supported, + + "value.argument.actual": supported, + "value.argument.actual.iteration": supported, + "value.argument.formal": supported, + "value.argument.formal.iteration": supported, + "value.argument.formal.constructor": supported, + "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.method": supported, + "value.argument.formal.method.iteration": supported, + "value.mapPair": supported, + "value.mapPair.iteration": supported, + "value.assignment": supported, + "value.assignment.compound": supported, + "value.constant": supported, + "value.variable": supported, + "value.foreach": supported, + "value.return": supported, + "value.return.lambda": supported, + "value.switch": supported, + "value.field.class": supported, + "value.field.enum": supported, + "value.yield": supported, + "value.throw": supported, + "value.typeAlias": supported, + "value.iteration.document": supported, + "value.iteration.class": supported, + "value.iteration.enum": supported, + "value.iteration.block": supported, + + "type.argument.formal": supported, + "type.argument.formal.iteration": supported, + "type.argument.formal.constructor": supported, + "type.argument.formal.constructor.iteration": supported, + "type.argument.formal.method": supported, + "type.argument.formal.method.iteration": supported, + "type.argument.formal.lambda": supported, + "type.argument.formal.lambda.iteration": supported, + "type.argument.catch": supported, + "type.return": supported, + "type.return.method": supported, + "type.foreach": supported, + "type.field.class": supported, + "type.constant": supported, + "type.variable.uninitialized": supported, + "type.variable.initialized": supported, + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, + "type.class": supported, + "type.enum": supported, + "type.alias": supported, + "type.cast": supported, + "type.iteration.document": supported, + "type.iteration.class": supported, + "type.iteration.block": supported, + + "interior.class": supported, + "interior.enum": supported, + "interior.function": supported, + "interior.constructor": supported, + "interior.method": supported, + "interior.lambda": supported, + "interior.if": supported, + "interior.try": supported, + "interior.switch": supported, + "interior.switchCase": supported, + "interior.for": supported, + "interior.foreach": supported, + "interior.while": supported, + "interior.doWhile": supported, + "interior.static": supported, + + /* NOT APPLICABLE */ + + // Interface (Dart has abstract classes instead) + "statement.interface": notApplicable, + "statement.field.interface": notApplicable, + "statement.iteration.interface": notApplicable, + "name.interface": notApplicable, + "name.field.interface": notApplicable, + "name.iteration.interface": notApplicable, + "type.interface": notApplicable, + "type.field.interface": notApplicable, + "type.iteration.interface": notApplicable, + "value.field.interface": notApplicable, + "interior.interface": notApplicable, + + // Namespace / package declaration statements + "statement.package": notApplicable, + "statement.namespace": notApplicable, + "name.namespace": notApplicable, + "interior.namespace": notApplicable, + + // Resource statements + "statement.resource": notApplicable, + "name.resource": notApplicable, + "value.resource": notApplicable, + "type.resource": notApplicable, + "interior.resource": notApplicable, + + // Command / markup / notebook + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Language constructs not modeled in Dart this way + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + "statement.assignment.destructuring": notApplicable, + "statement.variable.destructuring": notApplicable, + "name.assignment.destructuring": notApplicable, + "name.variable.destructuring": notApplicable, + "value.assignment.destructuring": notApplicable, + "value.variable.destructuring": notApplicable, + + // No enum constructor call facet + "functionCall.enum": notApplicable, + "functionCallee.enum": notApplicable, + + // Not applicable misc + regularExpression: notApplicable, + environment: notApplicable, + selector: notApplicable, + unit: notApplicable, }; diff --git a/queries/dart.scm b/queries/dart.scm index 8649c3e550..c8beb44fef 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -24,3 +24,15 @@ (class_definition name: (_) @name ) @class @name.domain + +;;!! "hello world" +;;! ^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ +(string_literal + _ @textFragment.start.endOf + _ @textFragment.end.startOf +) @string + +;;!! // Hello world +;;! ^^^^^^^^^^^^^^ +(comment) @comment @textFragment From 77a01f4146da390cd64d4c47dcc6d1e6d92c3bd4 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 12:08:31 +0100 Subject: [PATCH 02/20] function --- .../dart/class.iteration.document.scope | 12 +++++ .../functionCall/functionCall.chain.scope | 30 +++++++++++ .../functionCall.constructor.scope | 17 ++++++ .../functionCall/functionCall.generic.scope | 17 ++++++ .../functionCall/functionCall.method.scope | 17 ++++++ .../dart/functionCall/functionCall.scope | 17 ++++++ .../functionCallee/functionCallee.chain.scope | 33 ++++++++++++ .../functionCallee.constructor.scope | 17 ++++++ .../functionCallee.generic.scope | 17 ++++++ .../functionCallee.method.scope | 17 ++++++ .../dart/functionCallee/functionCallee.scope | 17 ++++++ .../dart/namedFunction.constructor.scope | 21 ++++++++ .../dart/namedFunction.iteration.class.scope | 13 +++++ .../namedFunction.iteration.document.scope | 12 +++++ .../scopes/dart/namedFunction.method.scope | 21 ++++++++ data/fixtures/scopes/dart/namedFunction.scope | 10 ++++ .../scopes/dart/string.multiLine.scope | 23 +++++--- .../scopes/dart/string.singleLine.scope | 17 ++++-- .../dart/textFragment.string.multiLine.scope | 12 ++--- .../dart/textFragment.string.singleLine.scope | 8 +-- .../common/src/scopeSupportFacets/dart.ts | 7 ++- queries/dart.scm | 52 +++++++++++++++++++ 22 files changed, 383 insertions(+), 24 deletions(-) create mode 100644 data/fixtures/scopes/dart/class.iteration.document.scope create mode 100644 data/fixtures/scopes/dart/functionCall/functionCall.chain.scope create mode 100644 data/fixtures/scopes/dart/functionCall/functionCall.constructor.scope create mode 100644 data/fixtures/scopes/dart/functionCall/functionCall.generic.scope create mode 100644 data/fixtures/scopes/dart/functionCall/functionCall.method.scope create mode 100644 data/fixtures/scopes/dart/functionCall/functionCall.scope create mode 100644 data/fixtures/scopes/dart/functionCallee/functionCallee.chain.scope create mode 100644 data/fixtures/scopes/dart/functionCallee/functionCallee.constructor.scope create mode 100644 data/fixtures/scopes/dart/functionCallee/functionCallee.generic.scope create mode 100644 data/fixtures/scopes/dart/functionCallee/functionCallee.method.scope create mode 100644 data/fixtures/scopes/dart/functionCallee/functionCallee.scope create mode 100644 data/fixtures/scopes/dart/namedFunction.constructor.scope create mode 100644 data/fixtures/scopes/dart/namedFunction.iteration.class.scope create mode 100644 data/fixtures/scopes/dart/namedFunction.iteration.document.scope create mode 100644 data/fixtures/scopes/dart/namedFunction.method.scope create mode 100644 data/fixtures/scopes/dart/namedFunction.scope diff --git a/data/fixtures/scopes/dart/class.iteration.document.scope b/data/fixtures/scopes/dart/class.iteration.document.scope new file mode 100644 index 0000000000..813bb62ea9 --- /dev/null +++ b/data/fixtures/scopes/dart/class.iteration.document.scope @@ -0,0 +1,12 @@ + +class Foo {} + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| class Foo {} +2| + < diff --git a/data/fixtures/scopes/dart/functionCall/functionCall.chain.scope b/data/fixtures/scopes/dart/functionCall/functionCall.chain.scope new file mode 100644 index 0000000000..6c5b9258a6 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCall/functionCall.chain.scope @@ -0,0 +1,30 @@ +var foo = bar().baz(); +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:10-0:15 + >-----< +0| var foo = bar().baz(); + +[#1 Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar().baz(); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:10-0:21 + >-----------< +0| var foo = bar().baz(); + +[#2 Removal] = 0:9-0:21 + >------------< +0| var foo = bar().baz(); + +[#2 Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar().baz(); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCall/functionCall.constructor.scope b/data/fixtures/scopes/dart/functionCall/functionCall.constructor.scope new file mode 100644 index 0000000000..a850e8434e --- /dev/null +++ b/data/fixtures/scopes/dart/functionCall/functionCall.constructor.scope @@ -0,0 +1,17 @@ +var foo = Bar(); +--- + +[Content] = +[Domain] = 0:10-0:15 + >-----< +0| var foo = Bar(); + +[Removal] = 0:9-0:15 + >------< +0| var foo = Bar(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = Bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCall/functionCall.generic.scope b/data/fixtures/scopes/dart/functionCall/functionCall.generic.scope new file mode 100644 index 0000000000..eeee4d6fab --- /dev/null +++ b/data/fixtures/scopes/dart/functionCall/functionCall.generic.scope @@ -0,0 +1,17 @@ +var foo = bar(); +--- + +[Content] = +[Domain] = 0:10-0:20 + >----------< +0| var foo = bar(); + +[Removal] = 0:9-0:20 + >-----------< +0| var foo = bar(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCall/functionCall.method.scope b/data/fixtures/scopes/dart/functionCall/functionCall.method.scope new file mode 100644 index 0000000000..3b26f52406 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCall/functionCall.method.scope @@ -0,0 +1,17 @@ +var foo = bar.baz(); +--- + +[Content] = +[Domain] = 0:10-0:19 + >---------< +0| var foo = bar.baz(); + +[Removal] = 0:9-0:19 + >----------< +0| var foo = bar.baz(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar.baz(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCall/functionCall.scope b/data/fixtures/scopes/dart/functionCall/functionCall.scope new file mode 100644 index 0000000000..89db2bf9d8 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCall/functionCall.scope @@ -0,0 +1,17 @@ +var foo = bar(); +--- + +[Content] = +[Domain] = 0:10-0:15 + >-----< +0| var foo = bar(); + +[Removal] = 0:9-0:15 + >------< +0| var foo = bar(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCallee/functionCallee.chain.scope b/data/fixtures/scopes/dart/functionCallee/functionCallee.chain.scope new file mode 100644 index 0000000000..3194cfc4d6 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCallee/functionCallee.chain.scope @@ -0,0 +1,33 @@ +var foo = bar().baz(); +--- + +[#1 Content] = +[#1 Removal] = 0:10-0:13 + >---< +0| var foo = bar().baz(); + +[#1 Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar().baz(); + +[#1 Domain] = 0:10-0:15 + >-----< +0| var foo = bar().baz(); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:10-0:19 + >---------< +0| var foo = bar().baz(); + +[#2 Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar().baz(); + +[#2 Domain] = 0:10-0:21 + >-----------< +0| var foo = bar().baz(); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCallee/functionCallee.constructor.scope b/data/fixtures/scopes/dart/functionCallee/functionCallee.constructor.scope new file mode 100644 index 0000000000..73732d318c --- /dev/null +++ b/data/fixtures/scopes/dart/functionCallee/functionCallee.constructor.scope @@ -0,0 +1,17 @@ +var foo = Bar(); +--- + +[Content] = +[Removal] = 0:10-0:13 + >---< +0| var foo = Bar(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = Bar(); + +[Domain] = 0:10-0:15 + >-----< +0| var foo = Bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCallee/functionCallee.generic.scope b/data/fixtures/scopes/dart/functionCallee/functionCallee.generic.scope new file mode 100644 index 0000000000..c8c2403ce1 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCallee/functionCallee.generic.scope @@ -0,0 +1,17 @@ +var foo = bar(); +--- + +[Content] = +[Removal] = 0:10-0:18 + >--------< +0| var foo = bar(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar(); + +[Domain] = 0:10-0:20 + >----------< +0| var foo = bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCallee/functionCallee.method.scope b/data/fixtures/scopes/dart/functionCallee/functionCallee.method.scope new file mode 100644 index 0000000000..673d15d2e8 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCallee/functionCallee.method.scope @@ -0,0 +1,17 @@ +var foo = bar.baz(); +--- + +[Content] = +[Removal] = 0:10-0:17 + >-------< +0| var foo = bar.baz(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar.baz(); + +[Domain] = 0:10-0:19 + >---------< +0| var foo = bar.baz(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCallee/functionCallee.scope b/data/fixtures/scopes/dart/functionCallee/functionCallee.scope new file mode 100644 index 0000000000..2b4e432f01 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCallee/functionCallee.scope @@ -0,0 +1,17 @@ +var foo = bar(); +--- + +[Content] = +[Removal] = 0:10-0:13 + >---< +0| var foo = bar(); + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = bar(); + +[Domain] = 0:10-0:15 + >-----< +0| var foo = bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/namedFunction.constructor.scope b/data/fixtures/scopes/dart/namedFunction.constructor.scope new file mode 100644 index 0000000000..9564fe79ea --- /dev/null +++ b/data/fixtures/scopes/dart/namedFunction.constructor.scope @@ -0,0 +1,21 @@ +class Foo { + Foo() {} +} +--- + +[Content] = +[Domain] = 1:4-1:12 + >--------< +1| Foo() {} + +[Removal] = 1:0-2:0 + >------------ +1| Foo() {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| Foo() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/dart/namedFunction.iteration.class.scope b/data/fixtures/scopes/dart/namedFunction.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/dart/namedFunction.iteration.class.scope @@ -0,0 +1,13 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/data/fixtures/scopes/dart/namedFunction.iteration.document.scope b/data/fixtures/scopes/dart/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..3196afd2bb --- /dev/null +++ b/data/fixtures/scopes/dart/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +void foo() {} + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| void foo() {} +2| + < diff --git a/data/fixtures/scopes/dart/namedFunction.method.scope b/data/fixtures/scopes/dart/namedFunction.method.scope new file mode 100644 index 0000000000..12d3e4a8d2 --- /dev/null +++ b/data/fixtures/scopes/dart/namedFunction.method.scope @@ -0,0 +1,21 @@ +class Foo { + void bar() {} +} +--- + +[Content] = +[Domain] = 1:4-1:17 + >-------------< +1| void bar() {} + +[Removal] = 1:0-2:0 + >----------------- +1| void bar() {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| void bar() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/dart/namedFunction.scope b/data/fixtures/scopes/dart/namedFunction.scope new file mode 100644 index 0000000000..49b1c64940 --- /dev/null +++ b/data/fixtures/scopes/dart/namedFunction.scope @@ -0,0 +1,10 @@ +void foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| void foo() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/dart/string.multiLine.scope b/data/fixtures/scopes/dart/string.multiLine.scope index 80dbca0966..b8802dda48 100644 --- a/data/fixtures/scopes/dart/string.multiLine.scope +++ b/data/fixtures/scopes/dart/string.multiLine.scope @@ -1,13 +1,22 @@ -"""Hello -world""" +var foo = """Hello +world"""; --- [Content] = -[Removal] = -[Domain] = 0:0-1:8 - >-------- -0| """Hello -1| world""" +[Domain] = 0:10-1:8 + >-------- +0| var foo = """Hello +1| world"""; --------< +[Removal] = 0:9-1:8 + >--------- +0| var foo = """Hello +1| world"""; + --------< + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = """Hello + [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/string.singleLine.scope b/data/fixtures/scopes/dart/string.singleLine.scope index 4b26cf31b3..f164d6069c 100644 --- a/data/fixtures/scopes/dart/string.singleLine.scope +++ b/data/fixtures/scopes/dart/string.singleLine.scope @@ -1,10 +1,17 @@ -"Hello world" +var foo = "Hello world"; --- [Content] = -[Removal] = -[Domain] = 0:0-0:13 - >-------------< -0| "Hello world" +[Domain] = 0:10-0:23 + >-------------< +0| var foo = "Hello world"; + +[Removal] = 0:9-0:23 + >--------------< +0| var foo = "Hello world"; + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = "Hello world"; [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/textFragment.string.multiLine.scope b/data/fixtures/scopes/dart/textFragment.string.multiLine.scope index 32632a1b32..d37fb937d1 100644 --- a/data/fixtures/scopes/dart/textFragment.string.multiLine.scope +++ b/data/fixtures/scopes/dart/textFragment.string.multiLine.scope @@ -1,13 +1,13 @@ -"""Hello -world""" +var foo = """Hello +world"""; --- [Content] = [Removal] = -[Domain] = 0:3-1:5 - >----- -0| """Hello -1| world""" +[Domain] = 0:13-1:5 + >----- +0| var foo = """Hello +1| world"""; -----< [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/textFragment.string.singleLine.scope b/data/fixtures/scopes/dart/textFragment.string.singleLine.scope index 85dcf5fa7f..5763e26b3a 100644 --- a/data/fixtures/scopes/dart/textFragment.string.singleLine.scope +++ b/data/fixtures/scopes/dart/textFragment.string.singleLine.scope @@ -1,10 +1,10 @@ -"Hello world" +var foo = "Hello world"; --- [Content] = [Removal] = -[Domain] = 0:1-0:12 - >-----------< -0| "Hello world" +[Domain] = 0:11-0:22 + >-----------< +0| var foo = "Hello world"; [Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index b7317d80dc..f952bc290a 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -1,14 +1,13 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported, notApplicable } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const dartScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, pairDelimiter: supported, list: supported, map: supported, - fieldAccess: supported, ifStatement: supported, anonymousFunction: supported, @@ -247,6 +246,10 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "interior.doWhile": supported, "interior.static": supported, + /* UNSUPPORTED */ + + fieldAccess: unsupported, + /* NOT APPLICABLE */ // Interface (Dart has abstract classes instead) diff --git a/queries/dart.scm b/queries/dart.scm index c8beb44fef..0793cb1577 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -1,3 +1,8 @@ +( + (program) @class.iteration @statement.iteration @namedFunction.iteration + (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) +) + ;;!! if () {} ;;! ^^^^^^^^ ( @@ -36,3 +41,50 @@ ;;!! // Hello world ;;! ^^^^^^^^^^^^^^ (comment) @comment @textFragment + +;;!! void foo() {} +;;! ^^^^^^^^^^^^^ +;;! ^^^ +(_ + (function_signature + name: (_) @name + ) @namedFunction.start @name.domain.start + . + (function_body) @namedFunction.end @name.domain.end +) + +;;!! void foo() {} +;;! ^^^^^^^^^^^^^ +;;! ^^^ +(_ + (method_signature + (_ + name: (_) @name + ) + ) @namedFunction.start @name.domain.start + . + (function_body) @namedFunction.end @name.domain.end +) + +;;!! foo(); +;;! ^^^^^ +;;! ^^^ +(_ + (identifier) @functionCallee.start @functionCall.start @functionCallee.domain.start + . + (selector)* @functionCallee.end + . + (selector + (argument_part + (type_arguments)? @functionCallee.end + (arguments) + ) + ) @functionCall.end @functionCallee.domain.end +) + +;;!! class Foo { } +;;! ^ +(class_body + "{" @namedFunction.iteration.start.endOf + "}" @namedFunction.iteration.end.startOf +) From aa67d73cf316a15507580deeb2e21f94365b04ae Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 13:21:44 +0100 Subject: [PATCH 03/20] statement --- .../scopes/dart/anonymousFunction.scope | 17 +++ .../scopes/dart/anonymousFunction2.scope | 17 +++ .../statement.assignment.compound.scope | 33 ++++++ .../dart/statement/statement.assignment.scope | 33 ++++++ .../dart/statement/statement.break.scope | 60 ++++++++++ .../dart/statement/statement.class.scope | 10 ++ .../dart/statement/statement.constant.scope | 10 ++ .../statement/statement.constructor.scope | 33 ++++++ .../dart/statement/statement.continue.scope | 60 ++++++++++ .../dart/statement/statement.doWhile.scope | 33 ++++++ .../dart/statement/statement.enum.scope | 10 ++ .../statement/statement.field.class.scope | 53 +++++++++ .../scopes/dart/statement/statement.for.scope | 33 ++++++ .../dart/statement/statement.foreach.scope | 33 ++++++ .../dart/statement/statement.function.scope | 10 ++ .../statement/statement.functionCall.scope | 33 ++++++ .../scopes/dart/statement/statement.if.scope | 42 +++++++ .../dart/statement/statement.import.scope | 10 ++ .../statement/statement.iteration.class.scope | 13 +++ .../statement.iteration.document.scope | 12 ++ .../dart/statement/statement.method.scope | 33 ++++++ .../dart/statement/statement.return.scope | 33 ++++++ .../dart/statement/statement.switch.scope | 33 ++++++ .../dart/statement/statement.throw.scope | 33 ++++++ .../scopes/dart/statement/statement.try.scope | 42 +++++++ .../dart/statement/statement.typeAlias.scope | 10 ++ .../dart/statement/statement.update.scope | 33 ++++++ .../statement.variable.initialized.scope | 10 ++ .../statement.variable.uninitialized.scope | 10 ++ .../dart/statement/statement.while.scope | 33 ++++++ .../dart/statement/statement.yield.scope | 33 ++++++ .../common/src/scopeSupportFacets/dart.ts | 8 +- queries/dart.scm | 110 ++++++++++++++++-- 33 files changed, 962 insertions(+), 14 deletions(-) create mode 100644 data/fixtures/scopes/dart/anonymousFunction.scope create mode 100644 data/fixtures/scopes/dart/anonymousFunction2.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.assignment.compound.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.assignment.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.break.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.class.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.constant.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.constructor.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.continue.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.doWhile.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.enum.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.field.class.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.for.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.foreach.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.function.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.functionCall.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.if.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.import.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.iteration.class.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.iteration.document.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.method.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.return.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.switch.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.throw.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.try.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.typeAlias.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.update.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.variable.initialized.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.while.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.yield.scope diff --git a/data/fixtures/scopes/dart/anonymousFunction.scope b/data/fixtures/scopes/dart/anonymousFunction.scope new file mode 100644 index 0000000000..57c97f3077 --- /dev/null +++ b/data/fixtures/scopes/dart/anonymousFunction.scope @@ -0,0 +1,17 @@ +var foo = () {}; +--- + +[Content] = +[Domain] = 0:10-0:15 + >-----< +0| var foo = () {}; + +[Removal] = 0:9-0:15 + >------< +0| var foo = () {}; + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = () {}; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/anonymousFunction2.scope b/data/fixtures/scopes/dart/anonymousFunction2.scope new file mode 100644 index 0000000000..ba2afe0480 --- /dev/null +++ b/data/fixtures/scopes/dart/anonymousFunction2.scope @@ -0,0 +1,17 @@ +var foo = () => 0; +--- + +[Content] = +[Domain] = 0:10-0:17 + >-------< +0| var foo = () => 0; + +[Removal] = 0:9-0:17 + >--------< +0| var foo = () => 0; + +[Leading delimiter] = 0:9-0:10 + >-< +0| var foo = () => 0; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.assignment.compound.scope b/data/fixtures/scopes/dart/statement/statement.assignment.compound.scope new file mode 100644 index 0000000000..5116ead019 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.assignment.compound.scope @@ -0,0 +1,33 @@ +void main() { + foo += 0; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo += 0; +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:13 + >---------< +1| foo += 0; + +[#2 Removal] = 1:0-2:0 + >------------- +1| foo += 0; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| foo += 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.assignment.scope b/data/fixtures/scopes/dart/statement/statement.assignment.scope new file mode 100644 index 0000000000..d7b1217b39 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.assignment.scope @@ -0,0 +1,33 @@ +void main() { + foo = 0; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo = 0; +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| foo = 0; + +[#2 Removal] = 1:0-2:0 + >------------ +1| foo = 0; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| foo = 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.break.scope b/data/fixtures/scopes/dart/statement/statement.break.scope new file mode 100644 index 0000000000..c09d642464 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.break.scope @@ -0,0 +1,60 @@ +void main() { + while (true) { + break; + } +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| while (true) { +2| break; +3| } +4| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-3:5 + >-------------- +1| while (true) { +2| break; +3| } + -----< + +[#2 Removal] = 1:0-4:0 + >------------------ +1| while (true) { +2| break; +3| } +4| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| while (true) { + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:8-2:14 + >------< +2| break; + +[#3 Removal] = 2:0-3:0 + >-------------- +2| break; +3| } + < + +[#3 Leading delimiter] = 2:0-2:8 + >--------< +2| break; + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.class.scope b/data/fixtures/scopes/dart/statement/statement.class.scope new file mode 100644 index 0000000000..a6008d311f --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.class.scope @@ -0,0 +1,10 @@ +class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.constant.scope b/data/fixtures/scopes/dart/statement/statement.constant.scope new file mode 100644 index 0000000000..9ec6744100 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.constant.scope @@ -0,0 +1,10 @@ +const foo = 0; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| const foo = 0; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.constructor.scope b/data/fixtures/scopes/dart/statement/statement.constructor.scope new file mode 100644 index 0000000000..00eb2f573a --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.constructor.scope @@ -0,0 +1,33 @@ +class Foo { + Foo() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:8-1:16 + >--------< +1| Foo() {} + +[#2 Removal] = 1:0-2:0 + >---------------- +1| Foo() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:8 + >--------< +1| Foo() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.continue.scope b/data/fixtures/scopes/dart/statement/statement.continue.scope new file mode 100644 index 0000000000..325abbc91e --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.continue.scope @@ -0,0 +1,60 @@ +void main() { + while (true) { + continue; + } +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| while (true) { +2| continue; +3| } +4| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-3:5 + >-------------- +1| while (true) { +2| continue; +3| } + -----< + +[#2 Removal] = 1:0-4:0 + >------------------ +1| while (true) { +2| continue; +3| } +4| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| while (true) { + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:8-2:17 + >---------< +2| continue; + +[#3 Removal] = 2:0-3:0 + >----------------- +2| continue; +3| } + < + +[#3 Leading delimiter] = 2:0-2:8 + >--------< +2| continue; + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.doWhile.scope b/data/fixtures/scopes/dart/statement/statement.doWhile.scope new file mode 100644 index 0000000000..19a64d7645 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.doWhile.scope @@ -0,0 +1,33 @@ +void main() { + do {} while (true); +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| do {} while (true); +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:23 + >-------------------< +1| do {} while (true); + +[#2 Removal] = 1:0-2:0 + >----------------------- +1| do {} while (true); +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| do {} while (true); + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.enum.scope b/data/fixtures/scopes/dart/statement/statement.enum.scope new file mode 100644 index 0000000000..88dd9cd028 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.enum.scope @@ -0,0 +1,10 @@ +enum Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.field.class.scope b/data/fixtures/scopes/dart/statement/statement.field.class.scope new file mode 100644 index 0000000000..d64dff1a16 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.field.class.scope @@ -0,0 +1,53 @@ +class Foo { + var bar; + var baz = 0; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| var bar; +2| var baz = 0; +3| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| var bar; + +[#2 Removal] = 1:0-2:0 + >------------ +1| var bar; +2| var baz = 0; + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| var bar; + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:4-2:16 + >------------< +2| var baz = 0; + +[#3 Removal] = 2:0-3:0 + >---------------- +2| var baz = 0; +3| } + < + +[#3 Leading delimiter] = 2:0-2:4 + >----< +2| var baz = 0; + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.for.scope b/data/fixtures/scopes/dart/statement/statement.for.scope new file mode 100644 index 0000000000..e4b7c80097 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.for.scope @@ -0,0 +1,33 @@ +void main() { + for (var i = 0; i < size; i++) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| for (var i = 0; i < size; i++) {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:37 + >---------------------------------< +1| for (var i = 0; i < size; i++) {} + +[#2 Removal] = 1:0-2:0 + >------------------------------------- +1| for (var i = 0; i < size; i++) {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| for (var i = 0; i < size; i++) {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.foreach.scope b/data/fixtures/scopes/dart/statement/statement.foreach.scope new file mode 100644 index 0000000000..9faabe280b --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.foreach.scope @@ -0,0 +1,33 @@ +void main() { + for (final v in values) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| for (final v in values) {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:30 + >--------------------------< +1| for (final v in values) {} + +[#2 Removal] = 1:0-2:0 + >------------------------------ +1| for (final v in values) {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| for (final v in values) {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.function.scope b/data/fixtures/scopes/dart/statement/statement.function.scope new file mode 100644 index 0000000000..1eb8467630 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.function.scope @@ -0,0 +1,10 @@ +void foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| void foo() {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.functionCall.scope b/data/fixtures/scopes/dart/statement/statement.functionCall.scope new file mode 100644 index 0000000000..067de83895 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.functionCall.scope @@ -0,0 +1,33 @@ +void main() { + bar(); +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| bar(); +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:10 + >------< +1| bar(); + +[#2 Removal] = 1:0-2:0 + >---------- +1| bar(); +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| bar(); + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.if.scope b/data/fixtures/scopes/dart/statement/statement.if.scope new file mode 100644 index 0000000000..e0e344f9e2 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.if.scope @@ -0,0 +1,42 @@ +void main() { + if (true) {} + else if (false) {} + else {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| if (true) {} +2| else if (false) {} +3| else {} +4| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-3:11 + >------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -----------< + +[#2 Removal] = 1:0-4:0 + >---------------- +1| if (true) {} +2| else if (false) {} +3| else {} +4| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| if (true) {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.import.scope b/data/fixtures/scopes/dart/statement/statement.import.scope new file mode 100644 index 0000000000..1a0431ca60 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.import.scope @@ -0,0 +1,10 @@ +import "foo.dart"; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| import "foo.dart"; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.iteration.class.scope b/data/fixtures/scopes/dart/statement/statement.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.iteration.class.scope @@ -0,0 +1,13 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/data/fixtures/scopes/dart/statement/statement.iteration.document.scope b/data/fixtures/scopes/dart/statement/statement.iteration.document.scope new file mode 100644 index 0000000000..8441b73e49 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo = 0; + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo = 0; +2| + < diff --git a/data/fixtures/scopes/dart/statement/statement.method.scope b/data/fixtures/scopes/dart/statement/statement.method.scope new file mode 100644 index 0000000000..16d0cf1c55 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.method.scope @@ -0,0 +1,33 @@ +class Foo { + void bar() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:17 + >-------------< +1| void bar() {} + +[#2 Removal] = 1:0-2:0 + >----------------- +1| void bar() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| void bar() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.return.scope b/data/fixtures/scopes/dart/statement/statement.return.scope new file mode 100644 index 0000000000..c112156b09 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.return.scope @@ -0,0 +1,33 @@ +void foo() { + return 0; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| void foo() { +1| return 0; +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:8-1:17 + >---------< +1| return 0; + +[#2 Removal] = 1:0-2:0 + >----------------- +1| return 0; +2| } + < + +[#2 Leading delimiter] = 1:0-1:8 + >--------< +1| return 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.switch.scope b/data/fixtures/scopes/dart/statement/statement.switch.scope new file mode 100644 index 0000000000..64f49d00cb --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.switch.scope @@ -0,0 +1,33 @@ +void main() { + switch (foo) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| switch (foo) {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:19 + >---------------< +1| switch (foo) {} + +[#2 Removal] = 1:0-2:0 + >------------------- +1| switch (foo) {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| switch (foo) {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.throw.scope b/data/fixtures/scopes/dart/statement/statement.throw.scope new file mode 100644 index 0000000000..b9316d96ac --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.throw.scope @@ -0,0 +1,33 @@ +void main() { + throw foo; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| throw foo; +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:14 + >----------< +1| throw foo; + +[#2 Removal] = 1:0-2:0 + >-------------- +1| throw foo; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| throw foo; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.try.scope b/data/fixtures/scopes/dart/statement/statement.try.scope new file mode 100644 index 0000000000..44e61b7f73 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.try.scope @@ -0,0 +1,42 @@ +void main() { + try {} + catch (e) {} + finally {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| try {} +2| catch (e) {} +3| finally {} +4| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-3:14 + >------ +1| try {} +2| catch (e) {} +3| finally {} + --------------< + +[#2 Removal] = 1:0-4:0 + >---------- +1| try {} +2| catch (e) {} +3| finally {} +4| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| try {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.typeAlias.scope b/data/fixtures/scopes/dart/statement/statement.typeAlias.scope new file mode 100644 index 0000000000..fb726c3afa --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.typeAlias.scope @@ -0,0 +1,10 @@ +typedef Foo = int; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| typedef Foo = int; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.update.scope b/data/fixtures/scopes/dart/statement/statement.update.scope new file mode 100644 index 0000000000..6013c7dcd9 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.update.scope @@ -0,0 +1,33 @@ +void main() { + foo++; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo++; +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:10 + >------< +1| foo++; + +[#2 Removal] = 1:0-2:0 + >---------- +1| foo++; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| foo++; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope b/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope new file mode 100644 index 0000000000..7fba2976e6 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope @@ -0,0 +1,10 @@ +var foo = 0; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| var foo = 0; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope b/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope new file mode 100644 index 0000000000..bb966b47f5 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope @@ -0,0 +1,10 @@ +var foo; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| var foo; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.while.scope b/data/fixtures/scopes/dart/statement/statement.while.scope new file mode 100644 index 0000000000..4f509bb925 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.while.scope @@ -0,0 +1,33 @@ +void main() { + while (true) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| while (true) {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:19 + >---------------< +1| while (true) {} + +[#2 Removal] = 1:0-2:0 + >------------------- +1| while (true) {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| while (true) {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.yield.scope b/data/fixtures/scopes/dart/statement/statement.yield.scope new file mode 100644 index 0000000000..7aa11d778e --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.yield.scope @@ -0,0 +1,33 @@ +void main() { + yield 0; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| yield 0; +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| yield 0; + +[#2 Removal] = 1:0-2:0 + >------------ +1| yield 0; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| yield 0; + +[#2 Insertion delimiter] = "\n" diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index f952bc290a..68801a9151 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -5,7 +5,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const dartScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, - pairDelimiter: supported, list: supported, map: supported, ifStatement: supported, @@ -128,9 +127,7 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "statement.throw": supported, "statement.break": supported, "statement.continue": supported, - "statement.static": supported, "statement.import": supported, - "statement.misc": supported, "statement.iteration.document": supported, "statement.iteration.class": supported, "statement.iteration.block": supported, @@ -313,9 +310,12 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "functionCall.enum": notApplicable, "functionCallee.enum": notApplicable, - // Not applicable misc + // Miscellaneous + "statement.misc": notApplicable, + "statement.static": notApplicable, regularExpression: notApplicable, environment: notApplicable, selector: notApplicable, unit: notApplicable, + pairDelimiter: notApplicable, }; diff --git a/queries/dart.scm b/queries/dart.scm index 0793cb1577..6c5451b29d 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -1,3 +1,45 @@ +;; https://github.com/UserNobody14/tree-sitter-dart/blob/master/src/grammar.json + +[ + (library_import) + (class_definition) + (expression_statement) + (return_statement) + (yield_statement) + (while_statement) + (try_statement) + (do_statement) + (break_statement) + (continue_statement) + (for_statement) + (switch_statement) + (enum_declaration) + (type_alias) +] @statement + +;;!! var foo = 0; +;;! ^^^^^^^^^^^^ +(_ + (inferred_type) @statement.start + . + (initialized_identifier_list) + . + ";" @statement.end +) + +;;!! const foo = 0; +;;! ^^^^^^^^^^^^^^ +(_ + (const_builtin) @statement.start + . + (static_final_declaration_list + . + (static_final_declaration) + ) + . + ";" @statement.end +) + ( (program) @class.iteration @statement.iteration @namedFunction.iteration (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) @@ -30,6 +72,21 @@ name: (_) @name ) @class @name.domain +;;!! class Foo { } +;;! ^ +(class_body + "{" @namedFunction.iteration.start.endOf @statement.iteration.start.endOf + "}" @namedFunction.iteration.end.startOf @statement.iteration.end.startOf +) + +;;!! var foo = 0; +;;! ^^^^^^^^^^^^ +(class_body + (declaration) @statement.start + . + ";" @statement.end +) + ;;!! "hello world" ;;! ^^^^^^^^^^^^^ ;;! ^^^^^^^^^^^ @@ -48,9 +105,9 @@ (_ (function_signature name: (_) @name - ) @namedFunction.start @name.domain.start + ) @namedFunction.start @statement.start @name.domain.start . - (function_body) @namedFunction.end @name.domain.end + (function_body) @namedFunction.end @statement.end @name.domain.end ) ;;!! void foo() {} @@ -61,9 +118,9 @@ (_ name: (_) @name ) - ) @namedFunction.start @name.domain.start + ) @namedFunction.start @statement.start @name.domain.start . - (function_body) @namedFunction.end @name.domain.end + (function_body) @namedFunction.end @statement.end @name.domain.end ) ;;!! foo(); @@ -82,9 +139,42 @@ ) @functionCall.end @functionCallee.domain.end ) -;;!! class Foo { } -;;! ^ -(class_body - "{" @namedFunction.iteration.start.endOf - "}" @namedFunction.iteration.end.startOf -) +;;!! () {} +;;!! () => 0 +(function_expression) @anonymousFunction + +;;!! return 0; +;;! ^ +(return_statement + (_) @value +) @value.domain + +;;!! yield 0; +;;! ^ +(yield_statement + (_) @value +) @value.domain + +;;!! throw foo; +;;! ^^^ +(expression_statement + (throw_expression + (_) @value + ) +) @value.domain + +;;!! while (true) {} +;;! ^^^^ +(while_statement + (parenthesized_expression + (_) @condition + ) +) @condition.domain + +;;!! do {} while (true); +;;! ^^^^ +(do_statement + (parenthesized_expression + (_) @condition + ) +) @condition.domain From f4f13d35be51e1d2adb14e6246951c5e9504ab08 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 13:32:21 +0100 Subject: [PATCH 04/20] disqualified delimiter --- .../scopes/dart/disqualifyDelimiter.scope | 64 +++++++++++++++++++ queries/dart.scm | 29 +++++++++ 2 files changed, 93 insertions(+) create mode 100644 data/fixtures/scopes/dart/disqualifyDelimiter.scope diff --git a/data/fixtures/scopes/dart/disqualifyDelimiter.scope b/data/fixtures/scopes/dart/disqualifyDelimiter.scope new file mode 100644 index 0000000000..45065e8d65 --- /dev/null +++ b/data/fixtures/scopes/dart/disqualifyDelimiter.scope @@ -0,0 +1,64 @@ +void main() { + 1 < 2; + 1 > 2; + 1 <= 2; + 1 >= 2; + a << 2; + a >> 2; + a <<= 2; + a >>= 2; + a >>> 2; + a >>>= 2; + () => 2; +} +class Foo { + int get bar => 0; +} +--- +[#1 Content] = 1:6-1:7 + >-< +1| 1 < 2; + +[#2 Content] = 2:6-2:7 + >-< +2| 1 > 2; + +[#3 Content] = 3:6-3:8 + >--< +3| 1 <= 2; + +[#4 Content] = 4:6-4:8 + >--< +4| 1 >= 2; + +[#5 Content] = 5:6-5:8 + >--< +5| a << 2; + +[#6 Content] = 6:6-6:8 + >--< +6| a >> 2; + +[#7 Content] = 7:6-7:9 + >---< +7| a <<= 2; + +[#8 Content] = 8:6-8:9 + >---< +8| a >>= 2; + +[#9 Content] = 9:6-9:9 + >---< +9| a >>> 2; + +[#10 Content] = 10:6-10:10 + >----< +10| a >>>= 2; + +[#11 Content] = 11:7-11:9 + >--< +11| () => 2; + +[#12 Content] = 14:16-14:18 + >--< +14| int get bar => 0; diff --git a/queries/dart.scm b/queries/dart.scm index 6c5451b29d..bbb66d6ac9 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -178,3 +178,32 @@ (_) @condition ) ) @condition.domain + +(relational_operator + [ + "<" + ">" + "<=" + ">=" + ] +) @disqualifyDelimiter +(shift_operator + [ + "<<" + ">>" + ">>>" + ] +) @disqualifyDelimiter +(assignment_expression + operator: [ + "<<=" + ">>=" + ">>>=" + ] @disqualifyDelimiter +) +(function_expression_body + "=>" @disqualifyDelimiter +) +(function_body + "=>" @disqualifyDelimiter +) From 9746686fe1d6f4e7f16a15e12b29c998ce4634d4 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 13:45:05 +0100 Subject: [PATCH 05/20] map --- .../dart/key/key.mapPair.iteration.scope | 9 ++++ .../scopes/dart/key/key.mapPair.scope | 41 +++++++++++++++++++ data/fixtures/scopes/dart/map2.scope | 23 +++++++++++ .../dart/value/value.mapPair.iteration.scope | 9 ++++ .../scopes/dart/value/value.mapPair.scope | 41 +++++++++++++++++++ queries/dart.scm | 40 +++++++++++++++--- 6 files changed, 157 insertions(+), 6 deletions(-) create mode 100644 data/fixtures/scopes/dart/key/key.mapPair.iteration.scope create mode 100644 data/fixtures/scopes/dart/key/key.mapPair.scope create mode 100644 data/fixtures/scopes/dart/map2.scope create mode 100644 data/fixtures/scopes/dart/value/value.mapPair.iteration.scope create mode 100644 data/fixtures/scopes/dart/value/value.mapPair.scope diff --git a/data/fixtures/scopes/dart/key/key.mapPair.iteration.scope b/data/fixtures/scopes/dart/key/key.mapPair.iteration.scope new file mode 100644 index 0000000000..c1d91d11eb --- /dev/null +++ b/data/fixtures/scopes/dart/key/key.mapPair.iteration.scope @@ -0,0 +1,9 @@ +void main() { + {"aaa": 0, "bbb": 1}; +} +--- + +[Content] = +[Domain] = 1:5-1:23 + >------------------< +1| {"aaa": 0, "bbb": 1}; diff --git a/data/fixtures/scopes/dart/key/key.mapPair.scope b/data/fixtures/scopes/dart/key/key.mapPair.scope new file mode 100644 index 0000000000..6c0733528a --- /dev/null +++ b/data/fixtures/scopes/dart/key/key.mapPair.scope @@ -0,0 +1,41 @@ +void main() { + {"aaa": 0, "bbb": 1}; +} +--- + +[#1 Content] = 1:5-1:10 + >-----< +1| {"aaa": 0, "bbb": 1}; + +[#1 Removal] = 1:5-1:12 + >-------< +1| {"aaa": 0, "bbb": 1}; + +[#1 Trailing delimiter] = 1:10-1:12 + >--< +1| {"aaa": 0, "bbb": 1}; + +[#1 Domain] = 1:5-1:13 + >--------< +1| {"aaa": 0, "bbb": 1}; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:15-1:20 + >-----< +1| {"aaa": 0, "bbb": 1}; + +[#2 Removal] = 1:15-1:22 + >-------< +1| {"aaa": 0, "bbb": 1}; + +[#2 Trailing delimiter] = 1:20-1:22 + >--< +1| {"aaa": 0, "bbb": 1}; + +[#2 Domain] = 1:15-1:23 + >--------< +1| {"aaa": 0, "bbb": 1}; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/map2.scope b/data/fixtures/scopes/dart/map2.scope new file mode 100644 index 0000000000..9b79803695 --- /dev/null +++ b/data/fixtures/scopes/dart/map2.scope @@ -0,0 +1,23 @@ +void mai9n() { + final {"aaa": bar, "bbb": baz} = foo; +} +--- + +[Content] = +[Domain] = 1:10-1:34 + >------------------------< +1| final {"aaa": bar, "bbb": baz} = foo; + +[Removal] = 1:10-1:35 + >-------------------------< +1| final {"aaa": bar, "bbb": baz} = foo; + +[Leading delimiter] = 1:9-1:10 + >-< +1| final {"aaa": bar, "bbb": baz} = foo; + +[Trailing delimiter] = 1:34-1:35 + >-< +1| final {"aaa": bar, "bbb": baz} = foo; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope b/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope new file mode 100644 index 0000000000..c1d91d11eb --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope @@ -0,0 +1,9 @@ +void main() { + {"aaa": 0, "bbb": 1}; +} +--- + +[Content] = +[Domain] = 1:5-1:23 + >------------------< +1| {"aaa": 0, "bbb": 1}; diff --git a/data/fixtures/scopes/dart/value/value.mapPair.scope b/data/fixtures/scopes/dart/value/value.mapPair.scope new file mode 100644 index 0000000000..b5aad62a34 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.mapPair.scope @@ -0,0 +1,41 @@ +void main() { + {"aaa": 0, "bbb": 1}; +} +--- + +[#1 Content] = 1:12-1:13 + >-< +1| {"aaa": 0, "bbb": 1}; + +[#1 Removal] = 1:10-1:13 + >---< +1| {"aaa": 0, "bbb": 1}; + +[#1 Leading delimiter] = 1:10-1:12 + >--< +1| {"aaa": 0, "bbb": 1}; + +[#1 Domain] = 1:5-1:13 + >--------< +1| {"aaa": 0, "bbb": 1}; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:22-1:23 + >-< +1| {"aaa": 0, "bbb": 1}; + +[#2 Removal] = 1:20-1:23 + >---< +1| {"aaa": 0, "bbb": 1}; + +[#2 Leading delimiter] = 1:20-1:22 + >--< +1| {"aaa": 0, "bbb": 1}; + +[#2 Domain] = 1:15-1:23 + >--------< +1| {"aaa": 0, "bbb": 1}; + +[#2 Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index bbb66d6ac9..554483118e 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -59,12 +59,40 @@ (list_pattern) ] @list -;;!! { value: 0 } -;;! ^^^^^^^^^^^^ -[ - (set_or_map_literal) - (map_pattern) -] @map +;;!! {"aaa": 0, "bbb": 1} +;;! ^^^^^^^^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^^^^^^^^ +(set_or_map_literal + "{" @collectionKey.iteration.start.endOf @value.iteration.start.endOf + "}" @collectionKey.iteration.end.startOf @value.iteration.end.startOf +) @map + +;;!! final {"aaa": 0, "bbb": 1} = foo; +;;! ^^^^^^^^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^^^^^^^^ +(map_pattern + "{" @collectionKey.iteration.start.endOf @value.iteration.start.endOf + "}" @collectionKey.iteration.end.startOf @value.iteration.end.startOf +) @map + +;;!! {"aaa": 0, "bbb": 1} +;;! ^^^^^ ^^^^^ +;;! ^ ^ +(pair + key: (_) @collectionKey @value.leading.endOf + value: (_) @value @collectionKey.trailing.startOf +) @_.domain + +;;!! final {"aaa": bar, "bbb": baz} = foo; +;;! ^^^^^ ^^^^^ +;;! ^^^ ^^^ +(map_pattern + (_) @collectionKey @value.leading.endOf @_.domain.start + . + ":" + . + (_) @value @collectionKey.trailing.startOf @_.domain.end +) ;;!! class Foo {} ;;! ^^^^^^^^^^^^ From 9de78c740d4e3d778d474c12ec17f4416b75f10d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 14:24:52 +0100 Subject: [PATCH 06/20] branch and condition --- .../dart/branch/branch.if.iteration.scope | 14 ++ .../branch/branch.switchCase.iteration.scope | 9 ++ .../dart/branch/branch.switchCase.scope | 27 ++++ .../dart/branch/branch.switchCase2.scope | 23 ++++ .../branch/branch.ternary.iteration.scope | 9 ++ .../scopes/dart/branch/branch.ternary.scope | 39 ++++++ .../dart/branch/branch.try.iteration.scope | 14 ++ .../scopes/dart/branch/branch.try.scope | 59 +++++++++ .../dart/condition/condition.doWhile.scope | 15 +++ .../scopes/dart/condition/condition.for.scope | 22 ++++ .../scopes/dart/condition/condition.if.scope | 32 +++++ .../condition.switchCase.iteration.scope | 9 ++ .../dart/condition/condition.switchCase.scope | 24 ++++ .../dart/condition/condition.ternary.scope | 26 ++++ .../dart/condition/condition.while.scope | 15 +++ .../scopes/dart/name/name.foreach.scope | 45 +++++++ .../dart/name/name.iteration.document.scope | 12 ++ .../scopes/dart/name/name.typeAlias.scope | 24 ++++ .../scopes/dart/value/value.foreach.scope | 22 ++++ .../dart/value/value.iteration.document.scope | 12 ++ .../dart/value/value.mapPair.iteration.scope | 13 +- .../scopes/dart/value/value.return.scope | 22 ++++ .../scopes/dart/value/value.switch.scope | 15 +++ .../scopes/dart/value/value.throw.scope | 22 ++++ .../scopes/dart/value/value.typeAlias.scope | 20 +++ .../scopes/dart/value/value.yield.scope | 22 ++++ queries/dart.scm | 120 +++++++++++++++++- 27 files changed, 681 insertions(+), 5 deletions(-) create mode 100644 data/fixtures/scopes/dart/branch/branch.if.iteration.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.switchCase.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.switchCase2.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.ternary.iteration.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.ternary.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.try.iteration.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.try.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.doWhile.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.for.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.if.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.switchCase.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.ternary.scope create mode 100644 data/fixtures/scopes/dart/condition/condition.while.scope create mode 100644 data/fixtures/scopes/dart/name/name.foreach.scope create mode 100644 data/fixtures/scopes/dart/name/name.iteration.document.scope create mode 100644 data/fixtures/scopes/dart/name/name.typeAlias.scope create mode 100644 data/fixtures/scopes/dart/value/value.foreach.scope create mode 100644 data/fixtures/scopes/dart/value/value.iteration.document.scope create mode 100644 data/fixtures/scopes/dart/value/value.return.scope create mode 100644 data/fixtures/scopes/dart/value/value.switch.scope create mode 100644 data/fixtures/scopes/dart/value/value.throw.scope create mode 100644 data/fixtures/scopes/dart/value/value.typeAlias.scope create mode 100644 data/fixtures/scopes/dart/value/value.yield.scope diff --git a/data/fixtures/scopes/dart/branch/branch.if.iteration.scope b/data/fixtures/scopes/dart/branch/branch.if.iteration.scope new file mode 100644 index 0000000000..9b9826c344 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.if.iteration.scope @@ -0,0 +1,14 @@ +void main() { + if (true) {} + else if (false) {} + else {} +} +--- + +[Content] = +[Domain] = 1:4-3:11 + >------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -----------< diff --git a/data/fixtures/scopes/dart/branch/branch.switchCase.iteration.scope b/data/fixtures/scopes/dart/branch/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..0dc65caa10 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.switchCase.iteration.scope @@ -0,0 +1,9 @@ +void main() { + switch (foo) { } +} +--- + +[Content] = +[Domain] = 1:18-1:19 + >-< +1| switch (foo) { } diff --git a/data/fixtures/scopes/dart/branch/branch.switchCase.scope b/data/fixtures/scopes/dart/branch/branch.switchCase.scope new file mode 100644 index 0000000000..413f68bc0e --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.switchCase.scope @@ -0,0 +1,27 @@ +void main() { + switch (foo) { + case 0: + break; + } +} +--- + +[Content] = +[Domain] = 2:8-3:18 + >------- +2| case 0: +3| break; + ------------------< + +[Removal] = 2:0-4:0 + >--------------- +2| case 0: +3| break; +4| } + < + +[Leading delimiter] = 2:0-2:8 + >--------< +2| case 0: + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/branch/branch.switchCase2.scope b/data/fixtures/scopes/dart/branch/branch.switchCase2.scope new file mode 100644 index 0000000000..8250be9d93 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.switchCase2.scope @@ -0,0 +1,23 @@ +void main() { + switch (foo) { + default: {} + } +} +--- + +[Content] = +[Domain] = 2:8-2:19 + >-----------< +2| default: {} + +[Removal] = 2:0-3:0 + >------------------- +2| default: {} +3| } + < + +[Leading delimiter] = 2:0-2:8 + >--------< +2| default: {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/branch/branch.ternary.iteration.scope b/data/fixtures/scopes/dart/branch/branch.ternary.iteration.scope new file mode 100644 index 0000000000..f7db1a12c3 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.ternary.iteration.scope @@ -0,0 +1,9 @@ +void main() { + true ? 0 : 1; +} +--- + +[Content] = +[Domain] = 1:4-1:16 + >------------< +1| true ? 0 : 1; diff --git a/data/fixtures/scopes/dart/branch/branch.ternary.scope b/data/fixtures/scopes/dart/branch/branch.ternary.scope new file mode 100644 index 0000000000..d7d3751aed --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.ternary.scope @@ -0,0 +1,39 @@ +void main() { + true ? 0 : 1; +} +--- + +[#1 Content] = +[#1 Domain] = 1:11-1:12 + >-< +1| true ? 0 : 1; + +[#1 Removal] = 1:11-1:13 + >--< +1| true ? 0 : 1; + +[#1 Leading delimiter] = 1:10-1:11 + >-< +1| true ? 0 : 1; + +[#1 Trailing delimiter] = 1:12-1:13 + >-< +1| true ? 0 : 1; + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:15-1:16 + >-< +1| true ? 0 : 1; + +[#2 Removal] = 1:14-1:16 + >--< +1| true ? 0 : 1; + +[#2 Leading delimiter] = 1:14-1:15 + >-< +1| true ? 0 : 1; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/branch/branch.try.iteration.scope b/data/fixtures/scopes/dart/branch/branch.try.iteration.scope new file mode 100644 index 0000000000..5f591026e5 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.try.iteration.scope @@ -0,0 +1,14 @@ +void main() { + try {} + catch (e) {} + finally {} +} +--- + +[Content] = +[Domain] = 1:4-3:14 + >------ +1| try {} +2| catch (e) {} +3| finally {} + --------------< diff --git a/data/fixtures/scopes/dart/branch/branch.try.scope b/data/fixtures/scopes/dart/branch/branch.try.scope new file mode 100644 index 0000000000..8e005b2714 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.try.scope @@ -0,0 +1,59 @@ +void main() { + try {} + catch (e) {} + finally {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:10 + >------< +1| try {} + +[#1 Removal] = 1:0-2:0 + >---------- +1| try {} +2| catch (e) {} + < + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| try {} + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:16 + >------------< +2| catch (e) {} + +[#2 Removal] = 2:0-3:0 + >---------------- +2| catch (e) {} +3| finally {} + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| catch (e) {} + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:4-3:14 + >----------< +3| finally {} + +[#3 Removal] = 3:0-4:0 + >-------------- +3| finally {} +4| } + < + +[#3 Leading delimiter] = 3:0-3:4 + >----< +3| finally {} + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/condition/condition.doWhile.scope b/data/fixtures/scopes/dart/condition/condition.doWhile.scope new file mode 100644 index 0000000000..e8acd57698 --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.doWhile.scope @@ -0,0 +1,15 @@ +void main() { + do {} while (true); +} +--- + +[Content] = +[Removal] = 1:17-1:21 + >----< +1| do {} while (true); + +[Domain] = 1:4-1:23 + >-------------------< +1| do {} while (true); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/condition/condition.for.scope b/data/fixtures/scopes/dart/condition/condition.for.scope new file mode 100644 index 0000000000..6a97afe44f --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.for.scope @@ -0,0 +1,22 @@ +void main() { + for (var i = 0; i < size; i++) {} +} +--- + +[Content] = 1:20-1:28 + >--------< +1| for (var i = 0; i < size; i++) {} + +[Removal] = 1:19-1:28 + >---------< +1| for (var i = 0; i < size; i++) {} + +[Leading delimiter] = 1:19-1:20 + >-< +1| for (var i = 0; i < size; i++) {} + +[Domain] = 1:4-1:37 + >---------------------------------< +1| for (var i = 0; i < size; i++) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/condition/condition.if.scope b/data/fixtures/scopes/dart/condition/condition.if.scope new file mode 100644 index 0000000000..c7d2ec769c --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.if.scope @@ -0,0 +1,32 @@ +void main() { + if (true) {} + else if (false) {} + else {} +} +--- + +[#1 Content] = +[#1 Removal] = 1:8-1:12 + >----< +1| if (true) {} + +[#1 Domain] = 1:4-3:11 + >------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -----------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:13-2:18 + >-----< +2| else if (false) {} + +[#2 Domain] = 2:4-2:22 + >------------------< +2| else if (false) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/condition/condition.switchCase.iteration.scope b/data/fixtures/scopes/dart/condition/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..0dc65caa10 --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.switchCase.iteration.scope @@ -0,0 +1,9 @@ +void main() { + switch (foo) { } +} +--- + +[Content] = +[Domain] = 1:18-1:19 + >-< +1| switch (foo) { } diff --git a/data/fixtures/scopes/dart/condition/condition.switchCase.scope b/data/fixtures/scopes/dart/condition/condition.switchCase.scope new file mode 100644 index 0000000000..f661838de8 --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.switchCase.scope @@ -0,0 +1,24 @@ +void main() { + switch (foo) { + case 0: break; + } +} +--- + +[Content] = 2:13-2:14 + >-< +2| case 0: break; + +[Removal] = 2:12-2:14 + >--< +2| case 0: break; + +[Leading delimiter] = 2:12-2:13 + >-< +2| case 0: break; + +[Domain] = 2:8-2:22 + >--------------< +2| case 0: break; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/condition/condition.ternary.scope b/data/fixtures/scopes/dart/condition/condition.ternary.scope new file mode 100644 index 0000000000..661043b1b9 --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.ternary.scope @@ -0,0 +1,26 @@ +void main() { + true ? 0 : 1; +} +--- + +[Content] = 1:4-1:8 + >----< +1| true ? 0 : 1; + +[Removal] = 1:4-1:9 + >-----< +1| true ? 0 : 1; + +[Leading delimiter] = 1:0-1:4 + >----< +1| true ? 0 : 1; + +[Trailing delimiter] = 1:8-1:9 + >-< +1| true ? 0 : 1; + +[Domain] = 1:4-1:16 + >------------< +1| true ? 0 : 1; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/condition/condition.while.scope b/data/fixtures/scopes/dart/condition/condition.while.scope new file mode 100644 index 0000000000..c8f2ddd08d --- /dev/null +++ b/data/fixtures/scopes/dart/condition/condition.while.scope @@ -0,0 +1,15 @@ +void main() { + while (true) {} +} +--- + +[Content] = +[Removal] = 1:11-1:15 + >----< +1| while (true) {} + +[Domain] = 1:4-1:19 + >---------------< +1| while (true) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.foreach.scope b/data/fixtures/scopes/dart/name/name.foreach.scope new file mode 100644 index 0000000000..8476d15987 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.foreach.scope @@ -0,0 +1,45 @@ +void main() { + for (final v in values) {} +} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| for (final v in values) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:15-1:16 + >-< +1| for (final v in values) {} + +[#2 Removal] = 1:15-1:17 + >--< +1| for (final v in values) {} + +[#2 Leading delimiter] = 1:14-1:15 + >-< +1| for (final v in values) {} + +[#2 Trailing delimiter] = 1:16-1:17 + >-< +1| for (final v in values) {} + +[#2 Domain] = 1:4-1:30 + >--------------------------< +1| for (final v in values) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.iteration.document.scope b/data/fixtures/scopes/dart/name/name.iteration.document.scope new file mode 100644 index 0000000000..8441b73e49 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo = 0; + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo = 0; +2| + < diff --git a/data/fixtures/scopes/dart/name/name.typeAlias.scope b/data/fixtures/scopes/dart/name/name.typeAlias.scope new file mode 100644 index 0000000000..a91d453657 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.typeAlias.scope @@ -0,0 +1,24 @@ +typedef Foo = int; +--- + +[Content] = 0:8-0:11 + >---< +0| typedef Foo = int; + +[Removal] = 0:0-0:14 + >--------------< +0| typedef Foo = int; + +[Leading delimiter] = 0:7-0:8 + >-< +0| typedef Foo = int; + +[Trailing delimiter] = 0:11-0:12 + >-< +0| typedef Foo = int; + +[Domain] = 0:0-0:18 + >------------------< +0| typedef Foo = int; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.foreach.scope b/data/fixtures/scopes/dart/value/value.foreach.scope new file mode 100644 index 0000000000..04f9ed6d28 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.foreach.scope @@ -0,0 +1,22 @@ +void main() { + for (final v in values) {} +} +--- + +[Content] = 1:20-1:26 + >------< +1| for (final v in values) {} + +[Removal] = 1:19-1:26 + >-------< +1| for (final v in values) {} + +[Leading delimiter] = 1:19-1:20 + >-< +1| for (final v in values) {} + +[Domain] = 1:4-1:30 + >--------------------------< +1| for (final v in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.iteration.document.scope b/data/fixtures/scopes/dart/value/value.iteration.document.scope new file mode 100644 index 0000000000..8441b73e49 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo = 0; + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo = 0; +2| + < diff --git a/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope b/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope index c1d91d11eb..f8b0d0dd1a 100644 --- a/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope +++ b/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope @@ -3,7 +3,16 @@ void main() { } --- -[Content] = -[Domain] = 1:5-1:23 +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| {"aaa": 0, "bbb": 1}; +2| } + -< + + +[#2 Content] = +[#2 Domain] = 1:5-1:23 >------------------< 1| {"aaa": 0, "bbb": 1}; diff --git a/data/fixtures/scopes/dart/value/value.return.scope b/data/fixtures/scopes/dart/value/value.return.scope new file mode 100644 index 0000000000..2b9370f11e --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.return.scope @@ -0,0 +1,22 @@ +void foo() { + return 0; +} +--- + +[Content] = 1:15-1:16 + >-< +1| return 0; + +[Removal] = 1:14-1:16 + >--< +1| return 0; + +[Leading delimiter] = 1:14-1:15 + >-< +1| return 0; + +[Domain] = 1:8-1:17 + >---------< +1| return 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.switch.scope b/data/fixtures/scopes/dart/value/value.switch.scope new file mode 100644 index 0000000000..2b25bd43a0 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.switch.scope @@ -0,0 +1,15 @@ +void main() { + switch (foo) {} +} +--- + +[Content] = +[Removal] = 1:12-1:15 + >---< +1| switch (foo) {} + +[Domain] = 1:4-1:19 + >---------------< +1| switch (foo) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.throw.scope b/data/fixtures/scopes/dart/value/value.throw.scope new file mode 100644 index 0000000000..307804dd65 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.throw.scope @@ -0,0 +1,22 @@ +void main() { + throw foo; +} +--- + +[Content] = 1:10-1:13 + >---< +1| throw foo; + +[Removal] = 1:9-1:13 + >----< +1| throw foo; + +[Leading delimiter] = 1:9-1:10 + >-< +1| throw foo; + +[Domain] = 1:4-1:14 + >----------< +1| throw foo; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.typeAlias.scope b/data/fixtures/scopes/dart/value/value.typeAlias.scope new file mode 100644 index 0000000000..33fd00595a --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.typeAlias.scope @@ -0,0 +1,20 @@ +typedef Foo = int; +--- + +[Content] = 0:14-0:17 + >---< +0| typedef Foo = int; + +[Removal] = 0:11-0:17 + >------< +0| typedef Foo = int; + +[Leading delimiter] = 0:11-0:14 + >---< +0| typedef Foo = int; + +[Domain] = 0:0-0:18 + >------------------< +0| typedef Foo = int; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.yield.scope b/data/fixtures/scopes/dart/value/value.yield.scope new file mode 100644 index 0000000000..4646c52836 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.yield.scope @@ -0,0 +1,22 @@ +void main() { + yield 0; +} +--- + +[Content] = 1:10-1:11 + >-< +1| yield 0; + +[Removal] = 1:9-1:11 + >--< +1| yield 0; + +[Leading delimiter] = 1:9-1:10 + >-< +1| yield 0; + +[Domain] = 1:4-1:12 + >--------< +1| yield 0; + +[Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index 554483118e..4596eb0309 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -45,13 +45,56 @@ (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) ) -;;!! if () {} -;;! ^^^^^^^^ ( - (if_statement) @ifStatement @statement + (program) @name.iteration @value.iteration + (#document-range! @name.iteration @value.iteration) +) + +;;!! if () {} else {} +;;! ^^^^^^^^^^^^^^^^ +( + (if_statement + . + (_) @condition + ) @ifStatement @statement @condition.domain (#not-parent-type? @ifStatement if_statement) ) +( + (if_statement) @branch.iteration + (#not-parent-type? @branch.iteration if_statement) +) + +;;!! else if () {} +;;! ^^^^^^^^^^^^^ +(if_statement + "else" @condition.domain.start + (if_statement + . + (_) @condition + consequence: (_) @condition.domain.end + ) +) + +;;!! try {} catch () {} finally {} +;;! ^^^^^^ +(try_statement + "try" @branch.start + body: (_) @branch.end +) @branch.iteration + +;;!! catch () +;;! ^^^^^^^^ +(try_statement + (catch_clause) @branch.start + . + (block) @branch.end +) + +;;!! finally () +;;! ^^^^^^^^^^ +(finally_clause) @branch + ;;!! [ 0 ] ;;! ^^^^^ [ @@ -191,6 +234,24 @@ ) ) @value.domain +;;!! for (var i = 0; i < size; i++) {} +;;! ^^^^^^^^ +(for_statement + (for_loop_parts + condition: (_) @condition + ) +) @condition.domain + +;;!! for (final v in values) {} +;;! ^ +;;! ^^^^^^ +(for_statement + (for_loop_parts + name: (_) @name + value: (_) @value + ) +) @_.domain + ;;!! while (true) {} ;;! ^^^^ (while_statement @@ -207,6 +268,59 @@ ) ) @condition.domain +;;!! switch (foo) {} +;;! ^^^ +(switch_statement + (parenthesized_expression + (_) @value + ) +) @value.domain + +;;!! case 0: break; +;;! ^^^^^^^^^^^^^^ +;;! ^ +(switch_statement_case + (case_builtin) + . + (_) @condition +) @branch @condition.domain + +;;!! default: break; +;;! ^^^^^^^^^^^^^^^ +(switch_statement_default) @branch + +;;!! switch () { } +;;! ^ +(switch_block + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf +) + +;;!! true ? 0 : 1; +;;! ^^^^ +;;! ^ ^ +(conditional_expression + . + (_) @condition + consequence: (_) @branch +) @condition.domain + +(conditional_expression + alternative: (_) @branch +) + +;;!! true ? 0 : 1; +(conditional_expression) @branch.iteration + +;;!! typedef Foo = int; +;;! ^^^ +;;! ^^^ +(type_alias + "typedef" @name.removal.start.startOf + (_) @name @value.leading.endOf + (_) @value @name.removal.end.startOf +) @_.domain + (relational_operator [ "<" From 1e5ccf163809c63f1cfdda7f8614036646689030 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 14:40:27 +0100 Subject: [PATCH 07/20] variables --- .../scopes/dart/name/name.assignment.scope | 41 +++++++++++ .../scopes/dart/name/name.constant.scope | 24 +++++++ .../dart/name/name.variable.initialized.scope | 24 +++++++ .../name/name.variable.uninitialized.scope | 17 +++++ .../scopes/dart/value/value.assignment.scope | 22 ++++++ .../scopes/dart/value/value.constant.scope | 20 ++++++ .../scopes/dart/value/value.variable.scope | 20 ++++++ queries/dart.scm | 70 ++++++++++++++----- 8 files changed, 222 insertions(+), 16 deletions(-) create mode 100644 data/fixtures/scopes/dart/name/name.assignment.scope create mode 100644 data/fixtures/scopes/dart/name/name.constant.scope create mode 100644 data/fixtures/scopes/dart/name/name.variable.initialized.scope create mode 100644 data/fixtures/scopes/dart/name/name.variable.uninitialized.scope create mode 100644 data/fixtures/scopes/dart/value/value.assignment.scope create mode 100644 data/fixtures/scopes/dart/value/value.constant.scope create mode 100644 data/fixtures/scopes/dart/value/value.variable.scope diff --git a/data/fixtures/scopes/dart/name/name.assignment.scope b/data/fixtures/scopes/dart/name/name.assignment.scope new file mode 100644 index 0000000000..8c9fe94e1a --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.assignment.scope @@ -0,0 +1,41 @@ +void main() { + foo = 0; +} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo = 0; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| foo = 0; + +[#2 Removal] = 1:4-1:10 + >------< +1| foo = 0; + +[#2 Trailing delimiter] = 1:7-1:10 + >---< +1| foo = 0; + +[#2 Domain] = 1:4-1:12 + >--------< +1| foo = 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.constant.scope b/data/fixtures/scopes/dart/name/name.constant.scope new file mode 100644 index 0000000000..cd15b48a5a --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.constant.scope @@ -0,0 +1,24 @@ +const foo = 0; +--- + +[Content] = 0:6-0:9 + >---< +0| const foo = 0; + +[Removal] = 0:0-0:12 + >------------< +0| const foo = 0; + +[Leading delimiter] = 0:5-0:6 + >-< +0| const foo = 0; + +[Trailing delimiter] = 0:9-0:10 + >-< +0| const foo = 0; + +[Domain] = 0:0-0:14 + >--------------< +0| const foo = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.variable.initialized.scope b/data/fixtures/scopes/dart/name/name.variable.initialized.scope new file mode 100644 index 0000000000..263bc28906 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.variable.initialized.scope @@ -0,0 +1,24 @@ +var foo = 0; +--- + +[Content] = 0:4-0:7 + >---< +0| var foo = 0; + +[Removal] = 0:0-0:10 + >----------< +0| var foo = 0; + +[Leading delimiter] = 0:3-0:4 + >-< +0| var foo = 0; + +[Trailing delimiter] = 0:7-0:8 + >-< +0| var foo = 0; + +[Domain] = 0:0-0:12 + >------------< +0| var foo = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope b/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope new file mode 100644 index 0000000000..73ee2234af --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope @@ -0,0 +1,17 @@ +var foo; +--- + +[Content] = 0:4-0:7 + >---< +0| var foo; + +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| var foo; + +[Leading delimiter] = 0:3-0:4 + >-< +0| var foo; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.assignment.scope b/data/fixtures/scopes/dart/value/value.assignment.scope new file mode 100644 index 0000000000..a3edce54cd --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.assignment.scope @@ -0,0 +1,22 @@ +void main() { + foo = 0; +} +--- + +[Content] = 1:10-1:11 + >-< +1| foo = 0; + +[Removal] = 1:7-1:11 + >----< +1| foo = 0; + +[Leading delimiter] = 1:7-1:10 + >---< +1| foo = 0; + +[Domain] = 1:4-1:12 + >--------< +1| foo = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.constant.scope b/data/fixtures/scopes/dart/value/value.constant.scope new file mode 100644 index 0000000000..b52ad1e5c6 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.constant.scope @@ -0,0 +1,20 @@ +const foo = 0; +--- + +[Content] = 0:12-0:13 + >-< +0| const foo = 0; + +[Removal] = 0:9-0:13 + >----< +0| const foo = 0; + +[Leading delimiter] = 0:9-0:12 + >---< +0| const foo = 0; + +[Domain] = 0:0-0:14 + >--------------< +0| const foo = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.variable.scope b/data/fixtures/scopes/dart/value/value.variable.scope new file mode 100644 index 0000000000..28cc6fc03f --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.variable.scope @@ -0,0 +1,20 @@ +var foo = 0; +--- + +[Content] = 0:10-0:11 + >-< +0| var foo = 0; + +[Removal] = 0:7-0:11 + >----< +0| var foo = 0; + +[Leading delimiter] = 0:7-0:10 + >---< +0| var foo = 0; + +[Domain] = 0:0-0:12 + >------------< +0| var foo = 0; + +[Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index 4596eb0309..4cf336992d 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -17,38 +17,76 @@ (type_alias) ] @statement +( + (program) @class.iteration @statement.iteration @namedFunction.iteration + (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) +) + +( + (program) @name.iteration @value.iteration + (#document-range! @name.iteration @value.iteration) +) + ;;!! var foo = 0; ;;! ^^^^^^^^^^^^ +;;! ^^^ +;;! ^ (_ - (inferred_type) @statement.start + (inferred_type) @statement.start @_.domain.start @name.removal.start.startOf . - (initialized_identifier_list) + (initialized_identifier_list + (initialized_identifier + (_) @name @value.leading.endOf + (_) @value @name.removal.end.startOf + ) + ) . - ";" @statement.end + ";" @statement.end @_.domain.end +) + +;;!! var foo; +;;! ^^^^^^^^ +;;! ^^^ +(_ + (inferred_type) @statement.start @name.removal.start @name.domain.start + . + (initialized_identifier_list + (initialized_identifier + . + (_) @name + . + ) + ) + . + ";" @statement.end @name.removal.end @name.domain.end ) ;;!! const foo = 0; ;;! ^^^^^^^^^^^^^^ +;;! ^^^ +;;! ^ (_ - (const_builtin) @statement.start + (const_builtin) @statement.start @_.domain.start @name.removal.start.startOf . (static_final_declaration_list - . - (static_final_declaration) + (static_final_declaration + (_) @name @value.leading.endOf + (_) @value @name.removal.end.startOf + ) ) . - ";" @statement.end + ";" @statement.end @_.domain.end ) -( - (program) @class.iteration @statement.iteration @namedFunction.iteration - (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) -) - -( - (program) @name.iteration @value.iteration - (#document-range! @name.iteration @value.iteration) -) +;;!! foo = 0; +;;! ^^^ +;;! ^ +(expression_statement + (assignment_expression + left: (_) @name @value.leading.endOf + right: (_) @value @name.trailing.startOf + ) +) @_.domain ;;!! if () {} else {} ;;! ^^^^^^^^^^^^^^^^ From fb0eaca74b6dfc91d646fd9b5e63f49fa8ac36e2 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 15:15:44 +0100 Subject: [PATCH 08/20] more --- .../scopes/cpp/value/value.field.class.scope | 10 +-- .../dart/functionCall/functionCall.enum.scope | 19 +++++ .../functionCallee/functionCallee.enum.scope | 19 +++++ .../dart/name/name.assignment.compound.scope | 41 ++++++++++ .../scopes/dart/name/name.constructor.scope | 45 +++++++++++ .../fixtures/scopes/dart/name/name.enum.scope | 24 ++++++ .../scopes/dart/name/name.field.class.scope | 70 ++++++++++++++++ .../scopes/dart/name/name.field.enum.scope | 63 +++++++++++++++ .../scopes/dart/name/name.function.scope | 17 ++++ .../dart/name/name.iteration.class.scope | 13 +++ .../dart/name/name.iteration.enum.scope | 13 +++ .../scopes/dart/name/name.method.scope | 45 +++++++++++ .../value/value.assignment.compound.scope | 22 ++++++ .../scopes/dart/value/value.field.class.scope | 22 ++++++ .../dart/value/value.iteration.class.scope | 13 +++ .../dart/value/value.return.lambda.scope | 22 ++++++ .../common/src/scopeSupportFacets/dart.ts | 10 +-- queries/dart.scm | 79 ++++++++++++++++++- 18 files changed, 534 insertions(+), 13 deletions(-) create mode 100644 data/fixtures/scopes/dart/functionCall/functionCall.enum.scope create mode 100644 data/fixtures/scopes/dart/functionCallee/functionCallee.enum.scope create mode 100644 data/fixtures/scopes/dart/name/name.assignment.compound.scope create mode 100644 data/fixtures/scopes/dart/name/name.constructor.scope create mode 100644 data/fixtures/scopes/dart/name/name.enum.scope create mode 100644 data/fixtures/scopes/dart/name/name.field.class.scope create mode 100644 data/fixtures/scopes/dart/name/name.field.enum.scope create mode 100644 data/fixtures/scopes/dart/name/name.function.scope create mode 100644 data/fixtures/scopes/dart/name/name.iteration.class.scope create mode 100644 data/fixtures/scopes/dart/name/name.iteration.enum.scope create mode 100644 data/fixtures/scopes/dart/name/name.method.scope create mode 100644 data/fixtures/scopes/dart/value/value.assignment.compound.scope create mode 100644 data/fixtures/scopes/dart/value/value.field.class.scope create mode 100644 data/fixtures/scopes/dart/value/value.iteration.class.scope create mode 100644 data/fixtures/scopes/dart/value/value.return.lambda.scope diff --git a/data/fixtures/scopes/cpp/value/value.field.class.scope b/data/fixtures/scopes/cpp/value/value.field.class.scope index b012818782..9e2a894d39 100644 --- a/data/fixtures/scopes/cpp/value/value.field.class.scope +++ b/data/fixtures/scopes/cpp/value/value.field.class.scope @@ -1,22 +1,22 @@ class Foo { - int bar = 1; + int bar = 0; } --- [Content] = 1:14-1:15 >-< -1| int bar = 1; +1| int bar = 0; [Removal] = 1:11-1:15 >----< -1| int bar = 1; +1| int bar = 0; [Leading delimiter] = 1:11-1:14 >---< -1| int bar = 1; +1| int bar = 0; [Domain] = 1:4-1:16 >------------< -1| int bar = 1; +1| int bar = 0; [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCall/functionCall.enum.scope b/data/fixtures/scopes/dart/functionCall/functionCall.enum.scope new file mode 100644 index 0000000000..c64c6f6094 --- /dev/null +++ b/data/fixtures/scopes/dart/functionCall/functionCall.enum.scope @@ -0,0 +1,19 @@ +enum Foo { + bar(); +} +--- + +[Content] = +[Domain] = 1:4-1:9 + >-----< +1| bar(); + +[Removal] = 1:0-1:9 + >---------< +1| bar(); + +[Leading delimiter] = 1:0-1:4 + >----< +1| bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/functionCallee/functionCallee.enum.scope b/data/fixtures/scopes/dart/functionCallee/functionCallee.enum.scope new file mode 100644 index 0000000000..332b38850a --- /dev/null +++ b/data/fixtures/scopes/dart/functionCallee/functionCallee.enum.scope @@ -0,0 +1,19 @@ +enum Foo { + bar(); +} +--- + +[Content] = +[Removal] = 1:4-1:7 + >---< +1| bar(); + +[Leading delimiter] = 1:0-1:4 + >----< +1| bar(); + +[Domain] = 1:4-1:9 + >-----< +1| bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.assignment.compound.scope b/data/fixtures/scopes/dart/name/name.assignment.compound.scope new file mode 100644 index 0000000000..42ac3a07fe --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.assignment.compound.scope @@ -0,0 +1,41 @@ +void main() { + foo += 0; +} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo += 0; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| foo += 0; + +[#2 Removal] = 1:4-1:11 + >-------< +1| foo += 0; + +[#2 Trailing delimiter] = 1:7-1:11 + >----< +1| foo += 0; + +[#2 Domain] = 1:4-1:13 + >---------< +1| foo += 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.constructor.scope b/data/fixtures/scopes/dart/name/name.constructor.scope new file mode 100644 index 0000000000..6c60f1ed8b --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.constructor.scope @@ -0,0 +1,45 @@ +class Foo { + Foo() {} +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| class Foo { + +[#1 Removal] = 0:6-0:10 + >----< +0| class Foo { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo { + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo { + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:8-1:11 + >---< +1| Foo() {} + +[#2 Leading delimiter] = 1:0-1:8 + >--------< +1| Foo() {} + +[#2 Domain] = 1:8-1:16 + >--------< +1| Foo() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.enum.scope b/data/fixtures/scopes/dart/name/name.enum.scope new file mode 100644 index 0000000000..09d2849071 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.enum.scope @@ -0,0 +1,24 @@ +enum Foo {} +--- + +[Content] = 0:5-0:8 + >---< +0| enum Foo {} + +[Removal] = 0:5-0:9 + >----< +0| enum Foo {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| enum Foo {} + +[Trailing delimiter] = 0:8-0:9 + >-< +0| enum Foo {} + +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.field.class.scope b/data/fixtures/scopes/dart/name/name.field.class.scope new file mode 100644 index 0000000000..7ccecb1c47 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.field.class.scope @@ -0,0 +1,70 @@ +class Foo { + var bar; + var baz = 1; +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| class Foo { + +[#1 Removal] = 0:6-0:10 + >----< +0| class Foo { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo { + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo { + +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| var bar; +2| var baz = 1; +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| var bar; + +[#2 Removal] = +[#2 Domain] = 1:4-1:12 + >--------< +1| var bar; + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| var bar; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:8-2:11 + >---< +2| var baz = 1; + +[#3 Removal] = 2:4-2:14 + >----------< +2| var baz = 1; + +[#3 Leading delimiter] = 2:7-2:8 + >-< +2| var baz = 1; + +[#3 Trailing delimiter] = 2:11-2:12 + >-< +2| var baz = 1; + +[#3 Domain] = 2:4-2:16 + >------------< +2| var baz = 1; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.field.enum.scope b/data/fixtures/scopes/dart/name/name.field.enum.scope new file mode 100644 index 0000000000..d0a0d3b2ff --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.field.enum.scope @@ -0,0 +1,63 @@ +enum Foo { + bar, + baz(); +} +--- + +[#1 Content] = 0:5-0:8 + >---< +0| enum Foo { + +[#1 Removal] = 0:5-0:9 + >----< +0| enum Foo { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| enum Foo { + +[#1 Trailing delimiter] = 0:8-0:9 + >-< +0| enum Foo { + +[#1 Domain] = 0:0-3:1 + >---------- +0| enum Foo { +1| bar, +2| baz(); +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 1:4-1:7 + >---< +1| bar, + +[#2 Removal] = 1:0-1:7 + >-------< +1| bar, + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| bar, + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 2:4-2:7 + >---< +2| baz(); + +[#3 Leading delimiter] = 2:0-2:4 + >----< +2| baz(); + +[#3 Domain] = 2:4-2:9 + >-----< +2| baz(); + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.function.scope b/data/fixtures/scopes/dart/name/name.function.scope new file mode 100644 index 0000000000..80cde86ee4 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.function.scope @@ -0,0 +1,17 @@ +void foo() {} +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| void foo() {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| void foo() {} + +[Domain] = 0:0-0:13 + >-------------< +0| void foo() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.iteration.class.scope b/data/fixtures/scopes/dart/name/name.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.class.scope @@ -0,0 +1,13 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/data/fixtures/scopes/dart/name/name.iteration.enum.scope b/data/fixtures/scopes/dart/name/name.iteration.enum.scope new file mode 100644 index 0000000000..9034c4ee11 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.enum.scope @@ -0,0 +1,13 @@ +enum Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| enum Foo { } + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| enum Foo { } diff --git a/data/fixtures/scopes/dart/name/name.method.scope b/data/fixtures/scopes/dart/name/name.method.scope new file mode 100644 index 0000000000..04159d17da --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.method.scope @@ -0,0 +1,45 @@ +class Foo { + void bar() {} +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| class Foo { + +[#1 Removal] = 0:6-0:10 + >----< +0| class Foo { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo { + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo { + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:13-1:16 + >---< +1| void bar() {} + +[#2 Leading delimiter] = 1:12-1:13 + >-< +1| void bar() {} + +[#2 Domain] = 1:8-1:21 + >-------------< +1| void bar() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.assignment.compound.scope b/data/fixtures/scopes/dart/value/value.assignment.compound.scope new file mode 100644 index 0000000000..c48e167ae9 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.assignment.compound.scope @@ -0,0 +1,22 @@ +void main() { + foo += 0; +} +--- + +[Content] = 1:11-1:12 + >-< +1| foo += 0; + +[Removal] = 1:7-1:12 + >-----< +1| foo += 0; + +[Leading delimiter] = 1:7-1:11 + >----< +1| foo += 0; + +[Domain] = 1:4-1:13 + >---------< +1| foo += 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.field.class.scope b/data/fixtures/scopes/dart/value/value.field.class.scope new file mode 100644 index 0000000000..64b60fed90 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.field.class.scope @@ -0,0 +1,22 @@ +class Foo { + var bar = 0; +} +--- + +[Content] = 1:14-1:15 + >-< +1| var bar = 0; + +[Removal] = 1:11-1:15 + >----< +1| var bar = 0; + +[Leading delimiter] = 1:11-1:14 + >---< +1| var bar = 0; + +[Domain] = 1:4-1:16 + >------------< +1| var bar = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.iteration.class.scope b/data/fixtures/scopes/dart/value/value.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.iteration.class.scope @@ -0,0 +1,13 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/data/fixtures/scopes/dart/value/value.return.lambda.scope b/data/fixtures/scopes/dart/value/value.return.lambda.scope new file mode 100644 index 0000000000..df6375f879 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.return.lambda.scope @@ -0,0 +1,22 @@ +void main() { + foo(() => 0); +} +--- + +[Content] = 1:14-1:15 + >-< +1| foo(() => 0); + +[Removal] = 1:13-1:15 + >--< +1| foo(() => 0); + +[Leading delimiter] = 1:13-1:14 + >-< +1| foo(() => 0); + +[Domain] = 1:8-1:15 + >-------< +1| foo(() => 0); + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index 68801a9151..28bf01bc08 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -24,11 +24,13 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "functionCall.method": supported, "functionCall.chain": supported, "functionCall.generic": supported, + "functionCall.enum": supported, functionCallee: supported, "functionCallee.constructor": supported, "functionCallee.method": supported, "functionCallee.chain": supported, "functionCallee.generic": supported, + "functionCallee.enum": supported, "argument.actual.singleLine": supported, "argument.actual.multiLine": supported, @@ -192,13 +194,11 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "value.return.lambda": supported, "value.switch": supported, "value.field.class": supported, - "value.field.enum": supported, "value.yield": supported, "value.throw": supported, "value.typeAlias": supported, "value.iteration.document": supported, "value.iteration.class": supported, - "value.iteration.enum": supported, "value.iteration.block": supported, "type.argument.formal": supported, @@ -306,9 +306,9 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "value.assignment.destructuring": notApplicable, "value.variable.destructuring": notApplicable, - // No enum constructor call facet - "functionCall.enum": notApplicable, - "functionCallee.enum": notApplicable, + // Enum values + "value.field.enum": notApplicable, + "value.iteration.enum": notApplicable, // Miscellaneous "statement.misc": notApplicable, diff --git a/queries/dart.scm b/queries/dart.scm index 4cf336992d..adfd22a7f6 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -188,14 +188,77 @@ "}" @namedFunction.iteration.end.startOf @statement.iteration.end.startOf ) +(class_body + "{" @name.iteration.start.endOf @value.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf +) + ;;!! var foo = 0; ;;! ^^^^^^^^^^^^ +;;! ^^^ +;;! ^ (class_body - (declaration) @statement.start + (declaration + (inferred_type) @statement.start @name.removal.start.startOf @_.domain.start + (initialized_identifier_list + (initialized_identifier + (_) @name @value.leading.endOf + (_) @value @name.removal.end.startOf + ) + ) + ) . - ";" @statement.end + ";" @statement.end @_.domain.end ) +;;!! var foo; +;;! ^^^^^^^^ +;;! ^^^ +(class_body + (declaration + (inferred_type) @statement.start @name.removal.start @name.domain.start + (initialized_identifier_list + (initialized_identifier + . + (_) @name + . + ) + ) + ) + . + ";" @statement.end @name.removal.end @name.domain.end +) + +;;!! enum Foo {} +;;! ^^^ +(enum_declaration + name: (_) @name +) @name.domain + +;;!! enum Foo { } +;;! ^ +(enum_body + "{" @name.iteration.start.endOf + "}" @name.iteration.end.startOf +) + +;;!! bar, +;;! ^^^ +( + (enum_constant + name: (_) @name + ) @name.domain + (#not-eq? @name.domain "") +) + +;;!! bar(), +;;! ^^^^^ +;;! ^^^ +(enum_constant + name: (_) @functionCallee + (argument_part) +) @functionCall @functionCallee.domain + ;;!! "hello world" ;;! ^^^^^^^^^^^^^ ;;! ^^^^^^^^^^^ @@ -250,7 +313,17 @@ ;;!! () {} ;;!! () => 0 -(function_expression) @anonymousFunction +(function_expression + (function_expression_body + [ + (block) + ( + "=>" + (_) @value + ) + ] + ) +) @anonymousFunction @value.domain ;;!! return 0; ;;! ^ From ce7154c9a923fa3cdf8c0a727e94c0d9c42c418b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 15:30:12 +0100 Subject: [PATCH 09/20] interior --- .../scopes/dart/interior/interior.class.scope | 10 ++ .../dart/interior/interior.constructor.scope | 27 +++++ .../dart/interior/interior.doWhile.scope | 27 +++++ .../scopes/dart/interior/interior.enum.scope | 10 ++ .../scopes/dart/interior/interior.for.scope | 27 +++++ .../dart/interior/interior.foreach.scope | 27 +++++ .../dart/interior/interior.function.scope | 10 ++ .../scopes/dart/interior/interior.if.scope | 52 +++++++++ .../dart/interior/interior.lambda.scope | 10 ++ .../dart/interior/interior.method.scope | 27 +++++ .../dart/interior/interior.switch.scope | 27 +++++ .../dart/interior/interior.switchCase.scope | 100 ++++++++++++++++++ .../dart/interior/interior.switchCase2.scope | 64 +++++++++++ .../scopes/dart/interior/interior.try.scope | 52 +++++++++ .../scopes/dart/interior/interior.while.scope | 27 +++++ .../common/src/scopeSupportFacets/dart.ts | 6 +- queries/dart.scm | 31 ++++++ 17 files changed, 532 insertions(+), 2 deletions(-) create mode 100644 data/fixtures/scopes/dart/interior/interior.class.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.constructor.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.doWhile.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.enum.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.for.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.foreach.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.function.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.if.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.lambda.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.method.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.switch.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.switchCase.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.switchCase2.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.try.scope create mode 100644 data/fixtures/scopes/dart/interior/interior.while.scope diff --git a/data/fixtures/scopes/dart/interior/interior.class.scope b/data/fixtures/scopes/dart/interior/interior.class.scope new file mode 100644 index 0000000000..13ef2f4d94 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.class.scope @@ -0,0 +1,10 @@ +class Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| class Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.constructor.scope b/data/fixtures/scopes/dart/interior/interior.constructor.scope new file mode 100644 index 0000000000..3c0f1442bc --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.constructor.scope @@ -0,0 +1,27 @@ +class Foo { + Foo() { } +} +--- + +[#1 Content] = 1:4-1:13 + >---------< +1| Foo() { } + +[#1 Removal] = +[#1 Domain] = 0:11-2:0 + > +0| class Foo { +1| Foo() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:11-1:12 + >-< +1| Foo() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.doWhile.scope b/data/fixtures/scopes/dart/interior/interior.doWhile.scope new file mode 100644 index 0000000000..e41339863b --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.doWhile.scope @@ -0,0 +1,27 @@ +void main() { + do { } while (true); +} +--- + +[#1 Content] = 1:4-1:24 + >--------------------< +1| do { } while (true); + +[#1 Removal] = +[#1 Domain] = 0:13-2:0 + > +0| void main() { +1| do { } while (true); +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:8-1:9 + >-< +1| do { } while (true); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.enum.scope b/data/fixtures/scopes/dart/interior/interior.enum.scope new file mode 100644 index 0000000000..d96875b078 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.enum.scope @@ -0,0 +1,10 @@ +enum Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:10-0:11 + >-< +0| enum Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.for.scope b/data/fixtures/scopes/dart/interior/interior.for.scope new file mode 100644 index 0000000000..362f422bbb --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.for.scope @@ -0,0 +1,27 @@ +void main() { + for (var i = 0; i < size; ++i) { } +} +--- + +[#1 Content] = 1:4-1:38 + >----------------------------------< +1| for (var i = 0; i < size; ++i) { } + +[#1 Removal] = +[#1 Domain] = 0:13-2:0 + > +0| void main() { +1| for (var i = 0; i < size; ++i) { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:36-1:37 + >-< +1| for (var i = 0; i < size; ++i) { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.foreach.scope b/data/fixtures/scopes/dart/interior/interior.foreach.scope new file mode 100644 index 0000000000..896bd45c94 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.foreach.scope @@ -0,0 +1,27 @@ +void main() { + for (final v in values) { } +} +--- + +[#1 Content] = 1:4-1:31 + >---------------------------< +1| for (final v in values) { } + +[#1 Removal] = +[#1 Domain] = 0:13-2:0 + > +0| void main() { +1| for (final v in values) { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:29-1:30 + >-< +1| for (final v in values) { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.function.scope b/data/fixtures/scopes/dart/interior/interior.function.scope new file mode 100644 index 0000000000..8a0c0bc456 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.function.scope @@ -0,0 +1,10 @@ +void foo() { } +--- + +[Content] = +[Removal] = +[Domain] = 0:12-0:13 + >-< +0| void foo() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.if.scope b/data/fixtures/scopes/dart/interior/interior.if.scope new file mode 100644 index 0000000000..d78f2e1188 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.if.scope @@ -0,0 +1,52 @@ +void main() { + if (true) { } + else if (false) { } + else { } +} +--- + +[#1 Content] = 1:4-3:12 + >------------- +1| if (true) { } +2| else if (false) { } +3| else { } + ------------< + +[#1 Removal] = +[#1 Domain] = 0:13-4:0 + > +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:15-1:16 + >-< +1| if (true) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:21-2:22 + >-< +2| else if (false) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = +[#4 Domain] = 3:10-3:11 + >-< +3| else { } + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.lambda.scope b/data/fixtures/scopes/dart/interior/interior.lambda.scope new file mode 100644 index 0000000000..5a59d8ab9d --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.lambda.scope @@ -0,0 +1,10 @@ +var foo = () { }; +--- + +[Content] = +[Removal] = +[Domain] = 0:14-0:15 + >-< +0| var foo = () { }; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.method.scope b/data/fixtures/scopes/dart/interior/interior.method.scope new file mode 100644 index 0000000000..a292acdca1 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.method.scope @@ -0,0 +1,27 @@ +class Foo { + void bar() { } +} +--- + +[#1 Content] = 1:4-1:18 + >--------------< +1| void bar() { } + +[#1 Removal] = +[#1 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:16-1:17 + >-< +1| void bar() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.switch.scope b/data/fixtures/scopes/dart/interior/interior.switch.scope new file mode 100644 index 0000000000..1aafa9a4db --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.switch.scope @@ -0,0 +1,27 @@ +void main() { + switch (value) { } +} +--- + +[#1 Content] = 1:4-1:22 + >------------------< +1| switch (value) { } + +[#1 Removal] = +[#1 Domain] = 0:13-2:0 + > +0| void main() { +1| switch (value) { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:20-1:21 + >-< +1| switch (value) { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.switchCase.scope b/data/fixtures/scopes/dart/interior/interior.switchCase.scope new file mode 100644 index 0000000000..cfe04f5d2d --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.switchCase.scope @@ -0,0 +1,100 @@ +void main() { + switch (foo) { + case 0: + bar; + break; + default: + bar; + break; + } +} +--- + +[#1 Content] = 1:4-8:5 + >-------------- +1| switch (foo) { +2| case 0: +3| bar; +4| break; +5| default: +6| bar; +7| break; +8| } + -----< + +[#1 Removal] = +[#1 Domain] = 0:13-9:0 + > +0| void main() { +1| switch (foo) { +2| case 0: +3| bar; +4| break; +5| default: +6| bar; +7| break; +8| } +9| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:8-7:18 + >------- +2| case 0: +3| bar; +4| break; +5| default: +6| bar; +7| break; + ------------------< + +[#2 Removal] = +[#2 Domain] = 1:18-8:4 + > +1| switch (foo) { +2| case 0: +3| bar; +4| break; +5| default: +6| bar; +7| break; +8| } + ----< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 3:12-4:18 + >---- +3| bar; +4| break; + ------------------< + +[#3 Removal] = +[#3 Domain] = 2:15-4:18 + > +2| case 0: +3| bar; +4| break; + ------------------< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 6:12-7:18 + >---- +6| bar; +7| break; + ------------------< + +[#4 Removal] = +[#4 Domain] = 5:16-7:18 + > +5| default: +6| bar; +7| break; + ------------------< + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.switchCase2.scope b/data/fixtures/scopes/dart/interior/interior.switchCase2.scope new file mode 100644 index 0000000000..70aa693e11 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.switchCase2.scope @@ -0,0 +1,64 @@ +void main() { + switch (foo) { + case 0: { } + default: { } + } +} +--- + +[#1 Content] = 1:4-4:5 + >-------------- +1| switch (foo) { +2| case 0: { } +3| default: { } +4| } + -----< + +[#1 Removal] = +[#1 Domain] = 0:13-5:0 + > +0| void main() { +1| switch (foo) { +2| case 0: { } +3| default: { } +4| } +5| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:8-3:20 + >----------- +2| case 0: { } +3| default: { } + --------------------< + +[#2 Removal] = +[#2 Domain] = 1:18-4:4 + > +1| switch (foo) { +2| case 0: { } +3| default: { } +4| } + ----< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:17-2:18 + >-< +2| case 0: { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = +[#4 Domain] = 3:18-3:19 + >-< +3| default: { } + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.try.scope b/data/fixtures/scopes/dart/interior/interior.try.scope new file mode 100644 index 0000000000..02c421f801 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.try.scope @@ -0,0 +1,52 @@ +void main() { + try { } + catch (e) { } + finally { } +} +--- + +[#1 Content] = 1:4-3:15 + >------- +1| try { } +2| catch (e) { } +3| finally { } + ---------------< + +[#1 Removal] = +[#1 Domain] = 0:13-4:0 + > +0| void main() { +1| try { } +2| catch (e) { } +3| finally { } +4| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:9-1:10 + >-< +1| try { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:15-2:16 + >-< +2| catch (e) { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = +[#4 Domain] = 3:13-3:14 + >-< +3| finally { } + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/interior/interior.while.scope b/data/fixtures/scopes/dart/interior/interior.while.scope new file mode 100644 index 0000000000..1999b39f09 --- /dev/null +++ b/data/fixtures/scopes/dart/interior/interior.while.scope @@ -0,0 +1,27 @@ +void main() { + while (true) { } +} +--- + +[#1 Content] = 1:4-1:20 + >----------------< +1| while (true) { } + +[#1 Removal] = +[#1 Domain] = 0:13-2:0 + > +0| void main() { +1| while (true) { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:18-1:19 + >-< +1| while (true) { } + +[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index 28bf01bc08..fc2e291744 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -241,7 +241,6 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "interior.foreach": supported, "interior.while": supported, "interior.doWhile": supported, - "interior.static": supported, /* UNSUPPORTED */ @@ -310,9 +309,12 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "value.field.enum": notApplicable, "value.iteration.enum": notApplicable, + // Static statement + "interior.static": notApplicable, + "statement.static": notApplicable, + // Miscellaneous "statement.misc": notApplicable, - "statement.static": notApplicable, regularExpression: notApplicable, environment: notApplicable, selector: notApplicable, diff --git a/queries/dart.scm b/queries/dart.scm index adfd22a7f6..68624b3772 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -27,6 +27,15 @@ (#document-range! @name.iteration @value.iteration) ) +;;!! { } +;;! ^ +(_ + . + "{" @interior.start.endOf + "}" @interior.end.startOf + . +) + ;;!! var foo = 0; ;;! ^^^^^^^^^^^^ ;;! ^^^ @@ -396,10 +405,32 @@ (_) @condition ) @branch @condition.domain +;;!! case 0: break; +;;! ^^^^^^^ +(switch_statement_case + ":" @interior.start.endOf + . + (_) @interior.end.endOf @_dummy + (_)? @interior.end.endOf + . + (#not-type? @_dummy block) +) + ;;!! default: break; ;;! ^^^^^^^^^^^^^^^ (switch_statement_default) @branch +;;!! default: break; +;;! ^^^^^^^ +(switch_statement_default + ":" @interior.start.endOf + . + (_) @interior.end.endOf @_dummy + (_)? @interior.end.endOf + . + (#not-type? @_dummy block) +) + ;;!! switch () { } ;;! ^ (switch_block From 6cc112d53dba89b504a0965670ab39443c7dd67c Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 15:41:10 +0100 Subject: [PATCH 10/20] if branch --- .../dart/branch/branch.if.elif.else.scope | 59 +++++++++++++++++++ .../scopes/dart/branch/branch.if.else.scope | 40 +++++++++++++ .../scopes/dart/branch/branch.if.scope | 16 +++++ queries/dart.scm | 17 +++++- 4 files changed, 130 insertions(+), 2 deletions(-) create mode 100644 data/fixtures/scopes/dart/branch/branch.if.elif.else.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.if.else.scope create mode 100644 data/fixtures/scopes/dart/branch/branch.if.scope diff --git a/data/fixtures/scopes/dart/branch/branch.if.elif.else.scope b/data/fixtures/scopes/dart/branch/branch.if.elif.else.scope new file mode 100644 index 0000000000..c5a958ed19 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.if.elif.else.scope @@ -0,0 +1,59 @@ +void main() { + if (true) {} + else if (false) {} + else {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:16 + >------------< +1| if (true) {} + +[#1 Removal] = 1:4-2:9 + >------------ +1| if (true) {} +2| else if (false) {} + ---------< + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| if (true) {} + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:22 + >------------------< +2| else if (false) {} + +[#2 Removal] = 2:4-3:4 + >------------------ +2| else if (false) {} +3| else {} + ----< + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| else if (false) {} + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:4-3:11 + >-------< +3| else {} + +[#3 Removal] = 3:0-4:0 + >----------- +3| else {} +4| } + < + +[#3 Leading delimiter] = 3:0-3:4 + >----< +3| else {} + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/branch/branch.if.else.scope b/data/fixtures/scopes/dart/branch/branch.if.else.scope new file mode 100644 index 0000000000..cd74705076 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.if.else.scope @@ -0,0 +1,40 @@ +void main() { + if (true) {} + else {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:16 + >------------< +1| if (true) {} + +[#1 Removal] = 1:4-2:4 + >------------ +1| if (true) {} +2| else {} + ----< + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| if (true) {} + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:11 + >-------< +2| else {} + +[#2 Removal] = 2:0-3:0 + >----------- +2| else {} +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| else {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/branch/branch.if.scope b/data/fixtures/scopes/dart/branch/branch.if.scope new file mode 100644 index 0000000000..ed25feef07 --- /dev/null +++ b/data/fixtures/scopes/dart/branch/branch.if.scope @@ -0,0 +1,16 @@ +void main() { + if (true) {} +} +--- + +[Content] = +[Removal] = +[Domain] = 1:4-1:16 + >------------< +1| if (true) {} + +[Leading delimiter] = 1:0-1:4 + >----< +1| if (true) {} + +[Insertion delimiter] = "\n" diff --git a/queries/dart.scm b/queries/dart.scm index 68624b3772..334490c9b0 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -99,10 +99,15 @@ ;;!! if () {} else {} ;;! ^^^^^^^^^^^^^^^^ +;;! ^^^^^^^^ ( (if_statement + "if" @branch.start @branch.removal.start . (_) @condition + consequence: (_) @branch.end @branch.removal.end + "else"? @branch.removal.end.startOf + alternative: (if_statement)? @branch.removal.end.startOf ) @ifStatement @statement @condition.domain (#not-parent-type? @ifStatement if_statement) ) @@ -115,14 +120,22 @@ ;;!! else if () {} ;;! ^^^^^^^^^^^^^ (if_statement - "else" @condition.domain.start + "else" @condition.domain.start @branch.start @branch.removal.start (if_statement . (_) @condition - consequence: (_) @condition.domain.end + consequence: (_) @condition.domain.end @branch.end @branch.removal.end + "else"? @branch.removal.end.startOf ) ) +;;!! else {} +;;! ^^^^^^^ +(if_statement + "else" @branch.start + alternative: (block) @branch.end +) + ;;!! try {} catch () {} finally {} ;;! ^^^^^^ (try_statement From 0758106d08822145906576c2a3c22a7bea3d03ab Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 16:17:51 +0100 Subject: [PATCH 11/20] argument list --- ...rgumentList.actual.constructor.empty.scope | 13 +++ ...entList.actual.constructor.multiLine.scope | 33 +++++++ ...ntList.actual.constructor.singleLine.scope | 13 +++ .../argumentList.actual.empty.scope | 13 +++ .../argumentList.actual.method.empty.scope | 13 +++ ...argumentList.actual.method.multiLine.scope | 33 +++++++ ...rgumentList.actual.method.singleLine.scope | 13 +++ .../argumentList.actual.multiLine.scope | 33 +++++++ .../argumentList.actual.singleLine.scope | 13 +++ ...rgumentList.formal.constructor.empty.scope | 15 +++ ...entList.formal.constructor.multiLine.scope | 35 +++++++ ...ntList.formal.constructor.singleLine.scope | 15 +++ .../argumentList.formal.empty.scope | 13 +++ .../argumentList.formal.lambda.empty.scope | 13 +++ ...argumentList.formal.lambda.multiLine.scope | 33 +++++++ ...rgumentList.formal.lambda.singleLine.scope | 13 +++ .../argumentList.formal.method.empty.scope | 15 +++ ...argumentList.formal.method.multiLine.scope | 35 +++++++ ...rgumentList.formal.method.singleLine.scope | 15 +++ .../argumentList.formal.multiLine.scope | 33 +++++++ .../argumentList.formal.singleLine.scope | 13 +++ queries/dart.scm | 97 +++++++++++++++++++ queries/java.scm | 4 +- queries/javascript.core.scm | 4 +- 24 files changed, 526 insertions(+), 4 deletions(-) create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.method.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.actual.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.method.empty.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.method.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argumentList/argumentList.formal.singleLine.scope diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.empty.scope new file mode 100644 index 0000000000..a90dabb1d1 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.empty.scope @@ -0,0 +1,13 @@ +var foo = Bar(); +--- + +[Content] = +[Removal] = 0:14-0:14 + >< +0| var foo = Bar(); + +[Domain] = 0:10-0:15 + >-----< +0| var foo = Bar(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..065cb9d8c7 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.multiLine.scope @@ -0,0 +1,33 @@ +var foo = Bar( + aaa, + bbb +); +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:14-3:0 + > +0| var foo = Bar( +1| aaa, +2| bbb +3| ); + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:10-3:1 + >---- +0| var foo = Bar( +1| aaa, +2| bbb +3| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..b7dae559f7 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.constructor.singleLine.scope @@ -0,0 +1,13 @@ +var foo = Bar(aaa, bbb); +--- + +[Content] = +[Removal] = 0:14-0:22 + >--------< +0| var foo = Bar(aaa, bbb); + +[Domain] = 0:10-0:23 + >-------------< +0| var foo = Bar(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.empty.scope new file mode 100644 index 0000000000..42ffba4741 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.empty.scope @@ -0,0 +1,13 @@ +var foo = bar(); +--- + +[Content] = +[Removal] = 0:14-0:14 + >< +0| var foo = bar(); + +[Domain] = 0:10-0:15 + >-----< +0| var foo = bar(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.empty.scope new file mode 100644 index 0000000000..b345bd4b6c --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.empty.scope @@ -0,0 +1,13 @@ +var foo = bar.baz(); +--- + +[Content] = +[Removal] = 0:18-0:18 + >< +0| var foo = bar.baz(); + +[Domain] = 0:10-0:19 + >---------< +0| var foo = bar.baz(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.multiLine.scope new file mode 100644 index 0000000000..ac6ef892fe --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.multiLine.scope @@ -0,0 +1,33 @@ +var foo = bar.baz( + aaa, + bbb +); +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:18-3:0 + > +0| var foo = bar.baz( +1| aaa, +2| bbb +3| ); + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:10-3:1 + >-------- +0| var foo = bar.baz( +1| aaa, +2| bbb +3| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.singleLine.scope new file mode 100644 index 0000000000..ad7c89111e --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.method.singleLine.scope @@ -0,0 +1,13 @@ +var foo = bar.baz(aaa, bbb); +--- + +[Content] = +[Removal] = 0:18-0:26 + >--------< +0| var foo = bar.baz(aaa, bbb); + +[Domain] = 0:10-0:27 + >-----------------< +0| var foo = bar.baz(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.multiLine.scope new file mode 100644 index 0000000000..2f0992b947 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.multiLine.scope @@ -0,0 +1,33 @@ +var foo = bar( + aaa, + bbb +); +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:14-3:0 + > +0| var foo = bar( +1| aaa, +2| bbb +3| ); + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:10-3:1 + >---- +0| var foo = bar( +1| aaa, +2| bbb +3| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.actual.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.actual.singleLine.scope new file mode 100644 index 0000000000..a717b1884d --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.actual.singleLine.scope @@ -0,0 +1,13 @@ +var foo = bar(aaa, bbb); +--- + +[Content] = +[Removal] = 0:14-0:22 + >--------< +0| var foo = bar(aaa, bbb); + +[Domain] = 0:10-0:23 + >-------------< +0| var foo = bar(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.empty.scope new file mode 100644 index 0000000000..99ce24e01a --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.empty.scope @@ -0,0 +1,15 @@ +class Foo { + Foo() {} +} +--- + +[Content] = +[Removal] = 1:8-1:8 + >< +1| Foo() {} + +[Domain] = 1:4-1:12 + >--------< +1| Foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..d1875c43c3 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.multiLine.scope @@ -0,0 +1,35 @@ +class Foo { + Foo( + aaa, + bbb + ) {} +} +--- + +[Content] = 2:8-3:11 + >---- +2| aaa, +3| bbb + -----------< + +[Removal] = 1:8-4:4 + > +1| Foo( +2| aaa, +3| bbb +4| ) {} + ----< + +[Leading delimiter] = 2:0-2:8 + >--------< +2| aaa, + +[Domain] = 1:4-4:8 + >---- +1| Foo( +2| aaa, +3| bbb +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..14a98ffa41 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.constructor.singleLine.scope @@ -0,0 +1,15 @@ +class Foo { + Foo(aaa, bbb) {} +} +--- + +[Content] = +[Removal] = 1:8-1:16 + >--------< +1| Foo(aaa, bbb) {} + +[Domain] = 1:4-1:20 + >----------------< +1| Foo(aaa, bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.empty.scope new file mode 100644 index 0000000000..9d4dd443f0 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.empty.scope @@ -0,0 +1,13 @@ +void foo() {} +--- + +[Content] = +[Removal] = 0:9-0:9 + >< +0| void foo() {} + +[Domain] = 0:0-0:13 + >-------------< +0| void foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope new file mode 100644 index 0000000000..e44da4901e --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope @@ -0,0 +1,13 @@ +var foo = () {}; +--- + +[Content] = +[Removal] = 0:11-0:11 + >< +0| var foo = () {}; + +[Domain] = 0:10-0:15 + >-----< +0| var foo = () {}; + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..5a8654d92e --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope @@ -0,0 +1,33 @@ +var foo = ( + aaa, + bbb +) {}; +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:11-3:0 + > +0| var foo = ( +1| aaa, +2| bbb +3| ) {}; + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:10-3:4 + >- +0| var foo = ( +1| aaa, +2| bbb +3| ) {}; + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..a141064261 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope @@ -0,0 +1,13 @@ +var foo = (aaa, bbb) {}; +--- + +[Content] = +[Removal] = 0:11-0:19 + >--------< +0| var foo = (aaa, bbb) {}; + +[Domain] = 0:10-0:23 + >-------------< +0| var foo = (aaa, bbb) {}; + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.empty.scope new file mode 100644 index 0000000000..a9d9cfde55 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.empty.scope @@ -0,0 +1,15 @@ +class Foo { + void bar() {} +} +--- + +[Content] = +[Removal] = 1:13-1:13 + >< +1| void bar() {} + +[Domain] = 1:4-1:17 + >-------------< +1| void bar() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.multiLine.scope new file mode 100644 index 0000000000..966b9cf8ab --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.multiLine.scope @@ -0,0 +1,35 @@ +class Foo { + void bar( + aaa, + bbb + ) {} +} +--- + +[Content] = 2:8-3:11 + >---- +2| aaa, +3| bbb + -----------< + +[Removal] = 1:13-4:4 + > +1| void bar( +2| aaa, +3| bbb +4| ) {} + ----< + +[Leading delimiter] = 2:0-2:8 + >--------< +2| aaa, + +[Domain] = 1:4-4:8 + >--------- +1| void bar( +2| aaa, +3| bbb +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.singleLine.scope new file mode 100644 index 0000000000..45ad3311d8 --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.method.singleLine.scope @@ -0,0 +1,15 @@ +class Foo { + void bar(aaa, bbb) {} +} +--- + +[Content] = +[Removal] = 1:13-1:21 + >--------< +1| void bar(aaa, bbb) {} + +[Domain] = 1:4-1:25 + >---------------------< +1| void bar(aaa, bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.multiLine.scope new file mode 100644 index 0000000000..05885b233c --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.multiLine.scope @@ -0,0 +1,33 @@ +void foo( + aaa, + bbb +) {} +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:9-3:0 + > +0| void foo( +1| aaa, +2| bbb +3| ) {} + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:0-3:4 + >--------- +0| void foo( +1| aaa, +2| bbb +3| ) {} + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.singleLine.scope new file mode 100644 index 0000000000..165a51acda --- /dev/null +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.singleLine.scope @@ -0,0 +1,13 @@ +void foo(aaa, bbb) {} +--- + +[Content] = +[Removal] = 0:9-0:17 + >--------< +0| void foo(aaa, bbb) {} + +[Domain] = 0:0-0:21 + >---------------------< +0| void foo(aaa, bbb) {} + +[Insertion delimiter] = ", " diff --git a/queries/dart.scm b/queries/dart.scm index 334490c9b0..e302c68124 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -317,6 +317,59 @@ (function_body) @namedFunction.end @statement.end @name.domain.end ) +;;!! void foo(aaa, bbb) {} +;;! ^^^^^^^^ +(_ + (function_signature + (formal_parameter_list + "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf + ) @argumentList + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") + (#child-range! @argumentList 1 -2) + ) @argumentList.domain.start @argumentOrParameter.iteration.domain.start + . + (function_body) @argumentList.domain.end @argumentOrParameter.iteration.domain.end +) + +;;!! void foo(aaa, bbb) {} +;;! ^^^^^^^^ +(_ + (method_signature + (_ + (formal_parameter_list + "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf + ) @argumentList + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") + (#child-range! @argumentList 1 -2) + ) @argumentList.domain.start @argumentOrParameter.iteration.domain.start + ) + . + (function_body) @argumentList.domain.end @argumentOrParameter.iteration.domain.end +) + +;;!! void foo(aaa, bbb) {} +;;! ^^^ ^^^ +( + (formal_parameter_list + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#not-type? @argumentOrParameter comment) + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) + +;;!! void foo(aaa, bbb) {} +;;! ^^^^^^^^ +(formal_parameter_list + "(" @name.iteration.start.endOf @value.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf +) + ;;!! foo(); ;;! ^^^^^ ;;! ^^^ @@ -333,6 +386,39 @@ ) @functionCall.end @functionCallee.domain.end ) +;;!! foo(aaa, bbb) +;;! ^^^^^^^^ +(_ + (identifier) @argumentList.domain.start @argumentOrParameter.iteration.domain.start + . + (selector)* + . + (selector + (argument_part + (arguments + "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf + ) @argumentList + ) + ) @argumentList.domain.end @argumentOrParameter.iteration.domain.end + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") + (#child-range! @argumentList 1 -2) +) + +;;!! foo(aaa, bbb); +;;! ^^^ ^^^ +( + (arguments + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#not-type? @argumentOrParameter comment) + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) + ;;!! () {} ;;!! () => 0 (function_expression @@ -347,6 +433,17 @@ ) ) @anonymousFunction @value.domain +;;!! (aaa, bbb) => {} +;;! ^^^^^^^^ +(function_expression + (formal_parameter_list + "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf + ) @argumentList + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") + (#child-range! @argumentList 1 -2) +) @argumentList.domain @argumentOrParameter.iteration.domain + ;;!! return 0; ;;! ^ (return_statement diff --git a/queries/java.scm b/queries/java.scm index 5eacffd201..29d829abc3 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -590,7 +590,7 @@ . (_)? @_.trailing.startOf ) @_dummy - (#not-type? @argumentOrParameter "block_comment") + (#not-type? @argumentOrParameter block_comment) (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) @@ -604,7 +604,7 @@ . (_)? @_.trailing.startOf ) @_dummy - (#not-type? @argumentOrParameter "block_comment") + (#not-type? @argumentOrParameter block_comment) (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) diff --git a/queries/javascript.core.scm b/queries/javascript.core.scm index 03eca48113..4447116649 100644 --- a/queries/javascript.core.scm +++ b/queries/javascript.core.scm @@ -812,7 +812,7 @@ . (_)? @_.trailing.startOf ) @_dummy - (#not-type? @argumentOrParameter "comment") + (#not-type? @argumentOrParameter comment) (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) @@ -826,7 +826,7 @@ . (_)? @_.trailing.startOf ) @_dummy - (#not-type? @argumentOrParameter "comment") + (#not-type? @argumentOrParameter comment) (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) From 83c65cd658bff1f4ba4507f794bde92286fbc73a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 16:33:44 +0100 Subject: [PATCH 12/20] arguments --- ...rgument.actual.constructor.iteration.scope | 10 ++++ ...rgument.actual.constructor.multiLine.scope | 44 ++++++++++++++++++ ...gument.actual.constructor.singleLine.scope | 33 +++++++++++++ .../argument/argument.actual.iteration.scope | 10 ++++ .../argument.actual.method.iteration.scope | 10 ++++ .../argument.actual.method.multiLine.scope | 44 ++++++++++++++++++ .../argument.actual.method.singleLine.scope | 33 +++++++++++++ .../argument/argument.actual.multiLine.scope | 44 ++++++++++++++++++ .../argument/argument.actual.singleLine.scope | 33 +++++++++++++ .../scopes/dart/argument/argument.catch.scope | 36 +++++++++++++++ ...rgument.formal.constructor.iteration.scope | 12 +++++ ...rgument.formal.constructor.multiLine.scope | 46 +++++++++++++++++++ ...gument.formal.constructor.singleLine.scope | 35 ++++++++++++++ .../argument/argument.formal.iteration.scope | 10 ++++ .../argument.formal.lambda.iteration.scope | 10 ++++ .../argument.formal.lambda.multiLine.scope | 45 ++++++++++++++++++ .../argument.formal.lambda.singleLine.scope | 33 +++++++++++++ .../argument.formal.method.iteration.scope | 12 +++++ .../argument.formal.method.multiLine.scope | 46 +++++++++++++++++++ .../argument.formal.method.singleLine.scope | 35 ++++++++++++++ .../argument/argument.formal.multiLine.scope | 44 ++++++++++++++++++ .../argument/argument.formal.singleLine.scope | 33 +++++++++++++ queries/dart.scm | 29 ++++++++++-- 23 files changed, 683 insertions(+), 4 deletions(-) create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.constructor.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.method.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.actual.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.catch.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.method.singleLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.multiLine.scope create mode 100644 data/fixtures/scopes/dart/argument/argument.formal.singleLine.scope diff --git a/data/fixtures/scopes/dart/argument/argument.actual.constructor.iteration.scope b/data/fixtures/scopes/dart/argument/argument.actual.constructor.iteration.scope new file mode 100644 index 0000000000..1d3ee10058 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.constructor.iteration.scope @@ -0,0 +1,10 @@ +var foo = Bar(aaa, bbb); +--- + +[Content] = 0:14-0:22 + >--------< +0| var foo = Bar(aaa, bbb); + +[Domain] = 0:10-0:23 + >-------------< +0| var foo = Bar(aaa, bbb); diff --git a/data/fixtures/scopes/dart/argument/argument.actual.constructor.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..a8133f576d --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.constructor.multiLine.scope @@ -0,0 +1,44 @@ +var foo = Bar( + aaa, + bbb +); +--- + +[#1 Content] = +[#1 Domain] = 1:8-1:11 + >---< +1| aaa, + +[#1 Removal] = 1:8-2:8 + >---- +1| aaa, +2| bbb + --------< + +[#1 Trailing delimiter] = 1:11-2:8 + >- +1| aaa, +2| bbb + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:8-2:11 + >---< +2| bbb + +[#2 Removal] = 1:11-2:11 + >- +1| aaa, +2| bbb + -----------< + +[#2 Leading delimiter] = 1:11-2:8 + >- +1| aaa, +2| bbb + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.actual.constructor.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..f84d1f507a --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.constructor.singleLine.scope @@ -0,0 +1,33 @@ +var foo = Bar(aaa, bbb); +--- + +[#1 Content] = +[#1 Domain] = 0:14-0:17 + >---< +0| var foo = Bar(aaa, bbb); + +[#1 Removal] = 0:14-0:19 + >-----< +0| var foo = Bar(aaa, bbb); + +[#1 Trailing delimiter] = 0:17-0:19 + >--< +0| var foo = Bar(aaa, bbb); + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:19-0:22 + >---< +0| var foo = Bar(aaa, bbb); + +[#2 Removal] = 0:17-0:22 + >-----< +0| var foo = Bar(aaa, bbb); + +[#2 Leading delimiter] = 0:17-0:19 + >--< +0| var foo = Bar(aaa, bbb); + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.actual.iteration.scope b/data/fixtures/scopes/dart/argument/argument.actual.iteration.scope new file mode 100644 index 0000000000..8284707cc5 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.iteration.scope @@ -0,0 +1,10 @@ +var foo = bar(aaa, bbb); +--- + +[Content] = 0:14-0:22 + >--------< +0| var foo = bar(aaa, bbb); + +[Domain] = 0:10-0:23 + >-------------< +0| var foo = bar(aaa, bbb); diff --git a/data/fixtures/scopes/dart/argument/argument.actual.method.iteration.scope b/data/fixtures/scopes/dart/argument/argument.actual.method.iteration.scope new file mode 100644 index 0000000000..d60804b34b --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.method.iteration.scope @@ -0,0 +1,10 @@ +var foo = bar.baz(aaa, bbb); +--- + +[Content] = 0:18-0:26 + >--------< +0| var foo = bar.baz(aaa, bbb); + +[Domain] = 0:10-0:27 + >-----------------< +0| var foo = bar.baz(aaa, bbb); diff --git a/data/fixtures/scopes/dart/argument/argument.actual.method.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.actual.method.multiLine.scope new file mode 100644 index 0000000000..a089e826f2 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.method.multiLine.scope @@ -0,0 +1,44 @@ +var foo = bar.baz( + aaa, + bbb +); +--- + +[#1 Content] = +[#1 Domain] = 1:8-1:11 + >---< +1| aaa, + +[#1 Removal] = 1:8-2:8 + >---- +1| aaa, +2| bbb + --------< + +[#1 Trailing delimiter] = 1:11-2:8 + >- +1| aaa, +2| bbb + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:8-2:11 + >---< +2| bbb + +[#2 Removal] = 1:11-2:11 + >- +1| aaa, +2| bbb + -----------< + +[#2 Leading delimiter] = 1:11-2:8 + >- +1| aaa, +2| bbb + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.actual.method.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.actual.method.singleLine.scope new file mode 100644 index 0000000000..4c9e75831c --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.method.singleLine.scope @@ -0,0 +1,33 @@ +var foo = bar.baz(aaa, bbb); +--- + +[#1 Content] = +[#1 Domain] = 0:18-0:21 + >---< +0| var foo = bar.baz(aaa, bbb); + +[#1 Removal] = 0:18-0:23 + >-----< +0| var foo = bar.baz(aaa, bbb); + +[#1 Trailing delimiter] = 0:21-0:23 + >--< +0| var foo = bar.baz(aaa, bbb); + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:23-0:26 + >---< +0| var foo = bar.baz(aaa, bbb); + +[#2 Removal] = 0:21-0:26 + >-----< +0| var foo = bar.baz(aaa, bbb); + +[#2 Leading delimiter] = 0:21-0:23 + >--< +0| var foo = bar.baz(aaa, bbb); + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.actual.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.actual.multiLine.scope new file mode 100644 index 0000000000..b33f841ccd --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.multiLine.scope @@ -0,0 +1,44 @@ +var foo = bar( + aaa, + bbb +); +--- + +[#1 Content] = +[#1 Domain] = 1:8-1:11 + >---< +1| aaa, + +[#1 Removal] = 1:8-2:8 + >---- +1| aaa, +2| bbb + --------< + +[#1 Trailing delimiter] = 1:11-2:8 + >- +1| aaa, +2| bbb + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:8-2:11 + >---< +2| bbb + +[#2 Removal] = 1:11-2:11 + >- +1| aaa, +2| bbb + -----------< + +[#2 Leading delimiter] = 1:11-2:8 + >- +1| aaa, +2| bbb + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.actual.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.actual.singleLine.scope new file mode 100644 index 0000000000..b362b10b33 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.actual.singleLine.scope @@ -0,0 +1,33 @@ +var foo = bar(aaa, bbb); +--- + +[#1 Content] = +[#1 Domain] = 0:14-0:17 + >---< +0| var foo = bar(aaa, bbb); + +[#1 Removal] = 0:14-0:19 + >-----< +0| var foo = bar(aaa, bbb); + +[#1 Trailing delimiter] = 0:17-0:19 + >--< +0| var foo = bar(aaa, bbb); + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:19-0:22 + >---< +0| var foo = bar(aaa, bbb); + +[#2 Removal] = 0:17-0:22 + >-----< +0| var foo = bar(aaa, bbb); + +[#2 Leading delimiter] = 0:17-0:19 + >--< +0| var foo = bar(aaa, bbb); + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.catch.scope b/data/fixtures/scopes/dart/argument/argument.catch.scope new file mode 100644 index 0000000000..e8fc3d0b57 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.catch.scope @@ -0,0 +1,36 @@ +void main() { + try {} + catch (e, s) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:11-2:12 + >-< +2| catch (e, s) {} + +[#1 Removal] = 2:11-2:14 + >---< +2| catch (e, s) {} + +[#1 Trailing delimiter] = 2:12-2:14 + >--< +2| catch (e, s) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 2:14-2:15 + >-< +2| catch (e, s) {} + +[#2 Removal] = 2:12-2:15 + >---< +2| catch (e, s) {} + +[#2 Leading delimiter] = 2:12-2:14 + >--< +2| catch (e, s) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/dart/argument/argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..dd095cb49c --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.constructor.iteration.scope @@ -0,0 +1,12 @@ +class Foo { + Foo(aaa, bbb) {} +} +--- + +[Content] = 1:12-1:20 + >--------< +1| Foo(aaa, bbb) {} + +[Domain] = 1:8-1:24 + >----------------< +1| Foo(aaa, bbb) {} diff --git a/data/fixtures/scopes/dart/argument/argument.formal.constructor.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..4af5ef6e55 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.constructor.multiLine.scope @@ -0,0 +1,46 @@ +class Foo { + Foo( + aaa, + bbb + ) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:11 + >---< +2| aaa, + +[#1 Removal] = 2:8-3:8 + >---- +2| aaa, +3| bbb + --------< + +[#1 Trailing delimiter] = 2:11-3:8 + >- +2| aaa, +3| bbb + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:11 + >---< +3| bbb + +[#2 Removal] = 2:11-3:11 + >- +2| aaa, +3| bbb + -----------< + +[#2 Leading delimiter] = 2:11-3:8 + >- +2| aaa, +3| bbb + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.formal.constructor.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..b6541a3246 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.constructor.singleLine.scope @@ -0,0 +1,35 @@ +class Foo { + Foo(aaa, bbb) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:8-1:11 + >---< +1| Foo(aaa, bbb) {} + +[#1 Removal] = 1:8-1:13 + >-----< +1| Foo(aaa, bbb) {} + +[#1 Trailing delimiter] = 1:11-1:13 + >--< +1| Foo(aaa, bbb) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:13-1:16 + >---< +1| Foo(aaa, bbb) {} + +[#2 Removal] = 1:11-1:16 + >-----< +1| Foo(aaa, bbb) {} + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| Foo(aaa, bbb) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.formal.iteration.scope b/data/fixtures/scopes/dart/argument/argument.formal.iteration.scope new file mode 100644 index 0000000000..d77a8814c2 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.iteration.scope @@ -0,0 +1,10 @@ +void foo(aaa, bbb) {} +--- + +[Content] = 0:9-0:17 + >--------< +0| void foo(aaa, bbb) {} + +[Domain] = 0:0-0:21 + >---------------------< +0| void foo(aaa, bbb) {} diff --git a/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..e6d900fdbc --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +var foo = (aaa, bbb) {}; +--- + +[Content] = 0:11-0:19 + >--------< +0| var foo = (aaa, bbb) {}; + +[Domain] = 0:10-0:23 + >-------------< +0| var foo = (aaa, bbb) {}; diff --git a/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..931431f00e --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope @@ -0,0 +1,45 @@ +var foo = ( + aaa, + bbb +) {}; + +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:7 + >---< +1| aaa, + +[#1 Removal] = 1:4-2:4 + >---- +1| aaa, +2| bbb + ----< + +[#1 Trailing delimiter] = 1:7-2:4 + >- +1| aaa, +2| bbb + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:7 + >---< +2| bbb + +[#2 Removal] = 1:7-2:7 + >- +1| aaa, +2| bbb + -------< + +[#2 Leading delimiter] = 1:7-2:4 + >- +1| aaa, +2| bbb + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..8fe895eaed --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope @@ -0,0 +1,33 @@ +var foo = (aaa, bbb) {}; +--- + +[#1 Content] = +[#1 Domain] = 0:11-0:14 + >---< +0| var foo = (aaa, bbb) {}; + +[#1 Removal] = 0:11-0:16 + >-----< +0| var foo = (aaa, bbb) {}; + +[#1 Trailing delimiter] = 0:14-0:16 + >--< +0| var foo = (aaa, bbb) {}; + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:16-0:19 + >---< +0| var foo = (aaa, bbb) {}; + +[#2 Removal] = 0:14-0:19 + >-----< +0| var foo = (aaa, bbb) {}; + +[#2 Leading delimiter] = 0:14-0:16 + >--< +0| var foo = (aaa, bbb) {}; + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.formal.method.iteration.scope b/data/fixtures/scopes/dart/argument/argument.formal.method.iteration.scope new file mode 100644 index 0000000000..71bcba801b --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.method.iteration.scope @@ -0,0 +1,12 @@ +class Foo { + void bar(aaa, bbb) {} +} +--- + +[Content] = 1:17-1:25 + >--------< +1| void bar(aaa, bbb) {} + +[Domain] = 1:8-1:29 + >---------------------< +1| void bar(aaa, bbb) {} diff --git a/data/fixtures/scopes/dart/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.method.multiLine.scope new file mode 100644 index 0000000000..11fccfc74a --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.method.multiLine.scope @@ -0,0 +1,46 @@ +class Foo { + void bar( + aaa, + bbb + ) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:11 + >---< +2| aaa, + +[#1 Removal] = 2:8-3:8 + >---- +2| aaa, +3| bbb + --------< + +[#1 Trailing delimiter] = 2:11-3:8 + >- +2| aaa, +3| bbb + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:11 + >---< +3| bbb + +[#2 Removal] = 2:11-3:11 + >- +2| aaa, +3| bbb + -----------< + +[#2 Leading delimiter] = 2:11-3:8 + >- +2| aaa, +3| bbb + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.method.singleLine.scope new file mode 100644 index 0000000000..08af2e3f0d --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.method.singleLine.scope @@ -0,0 +1,35 @@ +class Foo { + void bar(aaa, bbb) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:13-1:16 + >---< +1| void bar(aaa, bbb) {} + +[#1 Removal] = 1:13-1:18 + >-----< +1| void bar(aaa, bbb) {} + +[#1 Trailing delimiter] = 1:16-1:18 + >--< +1| void bar(aaa, bbb) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:18-1:21 + >---< +1| void bar(aaa, bbb) {} + +[#2 Removal] = 1:16-1:21 + >-----< +1| void bar(aaa, bbb) {} + +[#2 Leading delimiter] = 1:16-1:18 + >--< +1| void bar(aaa, bbb) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.multiLine.scope new file mode 100644 index 0000000000..959eec95f5 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.multiLine.scope @@ -0,0 +1,44 @@ +void foo( + aaa, + bbb +) {} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:7 + >---< +1| aaa, + +[#1 Removal] = 1:4-2:4 + >---- +1| aaa, +2| bbb + ----< + +[#1 Trailing delimiter] = 1:7-2:4 + >- +1| aaa, +2| bbb + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:7 + >---< +2| bbb + +[#2 Removal] = 1:7-2:7 + >- +1| aaa, +2| bbb + -------< + +[#2 Leading delimiter] = 1:7-2:4 + >- +1| aaa, +2| bbb + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.singleLine.scope new file mode 100644 index 0000000000..36e4f037b4 --- /dev/null +++ b/data/fixtures/scopes/dart/argument/argument.formal.singleLine.scope @@ -0,0 +1,33 @@ +void foo(aaa, bbb) {} +--- + +[#1 Content] = +[#1 Domain] = 0:9-0:12 + >---< +0| void foo(aaa, bbb) {} + +[#1 Removal] = 0:9-0:14 + >-----< +0| void foo(aaa, bbb) {} + +[#1 Trailing delimiter] = 0:12-0:14 + >--< +0| void foo(aaa, bbb) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:14-0:17 + >---< +0| void foo(aaa, bbb) {} + +[#2 Removal] = 0:12-0:17 + >-----< +0| void foo(aaa, bbb) {} + +[#2 Leading delimiter] = 0:12-0:14 + >--< +0| void foo(aaa, bbb) {} + +[#2 Insertion delimiter] = ", " diff --git a/queries/dart.scm b/queries/dart.scm index e302c68124..ef287961fd 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -143,12 +143,33 @@ body: (_) @branch.end ) @branch.iteration -;;!! catch () -;;! ^^^^^^^^ +;;!! catch (e, s) {} +;;! ^^^^^^^^^^^^^^^ +;;! ^^^^ (try_statement - (catch_clause) @branch.start + (catch_clause + "catch" @branch.start @argumentList.domain.start @argumentOrParameter.iteration.domain.start + (catch_parameters + "(" @argumentList.start.endOf @argumentOrParameter.iteration.start.endOf + ")" @argumentList.end.startOf @argumentOrParameter.iteration.end.startOf + ) + ) . - (block) @branch.end + (block) @branch.end @argumentList.domain.end @argumentOrParameter.iteration.domain.end +) + +;;!! catch (e, s) {} +;;! ^ ^ +( + (catch_parameters + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#not-type? @argumentOrParameter comment) + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) ;;!! finally () From 69ef3ab53e05baada68eab29a8d5bba54457dd6f Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 16:46:41 +0100 Subject: [PATCH 13/20] collection item --- .../collectionItem.unenclosed.iteration.scope | 10 +++ .../collectionItem.unenclosed.multiLine.scope | 58 +++++++++++++++++ ...collectionItem.unenclosed.singleLine.scope | 65 +++++++++++++++++++ queries/dart.scm | 30 ++++++++- 4 files changed, 162 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/dart/collectionItem.unenclosed.iteration.scope create mode 100644 data/fixtures/scopes/dart/collectionItem.unenclosed.multiLine.scope create mode 100644 data/fixtures/scopes/dart/collectionItem.unenclosed.singleLine.scope diff --git a/data/fixtures/scopes/dart/collectionItem.unenclosed.iteration.scope b/data/fixtures/scopes/dart/collectionItem.unenclosed.iteration.scope new file mode 100644 index 0000000000..d082914468 --- /dev/null +++ b/data/fixtures/scopes/dart/collectionItem.unenclosed.iteration.scope @@ -0,0 +1,10 @@ +var foo, bar; +--- + +[Content] = 0:4-0:12 + >--------< +0| var foo, bar; + +[Domain] = 0:0-0:13 + >-------------< +0| var foo, bar; diff --git a/data/fixtures/scopes/dart/collectionItem.unenclosed.multiLine.scope b/data/fixtures/scopes/dart/collectionItem.unenclosed.multiLine.scope new file mode 100644 index 0000000000..b70957c47e --- /dev/null +++ b/data/fixtures/scopes/dart/collectionItem.unenclosed.multiLine.scope @@ -0,0 +1,58 @@ +var foo, + bar; +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:7 + >-------< +0| var foo, + +[#1 Removal] = 0:0-0:8 + >--------< +0| var foo, + +[#1 Trailing delimiter] = 0:7-0:8 + >-< +0| var foo, + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:4-0:7 + >---< +0| var foo, + +[#2 Removal] = 0:4-1:8 + >---- +0| var foo, +1| bar; + --------< + +[#2 Trailing delimiter] = 0:7-1:8 + >- +0| var foo, +1| bar; + --------< + +[#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 1:8-1:11 + >---< +1| bar; + +[#3 Removal] = 0:7-1:11 + >- +0| var foo, +1| bar; + -----------< + +[#3 Leading delimiter] = 0:7-1:8 + >- +0| var foo, +1| bar; + --------< + +[#3 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/collectionItem.unenclosed.singleLine.scope b/data/fixtures/scopes/dart/collectionItem.unenclosed.singleLine.scope new file mode 100644 index 0000000000..b69df55916 --- /dev/null +++ b/data/fixtures/scopes/dart/collectionItem.unenclosed.singleLine.scope @@ -0,0 +1,65 @@ +var foo, bar; +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:7 + >-------< +0| var foo, bar; + +[#1 Removal] = 0:0-0:9 + >---------< +0| var foo, bar; + +[#1 Trailing delimiter] = 0:7-0:9 + >--< +0| var foo, bar; + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:4-0:7 + >---< +0| var foo, bar; + +[#2 Removal] = 0:4-0:9 + >-----< +0| var foo, bar; + +[#2 Trailing delimiter] = 0:7-0:9 + >--< +0| var foo, bar; + +[#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:9-0:12 + >---< +0| var foo, bar; + +[#3 Removal] = 0:7-0:12 + >-----< +0| var foo, bar; + +[#3 Leading delimiter] = 0:7-0:9 + >--< +0| var foo, bar; + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 0:9-0:13 + >----< +0| var foo, bar; + +[#4 Removal] = 0:7-0:13 + >------< +0| var foo, bar; + +[#4 Leading delimiter] = 0:7-0:9 + >--< +0| var foo, bar; + +[#4 Insertion delimiter] = ", " diff --git a/queries/dart.scm b/queries/dart.scm index ef287961fd..6a26227a2a 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -46,7 +46,11 @@ (initialized_identifier_list (initialized_identifier (_) @name @value.leading.endOf - (_) @value @name.removal.end.startOf + "=" + . + (_) @value.start @name.removal.end.startOf + (_)? @value.end + . ) ) . @@ -70,6 +74,30 @@ ";" @statement.end @name.removal.end @name.domain.end ) +;;!! var foo, bar; +;;! ^^^^^^^^ +(_ + (inferred_type) @collectionItem.iteration.domain.start + . + (initialized_identifier_list) @collectionItem.iteration + . + ";" @collectionItem.iteration.domain.end +) + +;;!! var foo, bar; +;;! ^^^ ^^^ +( + (initialized_identifier_list + (_)? @_.leading.endOf + . + (_) @collectionItem + . + (_)? @_.trailing.startOf + ) @_dummy + (#not-type? @collectionItem comment) + (#single-or-multi-line-delimiter! @collectionItem @_dummy ", " ",\n") +) + ;;!! const foo = 0; ;;! ^^^^^^^^^^^^^^ ;;! ^^^ From e92db3899cc821fe9c73474478feb3f42570da87 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 16:55:01 +0100 Subject: [PATCH 14/20] named arguments --- .../name/name.argument.actual.iteration.scope | 18 ++++++ .../dart/name/name.argument.actual.scope | 60 +++++++++++++++++++ .../value.argument.actual.iteration.scope | 18 ++++++ .../dart/value/value.argument.actual.scope | 41 +++++++++++++ queries/dart.scm | 17 ++++++ 5 files changed, 154 insertions(+) create mode 100644 data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.actual.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.actual.scope diff --git a/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope new file mode 100644 index 0000000000..20f4fb136b --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope @@ -0,0 +1,18 @@ +void main() { + foo(aaa: 0, bbb: 1); +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo(aaa: 0, bbb: 1); +2| } + -< + + +[#2 Content] = +[#2 Domain] = 1:8-1:22 + >--------------< +1| foo(aaa: 0, bbb: 1); diff --git a/data/fixtures/scopes/dart/name/name.argument.actual.scope b/data/fixtures/scopes/dart/name/name.argument.actual.scope new file mode 100644 index 0000000000..6438a689ad --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.actual.scope @@ -0,0 +1,60 @@ +void main() { + foo(aaa: 0, bbb: 1); +} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo(aaa: 0, bbb: 1); +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| foo(aaa: 0, bbb: 1); + +[#2 Removal] = 1:8-1:13 + >-----< +1| foo(aaa: 0, bbb: 1); + +[#2 Trailing delimiter] = 1:11-1:13 + >--< +1| foo(aaa: 0, bbb: 1); + +[#2 Domain] = 1:8-1:14 + >------< +1| foo(aaa: 0, bbb: 1); + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:16-1:19 + >---< +1| foo(aaa: 0, bbb: 1); + +[#3 Removal] = 1:16-1:21 + >-----< +1| foo(aaa: 0, bbb: 1); + +[#3 Trailing delimiter] = 1:19-1:21 + >--< +1| foo(aaa: 0, bbb: 1); + +[#3 Domain] = 1:16-1:22 + >------< +1| foo(aaa: 0, bbb: 1); + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope b/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope new file mode 100644 index 0000000000..20f4fb136b --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope @@ -0,0 +1,18 @@ +void main() { + foo(aaa: 0, bbb: 1); +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo(aaa: 0, bbb: 1); +2| } + -< + + +[#2 Content] = +[#2 Domain] = 1:8-1:22 + >--------------< +1| foo(aaa: 0, bbb: 1); diff --git a/data/fixtures/scopes/dart/value/value.argument.actual.scope b/data/fixtures/scopes/dart/value/value.argument.actual.scope new file mode 100644 index 0000000000..ed528b56a6 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.actual.scope @@ -0,0 +1,41 @@ +void main() { + foo(aaa: 0, bbb: 1); +} +--- + +[#1 Content] = 1:13-1:14 + >-< +1| foo(aaa: 0, bbb: 1); + +[#1 Removal] = 1:11-1:14 + >---< +1| foo(aaa: 0, bbb: 1); + +[#1 Leading delimiter] = 1:11-1:13 + >--< +1| foo(aaa: 0, bbb: 1); + +[#1 Domain] = 1:8-1:14 + >------< +1| foo(aaa: 0, bbb: 1); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:21-1:22 + >-< +1| foo(aaa: 0, bbb: 1); + +[#2 Removal] = 1:19-1:22 + >---< +1| foo(aaa: 0, bbb: 1); + +[#2 Leading delimiter] = 1:19-1:21 + >--< +1| foo(aaa: 0, bbb: 1); + +[#2 Domain] = 1:16-1:22 + >------< +1| foo(aaa: 0, bbb: 1); + +[#2 Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index 6a26227a2a..9333b94098 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -468,6 +468,23 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! foo(aaa, bbb); +;;! ^^^^^^^^ +(arguments + "(" @name.iteration.start.endOf @value.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf +) + +;;!! foo(aaa: 0, bbb: 1); +;;! ^^^ ^^^ +;;! ^ ^ +(named_argument + (label + (_) @name @value.leading.endOf + ) + (_) @value @name.trailing.startOf +) @_.domain + ;;!! () {} ;;!! () => 0 (function_expression From baef75a2121062f940880aa022dfe8000f0c985f Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 16:57:01 +0100 Subject: [PATCH 15/20] catch argument name --- .../dart/name/name.argument.catch.scope | 49 +++++++++++++++++++ queries/dart.scm | 6 +-- 2 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 data/fixtures/scopes/dart/name/name.argument.catch.scope diff --git a/data/fixtures/scopes/dart/name/name.argument.catch.scope b/data/fixtures/scopes/dart/name/name.argument.catch.scope new file mode 100644 index 0000000000..ed3594cea8 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.catch.scope @@ -0,0 +1,49 @@ +void main() { + try {} + catch (e, s) {} +} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-3:1 + >------------- +0| void main() { +1| try {} +2| catch (e, s) {} +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:11-2:12 + >-< +2| catch (e, s) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Domain] = 2:14-2:15 + >-< +2| catch (e, s) {} + +[#3 Removal] = 2:13-2:15 + >--< +2| catch (e, s) {} + +[#3 Leading delimiter] = 2:13-2:14 + >-< +2| catch (e, s) {} + +[#3 Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index 9333b94098..275fd952e4 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -190,11 +190,11 @@ ;;! ^ ^ ( (catch_parameters - (_)? @_.leading.endOf + (_)? @argumentOrParameter.leading.endOf . - (_) @argumentOrParameter + (_) @argumentOrParameter @name . - (_)? @_.trailing.startOf + (_)? @argumentOrParameter.trailing.startOf ) @_dummy (#not-type? @argumentOrParameter comment) (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") From 6d4150776eee8ff2a538f8d132d24287cf622c86 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 17:27:08 +0100 Subject: [PATCH 16/20] name and value arguments --- ...rgument.formal.constructor.iteration.scope | 27 ++++++ .../name.argument.formal.constructor.scope | 96 +++++++++++++++++++ .../name/name.argument.formal.iteration.scope | 13 +++ ...ame.argument.formal.lambda.iteration.scope | 13 +++ .../name/name.argument.formal.lambda.scope | 75 +++++++++++++++ ...ame.argument.formal.method.iteration.scope | 27 ++++++ .../name/name.argument.formal.method.scope | 96 +++++++++++++++++++ .../dart/name/name.argument.formal.scope | 68 +++++++++++++ ...rgument.formal.constructor.iteration.scope | 27 ++++++ .../value.argument.formal.constructor.scope | 41 ++++++++ .../value.argument.formal.iteration.scope | 13 +++ ...lue.argument.formal.method.iteration.scope | 27 ++++++ .../value/value.argument.formal.method.scope | 41 ++++++++ .../dart/value/value.argument.formal.scope | 39 ++++++++ queries/dart.scm | 17 ++++ 15 files changed, 620 insertions(+) create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.method.scope create mode 100644 data/fixtures/scopes/dart/name/name.argument.formal.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.method.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.scope diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..3286fefc20 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.constructor.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + Foo(aaa, [int bbb, ccc = 0]) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo(aaa, [int bbb, ccc = 0]) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| Foo(aaa, [int bbb, ccc = 0]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:8-1:31 + >-----------------------< +1| Foo(aaa, [int bbb, ccc = 0]) {} diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.constructor.scope b/data/fixtures/scopes/dart/name/name.argument.formal.constructor.scope new file mode 100644 index 0000000000..8cd0a21a18 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.constructor.scope @@ -0,0 +1,96 @@ +class Foo { + Foo(aaa, [int bbb, ccc = 0]) {} +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| class Foo { + +[#1 Removal] = 0:6-0:10 + >----< +0| class Foo { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo { + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo { + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo(aaa, [int bbb, ccc = 0]) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:4-1:7 + >---< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Domain] = 1:4-1:35 + >-------------------------------< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 1:8-1:11 + >---< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:18-1:21 + >---< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Removal] = 1:17-1:21 + >----< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Leading delimiter] = 1:17-1:18 + >-< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Domain] = 1:14-1:21 + >-------< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 1:23-1:26 + >---< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Removal] = 1:23-1:27 + >----< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Leading delimiter] = 1:22-1:23 + >-< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Trailing delimiter] = 1:26-1:27 + >-< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Domain] = 1:23-1:30 + >-------< +1| Foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.formal.iteration.scope new file mode 100644 index 0000000000..bc21558abf --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +void foo(aaa, [int bbb, ccc = 0]) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:36 + >------------------------------------< +0| void foo(aaa, [int bbb, ccc = 0]) {} + + +[#2 Content] = +[#2 Domain] = 0:9-0:32 + >-----------------------< +0| void foo(aaa, [int bbb, ccc = 0]) {} diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..b0266f70a5 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope @@ -0,0 +1,13 @@ +var foo = (aaa, [int bbb, ccc = 0]) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:38 + >--------------------------------------< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + + +[#2 Content] = +[#2 Domain] = 0:11-0:34 + >-----------------------< +0| var foo = (aaa, [int bbb, ccc = 0]) {} diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope new file mode 100644 index 0000000000..7f09ec2069 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope @@ -0,0 +1,75 @@ +var foo = (aaa, [int bbb, ccc = 0]) {} +--- + +[#1 Content] = 0:4-0:7 + >---< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#1 Removal] = 0:0-0:10 + >----------< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#1 Leading delimiter] = 0:3-0:4 + >-< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#1 Trailing delimiter] = 0:7-0:8 + >-< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#1 Domain] = 0:0-0:38 + >--------------------------------------< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:11-0:14 + >---< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:21-0:24 + >---< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#3 Removal] = 0:20-0:24 + >----< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#3 Leading delimiter] = 0:20-0:21 + >-< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#3 Domain] = 0:17-0:24 + >-------< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 0:26-0:29 + >---< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Removal] = 0:26-0:30 + >----< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Leading delimiter] = 0:25-0:26 + >-< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Trailing delimiter] = 0:29-0:30 + >-< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Domain] = 0:26-0:33 + >-------< +0| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..9b8fd27597 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + void bar(aaa, [int bbb, ccc = 0]) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar(aaa, [int bbb, ccc = 0]) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar(aaa, [int bbb, ccc = 0]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:13-1:36 + >-----------------------< +1| void bar(aaa, [int bbb, ccc = 0]) {} diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.method.scope b/data/fixtures/scopes/dart/name/name.argument.formal.method.scope new file mode 100644 index 0000000000..455d4b0a17 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.method.scope @@ -0,0 +1,96 @@ +class Foo { + void foo(aaa, [int bbb, ccc = 0]) {} +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| class Foo { + +[#1 Removal] = 0:6-0:10 + >----< +0| class Foo { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo { + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo { + +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void foo(aaa, [int bbb, ccc = 0]) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:9-1:12 + >---< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Leading delimiter] = 1:8-1:9 + >-< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Domain] = 1:4-1:40 + >------------------------------------< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 1:13-1:16 + >---< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:23-1:26 + >---< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Removal] = 1:22-1:26 + >----< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Leading delimiter] = 1:22-1:23 + >-< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Domain] = 1:19-1:26 + >-------< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 1:28-1:31 + >---< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Removal] = 1:28-1:32 + >----< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Leading delimiter] = 1:27-1:28 + >-< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Trailing delimiter] = 1:31-1:32 + >-< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Domain] = 1:28-1:35 + >-------< +1| void foo(aaa, [int bbb, ccc = 0]) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.scope b/data/fixtures/scopes/dart/name/name.argument.formal.scope new file mode 100644 index 0000000000..ce2c4bdaf6 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.argument.formal.scope @@ -0,0 +1,68 @@ +void foo(aaa, [int bbb, ccc = 0]) {} +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:8 + >---< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#1 Domain] = 0:0-0:36 + >------------------------------------< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:9-0:12 + >---< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:19-0:22 + >---< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#3 Removal] = 0:18-0:22 + >----< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#3 Leading delimiter] = 0:18-0:19 + >-< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#3 Domain] = 0:15-0:22 + >-------< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 0:24-0:27 + >---< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Removal] = 0:24-0:28 + >----< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Leading delimiter] = 0:23-0:24 + >-< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Trailing delimiter] = 0:27-0:28 + >-< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Domain] = 0:24-0:31 + >-------< +0| void foo(aaa, [int bbb, ccc = 0]) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/dart/value/value.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..dd8ea225af --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.constructor.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + Foo([aaa = 0, int bbb = 1]) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo([aaa = 0, int bbb = 1]) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| Foo([aaa = 0, int bbb = 1]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:8-1:30 + >----------------------< +1| Foo([aaa = 0, int bbb = 1]) {} diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.constructor.scope b/data/fixtures/scopes/dart/value/value.argument.formal.constructor.scope new file mode 100644 index 0000000000..17931ea98d --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.constructor.scope @@ -0,0 +1,41 @@ +class Foo { + Foo([aaa = 0, int bbb = 1]) {} +} +--- + +[#1 Content] = 1:15-1:16 + >-< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#1 Removal] = 1:12-1:16 + >----< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#1 Leading delimiter] = 1:12-1:15 + >---< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#1 Domain] = 1:9-1:16 + >-------< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:28-1:29 + >-< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#2 Removal] = 1:25-1:29 + >----< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#2 Leading delimiter] = 1:25-1:28 + >---< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#2 Domain] = 1:18-1:29 + >-----------< +1| Foo([aaa = 0, int bbb = 1]) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.iteration.scope b/data/fixtures/scopes/dart/value/value.argument.formal.iteration.scope new file mode 100644 index 0000000000..b9e811840b --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +void foo([aaa = 0, int bbb = 1]) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:35 + >-----------------------------------< +0| void foo([aaa = 0, int bbb = 1]) {} + + +[#2 Content] = +[#2 Domain] = 0:9-0:31 + >----------------------< +0| void foo([aaa = 0, int bbb = 1]) {} diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.method.iteration.scope b/data/fixtures/scopes/dart/value/value.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..a9e86b2329 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + void bar([aaa = 0, int bbb = 1]) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar([aaa = 0, int bbb = 1]) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar([aaa = 0, int bbb = 1]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:13-1:35 + >----------------------< +1| void bar([aaa = 0, int bbb = 1]) {} diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.method.scope b/data/fixtures/scopes/dart/value/value.argument.formal.method.scope new file mode 100644 index 0000000000..7cbc4193b9 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.method.scope @@ -0,0 +1,41 @@ +class Foo { + void bar([aaa = 0, int bbb = 1]) {} +} +--- + +[#1 Content] = 1:20-1:21 + >-< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#1 Removal] = 1:17-1:21 + >----< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#1 Leading delimiter] = 1:17-1:20 + >---< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#1 Domain] = 1:14-1:21 + >-------< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:33-1:34 + >-< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#2 Removal] = 1:30-1:34 + >----< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#2 Leading delimiter] = 1:30-1:33 + >---< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#2 Domain] = 1:23-1:34 + >-----------< +1| void bar([aaa = 0, int bbb = 1]) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.scope b/data/fixtures/scopes/dart/value/value.argument.formal.scope new file mode 100644 index 0000000000..d58c2d84e4 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.scope @@ -0,0 +1,39 @@ +void foo([aaa = 0, int bbb = 1]) {} +--- + +[#1 Content] = 0:16-0:17 + >-< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#1 Removal] = 0:13-0:17 + >----< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#1 Leading delimiter] = 0:13-0:16 + >---< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#1 Domain] = 0:10-0:17 + >-------< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:29-0:30 + >-< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#2 Removal] = 0:26-0:30 + >----< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#2 Leading delimiter] = 0:26-0:29 + >---< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#2 Domain] = 0:19-0:30 + >-----------< +0| void foo([aaa = 0, int bbb = 1]) {} + +[#2 Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index 275fd952e4..ba4ca5dec2 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -419,6 +419,23 @@ ")" @name.iteration.end.startOf @value.iteration.end.startOf ) +;;!! int aaa = 0 +;;! ^^^ +;;! ^^^ +;;! ^ +(_ + (formal_parameter + (type_identifier)? @type + (identifier) @name @value.leading.endOf + ) @_.domain.start + . + ( + "=" + . + (_) @value @_.domain.end + )? +) + ;;!! foo(); ;;! ^^^^^ ;;! ^^^ From b7497d9c1609b2af5bcf509619d4f2e7590bc7da Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 18:25:02 +0100 Subject: [PATCH 17/20] type --- .../argument.formal.lambda.iteration.scope | 16 ++- .../argument.formal.lambda.multiLine.scope | 70 +++++----- .../argument.formal.lambda.singleLine.scope | 40 +++--- .../argumentList.formal.lambda.empty.scope | 35 +++-- ...argumentList.formal.lambda.multiLine.scope | 78 ++++++----- ...rgumentList.formal.lambda.singleLine.scope | 35 +++-- .../dart/interior/interior.lambda.scope | 31 ++++- ...ame.argument.formal.lambda.iteration.scope | 19 ++- .../name/name.argument.formal.lambda.scope | 121 ++++++++++-------- .../scopes/dart/name/name.constructor.scope | 22 ++-- .../dart/name/name.variable.initialized.scope | 53 +++++--- .../name/name.variable.uninitialized.scope | 48 +++++-- .../statement.variable.initialized.scope | 37 +++++- .../statement.variable.uninitialized.scope | 37 +++++- .../scopes/dart/type/type.alias.scope | 10 ++ .../dart/type/type.argument.catch.scope | 47 +++++++ ...rgument.formal.constructor.iteration.scope | 27 ++++ .../type.argument.formal.constructor.scope | 53 ++++++++ .../type/type.argument.formal.iteration.scope | 13 ++ ...ype.argument.formal.lambda.iteration.scope | 18 +++ .../type/type.argument.formal.lambda.scope | 63 +++++++++ ...ype.argument.formal.method.iteration.scope | 27 ++++ .../type/type.argument.formal.method.scope | 76 +++++++++++ .../dart/type/type.argument.formal.scope | 58 +++++++++ .../fixtures/scopes/dart/type/type.cast.scope | 44 +++++++ .../scopes/dart/type/type.class.scope | 10 ++ .../scopes/dart/type/type.constant.scope | 24 ++++ .../fixtures/scopes/dart/type/type.enum.scope | 10 ++ .../scopes/dart/type/type.field.class.scope | 63 +++++++++ .../scopes/dart/type/type.foreach.scope | 48 +++++++ .../dart/type/type.iteration.class.scope | 13 ++ .../dart/type/type.iteration.document.scope | 12 ++ .../scopes/dart/type/type.return.method.scope | 38 ++++++ .../scopes/dart/type/type.return.scope | 20 +++ .../type/type.typeArgument.iteration.scope | 18 +++ .../scopes/dart/type/type.typeArgument.scope | 73 +++++++++++ .../dart/type/type.variable.initialized.scope | 48 +++++++ .../type/type.variable.uninitialized.scope | 48 +++++++ .../scopes/dart/value/value.variable.scope | 28 ++-- queries/dart.scm | 115 +++++++++-------- 40 files changed, 1359 insertions(+), 287 deletions(-) create mode 100644 data/fixtures/scopes/dart/type/type.alias.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.catch.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.method.scope create mode 100644 data/fixtures/scopes/dart/type/type.argument.formal.scope create mode 100644 data/fixtures/scopes/dart/type/type.cast.scope create mode 100644 data/fixtures/scopes/dart/type/type.class.scope create mode 100644 data/fixtures/scopes/dart/type/type.constant.scope create mode 100644 data/fixtures/scopes/dart/type/type.enum.scope create mode 100644 data/fixtures/scopes/dart/type/type.field.class.scope create mode 100644 data/fixtures/scopes/dart/type/type.foreach.scope create mode 100644 data/fixtures/scopes/dart/type/type.iteration.class.scope create mode 100644 data/fixtures/scopes/dart/type/type.iteration.document.scope create mode 100644 data/fixtures/scopes/dart/type/type.return.method.scope create mode 100644 data/fixtures/scopes/dart/type/type.return.scope create mode 100644 data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope create mode 100644 data/fixtures/scopes/dart/type/type.typeArgument.scope create mode 100644 data/fixtures/scopes/dart/type/type.variable.initialized.scope create mode 100644 data/fixtures/scopes/dart/type/type.variable.uninitialized.scope diff --git a/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope index e6d900fdbc..824b5665e7 100644 --- a/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope +++ b/data/fixtures/scopes/dart/argument/argument.formal.lambda.iteration.scope @@ -1,10 +1,12 @@ -var foo = (aaa, bbb) {}; +void main() { + var foo = (aaa, bbb) {}; +} --- -[Content] = 0:11-0:19 - >--------< -0| var foo = (aaa, bbb) {}; +[Content] = 1:15-1:23 + >--------< +1| var foo = (aaa, bbb) {}; -[Domain] = 0:10-0:23 - >-------------< -0| var foo = (aaa, bbb) {}; +[Domain] = 1:14-1:27 + >-------------< +1| var foo = (aaa, bbb) {}; diff --git a/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope index 931431f00e..c5627dfc65 100644 --- a/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope +++ b/data/fixtures/scopes/dart/argument/argument.formal.lambda.multiLine.scope @@ -1,45 +1,47 @@ -var foo = ( - aaa, - bbb -) {}; +void main() { + var foo = ( + aaa, + bbb + ) {}; +} --- [#1 Content] = -[#1 Domain] = 1:4-1:7 - >---< -1| aaa, - -[#1 Removal] = 1:4-2:4 - >---- -1| aaa, -2| bbb - ----< - -[#1 Trailing delimiter] = 1:7-2:4 - >- -1| aaa, -2| bbb - ----< +[#1 Domain] = 2:8-2:11 + >---< +2| aaa, + +[#1 Removal] = 2:8-3:8 + >---- +2| aaa, +3| bbb + --------< + +[#1 Trailing delimiter] = 2:11-3:8 + >- +2| aaa, +3| bbb + --------< [#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 2:4-2:7 - >---< -2| bbb - -[#2 Removal] = 1:7-2:7 - >- -1| aaa, -2| bbb - -------< - -[#2 Leading delimiter] = 1:7-2:4 - >- -1| aaa, -2| bbb - ----< +[#2 Domain] = 3:8-3:11 + >---< +3| bbb + +[#2 Removal] = 2:11-3:11 + >- +2| aaa, +3| bbb + -----------< + +[#2 Leading delimiter] = 2:11-3:8 + >- +2| aaa, +3| bbb + --------< [#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope b/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope index 8fe895eaed..16adfe5d7a 100644 --- a/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope +++ b/data/fixtures/scopes/dart/argument/argument.formal.lambda.singleLine.scope @@ -1,33 +1,35 @@ -var foo = (aaa, bbb) {}; +void main() { + var foo = (aaa, bbb) {}; +} --- [#1 Content] = -[#1 Domain] = 0:11-0:14 - >---< -0| var foo = (aaa, bbb) {}; +[#1 Domain] = 1:15-1:18 + >---< +1| var foo = (aaa, bbb) {}; -[#1 Removal] = 0:11-0:16 - >-----< -0| var foo = (aaa, bbb) {}; +[#1 Removal] = 1:15-1:20 + >-----< +1| var foo = (aaa, bbb) {}; -[#1 Trailing delimiter] = 0:14-0:16 - >--< -0| var foo = (aaa, bbb) {}; +[#1 Trailing delimiter] = 1:18-1:20 + >--< +1| var foo = (aaa, bbb) {}; [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 0:16-0:19 - >---< -0| var foo = (aaa, bbb) {}; +[#2 Domain] = 1:20-1:23 + >---< +1| var foo = (aaa, bbb) {}; -[#2 Removal] = 0:14-0:19 - >-----< -0| var foo = (aaa, bbb) {}; +[#2 Removal] = 1:18-1:23 + >-----< +1| var foo = (aaa, bbb) {}; -[#2 Leading delimiter] = 0:14-0:16 - >--< -0| var foo = (aaa, bbb) {}; +[#2 Leading delimiter] = 1:18-1:20 + >--< +1| var foo = (aaa, bbb) {}; [#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope index e44da4901e..1b964ec4f9 100644 --- a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.empty.scope @@ -1,13 +1,30 @@ -var foo = () {}; +void main() { + var foo = () {}; +} --- -[Content] = -[Removal] = 0:11-0:11 - >< -0| var foo = () {}; +[#1 Content] = +[#1 Removal] = 0:10-0:10 + >< +0| void main() { -[Domain] = 0:10-0:15 - >-----< -0| var foo = () {}; +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = () {}; +2| } + -< -[Insertion delimiter] = "" +[#1 Insertion delimiter] = "" + + +[#2 Content] = +[#2 Removal] = 1:15-1:15 + >< +1| var foo = () {}; + +[#2 Domain] = 1:14-1:19 + >-----< +1| var foo = () {}; + +[#2 Insertion delimiter] = "" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope index 5a8654d92e..82b22d7e0d 100644 --- a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.multiLine.scope @@ -1,33 +1,53 @@ -var foo = ( - aaa, - bbb -) {}; +void main() { + var foo = ( + aaa, + bbb + ) {}; +} --- -[Content] = 1:4-2:7 - >---- -1| aaa, -2| bbb - -------< - -[Removal] = 0:11-3:0 - > -0| var foo = ( -1| aaa, -2| bbb -3| ) {}; - < - -[Leading delimiter] = 1:0-1:4 - >----< -1| aaa, - -[Domain] = 0:10-3:4 - >- -0| var foo = ( -1| aaa, -2| bbb -3| ) {}; +[#1 Content] = +[#1 Removal] = 0:10-0:10 + >< +0| void main() { + +[#1 Domain] = 0:0-5:1 + >------------- +0| void main() { +1| var foo = ( +2| aaa, +3| bbb +4| ) {}; +5| } + -< + +[#1 Insertion delimiter] = "" + + +[#2 Content] = 2:8-3:11 + >---- +2| aaa, +3| bbb + -----------< + +[#2 Removal] = 1:15-4:4 + > +1| var foo = ( +2| aaa, +3| bbb +4| ) {}; ----< -[Insertion delimiter] = ",\n" +[#2 Leading delimiter] = 2:0-2:8 + >--------< +2| aaa, + +[#2 Domain] = 1:14-4:8 + >- +1| var foo = ( +2| aaa, +3| bbb +4| ) {}; + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope index a141064261..39a3088704 100644 --- a/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope +++ b/data/fixtures/scopes/dart/argumentList/argumentList.formal.lambda.singleLine.scope @@ -1,13 +1,30 @@ -var foo = (aaa, bbb) {}; +void main() { + var foo = (aaa, bbb) {}; +} --- -[Content] = -[Removal] = 0:11-0:19 - >--------< -0| var foo = (aaa, bbb) {}; +[#1 Content] = +[#1 Removal] = 0:10-0:10 + >< +0| void main() { -[Domain] = 0:10-0:23 - >-------------< -0| var foo = (aaa, bbb) {}; +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = (aaa, bbb) {}; +2| } + -< -[Insertion delimiter] = ", " +[#1 Insertion delimiter] = "" + + +[#2 Content] = +[#2 Removal] = 1:15-1:23 + >--------< +1| var foo = (aaa, bbb) {}; + +[#2 Domain] = 1:14-1:27 + >-------------< +1| var foo = (aaa, bbb) {}; + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/dart/interior/interior.lambda.scope b/data/fixtures/scopes/dart/interior/interior.lambda.scope index 5a59d8ab9d..9c3594fb03 100644 --- a/data/fixtures/scopes/dart/interior/interior.lambda.scope +++ b/data/fixtures/scopes/dart/interior/interior.lambda.scope @@ -1,10 +1,27 @@ -var foo = () { }; +void main() { + var foo = () { }; +} --- -[Content] = -[Removal] = -[Domain] = 0:14-0:15 - >-< -0| var foo = () { }; +[#1 Content] = 1:4-1:21 + >-----------------< +1| var foo = () { }; -[Insertion delimiter] = " " +[#1 Removal] = +[#1 Domain] = 0:13-2:0 + > +0| void main() { +1| var foo = () { }; +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:18-1:19 + >-< +1| var foo = () { }; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope index b0266f70a5..8c34e88cb9 100644 --- a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope +++ b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope @@ -1,13 +1,18 @@ -var foo = (aaa, [int bbb, ccc = 0]) {} +void main() { + var foo = (aaa, [int bbb, ccc = 0]) {} +} --- [#1 Content] = -[#1 Domain] = 0:0-0:38 - >--------------------------------------< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = (aaa, [int bbb, ccc = 0]) {} +2| } + -< [#2 Content] = -[#2 Domain] = 0:11-0:34 - >-----------------------< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#2 Domain] = 1:15-1:38 + >-----------------------< +1| var foo = (aaa, [int bbb, ccc = 0]) {} diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope index 7f09ec2069..fdfcfb1ebf 100644 --- a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope +++ b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.scope @@ -1,75 +1,96 @@ -var foo = (aaa, [int bbb, ccc = 0]) {} +void main() { + var foo = (aaa, [int bbb, ccc = 0]) {} +} --- -[#1 Content] = 0:4-0:7 - >---< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { -[#1 Removal] = 0:0-0:10 - >----------< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { -[#1 Leading delimiter] = 0:3-0:4 - >-< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = (aaa, [int bbb, ccc = 0]) {} +2| } + -< -[#1 Trailing delimiter] = 0:7-0:8 - >-< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#1 Insertion delimiter] = " " -[#1 Domain] = 0:0-0:38 - >--------------------------------------< -0| var foo = (aaa, [int bbb, ccc = 0]) {} -[#1 Insertion delimiter] = " " +[#2 Content] = 1:8-1:11 + >---< +1| var foo = (aaa, [int bbb, ccc = 0]) {} +[#2 Removal] = 1:4-1:14 + >----------< +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#2 Content] = -[#2 Removal] = -[#2 Domain] = 0:11-0:14 - >---< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#2 Trailing delimiter] = 1:11-1:12 + >-< +1| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#2 Domain] = 1:4-1:42 + >--------------------------------------< +1| var foo = (aaa, [int bbb, ccc = 0]) {} [#2 Insertion delimiter] = " " -[#3 Content] = 0:21-0:24 - >---< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 1:15-1:18 + >---< +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#3 Removal] = 0:20-0:24 - >----< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#3 Insertion delimiter] = " " -[#3 Leading delimiter] = 0:20-0:21 - >-< -0| var foo = (aaa, [int bbb, ccc = 0]) {} -[#3 Domain] = 0:17-0:24 - >-------< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#4 Content] = 1:25-1:28 + >---< +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#3 Insertion delimiter] = " " +[#4 Removal] = 1:24-1:28 + >----< +1| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Leading delimiter] = 1:24-1:25 + >-< +1| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#4 Domain] = 1:21-1:28 + >-------< +1| var foo = (aaa, [int bbb, ccc = 0]) {} +[#4 Insertion delimiter] = " " -[#4 Content] = 0:26-0:29 - >---< -0| var foo = (aaa, [int bbb, ccc = 0]) {} -[#4 Removal] = 0:26-0:30 - >----< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#5 Content] = 1:30-1:33 + >---< +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#4 Leading delimiter] = 0:25-0:26 - >-< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#5 Removal] = 1:30-1:34 + >----< +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#4 Trailing delimiter] = 0:29-0:30 +[#5 Leading delimiter] = 1:29-1:30 >-< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#4 Domain] = 0:26-0:33 - >-------< -0| var foo = (aaa, [int bbb, ccc = 0]) {} +[#5 Trailing delimiter] = 1:33-1:34 + >-< +1| var foo = (aaa, [int bbb, ccc = 0]) {} -[#4 Insertion delimiter] = " " +[#5 Domain] = 1:30-1:37 + >-------< +1| var foo = (aaa, [int bbb, ccc = 0]) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.constructor.scope b/data/fixtures/scopes/dart/name/name.constructor.scope index 6c60f1ed8b..c067b52eed 100644 --- a/data/fixtures/scopes/dart/name/name.constructor.scope +++ b/data/fixtures/scopes/dart/name/name.constructor.scope @@ -1,5 +1,5 @@ class Foo { - Foo() {} + Foo() {} } --- @@ -22,7 +22,7 @@ class Foo { [#1 Domain] = 0:0-2:1 >----------- 0| class Foo { -1| Foo() {} +1| Foo() {} 2| } -< @@ -30,16 +30,16 @@ class Foo { [#2 Content] = -[#2 Removal] = 1:8-1:11 - >---< -1| Foo() {} +[#2 Removal] = 1:4-1:7 + >---< +1| Foo() {} -[#2 Leading delimiter] = 1:0-1:8 - >--------< -1| Foo() {} +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| Foo() {} -[#2 Domain] = 1:8-1:16 - >--------< -1| Foo() {} +[#2 Domain] = 1:4-1:12 + >--------< +1| Foo() {} [#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.variable.initialized.scope b/data/fixtures/scopes/dart/name/name.variable.initialized.scope index 263bc28906..5c026bff2c 100644 --- a/data/fixtures/scopes/dart/name/name.variable.initialized.scope +++ b/data/fixtures/scopes/dart/name/name.variable.initialized.scope @@ -1,24 +1,45 @@ -var foo = 0; +void main() { + var foo = 0; +} --- -[Content] = 0:4-0:7 - >---< -0| var foo = 0; +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { -[Removal] = 0:0-0:10 - >----------< -0| var foo = 0; +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { -[Leading delimiter] = 0:3-0:4 - >-< -0| var foo = 0; +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = 0; +2| } + -< -[Trailing delimiter] = 0:7-0:8 +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| var foo = 0; + +[#2 Removal] = 1:4-1:14 + >----------< +1| var foo = 0; + +[#2 Leading delimiter] = 1:7-1:8 >-< -0| var foo = 0; +1| var foo = 0; + +[#2 Trailing delimiter] = 1:11-1:12 + >-< +1| var foo = 0; -[Domain] = 0:0-0:12 - >------------< -0| var foo = 0; +[#2 Domain] = 1:4-1:16 + >------------< +1| var foo = 0; -[Insertion delimiter] = " " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope b/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope index 73ee2234af..4a6042d3e2 100644 --- a/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope +++ b/data/fixtures/scopes/dart/name/name.variable.uninitialized.scope @@ -1,17 +1,41 @@ -var foo; +void main() { + var foo; +} --- -[Content] = 0:4-0:7 - >---< -0| var foo; +[#1 Content] = +[#1 Removal] = 0:5-0:9 + >----< +0| void main() { -[Removal] = -[Domain] = 0:0-0:8 - >--------< -0| var foo; +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| void main() { -[Leading delimiter] = 0:3-0:4 - >-< -0| var foo; +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo; +2| } + -< -[Insertion delimiter] = " " +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| var foo; + +[#2 Removal] = 1:4-1:11 + >-------< +1| var foo; + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| var foo; + +[#2 Domain] = 1:4-1:12 + >--------< +1| var foo; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope b/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope index 7fba2976e6..32ef60bdee 100644 --- a/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope +++ b/data/fixtures/scopes/dart/statement/statement.variable.initialized.scope @@ -1,10 +1,33 @@ -var foo = 0; +void main() { + var foo = 0; +} --- -[Content] = -[Removal] = -[Domain] = 0:0-0:12 - >------------< -0| var foo = 0; +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = 0; +2| } + -< -[Insertion delimiter] = "\n" +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:16 + >------------< +1| var foo = 0; + +[#2 Removal] = 1:0-2:0 + >---------------- +1| var foo = 0; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| var foo = 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope b/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope index bb966b47f5..8e3b2a81fa 100644 --- a/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope +++ b/data/fixtures/scopes/dart/statement/statement.variable.uninitialized.scope @@ -1,10 +1,33 @@ -var foo; +void main() { + var foo; +} --- -[Content] = -[Removal] = -[Domain] = 0:0-0:8 - >--------< -0| var foo; +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo; +2| } + -< -[Insertion delimiter] = "\n" +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| var foo; + +[#2 Removal] = 1:0-2:0 + >------------ +1| var foo; +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| var foo; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/dart/type/type.alias.scope b/data/fixtures/scopes/dart/type/type.alias.scope new file mode 100644 index 0000000000..5176c25ab9 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.alias.scope @@ -0,0 +1,10 @@ +typedef Foo = int; +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| typedef Foo = int; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.argument.catch.scope b/data/fixtures/scopes/dart/type/type.argument.catch.scope new file mode 100644 index 0000000000..96c85e1e02 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.catch.scope @@ -0,0 +1,47 @@ +void main() { + try {} + on Exception catch (e) {} +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-3:1 + >------------- +0| void main() { +1| try {} +2| on Exception catch (e) {} +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 2:7-2:16 + >---------< +2| on Exception catch (e) {} + +[#2 Removal] = 2:7-2:17 + >----------< +2| on Exception catch (e) {} + +[#2 Leading delimiter] = 2:6-2:7 + >-< +2| on Exception catch (e) {} + +[#2 Trailing delimiter] = 2:16-2:17 + >-< +2| on Exception catch (e) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/dart/type/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..3d0157d69a --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.constructor.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + Foo(int aaa, [int bbb = 0]) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo(int aaa, [int bbb = 0]) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| Foo(int aaa, [int bbb = 0]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:8-1:30 + >----------------------< +1| Foo(int aaa, [int bbb = 0]) {} diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.constructor.scope b/data/fixtures/scopes/dart/type/type.argument.formal.constructor.scope new file mode 100644 index 0000000000..dc735e99bd --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.constructor.scope @@ -0,0 +1,53 @@ +class Foo { + Foo(int aaa, [int bbb = 0]) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| Foo(int aaa, [int bbb = 0]) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| Foo(int aaa, [int bbb = 0]) {} + +[#2 Removal] = 1:8-1:12 + >----< +1| Foo(int aaa, [int bbb = 0]) {} + +[#2 Trailing delimiter] = 1:11-1:12 + >-< +1| Foo(int aaa, [int bbb = 0]) {} + +[#2 Domain] = 1:8-1:15 + >-------< +1| Foo(int aaa, [int bbb = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:18-1:21 + >---< +1| Foo(int aaa, [int bbb = 0]) {} + +[#3 Removal] = 1:18-1:22 + >----< +1| Foo(int aaa, [int bbb = 0]) {} + +[#3 Trailing delimiter] = 1:21-1:22 + >-< +1| Foo(int aaa, [int bbb = 0]) {} + +[#3 Domain] = 1:18-1:29 + >-----------< +1| Foo(int aaa, [int bbb = 0]) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.iteration.scope b/data/fixtures/scopes/dart/type/type.argument.formal.iteration.scope new file mode 100644 index 0000000000..0264bc59ac --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +void foo(int aaa, [int bbb = 0]) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:35 + >-----------------------------------< +0| void foo(int aaa, [int bbb = 0]) {} + + +[#2 Content] = +[#2 Domain] = 0:9-0:31 + >----------------------< +0| void foo(int aaa, [int bbb = 0]) {} diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..85ac5db6a7 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope @@ -0,0 +1,18 @@ +void main() { + var foo = (int aaa, [int bbb = 0]) {}; +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = (int aaa, [int bbb = 0]) {}; +2| } + -< + + +[#2 Content] = +[#2 Domain] = 1:15-1:37 + >----------------------< +1| var foo = (int aaa, [int bbb = 0]) {}; diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.lambda.scope b/data/fixtures/scopes/dart/type/type.argument.formal.lambda.scope new file mode 100644 index 0000000000..7269c75723 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.lambda.scope @@ -0,0 +1,63 @@ +void main() { + var foo = (int aaa, [int bbb = 0]) {}; +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = (int aaa, [int bbb = 0]) {}; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:15-1:18 + >---< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#2 Removal] = 1:15-1:19 + >----< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#2 Trailing delimiter] = 1:18-1:19 + >-< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#2 Domain] = 1:15-1:22 + >-------< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:25-1:28 + >---< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#3 Removal] = 1:25-1:29 + >----< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#3 Trailing delimiter] = 1:28-1:29 + >-< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#3 Domain] = 1:25-1:36 + >-----------< +1| var foo = (int aaa, [int bbb = 0]) {}; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/dart/type/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..e5cc789538 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + void bar(int aaa, [int bbb = 0]) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar(int aaa, [int bbb = 0]) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar(int aaa, [int bbb = 0]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:13-1:35 + >----------------------< +1| void bar(int aaa, [int bbb = 0]) {} diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.method.scope b/data/fixtures/scopes/dart/type/type.argument.formal.method.scope new file mode 100644 index 0000000000..277eb15546 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.method.scope @@ -0,0 +1,76 @@ +class Foo { + void bar(int aaa, [int bbb = 0]) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar(int aaa, [int bbb = 0]) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:8 + >----< +1| void bar(int aaa, [int bbb = 0]) {} + +[#2 Removal] = 1:4-1:9 + >-----< +1| void bar(int aaa, [int bbb = 0]) {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| void bar(int aaa, [int bbb = 0]) {} + +[#2 Trailing delimiter] = 1:8-1:9 + >-< +1| void bar(int aaa, [int bbb = 0]) {} + +[#2 Domain] = 1:4-1:39 + >-----------------------------------< +1| void bar(int aaa, [int bbb = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:13-1:16 + >---< +1| void bar(int aaa, [int bbb = 0]) {} + +[#3 Removal] = 1:13-1:17 + >----< +1| void bar(int aaa, [int bbb = 0]) {} + +[#3 Trailing delimiter] = 1:16-1:17 + >-< +1| void bar(int aaa, [int bbb = 0]) {} + +[#3 Domain] = 1:13-1:20 + >-------< +1| void bar(int aaa, [int bbb = 0]) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:23-1:26 + >---< +1| void bar(int aaa, [int bbb = 0]) {} + +[#4 Removal] = 1:23-1:27 + >----< +1| void bar(int aaa, [int bbb = 0]) {} + +[#4 Trailing delimiter] = 1:26-1:27 + >-< +1| void bar(int aaa, [int bbb = 0]) {} + +[#4 Domain] = 1:23-1:34 + >-----------< +1| void bar(int aaa, [int bbb = 0]) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.scope b/data/fixtures/scopes/dart/type/type.argument.formal.scope new file mode 100644 index 0000000000..9ca8184212 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.argument.formal.scope @@ -0,0 +1,58 @@ +void foo(int aaa, [int bbb = 0]) {} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void foo(int aaa, [int bbb = 0]) {} + +[#1 Removal] = 0:0-0:5 + >-----< +0| void foo(int aaa, [int bbb = 0]) {} + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void foo(int aaa, [int bbb = 0]) {} + +[#1 Domain] = 0:0-0:35 + >-----------------------------------< +0| void foo(int aaa, [int bbb = 0]) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:9-0:12 + >---< +0| void foo(int aaa, [int bbb = 0]) {} + +[#2 Removal] = 0:9-0:13 + >----< +0| void foo(int aaa, [int bbb = 0]) {} + +[#2 Trailing delimiter] = 0:12-0:13 + >-< +0| void foo(int aaa, [int bbb = 0]) {} + +[#2 Domain] = 0:9-0:16 + >-------< +0| void foo(int aaa, [int bbb = 0]) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:19-0:22 + >---< +0| void foo(int aaa, [int bbb = 0]) {} + +[#3 Removal] = 0:19-0:23 + >----< +0| void foo(int aaa, [int bbb = 0]) {} + +[#3 Trailing delimiter] = 0:22-0:23 + >-< +0| void foo(int aaa, [int bbb = 0]) {} + +[#3 Domain] = 0:19-0:30 + >-----------< +0| void foo(int aaa, [int bbb = 0]) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.cast.scope b/data/fixtures/scopes/dart/type/type.cast.scope new file mode 100644 index 0000000000..71cec9dbdb --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.cast.scope @@ -0,0 +1,44 @@ +void main() { + foo as int; +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| foo as int; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:11-1:14 + >---< +1| foo as int; + +[#2 Removal] = 1:10-1:14 + >----< +1| foo as int; + +[#2 Leading delimiter] = 1:10-1:11 + >-< +1| foo as int; + +[#2 Domain] = 1:4-1:14 + >----------< +1| foo as int; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.class.scope b/data/fixtures/scopes/dart/type/type.class.scope new file mode 100644 index 0000000000..79c274ccc6 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.class.scope @@ -0,0 +1,10 @@ +class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.constant.scope b/data/fixtures/scopes/dart/type/type.constant.scope new file mode 100644 index 0000000000..a36046e407 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.constant.scope @@ -0,0 +1,24 @@ +const int foo = 0; +--- + +[Content] = 0:6-0:9 + >---< +0| const int foo = 0; + +[Removal] = 0:6-0:10 + >----< +0| const int foo = 0; + +[Leading delimiter] = 0:5-0:6 + >-< +0| const int foo = 0; + +[Trailing delimiter] = 0:9-0:10 + >-< +0| const int foo = 0; + +[Domain] = 0:0-0:18 + >------------------< +0| const int foo = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.enum.scope b/data/fixtures/scopes/dart/type/type.enum.scope new file mode 100644 index 0000000000..70c26e7b58 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.enum.scope @@ -0,0 +1,10 @@ +enum Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.field.class.scope b/data/fixtures/scopes/dart/type/type.field.class.scope new file mode 100644 index 0000000000..528fd810c8 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.field.class.scope @@ -0,0 +1,63 @@ +class Foo { + int bar; + int baz = 0; +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| int bar; +2| int baz = 0; +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| int bar; + +[#2 Removal] = 1:4-1:8 + >----< +1| int bar; + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| int bar; + +[#2 Trailing delimiter] = 1:7-1:8 + >-< +1| int bar; + +[#2 Domain] = 1:4-1:12 + >--------< +1| int bar; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:4-2:7 + >---< +2| int baz = 0; + +[#3 Removal] = 2:4-2:8 + >----< +2| int baz = 0; + +[#3 Leading delimiter] = 2:0-2:4 + >----< +2| int baz = 0; + +[#3 Trailing delimiter] = 2:7-2:8 + >-< +2| int baz = 0; + +[#3 Domain] = 2:4-2:16 + >------------< +2| int baz = 0; + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.foreach.scope b/data/fixtures/scopes/dart/type/type.foreach.scope new file mode 100644 index 0000000000..d9184595a6 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.foreach.scope @@ -0,0 +1,48 @@ +void main() { + for (final int v in values) {} +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| for (final int v in values) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:15-1:18 + >---< +1| for (final int v in values) {} + +[#2 Removal] = 1:15-1:19 + >----< +1| for (final int v in values) {} + +[#2 Leading delimiter] = 1:14-1:15 + >-< +1| for (final int v in values) {} + +[#2 Trailing delimiter] = 1:18-1:19 + >-< +1| for (final int v in values) {} + +[#2 Domain] = 1:4-1:34 + >------------------------------< +1| for (final int v in values) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.iteration.class.scope b/data/fixtures/scopes/dart/type/type.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.iteration.class.scope @@ -0,0 +1,13 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/data/fixtures/scopes/dart/type/type.iteration.document.scope b/data/fixtures/scopes/dart/type/type.iteration.document.scope new file mode 100644 index 0000000000..f7552fe2fe --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.iteration.document.scope @@ -0,0 +1,12 @@ + +int foo = 0; + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| int foo = 0; +2| + < diff --git a/data/fixtures/scopes/dart/type/type.return.method.scope b/data/fixtures/scopes/dart/type/type.return.method.scope new file mode 100644 index 0000000000..6e555c6589 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.return.method.scope @@ -0,0 +1,38 @@ +class Foo { + int bar() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| int bar() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| int bar() {} + +[#2 Removal] = 1:4-1:8 + >----< +1| int bar() {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| int bar() {} + +[#2 Trailing delimiter] = 1:7-1:8 + >-< +1| int bar() {} + +[#2 Domain] = 1:4-1:16 + >------------< +1| int bar() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.return.scope b/data/fixtures/scopes/dart/type/type.return.scope new file mode 100644 index 0000000000..153e08a800 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.return.scope @@ -0,0 +1,20 @@ +int foo() {} +--- + +[Content] = 0:0-0:3 + >---< +0| int foo() {} + +[Removal] = 0:0-0:4 + >----< +0| int foo() {} + +[Trailing delimiter] = 0:3-0:4 + >-< +0| int foo() {} + +[Domain] = 0:0-0:12 + >------------< +0| int foo() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope b/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope new file mode 100644 index 0000000000..9bc4869a96 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope @@ -0,0 +1,18 @@ +void main() { + Map foo; +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| Map foo; +2| } + -< + + +[#2 Content] = +[#2 Domain] = 1:8-1:16 + >--------< +1| Map foo; diff --git a/data/fixtures/scopes/dart/type/type.typeArgument.scope b/data/fixtures/scopes/dart/type/type.typeArgument.scope new file mode 100644 index 0000000000..8434f1f45c --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.typeArgument.scope @@ -0,0 +1,73 @@ +void main() { + Map foo; +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| Map foo; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:17 + >-------------< +1| Map foo; + +[#2 Removal] = 1:4-1:18 + >--------------< +1| Map foo; + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| Map foo; + +[#2 Trailing delimiter] = 1:17-1:18 + >-< +1| Map foo; + +[#2 Domain] = 1:4-1:22 + >------------------< +1| Map foo; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 1:8-1:11 + >---< +1| Map foo; + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Domain] = 1:13-1:16 + >---< +1| Map foo; + +[#4 Removal] = 1:12-1:16 + >----< +1| Map foo; + +[#4 Leading delimiter] = 1:12-1:13 + >-< +1| Map foo; + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.variable.initialized.scope b/data/fixtures/scopes/dart/type/type.variable.initialized.scope new file mode 100644 index 0000000000..a6800402d7 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.variable.initialized.scope @@ -0,0 +1,48 @@ +void main() { + int foo = 0; +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| int foo = 0; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| int foo = 0; + +[#2 Removal] = 1:4-1:8 + >----< +1| int foo = 0; + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| int foo = 0; + +[#2 Trailing delimiter] = 1:7-1:8 + >-< +1| int foo = 0; + +[#2 Domain] = 1:4-1:16 + >------------< +1| int foo = 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/type/type.variable.uninitialized.scope b/data/fixtures/scopes/dart/type/type.variable.uninitialized.scope new file mode 100644 index 0000000000..483f0f3947 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.variable.uninitialized.scope @@ -0,0 +1,48 @@ +void main() { + int foo; +} +--- + +[#1 Content] = 0:0-0:4 + >----< +0| void main() { + +[#1 Removal] = 0:0-0:5 + >-----< +0| void main() { + +[#1 Trailing delimiter] = 0:4-0:5 + >-< +0| void main() { + +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| int foo; +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:7 + >---< +1| int foo; + +[#2 Removal] = 1:4-1:8 + >----< +1| int foo; + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| int foo; + +[#2 Trailing delimiter] = 1:7-1:8 + >-< +1| int foo; + +[#2 Domain] = 1:4-1:12 + >--------< +1| int foo; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/dart/value/value.variable.scope b/data/fixtures/scopes/dart/value/value.variable.scope index 28cc6fc03f..f3c6a1415a 100644 --- a/data/fixtures/scopes/dart/value/value.variable.scope +++ b/data/fixtures/scopes/dart/value/value.variable.scope @@ -1,20 +1,22 @@ -var foo = 0; +void main() { + var foo = 0; +} --- -[Content] = 0:10-0:11 - >-< -0| var foo = 0; +[Content] = 1:14-1:15 + >-< +1| var foo = 0; -[Removal] = 0:7-0:11 - >----< -0| var foo = 0; +[Removal] = 1:11-1:15 + >----< +1| var foo = 0; -[Leading delimiter] = 0:7-0:10 - >---< -0| var foo = 0; +[Leading delimiter] = 1:11-1:14 + >---< +1| var foo = 0; -[Domain] = 0:0-0:12 - >------------< -0| var foo = 0; +[Domain] = 1:4-1:16 + >------------< +1| var foo = 0; [Insertion delimiter] = " " diff --git a/queries/dart.scm b/queries/dart.scm index ba4ca5dec2..067210c8d0 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -17,14 +17,19 @@ (type_alias) ] @statement +( + (local_variable_declaration) @statement + (#not-parent-type? @statement for_loop_parts) +) + ( (program) @class.iteration @statement.iteration @namedFunction.iteration (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) ) ( - (program) @name.iteration @value.iteration - (#document-range! @name.iteration @value.iteration) + (program) @name.iteration @value.iteration @type.iteration + (#document-range! @name.iteration @value.iteration @type.iteration) ) ;;!! { } @@ -36,48 +41,39 @@ . ) -;;!! var foo = 0; -;;! ^^^^^^^^^^^^ +;;!! int foo = 0; +;;! ^^^ ;;! ^^^ ;;! ^ -(_ - (inferred_type) @statement.start @_.domain.start @name.removal.start.startOf - . - (initialized_identifier_list - (initialized_identifier - (_) @name @value.leading.endOf - "=" - . - (_) @value.start @name.removal.end.startOf - (_)? @value.end - . - ) +(local_variable_declaration + (initialized_variable_definition + (type_identifier)? @type.start + (type_arguments)? @type.end + name: (_) @name @value.leading.endOf @name.removal.end.endOf + value: (_)? @value @name.removal.end.startOf @name.removal.end.startOf ) - . - ";" @statement.end @_.domain.end +) @_.domain @name.removal.start.startOf + +;;!! Map foo; +;;! ^^^^^^^^^ +(type_arguments + "<" @type.iteration.start.endOf + ">" @type.iteration.end.startOf ) -;;!! var foo; -;;! ^^^^^^^^ -;;! ^^^ -(_ - (inferred_type) @statement.start @name.removal.start @name.domain.start - . - (initialized_identifier_list - (initialized_identifier - . - (_) @name - . - ) - ) - . - ";" @statement.end @name.removal.end @name.domain.end +;;!! Map foo; +;;! ^^^ ^^^ +(type_arguments + (type_identifier) @type ) ;;!! var foo, bar; ;;! ^^^^^^^^ (_ - (inferred_type) @collectionItem.iteration.domain.start + [ + (inferred_type) + (type_identifier) + ] @collectionItem.iteration.domain.start . (initialized_identifier_list) @collectionItem.iteration . @@ -105,6 +101,8 @@ (_ (const_builtin) @statement.start @_.domain.start @name.removal.start.startOf . + (type_identifier)? @type + . (static_final_declaration_list (static_final_declaration (_) @name @value.leading.endOf @@ -175,6 +173,7 @@ ;;! ^^^^^^^^^^^^^^^ ;;! ^^^^ (try_statement + (type_identifier)? @type (catch_clause "catch" @branch.start @argumentList.domain.start @argumentOrParameter.iteration.domain.start (catch_parameters @@ -250,7 +249,7 @@ ;;! ^^^^^^^^^^^^ (class_definition name: (_) @name -) @class @name.domain +) @class @type @name.domain ;;!! class Foo { } ;;! ^ @@ -260,8 +259,8 @@ ) (class_body - "{" @name.iteration.start.endOf @value.iteration.start.endOf - "}" @name.iteration.end.startOf @value.iteration.end.startOf + "{" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) ;;!! var foo = 0; @@ -270,14 +269,14 @@ ;;! ^ (class_body (declaration - (inferred_type) @statement.start @name.removal.start.startOf @_.domain.start + (type_identifier)? @type (initialized_identifier_list (initialized_identifier (_) @name @value.leading.endOf (_) @value @name.removal.end.startOf ) ) - ) + ) @statement.start @name.removal.start.startOf @_.domain.start . ";" @statement.end @_.domain.end ) @@ -287,7 +286,7 @@ ;;! ^^^ (class_body (declaration - (inferred_type) @statement.start @name.removal.start @name.domain.start + (type_identifier)? @type (initialized_identifier_list (initialized_identifier . @@ -295,16 +294,16 @@ . ) ) - ) + ) @statement.start @name.removal.start @_.domain.start . - ";" @statement.end @name.removal.end @name.domain.end + ";" @statement.end @name.removal.end @_.domain.end ) ;;!! enum Foo {} ;;! ^^^ (enum_declaration name: (_) @name -) @name.domain +) @type @name.domain ;;!! enum Foo { } ;;! ^ @@ -330,6 +329,15 @@ (argument_part) ) @functionCall @functionCallee.domain +;;!! foo as int +;;! ^^^ +(type_cast_expression + (type_cast + (as_operator) + (_) @type + ) +) @type.domain + ;;!! "hello world" ;;! ^^^^^^^^^^^^^ ;;! ^^^^^^^^^^^ @@ -344,26 +352,32 @@ ;;!! void foo() {} ;;! ^^^^^^^^^^^^^ +;;! ^^^^ ;;! ^^^ (_ (function_signature + . + (_) @type name: (_) @name - ) @namedFunction.start @statement.start @name.domain.start + ) @namedFunction.start @statement.start @_.domain.start . - (function_body) @namedFunction.end @statement.end @name.domain.end + (function_body) @namedFunction.end @statement.end @_.domain.end ) ;;!! void foo() {} ;;! ^^^^^^^^^^^^^ +;;! ^^^^ ;;! ^^^ (_ (method_signature (_ + . + (_)? @type name: (_) @name ) - ) @namedFunction.start @statement.start @name.domain.start + ) @namedFunction.start @statement.start @_.domain.start . - (function_body) @namedFunction.end @statement.end @name.domain.end + (function_body) @namedFunction.end @statement.end @_.domain.end ) ;;!! void foo(aaa, bbb) {} @@ -415,8 +429,8 @@ ;;!! void foo(aaa, bbb) {} ;;! ^^^^^^^^ (formal_parameter_list - "(" @name.iteration.start.endOf @value.iteration.start.endOf - ")" @name.iteration.end.startOf @value.iteration.end.startOf + "(" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) ;;!! int aaa = 0 @@ -560,6 +574,7 @@ ;;! ^^^^^^ (for_statement (for_loop_parts + (type_identifier)? @type name: (_) @name value: (_) @value ) @@ -654,7 +669,7 @@ "typedef" @name.removal.start.startOf (_) @name @value.leading.endOf (_) @value @name.removal.end.startOf -) @_.domain +) @type @_.domain (relational_operator [ From 364a1e194d97644e606ff1fd8e788c739ecf57d7 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 18:33:13 +0100 Subject: [PATCH 18/20] block iteration --- .../name/name.argument.actual.iteration.scope | 11 ++++- ...ame.argument.formal.lambda.iteration.scope | 11 ++++- .../dart/name/name.iteration.block.scope | 27 +++++++++++ .../dart/name/name.iteration.block2.scope | 13 ++++++ .../dart/name/name.iteration.block3.scope | 45 +++++++++++++++++++ .../dart/name/name.iteration.block4.scope | 27 +++++++++++ .../statement/statement.iteration.block.scope | 27 +++++++++++ .../statement.iteration.block2.scope | 13 ++++++ .../statement.iteration.block3.scope | 45 +++++++++++++++++++ .../statement.iteration.block4.scope | 27 +++++++++++ ...ype.argument.formal.lambda.iteration.scope | 11 ++++- .../dart/type/type.iteration.block.scope | 27 +++++++++++ .../dart/type/type.iteration.block2.scope | 13 ++++++ .../dart/type/type.iteration.block3.scope | 45 +++++++++++++++++++ .../dart/type/type.iteration.block4.scope | 27 +++++++++++ .../type/type.typeArgument.iteration.scope | 11 ++++- .../value.argument.actual.iteration.scope | 11 ++++- .../dart/value/value.iteration.block.scope | 27 +++++++++++ .../dart/value/value.iteration.block2.scope | 13 ++++++ .../dart/value/value.iteration.block3.scope | 45 +++++++++++++++++++ .../dart/value/value.iteration.block4.scope | 27 +++++++++++ .../dart/value/value.mapPair.iteration.scope | 11 ++++- queries/dart.scm | 12 +++++ 23 files changed, 520 insertions(+), 6 deletions(-) create mode 100644 data/fixtures/scopes/dart/name/name.iteration.block.scope create mode 100644 data/fixtures/scopes/dart/name/name.iteration.block2.scope create mode 100644 data/fixtures/scopes/dart/name/name.iteration.block3.scope create mode 100644 data/fixtures/scopes/dart/name/name.iteration.block4.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.iteration.block.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.iteration.block2.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.iteration.block3.scope create mode 100644 data/fixtures/scopes/dart/statement/statement.iteration.block4.scope create mode 100644 data/fixtures/scopes/dart/type/type.iteration.block.scope create mode 100644 data/fixtures/scopes/dart/type/type.iteration.block2.scope create mode 100644 data/fixtures/scopes/dart/type/type.iteration.block3.scope create mode 100644 data/fixtures/scopes/dart/type/type.iteration.block4.scope create mode 100644 data/fixtures/scopes/dart/value/value.iteration.block.scope create mode 100644 data/fixtures/scopes/dart/value/value.iteration.block2.scope create mode 100644 data/fixtures/scopes/dart/value/value.iteration.block3.scope create mode 100644 data/fixtures/scopes/dart/value/value.iteration.block4.scope diff --git a/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope index 20f4fb136b..f43dbc7a00 100644 --- a/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope +++ b/data/fixtures/scopes/dart/name/name.argument.actual.iteration.scope @@ -13,6 +13,15 @@ void main() { [#2 Content] = -[#2 Domain] = 1:8-1:22 +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| foo(aaa: 0, bbb: 1); +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:8-1:22 >--------------< 1| foo(aaa: 0, bbb: 1); diff --git a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope index 8c34e88cb9..c7b891f5e7 100644 --- a/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope +++ b/data/fixtures/scopes/dart/name/name.argument.formal.lambda.iteration.scope @@ -13,6 +13,15 @@ void main() { [#2 Content] = -[#2 Domain] = 1:15-1:38 +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| var foo = (aaa, [int bbb, ccc = 0]) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:38 >-----------------------< 1| var foo = (aaa, [int bbb, ccc = 0]) {} diff --git a/data/fixtures/scopes/dart/name/name.iteration.block.scope b/data/fixtures/scopes/dart/name/name.iteration.block.scope new file mode 100644 index 0000000000..5768db5310 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + void bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| void bar() { } diff --git a/data/fixtures/scopes/dart/name/name.iteration.block2.scope b/data/fixtures/scopes/dart/name/name.iteration.block2.scope new file mode 100644 index 0000000000..ea20927c6d --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.block2.scope @@ -0,0 +1,13 @@ +void foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| void foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| void foo() { } diff --git a/data/fixtures/scopes/dart/name/name.iteration.block3.scope b/data/fixtures/scopes/dart/name/name.iteration.block3.scope new file mode 100644 index 0000000000..c1543e41aa --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.block3.scope @@ -0,0 +1,45 @@ +void main() { + if (true) { } + else if (false) { } + else { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-4:0 + > +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| if (true) { } + + +[#4 Content] = +[#4 Domain] = 2:21-2:22 + >-< +2| else if (false) { } + + +[#5 Content] = +[#5 Domain] = 3:10-3:11 + >-< +3| else { } diff --git a/data/fixtures/scopes/dart/name/name.iteration.block4.scope b/data/fixtures/scopes/dart/name/name.iteration.block4.scope new file mode 100644 index 0000000000..6dc77fd461 --- /dev/null +++ b/data/fixtures/scopes/dart/name/name.iteration.block4.scope @@ -0,0 +1,27 @@ +void main() { + while (true) { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| while (true) { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| while (true) { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:18-1:19 + >-< +1| while (true) { } diff --git a/data/fixtures/scopes/dart/statement/statement.iteration.block.scope b/data/fixtures/scopes/dart/statement/statement.iteration.block.scope new file mode 100644 index 0000000000..5768db5310 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + void bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| void bar() { } diff --git a/data/fixtures/scopes/dart/statement/statement.iteration.block2.scope b/data/fixtures/scopes/dart/statement/statement.iteration.block2.scope new file mode 100644 index 0000000000..ea20927c6d --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.iteration.block2.scope @@ -0,0 +1,13 @@ +void foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| void foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| void foo() { } diff --git a/data/fixtures/scopes/dart/statement/statement.iteration.block3.scope b/data/fixtures/scopes/dart/statement/statement.iteration.block3.scope new file mode 100644 index 0000000000..c1543e41aa --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.iteration.block3.scope @@ -0,0 +1,45 @@ +void main() { + if (true) { } + else if (false) { } + else { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-4:0 + > +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| if (true) { } + + +[#4 Content] = +[#4 Domain] = 2:21-2:22 + >-< +2| else if (false) { } + + +[#5 Content] = +[#5 Domain] = 3:10-3:11 + >-< +3| else { } diff --git a/data/fixtures/scopes/dart/statement/statement.iteration.block4.scope b/data/fixtures/scopes/dart/statement/statement.iteration.block4.scope new file mode 100644 index 0000000000..6dc77fd461 --- /dev/null +++ b/data/fixtures/scopes/dart/statement/statement.iteration.block4.scope @@ -0,0 +1,27 @@ +void main() { + while (true) { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| while (true) { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| while (true) { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:18-1:19 + >-< +1| while (true) { } diff --git a/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope index 85ac5db6a7..38e9e05e78 100644 --- a/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope +++ b/data/fixtures/scopes/dart/type/type.argument.formal.lambda.iteration.scope @@ -13,6 +13,15 @@ void main() { [#2 Content] = -[#2 Domain] = 1:15-1:37 +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| var foo = (int aaa, [int bbb = 0]) {}; +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:37 >----------------------< 1| var foo = (int aaa, [int bbb = 0]) {}; diff --git a/data/fixtures/scopes/dart/type/type.iteration.block.scope b/data/fixtures/scopes/dart/type/type.iteration.block.scope new file mode 100644 index 0000000000..5768db5310 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + void bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| void bar() { } diff --git a/data/fixtures/scopes/dart/type/type.iteration.block2.scope b/data/fixtures/scopes/dart/type/type.iteration.block2.scope new file mode 100644 index 0000000000..ea20927c6d --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.iteration.block2.scope @@ -0,0 +1,13 @@ +void foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| void foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| void foo() { } diff --git a/data/fixtures/scopes/dart/type/type.iteration.block3.scope b/data/fixtures/scopes/dart/type/type.iteration.block3.scope new file mode 100644 index 0000000000..c1543e41aa --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.iteration.block3.scope @@ -0,0 +1,45 @@ +void main() { + if (true) { } + else if (false) { } + else { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-4:0 + > +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| if (true) { } + + +[#4 Content] = +[#4 Domain] = 2:21-2:22 + >-< +2| else if (false) { } + + +[#5 Content] = +[#5 Domain] = 3:10-3:11 + >-< +3| else { } diff --git a/data/fixtures/scopes/dart/type/type.iteration.block4.scope b/data/fixtures/scopes/dart/type/type.iteration.block4.scope new file mode 100644 index 0000000000..6dc77fd461 --- /dev/null +++ b/data/fixtures/scopes/dart/type/type.iteration.block4.scope @@ -0,0 +1,27 @@ +void main() { + while (true) { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| while (true) { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| while (true) { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:18-1:19 + >-< +1| while (true) { } diff --git a/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope b/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope index 9bc4869a96..2c55c5158e 100644 --- a/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope +++ b/data/fixtures/scopes/dart/type/type.typeArgument.iteration.scope @@ -13,6 +13,15 @@ void main() { [#2 Content] = -[#2 Domain] = 1:8-1:16 +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| Map foo; +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:8-1:16 >--------< 1| Map foo; diff --git a/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope b/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope index 20f4fb136b..f43dbc7a00 100644 --- a/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope +++ b/data/fixtures/scopes/dart/value/value.argument.actual.iteration.scope @@ -13,6 +13,15 @@ void main() { [#2 Content] = -[#2 Domain] = 1:8-1:22 +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| foo(aaa: 0, bbb: 1); +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:8-1:22 >--------------< 1| foo(aaa: 0, bbb: 1); diff --git a/data/fixtures/scopes/dart/value/value.iteration.block.scope b/data/fixtures/scopes/dart/value/value.iteration.block.scope new file mode 100644 index 0000000000..5768db5310 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + void bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| void bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| void bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| void bar() { } diff --git a/data/fixtures/scopes/dart/value/value.iteration.block2.scope b/data/fixtures/scopes/dart/value/value.iteration.block2.scope new file mode 100644 index 0000000000..ea20927c6d --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.iteration.block2.scope @@ -0,0 +1,13 @@ +void foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| void foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| void foo() { } diff --git a/data/fixtures/scopes/dart/value/value.iteration.block3.scope b/data/fixtures/scopes/dart/value/value.iteration.block3.scope new file mode 100644 index 0000000000..c1543e41aa --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.iteration.block3.scope @@ -0,0 +1,45 @@ +void main() { + if (true) { } + else if (false) { } + else { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-4:1 + >------------- +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-4:0 + > +0| void main() { +1| if (true) { } +2| else if (false) { } +3| else { } +4| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| if (true) { } + + +[#4 Content] = +[#4 Domain] = 2:21-2:22 + >-< +2| else if (false) { } + + +[#5 Content] = +[#5 Domain] = 3:10-3:11 + >-< +3| else { } diff --git a/data/fixtures/scopes/dart/value/value.iteration.block4.scope b/data/fixtures/scopes/dart/value/value.iteration.block4.scope new file mode 100644 index 0000000000..6dc77fd461 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.iteration.block4.scope @@ -0,0 +1,27 @@ +void main() { + while (true) { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| while (true) { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| while (true) { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:18-1:19 + >-< +1| while (true) { } diff --git a/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope b/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope index f8b0d0dd1a..cee120a4a0 100644 --- a/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope +++ b/data/fixtures/scopes/dart/value/value.mapPair.iteration.scope @@ -13,6 +13,15 @@ void main() { [#2 Content] = -[#2 Domain] = 1:5-1:23 +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| {"aaa": 0, "bbb": 1}; +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:5-1:23 >------------------< 1| {"aaa": 0, "bbb": 1}; diff --git a/queries/dart.scm b/queries/dart.scm index 067210c8d0..be4cf0a597 100644 --- a/queries/dart.scm +++ b/queries/dart.scm @@ -41,6 +41,18 @@ . ) +;;!! { } +;;! ^ +(block + "{" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf +) + +(block + "{" @statement.iteration.start.endOf + "}" @statement.iteration.end.startOf +) + ;;!! int foo = 0; ;;! ^^^ ;;! ^^^ From cc53bac2435036b8793032543d70a4a258b250f8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 19:03:16 +0100 Subject: [PATCH 19/20] add missing --- ...lue.argument.formal.lambda.iteration.scope | 27 +++++++++ .../value/value.argument.formal.lambda.scope | 60 +++++++++++++++++++ .../common/src/scopeSupportFacets/dart.ts | 3 + 3 files changed, 90 insertions(+) create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/dart/value/value.argument.formal.lambda.scope diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/dart/value/value.argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..24d8dc3e22 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.lambda.iteration.scope @@ -0,0 +1,27 @@ +void main() { + var foo = ([aaa = 0, int bbb = 1]) {}; +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------- +0| void main() { +1| var foo = ([aaa = 0, int bbb = 1]) {}; +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:13-2:0 + > +0| void main() { +1| var foo = ([aaa = 0, int bbb = 1]) {}; +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:37 + >----------------------< +1| var foo = ([aaa = 0, int bbb = 1]) {}; diff --git a/data/fixtures/scopes/dart/value/value.argument.formal.lambda.scope b/data/fixtures/scopes/dart/value/value.argument.formal.lambda.scope new file mode 100644 index 0000000000..0e88de3681 --- /dev/null +++ b/data/fixtures/scopes/dart/value/value.argument.formal.lambda.scope @@ -0,0 +1,60 @@ +void main() { + var foo = ([aaa = 0, int bbb = 1]) {}; +} +--- + +[#1 Content] = 1:14-1:41 + >---------------------------< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#1 Removal] = 1:11-1:41 + >------------------------------< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#1 Leading delimiter] = 1:11-1:14 + >---< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#1 Domain] = 1:4-1:42 + >--------------------------------------< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:22-1:23 + >-< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#2 Removal] = 1:19-1:23 + >----< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#2 Leading delimiter] = 1:19-1:22 + >---< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#2 Domain] = 1:16-1:23 + >-------< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:35-1:36 + >-< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#3 Removal] = 1:32-1:36 + >----< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#3 Leading delimiter] = 1:32-1:35 + >---< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#3 Domain] = 1:25-1:36 + >-----------< +1| var foo = ([aaa = 0, int bbb = 1]) {}; + +[#3 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/dart.ts b/packages/common/src/scopeSupportFacets/dart.ts index fc2e291744..4d7179e1f3 100644 --- a/packages/common/src/scopeSupportFacets/dart.ts +++ b/packages/common/src/scopeSupportFacets/dart.ts @@ -179,6 +179,8 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { "value.argument.actual.iteration": supported, "value.argument.formal": supported, "value.argument.formal.iteration": supported, + "value.argument.formal.lambda": supported, + "value.argument.formal.lambda.iteration": supported, "value.argument.formal.constructor": supported, "value.argument.formal.constructor.iteration": supported, "value.argument.formal.method": supported, @@ -315,6 +317,7 @@ export const dartScopeSupport: LanguageScopeSupportFacetMap = { // Miscellaneous "statement.misc": notApplicable, + "class.iteration.class": notApplicable, regularExpression: notApplicable, environment: notApplicable, selector: notApplicable, From 1de47beb9619f1dfcc011e19628f8196d37a0282 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Fri, 27 Feb 2026 19:04:41 +0100 Subject: [PATCH 20/20] restore c++ test --- data/fixtures/scopes/cpp/value/value.field.class.scope | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/data/fixtures/scopes/cpp/value/value.field.class.scope b/data/fixtures/scopes/cpp/value/value.field.class.scope index 9e2a894d39..b012818782 100644 --- a/data/fixtures/scopes/cpp/value/value.field.class.scope +++ b/data/fixtures/scopes/cpp/value/value.field.class.scope @@ -1,22 +1,22 @@ class Foo { - int bar = 0; + int bar = 1; } --- [Content] = 1:14-1:15 >-< -1| int bar = 0; +1| int bar = 1; [Removal] = 1:11-1:15 >----< -1| int bar = 0; +1| int bar = 1; [Leading delimiter] = 1:11-1:14 >---< -1| int bar = 0; +1| int bar = 1; [Domain] = 1:4-1:16 >------------< -1| int bar = 0; +1| int bar = 1; [Insertion delimiter] = " "