From 13b5180d6e19f9ac8fba74b3b1b2baa0c4f3368a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 11:12:41 +0100 Subject: [PATCH 01/31] working on kotlin facets --- .../kotlin/class.iteration.document.scope | 12 + data/fixtures/scopes/kotlin/class.scope | 10 + data/fixtures/scopes/kotlin/class2.scope | 13 + .../scopes/kotlin/comment.block.scope | 10 + .../scopes/kotlin/comment.block2.scope | 10 + .../fixtures/scopes/kotlin/comment.line.scope | 10 + data/fixtures/scopes/kotlin/ifStatement.scope | 15 + .../namedFunction.iteration.class.scope | 13 + .../namedFunction.iteration.document.scope | 12 + .../kotlin/statement/statement.if.scope | 15 + .../statement.iteration.document.scope | 12 + .../scopes/kotlin/string.multiLine.scope | 13 + .../scopes/kotlin/string.singleLine.scope | 10 + .../kotlin/textFragment.comment.block.scope | 10 + .../kotlin/textFragment.comment.block2.scope | 10 + .../kotlin/textFragment.comment.line.scope | 10 + .../textFragment.string.multiLine.scope | 13 + .../textFragment.string.singleLine.scope | 10 + .../kotlin/type/type.iteration.document.scope | 12 + .../value/value.iteration.document.scope | 12 + .../common/src/scopeSupportFacets/kotlin.ts | 301 +++++++++++++++++- queries/kotlin.scm | 94 ++++-- 22 files changed, 599 insertions(+), 28 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/class.iteration.document.scope create mode 100644 data/fixtures/scopes/kotlin/class.scope create mode 100644 data/fixtures/scopes/kotlin/class2.scope create mode 100644 data/fixtures/scopes/kotlin/comment.block.scope create mode 100644 data/fixtures/scopes/kotlin/comment.block2.scope create mode 100644 data/fixtures/scopes/kotlin/comment.line.scope create mode 100644 data/fixtures/scopes/kotlin/ifStatement.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction.iteration.class.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction.iteration.document.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.if.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.document.scope create mode 100644 data/fixtures/scopes/kotlin/string.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/string.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/textFragment.comment.block.scope create mode 100644 data/fixtures/scopes/kotlin/textFragment.comment.block2.scope create mode 100644 data/fixtures/scopes/kotlin/textFragment.comment.line.scope create mode 100644 data/fixtures/scopes/kotlin/textFragment.string.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/textFragment.string.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.document.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.iteration.document.scope diff --git a/data/fixtures/scopes/kotlin/class.iteration.document.scope b/data/fixtures/scopes/kotlin/class.iteration.document.scope new file mode 100644 index 0000000000..813bb62ea9 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/class.scope b/data/fixtures/scopes/kotlin/class.scope new file mode 100644 index 0000000000..ffbda12f63 --- /dev/null +++ b/data/fixtures/scopes/kotlin/class.scope @@ -0,0 +1,10 @@ +class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/class2.scope b/data/fixtures/scopes/kotlin/class2.scope new file mode 100644 index 0000000000..b73b26f0f0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/class2.scope @@ -0,0 +1,13 @@ +@bar +class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:12 + >---- +0| @bar +1| class Foo {} + ------------< + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/comment.block.scope b/data/fixtures/scopes/kotlin/comment.block.scope new file mode 100644 index 0000000000..5e8b51111c --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/comment.block2.scope b/data/fixtures/scopes/kotlin/comment.block2.scope new file mode 100644 index 0000000000..b5d8404237 --- /dev/null +++ b/data/fixtures/scopes/kotlin/comment.block2.scope @@ -0,0 +1,10 @@ +/** Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| /** Hello world */ + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/comment.line.scope b/data/fixtures/scopes/kotlin/comment.line.scope new file mode 100644 index 0000000000..7d1477b8a1 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/ifStatement.scope b/data/fixtures/scopes/kotlin/ifStatement.scope new file mode 100644 index 0000000000..14f2507621 --- /dev/null +++ b/data/fixtures/scopes/kotlin/ifStatement.scope @@ -0,0 +1,15 @@ +if (true) {} +else if (false) {} +else {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction.iteration.class.scope b/data/fixtures/scopes/kotlin/namedFunction.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/namedFunction.iteration.document.scope b/data/fixtures/scopes/kotlin/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..dd50539657 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +fun foo() {} + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| fun foo() {} +2| + < diff --git a/data/fixtures/scopes/kotlin/statement/statement.if.scope b/data/fixtures/scopes/kotlin/statement/statement.if.scope new file mode 100644 index 0000000000..14f2507621 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.if.scope @@ -0,0 +1,15 @@ +if (true) {} +else if (false) {} +else {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.iteration.document.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.document.scope new file mode 100644 index 0000000000..d737b02c9a --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo +2| + < diff --git a/data/fixtures/scopes/kotlin/string.multiLine.scope b/data/fixtures/scopes/kotlin/string.multiLine.scope new file mode 100644 index 0000000000..80dbca0966 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/string.singleLine.scope b/data/fixtures/scopes/kotlin/string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/textFragment.comment.block.scope b/data/fixtures/scopes/kotlin/textFragment.comment.block.scope new file mode 100644 index 0000000000..af33f95d00 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/textFragment.comment.block2.scope b/data/fixtures/scopes/kotlin/textFragment.comment.block2.scope new file mode 100644 index 0000000000..396e9267dc --- /dev/null +++ b/data/fixtures/scopes/kotlin/textFragment.comment.block2.scope @@ -0,0 +1,10 @@ +/** Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| /** Hello world */ + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/textFragment.comment.line.scope b/data/fixtures/scopes/kotlin/textFragment.comment.line.scope new file mode 100644 index 0000000000..6758f81490 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/textFragment.string.multiLine.scope b/data/fixtures/scopes/kotlin/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..32632a1b32 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/textFragment.string.singleLine.scope b/data/fixtures/scopes/kotlin/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..85dcf5fa7f --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/data/fixtures/scopes/kotlin/type/type.iteration.document.scope b/data/fixtures/scopes/kotlin/type/type.iteration.document.scope new file mode 100644 index 0000000000..d737b02c9a --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo +2| + < diff --git a/data/fixtures/scopes/kotlin/value/value.iteration.document.scope b/data/fixtures/scopes/kotlin/value/value.iteration.document.scope new file mode 100644 index 0000000000..d737b02c9a --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo +2| + < diff --git a/packages/common/src/scopeSupportFacets/kotlin.ts b/packages/common/src/scopeSupportFacets/kotlin.ts index a7c1e43b7e..6e06a8112c 100644 --- a/packages/common/src/scopeSupportFacets/kotlin.ts +++ b/packages/common/src/scopeSupportFacets/kotlin.ts @@ -1,12 +1,309 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { unsupported } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { - /* UNSUPPORTED */ + disqualifyDelimiter: supported, + anonymousFunction: supported, + list: supported, + map: 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.method.empty": supported, + "argumentList.actual.method.singleLine": supported, + "argumentList.actual.method.multiLine": supported, + "argumentList.actual.constructor.empty": supported, + "argumentList.actual.constructor.singleLine": supported, + "argumentList.actual.constructor.multiLine": supported, + "argumentList.formal.empty": supported, + "argumentList.formal.singleLine": supported, + "argumentList.formal.multiLine": supported, + "argumentList.formal.lambda.empty": supported, + "argumentList.formal.lambda.singleLine": supported, + "argumentList.formal.lambda.multiLine": supported, + "argumentList.formal.method.empty": supported, + "argumentList.formal.method.singleLine": supported, + "argumentList.formal.method.multiLine": supported, + "argumentList.formal.constructor.empty": supported, + "argumentList.formal.constructor.singleLine": supported, + "argumentList.formal.constructor.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, + + class: supported, + "class.iteration.block": supported, + "class.iteration.document": supported, + + "comment.block": supported, + "comment.line": supported, + + "condition.doWhile": supported, + "condition.if": supported, + "condition.switchCase": supported, + "condition.switchCase.iteration": supported, + "condition.while": supported, + + functionCall: supported, + "functionCall.constructor": supported, + "functionCall.method": supported, + "functionCall.chain": supported, + functionCallee: supported, + "functionCallee.constructor": supported, + "functionCallee.method": supported, + "functionCallee.chain": supported, + + namedFunction: supported, + "namedFunction.constructor": supported, + "namedFunction.method": supported, + "namedFunction.iteration.document": supported, + "namedFunction.iteration.class": supported, + + ifStatement: supported, + + "statement.class": supported, + "statement.interface": supported, + "statement.enum": supported, + "statement.field.class": supported, + "statement.field.interface": supported, + "statement.function": supported, + "statement.constructor": supported, + "statement.method": supported, + "statement.if": supported, + "statement.try": supported, + "statement.switch": supported, + "statement.foreach": supported, + "statement.while": supported, + "statement.doWhile": supported, + "statement.variable": supported, + "statement.assignment": supported, + "statement.return": supported, + "statement.break": supported, + "statement.continue": supported, + "statement.misc": supported, + "statement.iteration.document": supported, + "statement.iteration.class": supported, + "statement.iteration.interface": 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.formal": supported, + "name.argument.formal.iteration": supported, + "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, + "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, + "name.argument.catch": supported, + "name.argument.actual": supported, + "name.argument.actual.iteration": supported, + "name.assignment": supported, + "name.class": supported, + "name.interface": supported, + "name.enum": supported, + "name.constructor": supported, + "name.field.class": supported, + "name.field.interface": supported, + "name.foreach": supported, + "name.function": supported, + "name.method": supported, + "name.variable": supported, + "name.variable.pattern": supported, + "name.iteration.document": supported, + "name.iteration.class": supported, + "name.iteration.interface": 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.foreach": supported, + "value.switch": supported, + "value.field.class": supported, + "value.return": supported, + "value.return.lambda": supported, + "value.variable": supported, + "value.variable.pattern": supported, + "value.typeAlias": supported, + "value.iteration.block": supported, + "value.iteration.class": supported, + "value.iteration.document": supported, + + "type.argument.formal": supported, + "type.argument.formal.iteration": supported, + "type.argument.formal.method": supported, + "type.argument.formal.method.iteration": supported, + "type.argument.formal.constructor": supported, + "type.argument.formal.constructor.iteration": supported, + "type.argument.catch": supported, + "type.foreach": supported, + "type.field.class": supported, + "type.field.interface": supported, + "type.return": supported, + "type.variable": supported, + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, + "type.cast": supported, + "type.class": supported, + "type.enum": supported, + "type.interface": supported, + "type.alias": supported, + "type.iteration.block": supported, + "type.iteration.class": supported, + "type.iteration.interface": supported, + "type.iteration.document": supported, + + "interior.class": supported, + "interior.interface": supported, + "interior.enum": supported, + "interior.function": supported, + "interior.constructor": supported, + "interior.method": supported, + "interior.if": supported, + "interior.lambda": supported, + "interior.foreach": supported, + "interior.while": supported, + "interior.doWhile": supported, + "interior.switch": supported, + "interior.switchCase": supported, + "interior.try": supported, + + /* UNSUPPORTED */ fieldAccess: unsupported, /* NOT APPLICABLE */ + + // Element and tags + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Resource + "statement.resource": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, + "value.resource": notApplicable, + "value.resource.iteration": notApplicable, + "type.resource": notApplicable, + "type.resource.iteration": notApplicable, + "interior.resource": notApplicable, + + // Namespace + "statement.namespace": notApplicable, + "name.namespace": notApplicable, + "interior.namespace": notApplicable, + + // Branch loop + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + + // Ternary + "branch.ternary": notApplicable, + "branch.ternary.iteration": notApplicable, + "condition.ternary": notApplicable, + + // For loop (C-style) + "statement.for": notApplicable, + "condition.for": notApplicable, + "interior.for": notApplicable, + + // Yield + "statement.yield": notApplicable, + "value.yield": notApplicable, + + // Static + "statement.static": notApplicable, + "interior.static": notApplicable, + + // Keyword argument assignment pattern + "name.assignment.pattern": notApplicable, + + // Values in enum + "name.field.enum": notApplicable, + "value.field.enum": notApplicable, + "value.iteration.enum": notApplicable, + + // Miscellaneous + environment: notApplicable, + regularExpression: notApplicable, + selector: notApplicable, + unit: notApplicable, + pairDelimiter: notApplicable, }; diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 0b3b71be81..502f0d8164 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -4,49 +4,86 @@ ;; Define @statement based on parent node, because a statement can be an arbitrary expression (with ;; no expression_statement parent node) and we don't want every nested expression to be a statement. -(source_file - (_) @statement - (#not-type? @statement import_list) -) +;; (source_file +;; (_) @statement +;; (#not-type? @statement import_list) +;; ) -(import_header) @statement +;; (import_header) @statement -(statements - (_) @statement -) +;; (statements +;; (_) @statement +;; ) -(control_structure_body - (_) @statement - (#not-type? @statement statements) -) +;; (control_structure_body +;; (_) @statement +;; (#not-type? @statement statements) +;; ) + +;; (class_body +;; (_) @statement +;; ) + +;; (enum_class_body +;; (_) @statement +;; ) + +[ + (class_declaration) + + ;; Disabled on purpose. We have a better definition of this below. + ;; (if_expression) +] @statement + +[ + (class_declaration) +] @type -(class_body - (_) @statement +;; Entire document, including leading and trailing whitespace +( + (source_file) @class.iteration @statement.iteration @namedFunction.iteration + (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) +) +( + (source_file) @name.iteration @value.iteration @type.iteration + (#document-range! @name.iteration @value.iteration @type.iteration) ) -(enum_class_body - (_) @statement +;;!! { } +;;! ^ +(_ + "{" @statement.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statement.iteration.end.startOf @namedFunction.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 ) +;;!! class Foo {} (class_declaration (type_identifier) @name -) @class @_.domain +) @class @name.domain -(object_declaration - (type_identifier) @name -) @class @_.domain +;; (object_declaration +;; (type_identifier) @name +;; ) @class @name.domain -(companion_object - (type_identifier) @name -) @class @_.domain +;; (companion_object +;; (type_identifier) @name +;; ) @class @name.domain (function_declaration (simple_identifier) @name -) @namedFunction @_.domain +) @namedFunction @name.domain (secondary_constructor) @namedFunction -(if_expression) @ifStatement +;; Top level if statement +( + (if_expression) @ifStatement @statement + (#not-parent-type? @ifStatement control_structure_body) +) ;; ;; Literals and comments @@ -56,10 +93,15 @@ (lambda_literal) @anonymousFunction -(string_literal) @string @textFragment +;;!! "Hello world" +(string_literal + (string_content) @textFragment +) @string [ + ;;!! // Hello world (line_comment) + ;;!! /* Hello world */ (multiline_comment) ] @comment @textFragment From 4b00b5c3b26a29c42896da8bce64a66ea26a1167 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 11:22:50 +0100 Subject: [PATCH 02/31] named function --- .../namedFunction.constructor.scope | 21 ++++++++++++++++ .../namedFunction.constructor2.scope | 25 +++++++++++++++++++ .../namedFunction.constructor3.scope | 21 ++++++++++++++++ .../namedFunction.iteration.class.scope | 0 .../namedFunction.iteration.document.scope | 0 .../namedFunction/namedFunction.method.scope | 21 ++++++++++++++++ .../namedFunction/namedFunction.method2.scope | 25 +++++++++++++++++++ .../kotlin/namedFunction/namedFunction.scope | 10 ++++++++ .../kotlin/namedFunction/namedFunction2.scope | 13 ++++++++++ queries/kotlin.scm | 5 ++++ 10 files changed, 141 insertions(+) create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor2.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope rename data/fixtures/scopes/kotlin/{ => namedFunction}/namedFunction.iteration.class.scope (100%) rename data/fixtures/scopes/kotlin/{ => namedFunction}/namedFunction.iteration.document.scope (100%) create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.method.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.method2.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction2.scope diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor.scope new file mode 100644 index 0000000000..aa1ece2eea --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor.scope @@ -0,0 +1,21 @@ +class Foo { + constructor() {} +} +--- + +[Content] = +[Domain] = 1:4-1:20 + >----------------< +1| constructor() {} + +[Removal] = 1:0-2:0 + >-------------------- +1| constructor() {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| constructor() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor2.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor2.scope new file mode 100644 index 0000000000..765c2daea9 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor2.scope @@ -0,0 +1,25 @@ +class Foo { + @bar + constructor() {} +} +--- + +[Content] = +[Domain] = 1:4-2:20 + >---- +1| @bar +2| constructor() {} + --------------------< + +[Removal] = 1:0-3:0 + >-------- +1| @bar +2| constructor() {} +3| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| @bar + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope new file mode 100644 index 0000000000..df34d389bf --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope @@ -0,0 +1,21 @@ +class Foo { + init {} +} +--- + +[Content] = +[Domain] = 1:4-1:11 + >-------< +1| init {} + +[Removal] = 1:0-2:0 + >----------- +1| init {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| init {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction.iteration.class.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.iteration.class.scope similarity index 100% rename from data/fixtures/scopes/kotlin/namedFunction.iteration.class.scope rename to data/fixtures/scopes/kotlin/namedFunction/namedFunction.iteration.class.scope diff --git a/data/fixtures/scopes/kotlin/namedFunction.iteration.document.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.iteration.document.scope similarity index 100% rename from data/fixtures/scopes/kotlin/namedFunction.iteration.document.scope rename to data/fixtures/scopes/kotlin/namedFunction/namedFunction.iteration.document.scope diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method.scope new file mode 100644 index 0000000000..8b9e4f9ee7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method.scope @@ -0,0 +1,21 @@ +class Foo { + fun bar() {} +} +--- + +[Content] = +[Domain] = 1:4-1:16 + >------------< +1| fun bar() {} + +[Removal] = 1:0-2:0 + >---------------- +1| fun bar() {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| fun bar() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method2.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method2.scope new file mode 100644 index 0000000000..bf3dc71914 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method2.scope @@ -0,0 +1,25 @@ +class Foo { + @baz + fun bar() {} +} +--- + +[Content] = +[Domain] = 1:4-2:16 + >---- +1| @baz +2| fun bar() {} + ----------------< + +[Removal] = 1:0-3:0 + >-------- +1| @baz +2| fun bar() {} +3| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| @baz + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.scope new file mode 100644 index 0000000000..9f94e3d20b --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.scope @@ -0,0 +1,10 @@ +fun bar() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| fun bar() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction2.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction2.scope new file mode 100644 index 0000000000..7dfff22a50 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction2.scope @@ -0,0 +1,13 @@ +@baz +fun bar() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:12 + >---- +0| @baz +1| fun bar() {} + ------------< + +[Insertion delimiter] = "\n\n" diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 502f0d8164..48585ff51f 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -73,12 +73,17 @@ ;; (type_identifier) @name ;; ) @class @name.domain +;;!! fun foo() {} (function_declaration (simple_identifier) @name ) @namedFunction @name.domain +;;!! constructor() {} (secondary_constructor) @namedFunction +;;!! init {} +(anonymous_initializer) @namedFunction + ;; Top level if statement ( (if_expression) @ifStatement @statement From 8baf4962abd9ce824a917a7123483d05ba2bec3d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 12:01:14 +0100 Subject: [PATCH 03/31] statements --- .../scopes/kotlin/anonymousFunction.scope | 10 +++ .../scopes/kotlin/anonymousFunction2.scope | 10 +++ .../kotlin/name/name.iteration.class.scope | 13 ++++ .../kotlin/name/name.iteration.document.scope | 12 +++ .../kotlin/name/name.iteration.enum.scope | 13 ++++ .../name/name.iteration.interface.scope | 13 ++++ .../namedFunction.constructor3.scope | 21 ------ .../statement/statement.assignment.scope | 10 +++ .../kotlin/statement/statement.break.scope | 33 +++++++++ .../kotlin/statement/statement.class.scope | 10 +++ .../kotlin/statement/statement.class2.scope | 13 ++++ .../statement/statement.constructor.scope | 33 +++++++++ .../statement/statement.constructor2.scope | 38 ++++++++++ .../kotlin/statement/statement.continue.scope | 33 +++++++++ .../kotlin/statement/statement.doWhile.scope | 10 +++ .../kotlin/statement/statement.enum.scope | 10 +++ .../statement/statement.field.class.scope | 73 +++++++++++++++++++ .../statement/statement.field.interface.scope | 33 +++++++++ .../kotlin/statement/statement.for.scope | 10 +++ .../kotlin/statement/statement.foreach.scope | 10 +++ .../kotlin/statement/statement.function.scope | 10 +++ .../statement/statement.interface.scope | 10 +++ .../statement/statement.iteration.class.scope | 13 ++++ .../statement.iteration.interface.scope | 13 ++++ .../kotlin/statement/statement.method.scope | 33 +++++++++ .../kotlin/statement/statement.method2.scope | 38 ++++++++++ .../kotlin/statement/statement.return.scope | 33 +++++++++ .../kotlin/statement/statement.static.scope | 33 +++++++++ .../kotlin/statement/statement.switch.scope | 10 +++ .../kotlin/statement/statement.try.scope | 17 +++++ .../kotlin/statement/statement.variable.scope | 10 +++ .../kotlin/statement/statement.while.scope | 10 +++ .../scopes/kotlin/type/type.class.scope | 10 +++ .../scopes/kotlin/type/type.enum.scope | 10 +++ .../scopes/kotlin/type/type.interface.scope | 10 +++ queries/kotlin.scm | 33 ++++++--- 36 files changed, 669 insertions(+), 32 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/anonymousFunction.scope create mode 100644 data/fixtures/scopes/kotlin/anonymousFunction2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.class.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.document.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.enum.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.interface.scope delete mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.assignment.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.break.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.class.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.class2.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.constructor2.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.continue.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.doWhile.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.enum.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.field.class.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.field.interface.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.for.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.foreach.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.function.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.interface.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.class.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.interface.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.method.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.method2.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.return.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.static.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.switch.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.try.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.variable.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.while.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.class.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.enum.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.interface.scope diff --git a/data/fixtures/scopes/kotlin/anonymousFunction.scope b/data/fixtures/scopes/kotlin/anonymousFunction.scope new file mode 100644 index 0000000000..5ebd5f1eec --- /dev/null +++ b/data/fixtures/scopes/kotlin/anonymousFunction.scope @@ -0,0 +1,10 @@ +fun() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| fun() {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/anonymousFunction2.scope b/data/fixtures/scopes/kotlin/anonymousFunction2.scope new file mode 100644 index 0000000000..0665d08d1a --- /dev/null +++ b/data/fixtures/scopes/kotlin/anonymousFunction2.scope @@ -0,0 +1,10 @@ +{x -> 0} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| {x -> 0} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.class.scope b/data/fixtures/scopes/kotlin/name/name.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/name/name.iteration.document.scope b/data/fixtures/scopes/kotlin/name/name.iteration.document.scope new file mode 100644 index 0000000000..d737b02c9a --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo +2| + < diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.enum.scope b/data/fixtures/scopes/kotlin/name/name.iteration.enum.scope new file mode 100644 index 0000000000..e94d52284e --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.enum.scope @@ -0,0 +1,13 @@ +enum class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:18 + >------------------< +0| enum class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:16-0:17 + >-< +0| enum class Foo { } diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.interface.scope b/data/fixtures/scopes/kotlin/name/name.iteration.interface.scope new file mode 100644 index 0000000000..4140b6c622 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.interface.scope @@ -0,0 +1,13 @@ +interface Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| interface Foo { } + + +[#2 Content] = +[#2 Domain] = 0:15-0:16 + >-< +0| interface Foo { } diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope deleted file mode 100644 index df34d389bf..0000000000 --- a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.constructor3.scope +++ /dev/null @@ -1,21 +0,0 @@ -class Foo { - init {} -} ---- - -[Content] = -[Domain] = 1:4-1:11 - >-------< -1| init {} - -[Removal] = 1:0-2:0 - >----------- -1| init {} -2| } - < - -[Leading delimiter] = 1:0-1:4 - >----< -1| init {} - -[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.assignment.scope b/data/fixtures/scopes/kotlin/statement/statement.assignment.scope new file mode 100644 index 0000000000..acdb2b1498 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.assignment.scope @@ -0,0 +1,10 @@ +foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:7 + >-------< +0| foo = 0 + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.break.scope b/data/fixtures/scopes/kotlin/statement/statement.break.scope new file mode 100644 index 0000000000..22c1cfd287 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.break.scope @@ -0,0 +1,33 @@ +while (true) { + break +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >-------------- +0| while (true) { +1| break +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:9 + >-----< +1| break + +[#2 Removal] = 1:0-2:0 + >--------- +1| break +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| break + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.class.scope b/data/fixtures/scopes/kotlin/statement/statement.class.scope new file mode 100644 index 0000000000..a6008d311f --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/statement/statement.class2.scope b/data/fixtures/scopes/kotlin/statement/statement.class2.scope new file mode 100644 index 0000000000..2676bb1634 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.class2.scope @@ -0,0 +1,13 @@ +@bar +class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:12 + >---- +0| @bar +1| class Foo {} + ------------< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.constructor.scope b/data/fixtures/scopes/kotlin/statement/statement.constructor.scope new file mode 100644 index 0000000000..15212a3a3e --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.constructor.scope @@ -0,0 +1,33 @@ +class Foo { + constructor() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| constructor() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:20 + >----------------< +1| constructor() {} + +[#2 Removal] = 1:0-2:0 + >-------------------- +1| constructor() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| constructor() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.constructor2.scope b/data/fixtures/scopes/kotlin/statement/statement.constructor2.scope new file mode 100644 index 0000000000..e6e1ac1444 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.constructor2.scope @@ -0,0 +1,38 @@ +class Foo { + @bar + constructor() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| @bar +2| constructor() {} +3| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-2:20 + >---- +1| @bar +2| constructor() {} + --------------------< + +[#2 Removal] = 1:0-3:0 + >-------- +1| @bar +2| constructor() {} +3| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| @bar + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.continue.scope b/data/fixtures/scopes/kotlin/statement/statement.continue.scope new file mode 100644 index 0000000000..61621d39db --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.continue.scope @@ -0,0 +1,33 @@ +while (true) { + continue +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >-------------- +0| while (true) { +1| continue +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| continue + +[#2 Removal] = 1:0-2:0 + >------------ +1| continue +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| continue + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.doWhile.scope b/data/fixtures/scopes/kotlin/statement/statement.doWhile.scope new file mode 100644 index 0000000000..74d5b94183 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.doWhile.scope @@ -0,0 +1,10 @@ +do {} while (true) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| do {} while (true) + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.enum.scope b/data/fixtures/scopes/kotlin/statement/statement.enum.scope new file mode 100644 index 0000000000..f07ca5fc76 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.enum.scope @@ -0,0 +1,10 @@ +enum class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| enum class Foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.field.class.scope b/data/fixtures/scopes/kotlin/statement/statement.field.class.scope new file mode 100644 index 0000000000..f39490a583 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.field.class.scope @@ -0,0 +1,73 @@ +class Foo { + var bar: Int = 0 + val baz = 0 + val bongo +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >----------- +0| class Foo { +1| var bar: Int = 0 +2| val baz = 0 +3| val bongo +4| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:20 + >----------------< +1| var bar: Int = 0 + +[#2 Removal] = 1:0-2:0 + >-------------------- +1| var bar: Int = 0 +2| val baz = 0 + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| var bar: Int = 0 + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:4-2:15 + >-----------< +2| val baz = 0 + +[#3 Removal] = 2:0-3:0 + >--------------- +2| val baz = 0 +3| val bongo + < + +[#3 Leading delimiter] = 2:0-2:4 + >----< +2| val baz = 0 + +[#3 Insertion delimiter] = "\n" + + +[#4 Content] = +[#4 Domain] = 3:4-3:13 + >---------< +3| val bongo + +[#4 Removal] = 3:0-4:0 + >------------- +3| val bongo +4| } + < + +[#4 Leading delimiter] = 3:0-3:4 + >----< +3| val bongo + +[#4 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.field.interface.scope b/data/fixtures/scopes/kotlin/statement/statement.field.interface.scope new file mode 100644 index 0000000000..e0d9c16e35 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.field.interface.scope @@ -0,0 +1,33 @@ +interface Foo { + val bar: Int +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| interface Foo { +1| val bar: Int +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:16 + >------------< +1| val bar: Int + +[#2 Removal] = 1:0-2:0 + >---------------- +1| val bar: Int +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| val bar: Int + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.for.scope b/data/fixtures/scopes/kotlin/statement/statement.for.scope new file mode 100644 index 0000000000..1fd1c04a17 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.for.scope @@ -0,0 +1,10 @@ +for (i in 0 until size) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:26 + >--------------------------< +0| for (i in 0 until size) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.foreach.scope b/data/fixtures/scopes/kotlin/statement/statement.foreach.scope new file mode 100644 index 0000000000..8b146d89ba --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.foreach.scope @@ -0,0 +1,10 @@ +for (v in values) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:20 + >--------------------< +0| for (v in values) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.function.scope b/data/fixtures/scopes/kotlin/statement/statement.function.scope new file mode 100644 index 0000000000..2026908f66 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.function.scope @@ -0,0 +1,10 @@ +fun foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| fun foo() {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.interface.scope b/data/fixtures/scopes/kotlin/statement/statement.interface.scope new file mode 100644 index 0000000000..f114e8b3c6 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.interface.scope @@ -0,0 +1,10 @@ +interface Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:16 + >----------------< +0| interface Foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.iteration.class.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/statement/statement.iteration.interface.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.interface.scope new file mode 100644 index 0000000000..4140b6c622 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.iteration.interface.scope @@ -0,0 +1,13 @@ +interface Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| interface Foo { } + + +[#2 Content] = +[#2 Domain] = 0:15-0:16 + >-< +0| interface Foo { } diff --git a/data/fixtures/scopes/kotlin/statement/statement.method.scope b/data/fixtures/scopes/kotlin/statement/statement.method.scope new file mode 100644 index 0000000000..93f5951e2d --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.method.scope @@ -0,0 +1,33 @@ +class Foo { + fun bar() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:16 + >------------< +1| fun bar() {} + +[#2 Removal] = 1:0-2:0 + >---------------- +1| fun bar() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| fun bar() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.method2.scope b/data/fixtures/scopes/kotlin/statement/statement.method2.scope new file mode 100644 index 0000000000..d065bdf278 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.method2.scope @@ -0,0 +1,38 @@ +class Foo { + @baz + fun bar() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| @baz +2| fun bar() {} +3| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-2:16 + >---- +1| @baz +2| fun bar() {} + ----------------< + +[#2 Removal] = 1:0-3:0 + >-------- +1| @baz +2| fun bar() {} +3| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| @baz + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.return.scope b/data/fixtures/scopes/kotlin/statement/statement.return.scope new file mode 100644 index 0000000000..1acf5073fd --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.return.scope @@ -0,0 +1,33 @@ +fun bar() { + return 0 +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| fun bar() { +1| return 0 +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| return 0 + +[#2 Removal] = 1:0-2:0 + >------------ +1| return 0 +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| return 0 + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.static.scope b/data/fixtures/scopes/kotlin/statement/statement.static.scope new file mode 100644 index 0000000000..aa72d276ba --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.static.scope @@ -0,0 +1,33 @@ +class Foo { + init {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| init {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:11 + >-------< +1| init {} + +[#2 Removal] = 1:0-2:0 + >----------- +1| init {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| init {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.switch.scope b/data/fixtures/scopes/kotlin/statement/statement.switch.scope new file mode 100644 index 0000000000..1a66ac2f04 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.switch.scope @@ -0,0 +1,10 @@ +when (foo) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| when (foo) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.try.scope b/data/fixtures/scopes/kotlin/statement/statement.try.scope new file mode 100644 index 0000000000..b304252c85 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.try.scope @@ -0,0 +1,17 @@ +try { +} catch (ex: Exception) { +} finally { +} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-3:1 + >----- +0| try { +1| } catch (ex: Exception) { +2| } finally { +3| } + -< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable.scope b/data/fixtures/scopes/kotlin/statement/statement.variable.scope new file mode 100644 index 0000000000..3e53923b5e --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.variable.scope @@ -0,0 +1,10 @@ +val foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| val foo = 0 + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.while.scope b/data/fixtures/scopes/kotlin/statement/statement.while.scope new file mode 100644 index 0000000000..5aaf57be8f --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.while.scope @@ -0,0 +1,10 @@ +while (true) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| while (true) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/type/type.class.scope b/data/fixtures/scopes/kotlin/type/type.class.scope new file mode 100644 index 0000000000..79c274ccc6 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/type/type.enum.scope b/data/fixtures/scopes/kotlin/type/type.enum.scope new file mode 100644 index 0000000000..a7d730c62d --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.enum.scope @@ -0,0 +1,10 @@ +enum class Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| enum class Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.interface.scope b/data/fixtures/scopes/kotlin/type/type.interface.scope new file mode 100644 index 0000000000..b589a37a0f --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.interface.scope @@ -0,0 +1,10 @@ +interface Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:16 + >----------------< +0| interface Foo {} + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 48585ff51f..b5c07fee93 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -30,6 +30,18 @@ [ (class_declaration) + (function_declaration) + (secondary_constructor) + (anonymous_initializer) + (property_declaration) + (assignment) + (for_statement) + (while_statement) + (do_while_statement) + (jump_expression) + (when_expression) + (try_expression) + (call_expression) ;; Disabled on purpose. We have a better definition of this below. ;; (if_expression) @@ -60,6 +72,12 @@ "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) +;; Top level if statement +( + (if_expression) @ifStatement @statement + (#not-parent-type? @ifStatement control_structure_body) +) + ;;!! class Foo {} (class_declaration (type_identifier) @name @@ -81,23 +99,16 @@ ;;!! constructor() {} (secondary_constructor) @namedFunction -;;!! init {} -(anonymous_initializer) @namedFunction +;;!! fun() {} +(anonymous_function) @anonymousFunction -;; Top level if statement -( - (if_expression) @ifStatement @statement - (#not-parent-type? @ifStatement control_structure_body) -) +;;!! {x -> 0} +(lambda_literal) @anonymousFunction ;; ;; Literals and comments ;; -(anonymous_function) @anonymousFunction - -(lambda_literal) @anonymousFunction - ;;!! "Hello world" (string_literal (string_content) @textFragment From 5e4a393cfa966ec55f7fdfa9914e9b69154fc092 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 12:04:29 +0100 Subject: [PATCH 04/31] function call --- .../scopes/kotlin/functionCall.chain.scope | 19 ++++++++++++++ .../kotlin/functionCall.constructor.scope | 10 ++++++++ .../scopes/kotlin/functionCall.method.scope | 10 ++++++++ .../fixtures/scopes/kotlin/functionCall.scope | 10 ++++++++ .../scopes/kotlin/functionCallee.chain.scope | 25 +++++++++++++++++++ .../kotlin/functionCallee.constructor.scope | 13 ++++++++++ .../scopes/kotlin/functionCallee.method.scope | 13 ++++++++++ .../scopes/kotlin/functionCallee.scope | 13 ++++++++++ 8 files changed, 113 insertions(+) create mode 100644 data/fixtures/scopes/kotlin/functionCall.chain.scope create mode 100644 data/fixtures/scopes/kotlin/functionCall.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/functionCall.method.scope create mode 100644 data/fixtures/scopes/kotlin/functionCall.scope create mode 100644 data/fixtures/scopes/kotlin/functionCallee.chain.scope create mode 100644 data/fixtures/scopes/kotlin/functionCallee.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/functionCallee.method.scope create mode 100644 data/fixtures/scopes/kotlin/functionCallee.scope diff --git a/data/fixtures/scopes/kotlin/functionCall.chain.scope b/data/fixtures/scopes/kotlin/functionCall.chain.scope new file mode 100644 index 0000000000..c73434c70d --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCall.chain.scope @@ -0,0 +1,19 @@ +foo().bar() +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:5 + >-----< +0| foo().bar() + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:0-0:11 + >-----------< +0| foo().bar() + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCall.constructor.scope b/data/fixtures/scopes/kotlin/functionCall.constructor.scope new file mode 100644 index 0000000000..c6d74f15a1 --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCall.constructor.scope @@ -0,0 +1,10 @@ +Foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| Foo() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCall.method.scope b/data/fixtures/scopes/kotlin/functionCall.method.scope new file mode 100644 index 0000000000..6ab0ba4c3a --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCall.method.scope @@ -0,0 +1,10 @@ +foo.bar() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| foo.bar() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCall.scope b/data/fixtures/scopes/kotlin/functionCall.scope new file mode 100644 index 0000000000..00162e317c --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCall.scope @@ -0,0 +1,10 @@ +foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCallee.chain.scope b/data/fixtures/scopes/kotlin/functionCallee.chain.scope new file mode 100644 index 0000000000..b0b9872650 --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCallee.chain.scope @@ -0,0 +1,25 @@ +foo().bar() +--- + +[#1 Content] = +[#1 Removal] = 0:0-0:3 + >---< +0| foo().bar() + +[#1 Domain] = 0:0-0:5 + >-----< +0| foo().bar() + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:0-0:9 + >---------< +0| foo().bar() + +[#2 Domain] = 0:0-0:11 + >-----------< +0| foo().bar() + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCallee.constructor.scope b/data/fixtures/scopes/kotlin/functionCallee.constructor.scope new file mode 100644 index 0000000000..16cc5263eb --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCallee.constructor.scope @@ -0,0 +1,13 @@ +Foo() +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| Foo() + +[Domain] = 0:0-0:5 + >-----< +0| Foo() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCallee.method.scope b/data/fixtures/scopes/kotlin/functionCallee.method.scope new file mode 100644 index 0000000000..e77bc361ec --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCallee.method.scope @@ -0,0 +1,13 @@ +foo.bar() +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| foo.bar() + +[Domain] = 0:0-0:9 + >---------< +0| foo.bar() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCallee.scope b/data/fixtures/scopes/kotlin/functionCallee.scope new file mode 100644 index 0000000000..2b075b5c33 --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCallee.scope @@ -0,0 +1,13 @@ +foo() +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| foo() + +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = " " From 97c7d17610266634f1c9cbd65fbc45b06d9a5063 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 12:32:27 +0100 Subject: [PATCH 05/31] iteration --- .../kotlin/name/name.iteration.block.scope | 27 +++++++++++++++++ .../kotlin/name/name.iteration.block2.scope | 13 ++++++++ .../kotlin/name/name.iteration.block3.scope | 30 +++++++++++++++++++ .../kotlin/name/name.iteration.block4.scope | 13 ++++++++ .../statement/statement.iteration.block.scope | 27 +++++++++++++++++ .../statement.iteration.block2.scope | 13 ++++++++ .../statement.iteration.block3.scope | 30 +++++++++++++++++++ .../statement.iteration.block4.scope | 13 ++++++++ .../kotlin/type/type.iteration.block.scope | 27 +++++++++++++++++ .../kotlin/type/type.iteration.block2.scope | 13 ++++++++ .../kotlin/type/type.iteration.block3.scope | 30 +++++++++++++++++++ .../kotlin/type/type.iteration.block4.scope | 13 ++++++++ .../kotlin/type/type.iteration.class.scope | 13 ++++++++ .../type/type.iteration.interface.scope | 13 ++++++++ .../kotlin/value/value.iteration.block.scope | 27 +++++++++++++++++ .../kotlin/value/value.iteration.block2.scope | 13 ++++++++ .../kotlin/value/value.iteration.block3.scope | 30 +++++++++++++++++++ .../kotlin/value/value.iteration.block4.scope | 13 ++++++++ .../kotlin/value/value.iteration.class.scope | 13 ++++++++ .../common/src/scopeSupportFacets/kotlin.ts | 4 +-- queries/kotlin.scm | 12 ++++---- 21 files changed, 380 insertions(+), 7 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.block.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.block2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.block3.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.iteration.block4.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.block.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.block2.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.block3.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.iteration.block4.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.block.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.block2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.block3.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.block4.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.class.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.iteration.interface.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.iteration.block.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.iteration.block2.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.iteration.block3.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.iteration.block4.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.iteration.class.scope diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.block.scope b/data/fixtures/scopes/kotlin/name/name.iteration.block.scope new file mode 100644 index 0000000000..686814557e --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| fun bar() { } diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.block2.scope b/data/fixtures/scopes/kotlin/name/name.iteration.block2.scope new file mode 100644 index 0000000000..6d18e788c8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.block2.scope @@ -0,0 +1,13 @@ +fun foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| fun foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| fun foo() { } diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.block3.scope b/data/fixtures/scopes/kotlin/name/name.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.block3.scope @@ -0,0 +1,30 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >------------- +0| if (true) { } +1| else if (false) { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| if (true) { } + + +[#3 Content] = +[#3 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/data/fixtures/scopes/kotlin/name/name.iteration.block4.scope b/data/fixtures/scopes/kotlin/name/name.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.iteration.block4.scope @@ -0,0 +1,13 @@ +while (true) { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| while (true) { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| while (true) { } diff --git a/data/fixtures/scopes/kotlin/statement/statement.iteration.block.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.block.scope new file mode 100644 index 0000000000..686814557e --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| fun bar() { } diff --git a/data/fixtures/scopes/kotlin/statement/statement.iteration.block2.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.block2.scope new file mode 100644 index 0000000000..6d18e788c8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.iteration.block2.scope @@ -0,0 +1,13 @@ +fun foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| fun foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| fun foo() { } diff --git a/data/fixtures/scopes/kotlin/statement/statement.iteration.block3.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.iteration.block3.scope @@ -0,0 +1,30 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >------------- +0| if (true) { } +1| else if (false) { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| if (true) { } + + +[#3 Content] = +[#3 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/data/fixtures/scopes/kotlin/statement/statement.iteration.block4.scope b/data/fixtures/scopes/kotlin/statement/statement.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.iteration.block4.scope @@ -0,0 +1,13 @@ +while (true) { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| while (true) { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| while (true) { } diff --git a/data/fixtures/scopes/kotlin/type/type.iteration.block.scope b/data/fixtures/scopes/kotlin/type/type.iteration.block.scope new file mode 100644 index 0000000000..686814557e --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| fun bar() { } diff --git a/data/fixtures/scopes/kotlin/type/type.iteration.block2.scope b/data/fixtures/scopes/kotlin/type/type.iteration.block2.scope new file mode 100644 index 0000000000..6d18e788c8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.iteration.block2.scope @@ -0,0 +1,13 @@ +fun foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| fun foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| fun foo() { } diff --git a/data/fixtures/scopes/kotlin/type/type.iteration.block3.scope b/data/fixtures/scopes/kotlin/type/type.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.iteration.block3.scope @@ -0,0 +1,30 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >------------- +0| if (true) { } +1| else if (false) { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| if (true) { } + + +[#3 Content] = +[#3 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/data/fixtures/scopes/kotlin/type/type.iteration.block4.scope b/data/fixtures/scopes/kotlin/type/type.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.iteration.block4.scope @@ -0,0 +1,13 @@ +while (true) { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| while (true) { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| while (true) { } diff --git a/data/fixtures/scopes/kotlin/type/type.iteration.class.scope b/data/fixtures/scopes/kotlin/type/type.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/type/type.iteration.interface.scope b/data/fixtures/scopes/kotlin/type/type.iteration.interface.scope new file mode 100644 index 0000000000..4140b6c622 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.iteration.interface.scope @@ -0,0 +1,13 @@ +interface Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| interface Foo { } + + +[#2 Content] = +[#2 Domain] = 0:15-0:16 + >-< +0| interface Foo { } diff --git a/data/fixtures/scopes/kotlin/value/value.iteration.block.scope b/data/fixtures/scopes/kotlin/value/value.iteration.block.scope new file mode 100644 index 0000000000..686814557e --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| fun bar() { } diff --git a/data/fixtures/scopes/kotlin/value/value.iteration.block2.scope b/data/fixtures/scopes/kotlin/value/value.iteration.block2.scope new file mode 100644 index 0000000000..6d18e788c8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.iteration.block2.scope @@ -0,0 +1,13 @@ +fun foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| fun foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| fun foo() { } diff --git a/data/fixtures/scopes/kotlin/value/value.iteration.block3.scope b/data/fixtures/scopes/kotlin/value/value.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.iteration.block3.scope @@ -0,0 +1,30 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >------------- +0| if (true) { } +1| else if (false) { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| if (true) { } + + +[#3 Content] = +[#3 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/data/fixtures/scopes/kotlin/value/value.iteration.block4.scope b/data/fixtures/scopes/kotlin/value/value.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.iteration.block4.scope @@ -0,0 +1,13 @@ +while (true) { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| while (true) { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| while (true) { } diff --git a/data/fixtures/scopes/kotlin/value/value.iteration.class.scope b/data/fixtures/scopes/kotlin/value/value.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/packages/common/src/scopeSupportFacets/kotlin.ts b/packages/common/src/scopeSupportFacets/kotlin.ts index 6e06a8112c..a2c52829ef 100644 --- a/packages/common/src/scopeSupportFacets/kotlin.ts +++ b/packages/common/src/scopeSupportFacets/kotlin.ts @@ -6,8 +6,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, anonymousFunction: supported, - list: supported, - map: supported, "argument.actual.singleLine": supported, "argument.actual.multiLine": supported, @@ -306,4 +304,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { selector: notApplicable, unit: notApplicable, pairDelimiter: notApplicable, + list: notApplicable, + map: notApplicable, }; diff --git a/queries/kotlin.scm b/queries/kotlin.scm index b5c07fee93..338a2a53ab 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -41,15 +41,17 @@ (jump_expression) (when_expression) (try_expression) - (call_expression) ;; Disabled on purpose. We have a better definition of this below. ;; (if_expression) ] @statement -[ - (class_declaration) -] @type +(control_structure_body + (call_expression) @statement +) +(source_file + (call_expression) @statement +) ;; Entire document, including leading and trailing whitespace ( @@ -81,7 +83,7 @@ ;;!! class Foo {} (class_declaration (type_identifier) @name -) @class @name.domain +) @class @type @name.domain ;; (object_declaration ;; (type_identifier) @name From c5e4bb2a2ab672c789d0df01e24e99608b73b70d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 13:16:05 +0100 Subject: [PATCH 06/31] name and value --- .../scopes/kotlin/name/name.assignment.scope | 20 +++ .../scopes/kotlin/name/name.class.scope | 24 +++ .../scopes/kotlin/name/name.constructor.scope | 45 ++++++ .../scopes/kotlin/name/name.enum.scope | 24 +++ .../scopes/kotlin/name/name.field.class.scope | 94 +++++++++++ .../scopes/kotlin/name/name.field.enum.scope | 63 ++++++++ .../kotlin/name/name.field.interface.scope | 48 ++++++ .../scopes/kotlin/name/name.foreach.scope | 20 +++ .../scopes/kotlin/name/name.interface.scope | 24 +++ .../scopes/kotlin/name/name.method.scope | 45 ++++++ .../scopes/kotlin/name/name.variable.scope | 24 +++ .../statement/statement.field.class.scope | 18 +-- .../kotlin/value/value.assignment.scope | 20 +++ .../kotlin/value/value.field.class.scope | 42 +++++ .../scopes/kotlin/value/value.foreach.scope | 20 +++ .../kotlin/value/value.return.lambda.scope | 20 +++ .../scopes/kotlin/value/value.return.scope | 22 +++ .../scopes/kotlin/value/value.switch.scope | 13 ++ .../scopes/kotlin/value/value.variable.scope | 20 +++ .../scopes/kotlin/value/value.variable2.scope | 20 +++ queries/kotlin.scm | 153 ++++++++++-------- 21 files changed, 705 insertions(+), 74 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/name/name.assignment.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.class.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.enum.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.field.class.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.field.enum.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.field.interface.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.foreach.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.interface.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.method.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.variable.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.assignment.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.field.class.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.foreach.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.return.lambda.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.return.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.switch.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.variable.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.variable2.scope diff --git a/data/fixtures/scopes/kotlin/name/name.assignment.scope b/data/fixtures/scopes/kotlin/name/name.assignment.scope new file mode 100644 index 0000000000..ccbd90c654 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.assignment.scope @@ -0,0 +1,20 @@ +foo = 0 +--- + +[Content] = 0:0-0:3 + >---< +0| foo = 0 + +[Removal] = 0:0-0:4 + >----< +0| foo = 0 + +[Trailing delimiter] = 0:3-0:4 + >-< +0| foo = 0 + +[Domain] = 0:0-0:7 + >-------< +0| foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.class.scope b/data/fixtures/scopes/kotlin/name/name.class.scope new file mode 100644 index 0000000000..211086562c --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.class.scope @@ -0,0 +1,24 @@ +class Foo {} +--- + +[Content] = 0:6-0:9 + >---< +0| class Foo {} + +[Removal] = 0:6-0:10 + >----< +0| class Foo {} + +[Leading delimiter] = 0:5-0:6 + >-< +0| class Foo {} + +[Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo {} + +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.constructor.scope b/data/fixtures/scopes/kotlin/name/name.constructor.scope new file mode 100644 index 0000000000..0f06c0b675 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.constructor.scope @@ -0,0 +1,45 @@ +class Foo { + constructor() {} +} +--- + +[#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| constructor() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:4-1:15 + >-----------< +1| constructor() {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| constructor() {} + +[#2 Domain] = 1:4-1:20 + >----------------< +1| constructor() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.enum.scope b/data/fixtures/scopes/kotlin/name/name.enum.scope new file mode 100644 index 0000000000..049f0a5883 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.enum.scope @@ -0,0 +1,24 @@ +enum class Foo {} +--- + +[Content] = 0:11-0:14 + >---< +0| enum class Foo {} + +[Removal] = 0:11-0:15 + >----< +0| enum class Foo {} + +[Leading delimiter] = 0:10-0:11 + >-< +0| enum class Foo {} + +[Trailing delimiter] = 0:14-0:15 + >-< +0| enum class Foo {} + +[Domain] = 0:0-0:17 + >-----------------< +0| enum class Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.field.class.scope b/data/fixtures/scopes/kotlin/name/name.field.class.scope new file mode 100644 index 0000000000..c03fbe7548 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.field.class.scope @@ -0,0 +1,94 @@ +class Foo { + var bar: Int = 0 + val baz = 0 + val bongo: Int +} +--- + +[#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-4:1 + >----------- +0| class Foo { +1| var bar: Int = 0 +2| val baz = 0 +3| val bongo: Int +4| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| var bar: Int = 0 + +[#2 Removal] = 1:7-1:11 + >----< +1| var bar: Int = 0 + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| var bar: Int = 0 + +[#2 Domain] = 1:4-1:20 + >----------------< +1| var bar: Int = 0 + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:8-2:11 + >---< +2| val baz = 0 + +[#3 Removal] = 2:8-2:12 + >----< +2| val baz = 0 + +[#3 Leading delimiter] = 2:7-2:8 + >-< +2| val baz = 0 + +[#3 Trailing delimiter] = 2:11-2:12 + >-< +2| val baz = 0 + +[#3 Domain] = 2:4-2:15 + >-----------< +2| val baz = 0 + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 3:8-3:13 + >-----< +3| val bongo: Int + +[#4 Removal] = 3:7-3:13 + >------< +3| val bongo: Int + +[#4 Leading delimiter] = 3:7-3:8 + >-< +3| val bongo: Int + +[#4 Domain] = 3:4-3:18 + >--------------< +3| val bongo: Int + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.field.enum.scope b/data/fixtures/scopes/kotlin/name/name.field.enum.scope new file mode 100644 index 0000000000..3e18c1fffa --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.field.enum.scope @@ -0,0 +1,63 @@ +enum class Foo { + bar, + baz() +} +--- + +[#1 Content] = 0:11-0:14 + >---< +0| enum class Foo { + +[#1 Removal] = 0:11-0:15 + >----< +0| enum class Foo { + +[#1 Leading delimiter] = 0:10-0:11 + >-< +0| enum class Foo { + +[#1 Trailing delimiter] = 0:14-0:15 + >-< +0| enum class Foo { + +[#1 Domain] = 0:0-3:1 + >---------------- +0| enum class 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/kotlin/name/name.field.interface.scope b/data/fixtures/scopes/kotlin/name/name.field.interface.scope new file mode 100644 index 0000000000..62b2cf00ea --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.field.interface.scope @@ -0,0 +1,48 @@ +interface Foo { + val bar: Int +} +--- + +[#1 Content] = 0:10-0:13 + >---< +0| interface Foo { + +[#1 Removal] = 0:10-0:14 + >----< +0| interface Foo { + +[#1 Leading delimiter] = 0:9-0:10 + >-< +0| interface Foo { + +[#1 Trailing delimiter] = 0:13-0:14 + >-< +0| interface Foo { + +[#1 Domain] = 0:0-2:1 + >--------------- +0| interface Foo { +1| val bar: Int +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| val bar: Int + +[#2 Removal] = 1:7-1:11 + >----< +1| val bar: Int + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| val bar: Int + +[#2 Domain] = 1:4-1:16 + >------------< +1| val bar: Int + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.foreach.scope b/data/fixtures/scopes/kotlin/name/name.foreach.scope new file mode 100644 index 0000000000..e71717e127 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.foreach.scope @@ -0,0 +1,20 @@ +for (v in values) {} +--- + +[Content] = 0:5-0:6 + >-< +0| for (v in values) {} + +[Removal] = 0:5-0:7 + >--< +0| for (v in values) {} + +[Trailing delimiter] = 0:6-0:7 + >-< +0| for (v in values) {} + +[Domain] = 0:0-0:20 + >--------------------< +0| for (v in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.interface.scope b/data/fixtures/scopes/kotlin/name/name.interface.scope new file mode 100644 index 0000000000..52074b01f0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.interface.scope @@ -0,0 +1,24 @@ +interface Foo {} +--- + +[Content] = 0:10-0:13 + >---< +0| interface Foo {} + +[Removal] = 0:10-0:14 + >----< +0| interface Foo {} + +[Leading delimiter] = 0:9-0:10 + >-< +0| interface Foo {} + +[Trailing delimiter] = 0:13-0:14 + >-< +0| interface Foo {} + +[Domain] = 0:0-0:16 + >----------------< +0| interface Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.method.scope b/data/fixtures/scopes/kotlin/name/name.method.scope new file mode 100644 index 0000000000..b0b86dc608 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.method.scope @@ -0,0 +1,45 @@ +class Foo { + fun 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| fun bar() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:8-1:11 + >---< +1| fun bar() {} + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| fun bar() {} + +[#2 Domain] = 1:4-1:16 + >------------< +1| fun bar() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.variable.scope b/data/fixtures/scopes/kotlin/name/name.variable.scope new file mode 100644 index 0000000000..608e22c538 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.variable.scope @@ -0,0 +1,24 @@ +val foo = 0 +--- + +[Content] = 0:4-0:7 + >---< +0| val foo = 0 + +[Removal] = 0:4-0:8 + >----< +0| val foo = 0 + +[Leading delimiter] = 0:3-0:4 + >-< +0| val foo = 0 + +[Trailing delimiter] = 0:7-0:8 + >-< +0| val foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| val foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/statement/statement.field.class.scope b/data/fixtures/scopes/kotlin/statement/statement.field.class.scope index f39490a583..429629e4b9 100644 --- a/data/fixtures/scopes/kotlin/statement/statement.field.class.scope +++ b/data/fixtures/scopes/kotlin/statement/statement.field.class.scope @@ -1,7 +1,7 @@ class Foo { var bar: Int = 0 val baz = 0 - val bongo + val bongo: Int } --- @@ -12,7 +12,7 @@ class Foo { 0| class Foo { 1| var bar: Int = 0 2| val baz = 0 -3| val bongo +3| val bongo: Int 4| } -< @@ -45,7 +45,7 @@ class Foo { [#3 Removal] = 2:0-3:0 >--------------- 2| val baz = 0 -3| val bongo +3| val bongo: Int < [#3 Leading delimiter] = 2:0-2:4 @@ -56,18 +56,18 @@ class Foo { [#4 Content] = -[#4 Domain] = 3:4-3:13 - >---------< -3| val bongo +[#4 Domain] = 3:4-3:18 + >--------------< +3| val bongo: Int [#4 Removal] = 3:0-4:0 - >------------- -3| val bongo + >------------------ +3| val bongo: Int 4| } < [#4 Leading delimiter] = 3:0-3:4 >----< -3| val bongo +3| val bongo: Int [#4 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/value/value.assignment.scope b/data/fixtures/scopes/kotlin/value/value.assignment.scope new file mode 100644 index 0000000000..6e89de0927 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.assignment.scope @@ -0,0 +1,20 @@ +foo = 0 +--- + +[Content] = 0:6-0:7 + >-< +0| foo = 0 + +[Removal] = 0:3-0:7 + >----< +0| foo = 0 + +[Leading delimiter] = 0:3-0:6 + >---< +0| foo = 0 + +[Domain] = 0:0-0:7 + >-------< +0| foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.field.class.scope b/data/fixtures/scopes/kotlin/value/value.field.class.scope new file mode 100644 index 0000000000..ffc48eea80 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.field.class.scope @@ -0,0 +1,42 @@ +class Foo { + val bar: Int = 0 + val baz = 0 +} +--- + +[#1 Content] = 1:19-1:20 + >-< +1| val bar: Int = 0 + +[#1 Removal] = 1:16-1:20 + >----< +1| val bar: Int = 0 + +[#1 Leading delimiter] = 1:16-1:19 + >---< +1| val bar: Int = 0 + +[#1 Domain] = 1:4-1:20 + >----------------< +1| val bar: Int = 0 + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:14-2:15 + >-< +2| val baz = 0 + +[#2 Removal] = 2:11-2:15 + >----< +2| val baz = 0 + +[#2 Leading delimiter] = 2:11-2:14 + >---< +2| val baz = 0 + +[#2 Domain] = 2:4-2:15 + >-----------< +2| val baz = 0 + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.foreach.scope b/data/fixtures/scopes/kotlin/value/value.foreach.scope new file mode 100644 index 0000000000..b360506e19 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.foreach.scope @@ -0,0 +1,20 @@ +for (v in values) {} +--- + +[Content] = 0:10-0:16 + >------< +0| for (v in values) {} + +[Removal] = 0:9-0:16 + >-------< +0| for (v in values) {} + +[Leading delimiter] = 0:9-0:10 + >-< +0| for (v in values) {} + +[Domain] = 0:0-0:20 + >--------------------< +0| for (v in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.return.lambda.scope b/data/fixtures/scopes/kotlin/value/value.return.lambda.scope new file mode 100644 index 0000000000..7971bc194d --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.return.lambda.scope @@ -0,0 +1,20 @@ +{x -> 0} +--- + +[Content] = 0:6-0:7 + >-< +0| {x -> 0} + +[Removal] = 0:5-0:7 + >--< +0| {x -> 0} + +[Leading delimiter] = 0:5-0:6 + >-< +0| {x -> 0} + +[Domain] = 0:0-0:8 + >--------< +0| {x -> 0} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.return.scope b/data/fixtures/scopes/kotlin/value/value.return.scope new file mode 100644 index 0000000000..f2114175c8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.return.scope @@ -0,0 +1,22 @@ +fun bar() { + return 0 +} +--- + +[Content] = 1:11-1:12 + >-< +1| return 0 + +[Removal] = 1:10-1:12 + >--< +1| return 0 + +[Leading delimiter] = 1:10-1:11 + >-< +1| return 0 + +[Domain] = 1:4-1:12 + >--------< +1| return 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.switch.scope b/data/fixtures/scopes/kotlin/value/value.switch.scope new file mode 100644 index 0000000000..1e201754f8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.switch.scope @@ -0,0 +1,13 @@ +when (foo) {} +--- + +[Content] = +[Removal] = 0:6-0:9 + >---< +0| when (foo) {} + +[Domain] = 0:0-0:13 + >-------------< +0| when (foo) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.variable.scope b/data/fixtures/scopes/kotlin/value/value.variable.scope new file mode 100644 index 0000000000..06dc0be9f8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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:11 + >-----------< +0| var foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.variable2.scope b/data/fixtures/scopes/kotlin/value/value.variable2.scope new file mode 100644 index 0000000000..4ef2ac039c --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.variable2.scope @@ -0,0 +1,20 @@ +var foo: Int = 0 +--- + +[Content] = 0:15-0:16 + >-< +0| var foo: Int = 0 + +[Removal] = 0:12-0:16 + >----< +0| var foo: Int = 0 + +[Leading delimiter] = 0:12-0:15 + >---< +0| var foo: Int = 0 + +[Domain] = 0:0-0:16 + >----------------< +0| var foo: Int = 0 + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 338a2a53ab..4474b47912 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -99,13 +99,20 @@ ) @namedFunction @name.domain ;;!! constructor() {} -(secondary_constructor) @namedFunction +(secondary_constructor + "constructor" @name +) @namedFunction @name.domain ;;!! fun() {} (anonymous_function) @anonymousFunction ;;!! {x -> 0} -(lambda_literal) @anonymousFunction +(lambda_literal + ( + "->" + (_) @value + )? +) @anonymousFunction @value.domain ;; ;; Literals and comments @@ -304,83 +311,106 @@ (#not-type? @type.end "type_constraints") ) -(variable_declaration - (simple_identifier) @name -) @_.domain +;; (variable_declaration +;; (simple_identifier) @name +;; ) @_.domain -(variable_declaration - ":" - . - (_) @type.start -) @type.end.endOf @_.domain +;; (variable_declaration +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf @_.domain -(multi_variable_declaration) @name.iteration @type.iteration +;; (multi_variable_declaration) @name.iteration @type.iteration +;;!! val foo (property_declaration (variable_declaration (simple_identifier) @name ) + . ) @_.domain +;;!! val foo = 0 (property_declaration + (variable_declaration + (simple_identifier) @name + ) @value.leading.endOf "=" - . (_) @value ) @_.domain -(property_declaration - (property_delegate - (_) @value - ) +;;!! foo = 0 +(assignment + (directly_assignable_expression) @name @value.leading.endOf + (_) @value + . ) @_.domain -(property_declaration - (variable_declaration - ":" - . - (_) @type.start - ) @type.end.endOf -) @_.domain +;; (property_declaration +;; "=" +;; . +;; (_) @value +;; ) @_.domain -(property_declaration - (multi_variable_declaration) @name.iteration @type.iteration -) @name.iteration.domain @type.iteration.domain +;; (property_declaration +;; (property_delegate +;; (_) @value +;; ) +;; ) @_.domain +;; (property_declaration +;; (variable_declaration +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf +;; ) @_.domain + +;; (property_declaration +;; (multi_variable_declaration) @name.iteration @type.iteration +;; ) @name.iteration.domain @type.iteration.domain + +;;!! for (v in values) {} (for_statement (variable_declaration (simple_identifier) @name ) -) @_.domain - -(for_statement "in" . (_) @value ) @_.domain -(for_statement - (variable_declaration - ":" - . - (_) @type.start - ) @type.end.endOf -) @_.domain +;;!! for (i in 0 until size) {} +;; (for_statement +;; "in" +;; . +;; (_) @value +;; ) @value.domain -(for_statement - (multi_variable_declaration) @name.iteration @type.iteration -) @name.iteration.domain @type.iteration.domain +;; (for_statement +;; (variable_declaration +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf +;; ) @type.domain + +;; (for_statement +;; (multi_variable_declaration) @name.iteration @type.iteration +;; ) @name.iteration.domain @type.iteration.domain (when_subject (variable_declaration (simple_identifier) @name ) -) @_.domain +) @name.domain (when_subject "=" . (_) @value -) @_.domain +) @value.domain (when_subject (variable_declaration @@ -388,7 +418,7 @@ . (_) @type.start ) @type.end.endOf -) @_.domain +) @type.domain (getter ":" @@ -396,7 +426,7 @@ (_) @type.start (_)? @type.end (function_body) -) @_.domain +) @type.domain (setter ":" @@ -404,17 +434,17 @@ (_) @type.start (_)? @type.end (function_body) -) @_.domain +) @type.domain (parameter_with_optional_type (simple_identifier) @name -) @_.domain +) @name.domain (parameter_with_optional_type ":" . (_) @type.start -) @type.end.endOf @_.domain +) @type.end.endOf @type.domain ;; Function parameter without default (function_value_parameters @@ -511,12 +541,6 @@ ) ) @_.domain -(assignment - (directly_assignable_expression) @name - (_) @value - . -) @_.domain - (value_argument (simple_identifier) @name "=" @@ -539,9 +563,6 @@ (call_expression) (constructor_invocation) (constructor_delegation_call) - (enum_entry - (value_arguments) - ) ] @functionCall ( @@ -562,13 +583,13 @@ ) ) @_.domain.start -(call_suffix - (annotated_lambda) @argumentOrParameter -) +;; (call_suffix +;; (annotated_lambda) @argumentOrParameter +;; ) -(call_expression - (call_suffix) @argumentOrParameter.iteration -) @argumentOrParameter.iteration.domain +;; (call_expression +;; (call_suffix) @argumentOrParameter.iteration +;; ) @argumentOrParameter.iteration.domain (constructor_invocation (user_type) @functionCallee @@ -595,17 +616,19 @@ ) ) @argumentOrParameter.iteration.domain +;;!! BAR, (enum_entry - (simple_identifier) @functionCallee - (value_arguments) -) @_.domain + (simple_identifier) @name +) @name.domain +;;!! BAR() (enum_entry + (simple_identifier) @functionCallee (value_arguments "(" @argumentOrParameter.iteration.start.endOf ")" @argumentOrParameter.iteration.end.startOf ) -) @argumentOrParameter.iteration.domain +) @functionCall @functionCallee.domain @argumentOrParameter.iteration.domain ( (function_value_parameters From 63927763a9b00ac66b9a113d277a3d08c2a88722 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 14:15:54 +0100 Subject: [PATCH 07/31] interior --- .../branch/branch.switchCase.iteration.scope | 10 + .../kotlin/condition/condition.doWhile.scope | 13 + .../kotlin/condition/condition.if.scope | 30 ++ .../condition.switchCase.iteration.scope | 10 + .../condition/condition.switchCase.scope | 26 ++ .../condition/condition.switchCase2.scope | 40 +++ .../kotlin/condition/condition.ternary.scope | 13 + .../kotlin/condition/condition.while.scope | 13 + .../kotlin/interior/interior.class.scope | 10 + .../interior/interior.constructor.scope | 27 ++ .../kotlin/interior/interior.doWhile.scope | 10 + .../kotlin/interior/interior.enum.scope | 10 + .../scopes/kotlin/interior/interior.for.scope | 10 + .../kotlin/interior/interior.foreach.scope | 10 + .../scopes/kotlin/interior/interior.if.scope | 30 ++ .../kotlin/interior/interior.interface.scope | 10 + .../kotlin/interior/interior.lambda.scope | 10 + .../kotlin/interior/interior.method.scope | 27 ++ .../kotlin/interior/interior.static.scope | 27 ++ .../kotlin/interior/interior.switch.scope | 10 + .../kotlin/interior/interior.switchCase.scope | 87 ++++++ .../scopes/kotlin/interior/interior.try.scope | 37 +++ .../kotlin/interior/interior.while.scope | 10 + .../kotlin/name/name.argument.catch.scope | 27 ++ .../common/src/scopeSupportFacets/kotlin.ts | 2 +- queries/kotlin.scm | 277 ++++++++++-------- 26 files changed, 666 insertions(+), 120 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/branch/branch.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.doWhile.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.if.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.switchCase.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.switchCase2.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.ternary.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.while.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.class.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.doWhile.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.enum.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.for.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.foreach.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.if.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.interface.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.lambda.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.method.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.static.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.switch.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.switchCase.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.try.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.while.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.catch.scope diff --git a/data/fixtures/scopes/kotlin/branch/branch.switchCase.iteration.scope b/data/fixtures/scopes/kotlin/branch/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..7343248d28 --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.switchCase.iteration.scope @@ -0,0 +1,10 @@ +when (foo) { } +--- + +[Content] = 0:12-0:13 + >-< +0| when (foo) { } + +[Domain] = 0:0-0:14 + >--------------< +0| when (foo) { } diff --git a/data/fixtures/scopes/kotlin/condition/condition.doWhile.scope b/data/fixtures/scopes/kotlin/condition/condition.doWhile.scope new file mode 100644 index 0000000000..a5db4c6278 --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.doWhile.scope @@ -0,0 +1,13 @@ +do {} while (true) +--- + +[Content] = +[Removal] = 0:13-0:17 + >----< +0| do {} while (true) + +[Domain] = 0:0-0:18 + >------------------< +0| do {} while (true) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/condition/condition.if.scope b/data/fixtures/scopes/kotlin/condition/condition.if.scope new file mode 100644 index 0000000000..4f5ac14fc6 --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.if.scope @@ -0,0 +1,30 @@ +if (true) {} +else if (false) {} +else {} +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:8 + >----< +0| if (true) {} + +[#1 Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:9-1:14 + >-----< +1| else if (false) {} + +[#2 Domain] = 1:0-1:18 + >------------------< +1| else if (false) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/condition/condition.switchCase.iteration.scope b/data/fixtures/scopes/kotlin/condition/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..7343248d28 --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.switchCase.iteration.scope @@ -0,0 +1,10 @@ +when (foo) { } +--- + +[Content] = 0:12-0:13 + >-< +0| when (foo) { } + +[Domain] = 0:0-0:14 + >--------------< +0| when (foo) { } diff --git a/data/fixtures/scopes/kotlin/condition/condition.switchCase.scope b/data/fixtures/scopes/kotlin/condition/condition.switchCase.scope new file mode 100644 index 0000000000..951eb90612 --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.switchCase.scope @@ -0,0 +1,26 @@ +when (foo) { + 0 -> break +} +--- + +[Content] = 1:4-1:5 + >-< +1| 0 -> break + +[Removal] = 1:4-1:6 + >--< +1| 0 -> break + +[Leading delimiter] = 1:0-1:4 + >----< +1| 0 -> break + +[Trailing delimiter] = 1:5-1:6 + >-< +1| 0 -> break + +[Domain] = 1:4-1:14 + >----------< +1| 0 -> break + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/condition/condition.switchCase2.scope b/data/fixtures/scopes/kotlin/condition/condition.switchCase2.scope new file mode 100644 index 0000000000..3d6bbfb259 --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.switchCase2.scope @@ -0,0 +1,40 @@ +when (foo) { + 0, 1 -> break +} +--- + +[#1.1 Content] = 1:4-1:5 + >-< +1| 0, 1 -> break + +[#1.1 Removal] = 1:0-1:5 + >-----< +1| 0, 1 -> break + +[#1.1 Leading delimiter] = 1:0-1:4 + >----< +1| 0, 1 -> break + +[#1.1 Insertion delimiter] = " " + +[#1.2 Content] = 1:7-1:8 + >-< +1| 0, 1 -> break + +[#1.2 Removal] = 1:7-1:9 + >--< +1| 0, 1 -> break + +[#1.2 Leading delimiter] = 1:6-1:7 + >-< +1| 0, 1 -> break + +[#1.2 Trailing delimiter] = 1:8-1:9 + >-< +1| 0, 1 -> break + +[#1.2 Insertion delimiter] = " " + +[#1 Domain] = 1:4-1:17 + >-------------< +1| 0, 1 -> break diff --git a/data/fixtures/scopes/kotlin/condition/condition.ternary.scope b/data/fixtures/scopes/kotlin/condition/condition.ternary.scope new file mode 100644 index 0000000000..543169cb1c --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.ternary.scope @@ -0,0 +1,13 @@ +if (true) 0 else 1 +--- + +[Content] = +[Removal] = 0:4-0:8 + >----< +0| if (true) 0 else 1 + +[Domain] = 0:0-0:18 + >------------------< +0| if (true) 0 else 1 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/condition/condition.while.scope b/data/fixtures/scopes/kotlin/condition/condition.while.scope new file mode 100644 index 0000000000..61cd7d9e7a --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.while.scope @@ -0,0 +1,13 @@ +while (true) {} +--- + +[Content] = +[Removal] = 0:7-0:11 + >----< +0| while (true) {} + +[Domain] = 0:0-0:15 + >---------------< +0| while (true) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.class.scope b/data/fixtures/scopes/kotlin/interior/interior.class.scope new file mode 100644 index 0000000000..13ef2f4d94 --- /dev/null +++ b/data/fixtures/scopes/kotlin/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/kotlin/interior/interior.constructor.scope b/data/fixtures/scopes/kotlin/interior/interior.constructor.scope new file mode 100644 index 0000000000..21da00c906 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.constructor.scope @@ -0,0 +1,27 @@ +class Foo { + constructor() { } +} +--- + +[#1 Content] = 1:4-1:21 + >-----------------< +1| constructor() { } + +[#1 Removal] = +[#1 Domain] = 0:11-2:0 + > +0| class Foo { +1| constructor() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:19-1:20 + >-< +1| constructor() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.doWhile.scope b/data/fixtures/scopes/kotlin/interior/interior.doWhile.scope new file mode 100644 index 0000000000..1c2166cf2f --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.doWhile.scope @@ -0,0 +1,10 @@ +do { } while (true) +--- + +[Content] = +[Removal] = +[Domain] = 0:4-0:5 + >-< +0| do { } while (true) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.enum.scope b/data/fixtures/scopes/kotlin/interior/interior.enum.scope new file mode 100644 index 0000000000..ba8db21a41 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.enum.scope @@ -0,0 +1,10 @@ +enum class Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:16-0:17 + >-< +0| enum class Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.for.scope b/data/fixtures/scopes/kotlin/interior/interior.for.scope new file mode 100644 index 0000000000..47b9d05522 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.for.scope @@ -0,0 +1,10 @@ +for (i in 0 until size) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:25-0:26 + >-< +0| for (i in 0 until size) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.foreach.scope b/data/fixtures/scopes/kotlin/interior/interior.foreach.scope new file mode 100644 index 0000000000..7738d34017 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.foreach.scope @@ -0,0 +1,10 @@ +for (v in values) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:19-0:20 + >-< +0| for (v in values) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.if.scope b/data/fixtures/scopes/kotlin/interior/interior.if.scope new file mode 100644 index 0000000000..407453929f --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.if.scope @@ -0,0 +1,30 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:6-2:7 + >-< +2| else { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.interface.scope b/data/fixtures/scopes/kotlin/interior/interior.interface.scope new file mode 100644 index 0000000000..b9968a2fff --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.interface.scope @@ -0,0 +1,10 @@ +interface Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:15-0:16 + >-< +0| interface Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.lambda.scope b/data/fixtures/scopes/kotlin/interior/interior.lambda.scope new file mode 100644 index 0000000000..54d303e92f --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.lambda.scope @@ -0,0 +1,10 @@ +{ } +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:2 + >-< +0| { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.method.scope b/data/fixtures/scopes/kotlin/interior/interior.method.scope new file mode 100644 index 0000000000..5e1e62642d --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.method.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar() { } +} +--- + +[#1 Content] = 1:4-1:17 + >-------------< +1| fun bar() { } + +[#1 Removal] = +[#1 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:15-1:16 + >-< +1| fun bar() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.static.scope b/data/fixtures/scopes/kotlin/interior/interior.static.scope new file mode 100644 index 0000000000..c50e7cda65 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.static.scope @@ -0,0 +1,27 @@ +class Foo { + init { } +} +--- + +[#1 Content] = 1:4-1:12 + >--------< +1| init { } + +[#1 Removal] = +[#1 Domain] = 0:11-2:0 + > +0| class Foo { +1| init { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:10-1:11 + >-< +1| init { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.switch.scope b/data/fixtures/scopes/kotlin/interior/interior.switch.scope new file mode 100644 index 0000000000..18bb219b2d --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.switch.scope @@ -0,0 +1,10 @@ +when (value) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:14-0:15 + >-< +0| when (value) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.switchCase.scope b/data/fixtures/scopes/kotlin/interior/interior.switchCase.scope new file mode 100644 index 0000000000..d9d9833bd0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.switchCase.scope @@ -0,0 +1,87 @@ +when (foo) { + 0 -> + bar() + 1 -> { + bar() + break + } + else -> bar() +--- + +[#1 Content] = 2:8-2:13 + >-----< +2| bar() + +[#1 Removal] = 1:8-2:13 + > +1| 0 -> +2| bar() + -------------< + +[#1 Domain] = 1:4-2:13 + >---- +1| 0 -> +2| bar() + -------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 3:9-6:5 + >- +3| 1 -> { +4| bar() +5| break +6| } + -----< + +[#2 Removal] = 3:8-6:5 + >-- +3| 1 -> { +4| bar() +5| break +6| } + -----< + +[#2 Domain] = 3:4-6:5 + >------ +3| 1 -> { +4| bar() +5| break +6| } + -----< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 4:8-5:13 + >----- +4| bar() +5| break + -------------< + +[#3 Removal] = +[#3 Domain] = 3:10-6:4 + > +3| 1 -> { +4| bar() +5| break +6| } + ----< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 7:12-7:17 + >-----< +7| else -> bar() + +[#4 Removal] = 7:11-7:17 + >------< +7| else -> bar() + +[#4 Domain] = 7:4-7:17 + >-------------< +7| else -> bar() + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.try.scope b/data/fixtures/scopes/kotlin/interior/interior.try.scope new file mode 100644 index 0000000000..02b8ad0d84 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.try.scope @@ -0,0 +1,37 @@ +try { +} catch (ex: Exception) { +} finally { +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:5-1:0 + > +0| try { +1| } catch (ex: Exception) { + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:25-2:0 + > +1| } catch (ex: Exception) { +2| } finally { + < + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:11-3:0 + > +2| } finally { +3| } + < + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/interior/interior.while.scope b/data/fixtures/scopes/kotlin/interior/interior.while.scope new file mode 100644 index 0000000000..1afbe23128 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.while.scope @@ -0,0 +1,10 @@ +while (true) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:14-0:15 + >-< +0| while (true) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.catch.scope b/data/fixtures/scopes/kotlin/name/name.argument.catch.scope new file mode 100644 index 0000000000..6d686d18c9 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.catch.scope @@ -0,0 +1,27 @@ +try { +} catch (e: MyException) { +} catch (e: Exception) {} +--- + +[#1 Content] = +[#1 Removal] = 1:9-1:10 + >-< +1| } catch (e: MyException) { + +[#1 Domain] = 1:9-1:23 + >--------------< +1| } catch (e: MyException) { + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:9-2:10 + >-< +2| } catch (e: Exception) {} + +[#2 Domain] = 2:9-2:21 + >------------< +2| } catch (e: Exception) {} + +[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/kotlin.ts b/packages/common/src/scopeSupportFacets/kotlin.ts index a2c52829ef..085386b696 100644 --- a/packages/common/src/scopeSupportFacets/kotlin.ts +++ b/packages/common/src/scopeSupportFacets/kotlin.ts @@ -219,6 +219,7 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "interior.switch": supported, "interior.switchCase": supported, "interior.try": supported, + "interior.for": supported, /* UNSUPPORTED */ @@ -280,7 +281,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { // For loop (C-style) "statement.for": notApplicable, "condition.for": notApplicable, - "interior.for": notApplicable, // Yield "statement.yield": notApplicable, diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 4474b47912..97f3fdbea3 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -74,12 +74,40 @@ "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) +;;!! { } +;;! ^ +(_ + "{" @interior.start.endOf + "}" @interior.end.startOf +) + ;; Top level if statement ( - (if_expression) @ifStatement @statement - (#not-parent-type? @ifStatement control_structure_body) + (_ + (if_expression + condition: (_) @condition + ) @ifStatement @statement @condition.domain + ) @_dummy + (#not-parent-type? @_dummy if_expression) +) + +;;!! else if (true) {} +(if_expression + "else" @condition.domain.start + (control_structure_body + (if_expression + condition: (_) @condition + consequence: (_) @condition.domain.end + ) + ) ) +;;!! else {} +;; (if_expression +;; "else" @statement.start +;; (control_structure_body) @statement.end +;; ) + ;;!! class Foo {} (class_declaration (type_identifier) @name @@ -134,68 +162,84 @@ ;; Branches and conditions ;; -(when_entry) @branch +;;!! when (foo) { } +;;! ^^^ +;;! ^ +(when_expression + (when_subject + (_) @value + ) + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf +) @value.domain @branch.iteration.domain @condition.iteration.domain +;;!! 0, 1 -> break +;;! ^ ^ (when_entry - [ - (when_condition) - "else" - ] @condition + (when_condition) @condition (#allow-multiple! @condition) -) @_.domain +) @branch @condition.domain -(when_expression) @branch.iteration @condition.iteration +;;!! 0 -> break +;;! ^^^^^^ +(when_entry + "->" @interior.start.endOf + (control_structure_body + . + (_) + ) @interior.end.endOf +) @interior.domain -(if_expression - "if" - . - "(" - . - (_) @condition - . - ")" -) @_.domain +;; (if_expression +;; "if" +;; . +;; "(" +;; . +;; (_) @condition +;; . +;; ")" +;; ) @_.domain ;; If branch -(if_expression - "if" @branch.start @branch.removal.start - . - "(" - . - (_) - . - ")" - . - (control_structure_body) @branch.end @branch.removal.end - ( - "else" - (control_structure_body) @branch.removal.end.startOf - )? -) +;; (if_expression +;; "if" @branch.start @branch.removal.start +;; . +;; "(" +;; . +;; (_) +;; . +;; ")" +;; . +;; (control_structure_body) @branch.end @branch.removal.end +;; ( +;; "else" +;; (control_structure_body) @branch.removal.end.startOf +;; )? +;; ) ;; Else-if branch -(if_expression - "else" @branch.start @condition.domain.start - (control_structure_body - (if_expression - "if" - . - "(" - . - (_) @condition - . - ")" - . - (control_structure_body) @branch.end @condition.domain.end - ) - ) -) +;; (if_expression +;; "else" @branch.start @condition.domain.start +;; (control_structure_body +;; (if_expression +;; "if" +;; . +;; "(" +;; . +;; (_) @condition +;; . +;; ")" +;; . +;; (control_structure_body) @branch.end @condition.domain.end +;; ) +;; ) +;; ) ;; Else branch -(if_expression - "else" @branch.start - (control_structure_body) @branch.end -) +;; (if_expression +;; "else" @branch.start +;; (control_structure_body) @branch.end +;; ) (while_statement "while" @@ -216,11 +260,6 @@ . ) @_.domain -(when_expression - (when_subject) @value - (#child-range! @value 0 -1 true true) -) @_.domain - ;; ;; Name, value, type, and key ;; @@ -478,82 +517,82 @@ ">" @type.iteration.end.startOf ) -(anonymous_function - ":" - . - (_) @type.start - (_)? @type.end - . - (function_body) -) @_.domain +;; (anonymous_function +;; ":" +;; .u +;; (_) @type.start +;; (_)? @type.end +;; . +;; (function_body) +;; ) @_.domain -( - (anonymous_function - ":" - . - (_) @type - . - ) @_.domain -) -( - (anonymous_function - ":" - . - (_) @type.start - (_) @type.end - . - ) @_.domain - (#not-type? @type.end "function_body") -) +;; ( +;; (anonymous_function +;; ":" +;; . +;; (_) @type +;; . +;; ) @_.domain +;; ) +;; ( +;; (anonymous_function +;; ":" +;; . +;; (_) @type.start +;; (_) @type.end +;; . +;; ) @_.domain +;; (#not-type? @type.end "function_body") +;; ) +;;!! catch (e: Exception) {} +;;! ^ +;;! ^^^^^^^^^^ (catch_block - (simple_identifier) @name + (simple_identifier) @name @name.domain.start @value.domain.start ":" - . - (_) @type.start - (_)? @type.end - . - ")" -) @_.domain + (_) @type @name.domain.end @value.domain.end +) +;;!! return 0 +;;! ^ (jump_expression [ "return" "throw" ] - . (_) @value -) @_.domain +) @value.domain -(jump_expression - "return@" - . - (label) - . - (_) @value -) @_.domain +;; (jump_expression +;; "return@" +;; . +;; (label) +;; . +;; (_) @value +;; ) @_.domain -(_ - (function_body - "=" - . - (_) @value - ) -) @_.domain +;; (_ +;; (function_body +;; "=" +;; . +;; (_) @value +;; ) +;; ) @_.domain -(value_argument - (simple_identifier) @name - "=" - . - (_) @value.start -) @value.end.endOf @_.domain +;; (value_argument +;; (simple_identifier) @name +;; "=" +;; . +;; (_) @value.start +;; ) @value.end.endOf @_.domain -(infix_expression - (_) @collectionKey - (simple_identifier) @_dummy - (#eq? @_dummy "to") - (_) @value -) @_.domain +;; (infix_expression +;; (_) @collectionKey +;; (simple_identifier) @_dummy +;; (#eq? @_dummy "to") +;; (_) @value +;; ) @_.domain ;; ;; Function call, callee, arguments, and parameters From 4dd2225b6d24b321684a287f9518eff335839143 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 14:57:40 +0100 Subject: [PATCH 08/31] branch --- .../kotlin/branch/branch.if.elif.else.scope | 45 +++++++ .../scopes/kotlin/branch/branch.if.else.scope | 30 +++++ .../kotlin/branch/branch.if.iteration.scope | 12 ++ .../scopes/kotlin/branch/branch.if.scope | 10 ++ .../kotlin/branch/branch.switchCase.scope | 44 +++++++ .../branch/branch.ternary.iteration.scope | 7 + .../scopes/kotlin/branch/branch.ternary.scope | 33 +++++ .../kotlin/branch/branch.try.iteration.scope | 14 ++ .../scopes/kotlin/branch/branch.try.scope | 68 ++++++++++ queries/kotlin.scm | 122 ++++++++++++------ 10 files changed, 343 insertions(+), 42 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/branch/branch.if.elif.else.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.if.else.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.if.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.if.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.switchCase.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.ternary.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.ternary.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.try.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/branch/branch.try.scope diff --git a/data/fixtures/scopes/kotlin/branch/branch.if.elif.else.scope b/data/fixtures/scopes/kotlin/branch/branch.if.elif.else.scope new file mode 100644 index 0000000000..8bf55324af --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.if.elif.else.scope @@ -0,0 +1,45 @@ +if (true) {} +else if (false) {} +else {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| if (true) {} + +[#1 Removal] = 0:0-1:5 + >------------ +0| if (true) {} +1| else if (false) {} + -----< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:0-1:18 + >------------------< +1| else if (false) {} + +[#2 Removal] = 1:0-2:0 + >------------------ +1| else if (false) {} +2| else {} + < + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:0-2:7 + >-------< +2| else {} + +[#3 Removal] = 1:18-2:7 + > +1| else if (false) {} +2| else {} + -------< + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/branch/branch.if.else.scope b/data/fixtures/scopes/kotlin/branch/branch.if.else.scope new file mode 100644 index 0000000000..489c0edd09 --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.if.else.scope @@ -0,0 +1,30 @@ +if (true) {} +else {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| if (true) {} + +[#1 Removal] = 0:0-1:0 + >------------ +0| if (true) {} +1| else {} + < + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:0-1:7 + >-------< +1| else {} + +[#2 Removal] = 0:12-1:7 + > +0| if (true) {} +1| else {} + -------< + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/branch/branch.if.iteration.scope b/data/fixtures/scopes/kotlin/branch/branch.if.iteration.scope new file mode 100644 index 0000000000..84064bd4fa --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.if.iteration.scope @@ -0,0 +1,12 @@ +if (true) {} +else if (false) {} +else {} +--- + +[Content] = +[Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< diff --git a/data/fixtures/scopes/kotlin/branch/branch.if.scope b/data/fixtures/scopes/kotlin/branch/branch.if.scope new file mode 100644 index 0000000000..26855fbbaa --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.if.scope @@ -0,0 +1,10 @@ +if (true) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| if (true) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/branch/branch.switchCase.scope b/data/fixtures/scopes/kotlin/branch/branch.switchCase.scope new file mode 100644 index 0000000000..a4db6df212 --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.switchCase.scope @@ -0,0 +1,44 @@ +when (foo) { + 0 -> + break + else -> {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-2:13 + >---- +1| 0 -> +2| break + -------------< + +[#1 Removal] = 1:0-3:0 + >-------- +1| 0 -> +2| break +3| else -> {} + < + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| 0 -> + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 3:4-3:14 + >----------< +3| else -> {} + +[#2 Removal] = 3:0-4:0 + >-------------- +3| else -> {} +4| } + < + +[#2 Leading delimiter] = 3:0-3:4 + >----< +3| else -> {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/branch/branch.ternary.iteration.scope b/data/fixtures/scopes/kotlin/branch/branch.ternary.iteration.scope new file mode 100644 index 0000000000..169fec3094 --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.ternary.iteration.scope @@ -0,0 +1,7 @@ +if (true) 0 else 1 +--- + +[Content] = +[Domain] = 0:0-0:18 + >------------------< +0| if (true) 0 else 1 diff --git a/data/fixtures/scopes/kotlin/branch/branch.ternary.scope b/data/fixtures/scopes/kotlin/branch/branch.ternary.scope new file mode 100644 index 0000000000..4829d09cdc --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.ternary.scope @@ -0,0 +1,33 @@ +if (true) 0 else 1 +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:11 + >-----------< +0| if (true) 0 else 1 + +[#1 Removal] = 0:0-0:12 + >------------< +0| if (true) 0 else 1 + +[#1 Trailing delimiter] = 0:11-0:12 + >-< +0| if (true) 0 else 1 + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:12-0:18 + >------< +0| if (true) 0 else 1 + +[#2 Removal] = 0:11-0:18 + >-------< +0| if (true) 0 else 1 + +[#2 Leading delimiter] = 0:11-0:12 + >-< +0| if (true) 0 else 1 + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/branch/branch.try.iteration.scope b/data/fixtures/scopes/kotlin/branch/branch.try.iteration.scope new file mode 100644 index 0000000000..9b5ab1f938 --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.try.iteration.scope @@ -0,0 +1,14 @@ +try { +} catch (ex: Exception) { +} finally { +} +--- + +[Content] = +[Domain] = 0:0-3:1 + >----- +0| try { +1| } catch (ex: Exception) { +2| } finally { +3| } + -< diff --git a/data/fixtures/scopes/kotlin/branch/branch.try.scope b/data/fixtures/scopes/kotlin/branch/branch.try.scope new file mode 100644 index 0000000000..a1ef010a2b --- /dev/null +++ b/data/fixtures/scopes/kotlin/branch/branch.try.scope @@ -0,0 +1,68 @@ +try { +} catch (ex: Exception) { +} finally { +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-1:1 + >----- +0| try { +1| } catch (ex: Exception) { + -< + +[#1 Removal] = 0:0-1:2 + >----- +0| try { +1| } catch (ex: Exception) { + --< + +[#1 Trailing delimiter] = 1:1-1:2 + >-< +1| } catch (ex: Exception) { + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:2-2:1 + >----------------------- +1| } catch (ex: Exception) { +2| } finally { + -< + +[#2 Removal] = 1:2-2:2 + >----------------------- +1| } catch (ex: Exception) { +2| } finally { + --< + +[#2 Leading delimiter] = 1:1-1:2 + >-< +1| } catch (ex: Exception) { + +[#2 Trailing delimiter] = 2:1-2:2 + >-< +2| } finally { + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:2-3:1 + >--------- +2| } finally { +3| } + -< + +[#3 Removal] = 2:1-3:1 + >---------- +2| } finally { +3| } + -< + +[#3 Leading delimiter] = 2:1-2:2 + >-< +2| } finally { + +[#3 Insertion delimiter] = "\n" diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 97f3fdbea3..836f2d0a73 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -81,38 +81,6 @@ "}" @interior.end.startOf ) -;; Top level if statement -( - (_ - (if_expression - condition: (_) @condition - ) @ifStatement @statement @condition.domain - ) @_dummy - (#not-parent-type? @_dummy if_expression) -) - -;;!! else if (true) {} -(if_expression - "else" @condition.domain.start - (control_structure_body - (if_expression - condition: (_) @condition - consequence: (_) @condition.domain.end - ) - ) -) - -;;!! else {} -;; (if_expression -;; "else" @statement.start -;; (control_structure_body) @statement.end -;; ) - -;;!! class Foo {} -(class_declaration - (type_identifier) @name -) @class @type @name.domain - ;; (object_declaration ;; (type_identifier) @name ;; ) @class @name.domain @@ -162,6 +130,77 @@ ;; Branches and conditions ;; +;; Top level if statement +( + (_ + (if_expression) @ifStatement @statement @branch.iteration + ) @_dummy + (#not-parent-type? @_dummy if_expression) +) + +( + (_ + (if_expression + "if" @branch.start @branch.removal.start.startOf + condition: (_) @condition + consequence: (_) @branch.end @branch.removal.end.endOf + "else"? @branch.removal.end.startOf + alternative: (control_structure_body + . + (if_expression) @branch.removal.end.startOf + )? + ) @condition.domain + ) @_dummy + (#not-parent-type? @_dummy if_expression) +) + +;;!! else if (true) {} +(if_expression + "else" @condition.domain.start @branch.start + (control_structure_body + (if_expression + condition: (_) @condition + consequence: (_) @condition.domain.end @branch.end + ) + ) +) + +;;!! else {} +(if_expression + "else" @branch.start + (control_structure_body + "{" + ) @branch.end +) + +;;!! if (true) 0 else 1 +;;! ^^^^^^ +(if_expression + "else" @branch.start + (control_structure_body + . + (_) @_dummy + ) @branch.end + (#not-type? @_dummy if_expression) +) + +;;!! try {} catch {} +(try_expression + "try" @branch.start + "}" @branch.end +) @branch.iteration + +;;!! catch (e: Exception) {} +;;! ^ +;;! ^^^^^^^^^^ +(catch_block + (simple_identifier) @name @name.domain.start @value.domain.start + ":" + (_) @type @name.domain.end @value.domain.end +) @branch + +(finally_block) @branch + ;;!! when (foo) { } ;;! ^^^ ;;! ^ @@ -173,12 +212,15 @@ "}" @branch.iteration.end.startOf @condition.iteration.end.startOf ) @value.domain @branch.iteration.domain @condition.iteration.domain +;;!! 0 -> break +(when_entry) @branch + ;;!! 0, 1 -> break ;;! ^ ^ (when_entry (when_condition) @condition (#allow-multiple! @condition) -) @branch @condition.domain +) @condition.domain ;;!! 0 -> break ;;! ^^^^^^ @@ -275,6 +317,11 @@ (_) @value.start @type.start ) @value.end.endOf @type.end.endOf @_.domain +;;!! class Foo {} +(class_declaration + (type_identifier) @name +) @class @type @name.domain + (class_parameter (simple_identifier) @name ) @_.domain @@ -545,15 +592,6 @@ ;; (#not-type? @type.end "function_body") ;; ) -;;!! catch (e: Exception) {} -;;! ^ -;;! ^^^^^^^^^^ -(catch_block - (simple_identifier) @name @name.domain.start @value.domain.start - ":" - (_) @type @name.domain.end @value.domain.end -) - ;;!! return 0 ;;! ^ (jump_expression From f49b5350427318cf4b08bfdbb761c6c900d94d70 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 17:32:46 +0100 Subject: [PATCH 09/31] More work --- queries/kotlin.scm | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 836f2d0a73..e8c6465079 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -1,3 +1,5 @@ +;; https://github.com/fwcd/tree-sitter-kotlin/blob/main/src/grammar.json + ;; ;; Declarations and statements ;; @@ -642,6 +644,41 @@ (constructor_delegation_call) ] @functionCall +;;!! fun foo(aaa: Int, bbb: Int) {} +;;! ^^^^^^^^^^^^^^^^^^ +(_ + (function_value_parameters + "(" @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 + +;;!! class Foo(aaa: Int, bbb: Int) {} +;;! ^^^^^^^^^^^^^^^^^^ +(_ + (primary_constructor + "(" @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 + +;;!! foo(aaa, bbb) +;;! ^^^^^^^^ +(_ + (call_suffix + (value_arguments + "(" @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 + ( (value_arguments (_)? @_.leading.endOf From 44882d0a27b4e1c30bd85228db1865c3996f6418 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 18:03:07 +0100 Subject: [PATCH 10/31] More tests --- ...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 | 13 +++++++ ...entList.formal.constructor.multiLine.scope | 35 ++++++++++++++++++ ...ntList.formal.constructor.multiLine2.scope | 33 +++++++++++++++++ ...ntList.formal.constructor.singleLine.scope | 15 ++++++++ ...tList.formal.constructor.singleLine2.scope | 13 +++++++ .../argumentList.formal.method.empty.scope | 15 ++++++++ ...argumentList.formal.method.multiLine.scope | 36 +++++++++++++++++++ ...rgumentList.formal.method.singleLine.scope | 15 ++++++++ queries/kotlin.scm | 24 ++++++------- 18 files changed, 364 insertions(+), 12 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.empty.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.empty.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.empty.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.empty.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.singleLine.scope diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty.scope new file mode 100644 index 0000000000..58e2245d03 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty.scope @@ -0,0 +1,13 @@ +Foo() +--- + +[Content] = +[Removal] = 0:4-0:4 + >< +0| Foo() + +[Domain] = 0:0-0:5 + >-----< +0| Foo() + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..06616a6faf --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine.scope @@ -0,0 +1,33 @@ +Foo( + aaa, + bbb +) +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:4-3:0 + > +0| Foo( +1| aaa, +2| bbb +3| ) + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:0-3:1 + >---- +0| Foo( +1| aaa, +2| bbb +3| ) + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..77680199f4 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine.scope @@ -0,0 +1,13 @@ +Foo(aaa, bbb) +--- + +[Content] = +[Removal] = 0:4-0:12 + >--------< +0| Foo(aaa, bbb) + +[Domain] = 0:0-0:13 + >-------------< +0| Foo(aaa, bbb) + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.empty.scope new file mode 100644 index 0000000000..947915ef96 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.empty.scope @@ -0,0 +1,13 @@ +foo() +--- + +[Content] = +[Removal] = 0:4-0:4 + >< +0| foo() + +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.empty.scope new file mode 100644 index 0000000000..ed61422204 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.empty.scope @@ -0,0 +1,13 @@ +foo.bar() +--- + +[Content] = +[Removal] = 0:8-0:8 + >< +0| foo.bar() + +[Domain] = 0:0-0:9 + >---------< +0| foo.bar() + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.multiLine.scope new file mode 100644 index 0000000000..fbf6ce60c0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.multiLine.scope @@ -0,0 +1,33 @@ +foo.bar( + aaa, + bbb +) +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:8-3:0 + > +0| foo.bar( +1| aaa, +2| bbb +3| ) + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:0-3:1 + >-------- +0| foo.bar( +1| aaa, +2| bbb +3| ) + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.singleLine.scope new file mode 100644 index 0000000000..69cf068256 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.method.singleLine.scope @@ -0,0 +1,13 @@ +foo.bar(aaa, bbb) +--- + +[Content] = +[Removal] = 0:8-0:16 + >--------< +0| foo.bar(aaa, bbb) + +[Domain] = 0:0-0:17 + >-----------------< +0| foo.bar(aaa, bbb) + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.multiLine.scope new file mode 100644 index 0000000000..642614d02e --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.multiLine.scope @@ -0,0 +1,33 @@ +foo( + aaa, + bbb +) +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:4-3:0 + > +0| foo( +1| aaa, +2| bbb +3| ) + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:0-3:1 + >---- +0| foo( +1| aaa, +2| bbb +3| ) + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.singleLine.scope new file mode 100644 index 0000000000..f0de18dd5d --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.singleLine.scope @@ -0,0 +1,13 @@ +foo(aaa, bbb) +--- + +[Content] = +[Removal] = 0:4-0:12 + >--------< +0| foo(aaa, bbb) + +[Domain] = 0:0-0:13 + >-------------< +0| foo(aaa, bbb) + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.empty.scope new file mode 100644 index 0000000000..ef9aee1a16 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.empty.scope @@ -0,0 +1,13 @@ +class Foo() {} +--- + +[Content] = +[Removal] = 0:10-0:10 + >< +0| class Foo() {} + +[Domain] = 0:0-0:14 + >--------------< +0| class Foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..b794300da7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine.scope @@ -0,0 +1,35 @@ +class Foo { + constructor( + aaa: Int, + bbb: Int + ) {} +} +--- + +[Content] = 2:8-3:16 + >--------- +2| aaa: Int, +3| bbb: Int + ----------------< + +[Removal] = 1:16-4:4 + > +1| constructor( +2| aaa: Int, +3| bbb: Int +4| ) {} + ----< + +[Leading delimiter] = 2:0-2:8 + >--------< +2| aaa: Int, + +[Domain] = 1:4-4:8 + >------------ +1| constructor( +2| aaa: Int, +3| bbb: Int +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine2.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine2.scope new file mode 100644 index 0000000000..b6169a8c3e --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.multiLine2.scope @@ -0,0 +1,33 @@ +class Foo( + aaa: Int, + bbb: Int +) {} +--- + +[Content] = 1:4-2:12 + >--------- +1| aaa: Int, +2| bbb: Int + ------------< + +[Removal] = 0:10-3:0 + > +0| class Foo( +1| aaa: Int, +2| bbb: Int +3| ) {} + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa: Int, + +[Domain] = 0:0-3:4 + >---------- +0| class Foo( +1| aaa: Int, +2| bbb: Int +3| ) {} + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..a8e6de8abc --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine.scope @@ -0,0 +1,15 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[Content] = +[Removal] = 1:16-1:34 + >------------------< +1| constructor(aaa: Int, bbb: Int) {} + +[Domain] = 1:4-1:38 + >----------------------------------< +1| constructor(aaa: Int, bbb: Int) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine2.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine2.scope new file mode 100644 index 0000000000..2c4a96e79b --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.constructor.singleLine2.scope @@ -0,0 +1,13 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[Content] = +[Removal] = 0:10-0:28 + >------------------< +0| class Foo(aaa: Int, bbb: Int) {} + +[Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.empty.scope new file mode 100644 index 0000000000..f2a5f48d4a --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.empty.scope @@ -0,0 +1,15 @@ +class Foo { + fun bar() {} +} +--- + +[Content] = +[Removal] = 1:12-1:12 + >< +1| fun bar() {} + +[Domain] = 1:4-1:16 + >------------< +1| fun bar() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.multiLine.scope new file mode 100644 index 0000000000..fd47d799de --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.multiLine.scope @@ -0,0 +1,36 @@ +class Foo { + void bar( + aaa: Int, + bbb: Int + ) {} +} +--- + +[Content] = 2:8-3:16 + >--------- +2| aaa: Int, +3| bbb: Int + ----------------< + +[Removal] = 1:13-4:4 + > +1| void bar( +2| aaa: Int, +3| bbb: Int +4| ) {} + ----< + +[Leading delimiter] = 2:0-2:8 + >--------< +2| aaa: Int, + +[Domain] = 0:0-4:8 + >----------- +0| class Foo { +1| void bar( +2| aaa: Int, +3| bbb: Int +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.singleLine.scope new file mode 100644 index 0000000000..9df3a17bbe --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.method.singleLine.scope @@ -0,0 +1,15 @@ +class Foo { + fun bar(aaa: Int, bbb: Int) {} +} +--- + +[Content] = +[Removal] = 1:12-1:30 + >------------------< +1| fun bar(aaa: Int, bbb: Int) {} + +[Domain] = 1:4-1:34 + >------------------------------< +1| fun bar(aaa: Int, bbb: Int) {} + +[Insertion delimiter] = ", " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index e8c6465079..769bf5de58 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -709,12 +709,12 @@ (user_type) @functionCallee ) @_.domain -(constructor_invocation - (value_arguments - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @argumentOrParameter.iteration.domain +;; (constructor_invocation +;; (value_arguments +;; "(" @argumentOrParameter.iteration.start.endOf +;; ")" @argumentOrParameter.iteration.end.startOf +;; ) +;; ) @argumentOrParameter.iteration.domain (constructor_delegation_call [ @@ -723,12 +723,12 @@ ] @functionCallee ) @_.domain -(constructor_delegation_call - (value_arguments - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @argumentOrParameter.iteration.domain +;; (constructor_delegation_call +;; (value_arguments +;; "(" @argumentOrParameter.iteration.start.endOf +;; ")" @argumentOrParameter.iteration.end.startOf +;; ) +;; ) @argumentOrParameter.iteration.domain ;;!! BAR, (enum_entry From 8f5db8734391c54ae7984d0b5eaef7cde618abbd Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 1 Feb 2026 19:34:43 +0100 Subject: [PATCH 11/31] More tests --- ...rgument.actual.constructor.iteration.scope | 10 ++++++ .../argument/argument.actual.iteration.scope | 10 ++++++ .../argument.formal.lambda.iteration.scope | 10 ++++++ ...argumentList.formal.lambda.multiLine.scope | 35 +++++++++++++++++++ ...rgumentList.formal.lambda.singleLine.scope | 24 +++++++++++++ queries/kotlin.scm | 7 ++++ 6 files changed, 96 insertions(+) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.singleLine.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration.scope new file mode 100644 index 0000000000..69ff7aa216 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration.scope @@ -0,0 +1,10 @@ +Foo(aaa, bbb) +--- + +[Content] = 0:4-0:12 + >--------< +0| Foo(aaa, bbb) + +[Domain] = 0:0-0:13 + >-------------< +0| Foo(aaa, bbb) diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.iteration.scope new file mode 100644 index 0000000000..1b28526f67 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.iteration.scope @@ -0,0 +1,10 @@ +foo(aaa, bbb) +--- + +[Content] = 0:4-0:12 + >--------< +0| foo(aaa, bbb) + +[Domain] = 0:0-0:13 + >-------------< +0| foo(aaa, bbb) diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..11a8eddbfb --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.iteration.scope @@ -0,0 +1,10 @@ +{ aaa, bbb -> } +--- + +[Content] = 0:2-0:10 + >--------< +0| { aaa, bbb -> } + +[Domain] = 0:0-0:15 + >---------------< +0| { aaa, bbb -> } diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..b5e43d7998 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.multiLine.scope @@ -0,0 +1,35 @@ +{ + aaa, + bbb -> +} +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb -> + -------< + +[Removal] = 1:4-2:8 + >---- +1| aaa, +2| bbb -> + --------< + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Trailing delimiter] = 2:7-2:8 + >-< +2| bbb -> + +[Domain] = 0:0-3:1 + >- +0| { +1| aaa, +2| bbb -> +3| } + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..37f9417c86 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.singleLine.scope @@ -0,0 +1,24 @@ +{ aaa, bbb -> } +--- + +[Content] = 0:2-0:10 + >--------< +0| { aaa, bbb -> } + +[Removal] = 0:2-0:11 + >---------< +0| { aaa, bbb -> } + +[Leading delimiter] = 0:1-0:2 + >-< +0| { aaa, bbb -> } + +[Trailing delimiter] = 0:10-0:11 + >-< +0| { aaa, bbb -> } + +[Domain] = 0:0-0:15 + >---------------< +0| { aaa, bbb -> } + +[Insertion delimiter] = ", " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 769bf5de58..7ef3e48e0e 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -655,6 +655,13 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +;;!! { aaa, bbb -> } +;;! ^^^^^^^^ +(_ + (lambda_parameters) @argumentList @argumentOrParameter.iteration + (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") +) @argumentList.domain @argumentOrParameter.iteration.domain + ;;!! class Foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ (_ From 800f7faac9919b89e5ee3f7ac4562baf7d4e0f07 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 08:54:04 +0100 Subject: [PATCH 12/31] more iteration --- .../argument.actual.method.iteration.scope | 10 + ...rgument.formal.constructor.iteration.scope | 12 + ...gument.formal.constructor.iteration2.scope | 10 + ...rgument.formal.constructor.iteration.scope | 27 ++ ...gument.formal.constructor.iteration2.scope | 13 + ...ame.argument.formal.method.iteration.scope | 27 ++ ...rgument.formal.constructor.iteration.scope | 27 ++ ...gument.formal.constructor.iteration2.scope | 13 + ...ype.argument.formal.method.iteration.scope | 27 ++ .../type/type.typeArgument.iteration.scope | 13 + queries/kotlin.scm | 306 +++++++++--------- 11 files changed, 339 insertions(+), 146 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.method.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.typeArgument.iteration.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.method.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.method.iteration.scope new file mode 100644 index 0000000000..8b3899b4a1 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.method.iteration.scope @@ -0,0 +1,10 @@ +foo.bar(aaa, bbb) +--- + +[Content] = 0:8-0:16 + >--------< +0| foo.bar(aaa, bbb) + +[Domain] = 0:0-0:17 + >-----------------< +0| foo.bar(aaa, bbb) diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..8a0d372d4c --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope @@ -0,0 +1,12 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[Content] = 1:16-1:34 + >------------------< +1| constructor(aaa: Int, bbb: Int) {} + +[Domain] = 1:4-1:38 + >----------------------------------< +1| constructor(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope new file mode 100644 index 0000000000..3b4393dee0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope @@ -0,0 +1,10 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[Content] = 0:10-0:28 + >------------------< +0| class Foo(aaa: Int, bbb: Int) {} + +[Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..d58138ab5c --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| constructor(aaa: Int, bbb: Int) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| constructor(aaa: Int, bbb: Int) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:34 + >------------------< +1| constructor(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration2.scope new file mode 100644 index 0000000000..44868ed858 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.iteration2.scope @@ -0,0 +1,13 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} + + +[#2 Content] = +[#2 Domain] = 0:10-0:28 + >------------------< +0| class Foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..d4b45da11e --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar(aaa: Int, bbb: Int) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar(aaa: Int, bbb: Int) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:12-1:30 + >------------------< +1| fun bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..d58138ab5c --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| constructor(aaa: Int, bbb: Int) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| constructor(aaa: Int, bbb: Int) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:34 + >------------------< +1| constructor(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration2.scope new file mode 100644 index 0000000000..44868ed858 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.iteration2.scope @@ -0,0 +1,13 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} + + +[#2 Content] = +[#2 Domain] = 0:10-0:28 + >------------------< +0| class Foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..d4b45da11e --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar(aaa: Int, bbb: Int) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar(aaa: Int, bbb: Int) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:12-1:30 + >------------------< +1| fun bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/type/type.typeArgument.iteration.scope b/data/fixtures/scopes/kotlin/type/type.typeArgument.iteration.scope new file mode 100644 index 0000000000..d9b46b9799 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.typeArgument.iteration.scope @@ -0,0 +1,13 @@ +var foo: Map +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:22 + >----------------------< +0| var foo: Map + + +[#2 Content] = +[#2 Domain] = 0:13-0:21 + >--------< +0| var foo: Map diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 7ef3e48e0e..a8df88121d 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -638,11 +638,46 @@ ;; Function call, callee, arguments, and parameters ;; -[ - (call_expression) - (constructor_invocation) - (constructor_delegation_call) -] @functionCall +;; [ +;; (call_expression) +;; ;; (constructor_invocation) +;; ;; (constructor_delegation_call) +;; ] @functionCall + +;;!! foo() +;;! ^^^ +(call_expression + [ + (simple_identifier) + (navigation_expression) + ] @functionCallee +) @functionCall @functionCallee.domain + +;; (call_suffix +;; (annotated_lambda) @argumentOrParameter +;; ) + +;; (call_expression +;; (call_suffix) @argumentOrParameter.iteration +;; ) @argumentOrParameter.iteration.domain + +;; (constructor_invocation +;; (user_type) @functionCallee +;; ) @_.domain + +;; (constructor_invocation +;; (value_arguments +;; "(" @argumentOrParameter.iteration.start.endOf +;; ")" @argumentOrParameter.iteration.end.startOf +;; ) +;; ) @argumentOrParameter.iteration.domain + +;; (constructor_delegation_call +;; [ +;; "this" +;; "super" +;; ] @functionCallee +;; ) @_.domain ;;!! fun foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ @@ -655,6 +690,11 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +(function_value_parameters + "(" @name.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @type.iteration.end.startOf +) + ;;!! { aaa, bbb -> } ;;! ^^^^^^^^ (_ @@ -673,6 +713,11 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +(primary_constructor + "(" @name.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @type.iteration.end.startOf +) + ;;!! foo(aaa, bbb) ;;! ^^^^^^^^ (_ @@ -686,6 +731,11 @@ ) ) @argumentList.domain @argumentOrParameter.iteration.domain +(value_arguments + "(" @name.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @type.iteration.end.startOf +) + ( (value_arguments (_)? @_.leading.endOf @@ -697,39 +747,6 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) -(call_expression - (_) @functionCallee.start - (call_suffix - (type_arguments)? @functionCallee.end - ) -) @_.domain.start - -;; (call_suffix -;; (annotated_lambda) @argumentOrParameter -;; ) - -;; (call_expression -;; (call_suffix) @argumentOrParameter.iteration -;; ) @argumentOrParameter.iteration.domain - -(constructor_invocation - (user_type) @functionCallee -) @_.domain - -;; (constructor_invocation -;; (value_arguments -;; "(" @argumentOrParameter.iteration.start.endOf -;; ")" @argumentOrParameter.iteration.end.startOf -;; ) -;; ) @argumentOrParameter.iteration.domain - -(constructor_delegation_call - [ - "this" - "super" - ] @functionCallee -) @_.domain - ;; (constructor_delegation_call ;; (value_arguments ;; "(" @argumentOrParameter.iteration.start.endOf @@ -745,121 +762,118 @@ ;;!! BAR() (enum_entry (simple_identifier) @functionCallee - (value_arguments - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @functionCall @functionCallee.domain @argumentOrParameter.iteration.domain + (value_arguments) +) @functionCall @functionCallee.domain -( - (function_value_parameters - (_)? @_.leading.endOf - . - [ - "," - "(" - ] - . - [ - (line_comment) - (multiline_comment) - ] * - . - (parameter_modifiers)? @argumentOrParameter.start - . - (parameter) @argumentOrParameter.end - . - [ - (line_comment) - (multiline_comment) - ] * - . - [ - "," - ")" - ] - . - (_)? @_.trailing.startOf - ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") -) +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; [ +;; "," +;; "(" +;; ] +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; (parameter_modifiers)? @argumentOrParameter.start +;; . +;; (parameter) @argumentOrParameter.end +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") +;; ) -( - (function_value_parameters - (_)? @_.leading.endOf - . - [ - "," - "(" - ] - . - [ - (line_comment) - (multiline_comment) - ] * - . - (parameter_modifiers)? @argumentOrParameter.start.startOf - . - (parameter) @argumentOrParameter.start - . - (_) @argumentOrParameter.end - (#not-type? @argumentOrParameter.end "parameter" "parameter_modifiers") - . - [ - (line_comment) - (multiline_comment) - ] * - . - [ - "," - ")" - ] - . - (_)? @_.trailing.startOf - ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") -) +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; [ +;; "," +;; "(" +;; ] +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; (parameter_modifiers)? @argumentOrParameter.start.startOf +;; . +;; (parameter) @argumentOrParameter.start +;; . +;; (_) @argumentOrParameter.end +;; (#not-type? @argumentOrParameter.end "parameter" "parameter_modifiers") +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") +;; ) -(_ - (function_value_parameters) @argumentOrParameter.iteration -) @argumentOrParameter.iteration.domain +;; (_ +;; (function_value_parameters) @argumentOrParameter.iteration +;; ) @argumentOrParameter.iteration.domain -( - (primary_constructor - (_)? @_.leading.endOf - . - (class_parameter) @argumentOrParameter - . - (_)? @_.trailing.startOf - ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -) +;; ( +;; (primary_constructor +;; (_)? @_.leading.endOf +;; . +;; (class_parameter) @argumentOrParameter +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +;; ) -(class_declaration - (primary_constructor) @argumentOrParameter.iteration -) @argumentOrParameter.iteration.domain +;; (class_declaration +;; (primary_constructor) @argumentOrParameter.iteration +;; ) @argumentOrParameter.iteration.domain -(parameter_with_optional_type) @argumentOrParameter +;; (parameter_with_optional_type) @argumentOrParameter ;; There is only one parameter allowed, but we treat it as iterable for consistency. -(setter - (parameter_with_optional_type) @argumentOrParameter.iteration -) @argumentOrParameter.iteration.domain +;; (setter +;; (parameter_with_optional_type) @argumentOrParameter.iteration +;; ) @argumentOrParameter.iteration.domain -( - (lambda_parameters - (_)? @_.leading.endOf - . - [ - (variable_declaration) - (multi_variable_declaration) - ] @argumentOrParameter - . - (_)? @_.trailing.startOf - ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -) +;; ( +;; (lambda_parameters +;; (_)? @_.leading.endOf +;; . +;; [ +;; (variable_declaration) +;; (multi_variable_declaration) +;; ] @argumentOrParameter +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +;; ) -(lambda_literal - (lambda_parameters) @argumentOrParameter.iteration -) @argumentOrParameter.iteration.domain +;; (lambda_literal +;; (lambda_parameters) @argumentOrParameter.iteration +;; ) @argumentOrParameter.iteration.domain From ed693c45fc91899a793c8f4d9247ac8cb0cedcc5 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 15:25:24 +0100 Subject: [PATCH 13/31] lambda --- .../argumentList.formal.lambda.empty.scope | 17 +++++++++++++++++ queries/kotlin.scm | 18 +++++++++++++----- 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.empty.scope diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.empty.scope new file mode 100644 index 0000000000..983545020d --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.lambda.empty.scope @@ -0,0 +1,17 @@ +{ -> } +--- + +[Content] = +[Removal] = 0:1-0:1 + >< +0| { -> } + +[Trailing delimiter] = 0:1-0:2 + >-< +0| { -> } + +[Domain] = 0:0-0:6 + >------< +0| { -> } + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index a8df88121d..c618eb489a 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -106,10 +106,7 @@ ;;!! {x -> 0} (lambda_literal - ( - "->" - (_) @value - )? + (statements)? @value ) @anonymousFunction @value.domain ;; @@ -697,11 +694,22 @@ ;;!! { aaa, bbb -> } ;;! ^^^^^^^^ -(_ +(lambda_literal (lambda_parameters) @argumentList @argumentOrParameter.iteration (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") ) @argumentList.domain @argumentOrParameter.iteration.domain +;;!! { -> } +(lambda_literal + "{" @argumentList.start.endOf @argumentList.removal.start.endOf + . + [ + (statements) + "->" + "}" + ] +) @argumentList.domain + ;;!! class Foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ (_ From 483b991c3bb849cbced3b6cbf97b1226f4dcec46 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 16:38:42 +0100 Subject: [PATCH 14/31] type and name --- .../name.argument.formal.constructor.scope | 76 ++++ .../name.argument.formal.constructor2.scope | 48 +++ .../name/name.argument.formal.method.scope | 76 ++++ .../kotlin/type/type.argument.catch.scope | 42 ++ .../type.argument.formal.constructor.scope | 53 +++ .../type.argument.formal.constructor2.scope | 48 +++ .../type/type.argument.formal.method.scope | 53 +++ .../scopes/kotlin/type/type.field.class.scope | 55 +++ .../kotlin/type/type.field.interface.scope | 34 ++ .../scopes/kotlin/type/type.foreach.scope | 20 + .../scopes/kotlin/type/type.return.scope | 20 + .../kotlin/type/type.typeArgument.scope | 52 +++ .../scopes/kotlin/type/type.variable.scope | 20 + .../scopes/kotlin/type/type.variable2.scope | 20 + queries/kotlin.scm | 368 ++++++++++-------- 15 files changed, 819 insertions(+), 166 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.catch.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.field.class.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.field.interface.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.foreach.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.return.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.typeArgument.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.variable.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.variable2.scope diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope new file mode 100644 index 0000000000..44e37cd531 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope @@ -0,0 +1,76 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[#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| constructor(aaa: Int, bbb: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:4-1:15 + >-----------< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Domain] = 1:4-1:38 + >----------------------------------< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:16-1:19 + >---< +1| constructor(aaa: Int, bbb: Int) {} + +[#3 Domain] = 1:16-1:24 + >--------< +1| constructor(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:26-1:29 + >---< +1| constructor(aaa: Int, bbb: Int) {} + +[#4 Removal] = 1:25-1:29 + >----< +1| constructor(aaa: Int, bbb: Int) {} + +[#4 Leading delimiter] = 1:25-1:26 + >-< +1| constructor(aaa: Int, bbb: Int) {} + +[#4 Domain] = 1:26-1:34 + >--------< +1| constructor(aaa: Int, bbb: Int) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope new file mode 100644 index 0000000000..7fe4e513b6 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope @@ -0,0 +1,48 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Removal] = 0:6-0:9 + >---< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:10-0:13 + >---< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 0:10-0:18 + >--------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:20-0:23 + >---< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Removal] = 0:19-0:23 + >----< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 0:19-0:20 + >-< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Domain] = 0:20-0:28 + >--------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope new file mode 100644 index 0000000000..053f227429 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope @@ -0,0 +1,76 @@ +class Foo { + fun foo(aaa: Int, bbb: Int) {} +} +--- + +[#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| fun foo(aaa: Int, bbb: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:8-1:11 + >---< +1| fun foo(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| fun foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 1:4-1:34 + >------------------------------< +1| fun foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:12-1:15 + >---< +1| fun foo(aaa: Int, bbb: Int) {} + +[#3 Domain] = 1:12-1:20 + >--------< +1| fun foo(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:22-1:25 + >---< +1| fun foo(aaa: Int, bbb: Int) {} + +[#4 Removal] = 1:21-1:25 + >----< +1| fun foo(aaa: Int, bbb: Int) {} + +[#4 Leading delimiter] = 1:21-1:22 + >-< +1| fun foo(aaa: Int, bbb: Int) {} + +[#4 Domain] = 1:22-1:30 + >--------< +1| fun foo(aaa: Int, bbb: Int) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.catch.scope b/data/fixtures/scopes/kotlin/type/type.argument.catch.scope new file mode 100644 index 0000000000..52c261a412 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.catch.scope @@ -0,0 +1,42 @@ +try { +} catch (e: MyException) { +} catch (e: Exception) { +} +--- + +[#1 Content] = 1:12-1:23 + >-----------< +1| } catch (e: MyException) { + +[#1 Removal] = 1:11-1:23 + >------------< +1| } catch (e: MyException) { + +[#1 Leading delimiter] = 1:11-1:12 + >-< +1| } catch (e: MyException) { + +[#1 Domain] = 1:9-1:23 + >--------------< +1| } catch (e: MyException) { + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:12-2:21 + >---------< +2| } catch (e: Exception) { + +[#2 Removal] = 2:11-2:21 + >----------< +2| } catch (e: Exception) { + +[#2 Leading delimiter] = 2:11-2:12 + >-< +2| } catch (e: Exception) { + +[#2 Domain] = 2:9-2:21 + >------------< +2| } catch (e: Exception) { + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope new file mode 100644 index 0000000000..d0c221e6b9 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope @@ -0,0 +1,53 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| constructor(aaa: Int, bbb: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:21-1:24 + >---< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Removal] = 1:19-1:24 + >-----< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:19-1:21 + >--< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Domain] = 1:16-1:24 + >--------< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:31-1:34 + >---< +1| constructor(aaa: Int, bbb: Int) {} + +[#3 Removal] = 1:29-1:34 + >-----< +1| constructor(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 1:29-1:31 + >--< +1| constructor(aaa: Int, bbb: Int) {} + +[#3 Domain] = 1:26-1:34 + >--------< +1| constructor(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope new file mode 100644 index 0000000000..f1d1721c04 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope @@ -0,0 +1,48 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:15-0:18 + >---< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Removal] = 0:13-0:18 + >-----< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 0:13-0:15 + >--< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 0:10-0:18 + >--------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:25-0:28 + >---< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Removal] = 0:23-0:28 + >-----< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 0:23-0:25 + >--< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Domain] = 0:20-0:28 + >--------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope new file mode 100644 index 0000000000..21a10260ff --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope @@ -0,0 +1,53 @@ +class Foo { + fun bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar(aaa: Int, bbb: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:17-1:20 + >---< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Removal] = 1:15-1:20 + >-----< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:15-1:17 + >--< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Domain] = 1:12-1:20 + >--------< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:27-1:30 + >---< +1| fun bar(aaa: Int, bbb: Int) {} + +[#3 Removal] = 1:25-1:30 + >-----< +1| fun bar(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 1:25-1:27 + >--< +1| fun bar(aaa: Int, bbb: Int) {} + +[#3 Domain] = 1:22-1:30 + >--------< +1| fun bar(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.field.class.scope b/data/fixtures/scopes/kotlin/type/type.field.class.scope new file mode 100644 index 0000000000..b4ae9a39e7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.field.class.scope @@ -0,0 +1,55 @@ +class Foo { + val bar: Int + var baz: Int = 0 +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| val bar: Int +2| var baz: Int = 0 +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:13-1:16 + >---< +1| val bar: Int + +[#2 Removal] = 1:11-1:16 + >-----< +1| val bar: Int + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| val bar: Int + +[#2 Domain] = 1:4-1:16 + >------------< +1| val bar: Int + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:13-2:16 + >---< +2| var baz: Int = 0 + +[#3 Removal] = 2:11-2:16 + >-----< +2| var baz: Int = 0 + +[#3 Leading delimiter] = 2:11-2:13 + >--< +2| var baz: Int = 0 + +[#3 Domain] = 2:4-2:20 + >----------------< +2| var baz: Int = 0 + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.field.interface.scope b/data/fixtures/scopes/kotlin/type/type.field.interface.scope new file mode 100644 index 0000000000..912dcfef90 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.field.interface.scope @@ -0,0 +1,34 @@ +interface Foo { + val bar: Int +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >--------------- +0| interface Foo { +1| val bar: Int +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:13-1:16 + >---< +1| val bar: Int + +[#2 Removal] = 1:11-1:16 + >-----< +1| val bar: Int + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| val bar: Int + +[#2 Domain] = 1:4-1:16 + >------------< +1| val bar: Int + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.foreach.scope b/data/fixtures/scopes/kotlin/type/type.foreach.scope new file mode 100644 index 0000000000..40e7127cf5 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.foreach.scope @@ -0,0 +1,20 @@ +for (v: Int in values) {} +--- + +[Content] = 0:8-0:11 + >---< +0| for (v: Int in values) {} + +[Removal] = 0:6-0:11 + >-----< +0| for (v: Int in values) {} + +[Leading delimiter] = 0:6-0:8 + >--< +0| for (v: Int in values) {} + +[Domain] = 0:0-0:25 + >-------------------------< +0| for (v: Int in values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.return.scope b/data/fixtures/scopes/kotlin/type/type.return.scope new file mode 100644 index 0000000000..d0334866dd --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.return.scope @@ -0,0 +1,20 @@ +fun foo(): Int {} +--- + +[Content] = 0:11-0:14 + >---< +0| fun foo(): Int {} + +[Removal] = 0:9-0:14 + >-----< +0| fun foo(): Int {} + +[Leading delimiter] = 0:9-0:11 + >--< +0| fun foo(): Int {} + +[Domain] = 0:0-0:17 + >-----------------< +0| fun foo(): Int {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.typeArgument.scope b/data/fixtures/scopes/kotlin/type/type.typeArgument.scope new file mode 100644 index 0000000000..15bfbbb685 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.typeArgument.scope @@ -0,0 +1,52 @@ +var foo: Map +--- + +[#1 Content] = 0:9-0:22 + >-------------< +0| var foo: Map + +[#1 Removal] = 0:7-0:22 + >---------------< +0| var foo: Map + +[#1 Leading delimiter] = 0:7-0:9 + >--< +0| var foo: Map + +[#1 Domain] = 0:0-0:22 + >----------------------< +0| var foo: Map + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| var foo: Map + +[#2 Removal] = 0:13-0:18 + >-----< +0| var foo: Map + +[#2 Trailing delimiter] = 0:16-0:18 + >--< +0| var foo: Map + +[#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:18-0:21 + >---< +0| var foo: Map + +[#3 Removal] = 0:16-0:21 + >-----< +0| var foo: Map + +[#3 Leading delimiter] = 0:16-0:18 + >--< +0| var foo: Map + +[#3 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/type/type.variable.scope b/data/fixtures/scopes/kotlin/type/type.variable.scope new file mode 100644 index 0000000000..99f31b1b07 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.variable.scope @@ -0,0 +1,20 @@ +var foo: Int +--- + +[Content] = 0:9-0:12 + >---< +0| var foo: Int + +[Removal] = 0:7-0:12 + >-----< +0| var foo: Int + +[Leading delimiter] = 0:7-0:9 + >--< +0| var foo: Int + +[Domain] = 0:0-0:12 + >------------< +0| var foo: Int + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.variable2.scope b/data/fixtures/scopes/kotlin/type/type.variable2.scope new file mode 100644 index 0000000000..ded7ac42ef --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.variable2.scope @@ -0,0 +1,20 @@ +val foo: Int = 0 +--- + +[Content] = 0:9-0:12 + >---< +0| val foo: Int = 0 + +[Removal] = 0:7-0:12 + >-----< +0| val foo: Int = 0 + +[Leading delimiter] = 0:7-0:9 + >--< +0| val foo: Int = 0 + +[Domain] = 0:0-0:16 + >----------------< +0| val foo: Int = 0 + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index c618eb489a..a175480402 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -91,10 +91,14 @@ ;; (type_identifier) @name ;; ) @class @name.domain -;;!! fun foo() {} +;;!! fun foo(): Int {} +;;! ^^^ +;;! ^^^ (function_declaration (simple_identifier) @name -) @namedFunction @name.domain + (function_value_parameters) @type.leading.endOf + (user_type)? @type +) @namedFunction @_.domain ;;!! constructor() {} (secondary_constructor @@ -193,11 +197,12 @@ ;;! ^ ;;! ^^^^^^^^^^ (catch_block - (simple_identifier) @name @name.domain.start @value.domain.start + (simple_identifier) @name @name.domain.start @type.domain.start ":" - (_) @type @name.domain.end @value.domain.end + (_) @type @name.domain.end @type.domain.end ) @branch +;;!! finally {} (finally_block) @branch ;;!! when (foo) { } @@ -282,119 +287,117 @@ ;; (control_structure_body) @branch.end ;; ) +;;!! while (true) {} +;;! ^^^^ (while_statement "while" - . "(" - . (_) @condition - . ")" -) @_.domain +) @condition.domain +;;!! do {} while (true) +;;! ^^^^ (do_while_statement "(" - . (_) @condition - . ")" - . -) @_.domain +) @condition.domain ;; ;; Name, value, type, and key ;; -(type_alias - "typealias" - . - (_) @name.start - (_)? @name.end - . - "=" - . - (_) @value.start @type.start -) @value.end.endOf @type.end.endOf @_.domain +;; (type_alias +;; "typealias" +;; . +;; (_) @name.start +;; (_)? @name.end +;; . +;; "=" +;; . +;; (_) @value.start @type.start +;; ) @value.end.endOf @type.end.endOf @_.domain ;;!! class Foo {} (class_declaration (type_identifier) @name ) @class @type @name.domain -(class_parameter - (simple_identifier) @name -) @_.domain +;; (class_parameter +;; (simple_identifier) @name +;; ) @_.domain -(class_parameter - ":" - . - (_) @type.start - (_)? @type.end - . - "=" - (_) @value -) @_.domain +;; (class_parameter +;; ":" +;; . +;; (_) @type.start +;; (_)? @type.end +;; . +;; "=" +;; (_) @value +;; ) @_.domain -;; Known issue: this won't work with multiple-node types. -(class_parameter - ":" - . - (_) @type - . -) @_.domain +;; ;; Known issue: this won't work with multiple-node types. +;; (class_parameter +;; ":" +;; . +;; (_) @type +;; . +;; ) @_.domain -;; Function declarations with type constraints -(function_declaration - ":" - . - (_) @type.start - (_)? @type.end - . - (type_constraints) -) @_.domain +;; ;; Function declarations with type constraints +;; (function_declaration +;; ":" +;; . +;; (_) @type.start +;; (_)? @type.end +;; . +;; (type_constraints) +;; ) @_.domain -;; Function declarations with no type constraints but with body -( - (function_declaration - ":" - . - (_) @type - . - (function_body) - ) @_.domain -) -( - (function_declaration - ":" - . - (_) @type.start - (_) @type.end - . - (function_body) - ) @_.domain - (#not-type? @type.end "type_constraints") -) +;; ;; Function declarations with no type constraints but with body +;; ( +;; (function_declaration +;; ":" +;; . +;; (_) @type +;; . +;; (function_body) +;; ) @_.domain +;; ) +;; ( +;; (function_declaration +;; ":" +;; . +;; (_) @type.start +;; (_) @type.end +;; . +;; (function_body) +;; ) @_.domain +;; (#not-type? @type.end "type_constraints") +;; ) -;; Function declaration without body or type constraints -( - (function_declaration - ":" - . - (_) @type - . - ) @_.domain -) -( - (function_declaration - ":" - . - (_) @type.start - (_) @type.end - . - ) @_.domain - (#not-type? @type.end "function_body") - (#not-type? @type.end "type_constraints") -) +;; ;; Function declaration without body or type constraints +;; ( +;; (function_declaration +;; ":" +;; . +;; (_) @type +;; . +;; ) @_.domain +;; ) +;; ( +;; (function_declaration +;; ":" +;; . +;; (_) @type.start +;; (_) @type.end +;; . +;; ) @_.domain +;; (#not-type? @type.end "function_body") +;; (#not-type? @type.end "type_constraints") +;; ) ;; (variable_declaration ;; (simple_identifier) @name @@ -408,18 +411,20 @@ ;; (multi_variable_declaration) @name.iteration @type.iteration -;;!! val foo +;;!! val foo: Int (property_declaration (variable_declaration - (simple_identifier) @name + (simple_identifier) @name @type.leading.endOf + (user_type)? @type ) . ) @_.domain -;;!! val foo = 0 +;;!! val foo: Int = 0 (property_declaration (variable_declaration - (simple_identifier) @name + (simple_identifier) @name @type.leading.endOf + (user_type)? @type ) @value.leading.endOf "=" (_) @value @@ -456,10 +461,13 @@ ;; (multi_variable_declaration) @name.iteration @type.iteration ;; ) @name.iteration.domain @type.iteration.domain -;;!! for (v in values) {} +;;!! for (v: Int in values) {} +;;! ^ +;;! ^^^ (for_statement (variable_declaration - (simple_identifier) @name + (simple_identifier) @name @type.leading.endOf + (user_type)? @type ) "in" . @@ -485,83 +493,75 @@ ;; (multi_variable_declaration) @name.iteration @type.iteration ;; ) @name.iteration.domain @type.iteration.domain -(when_subject - (variable_declaration - (simple_identifier) @name - ) -) @name.domain +;; (when_subject +;; (variable_declaration +;; (simple_identifier) @name +;; ) +;; ) @name.domain -(when_subject - "=" - . - (_) @value -) @value.domain +;; (when_subject +;; "=" +;; . +;; (_) @value +;; ) @value.domain -(when_subject - (variable_declaration - ":" - . - (_) @type.start - ) @type.end.endOf -) @type.domain +;; (when_subject +;; (variable_declaration +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf +;; ) @type.domain -(getter - ":" - . - (_) @type.start - (_)? @type.end - (function_body) -) @type.domain +;; (getter +;; ":" +;; . +;; (_) @type.start +;; (_)? @type.end +;; (function_body) +;; ) @type.domain -(setter - ":" - . - (_) @type.start - (_)? @type.end - (function_body) -) @type.domain +;; (setter +;; ":" +;; . +;; (_) @type.start +;; (_)? @type.end +;; (function_body) +;; ) @type.domain -(parameter_with_optional_type - (simple_identifier) @name -) @name.domain +;; (parameter_with_optional_type +;; (simple_identifier) @name +;; ) @name.domain -(parameter_with_optional_type - ":" - . - (_) @type.start -) @type.end.endOf @type.domain +;; (parameter_with_optional_type +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf @type.domain ;; Function parameter without default -(function_value_parameters - (parameter - (simple_identifier) @name - ":" - . - (_) @type.start - ) @type.end.endOf @_.domain -) +;; (function_value_parameters +;; (parameter +;; (simple_identifier) @name +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf @_.domain +;; ) ;; Function parameter with default -(function_value_parameters - (parameter - (simple_identifier) @name - ":" - . - (_) @type.start - ) @type.end.endOf @_.domain.start - . - "=" - . - (_) @value @_.domain.end -) - -(type_arguments - (type_projection) @type -) -(type_arguments - "<" @type.iteration.start.endOf - ">" @type.iteration.end.startOf -) +;; (function_value_parameters +;; (parameter +;; (simple_identifier) @name +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf @_.domain.start +;; . +;; "=" +;; . +;; (_) @value @_.domain.end +;; ) ;; (anonymous_function ;; ":" @@ -712,7 +712,7 @@ ;;!! class Foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ -(_ +(class_declaration (primary_constructor "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf @@ -728,7 +728,7 @@ ;;!! foo(aaa, bbb) ;;! ^^^^^^^^ -(_ +(call_expression (call_suffix (value_arguments "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf @@ -755,6 +755,42 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! var foo: Map +;;! ^^^^^^^^ +(type_arguments + "<" @type.iteration.start.endOf + ">" @type.iteration.end.startOf +) + +;;!! var foo: Map +;;! ^^^ ^^^ +( + (type_arguments + (_)? @_.leading.endOf + . + (_) @type + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @type @_dummy ", " ",\n") +) + +;;!! fun foo(aaa: Int, bbb: Int) {} +;;! ^^^ ^^^ +;;! ^^^ ^^^ +(parameter + (simple_identifier) @name @type.leading.endOf + (user_type) @type +) @_.domain + +;;!! class Foo(aaa: Int, bbb: Int) {} +;;! ^^^ ^^^ +;;! ^^^ ^^^ +(class_parameter + (simple_identifier) @name @type.leading.endOf + (user_type) @type +) @_.domain + ;; (constructor_delegation_call ;; (value_arguments ;; "(" @argumentOrParameter.iteration.start.endOf From 72c42516671e29ce67cf9320f882f77573595706 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 16:51:17 +0100 Subject: [PATCH 15/31] disqualified delimiters --- .../scopes/kotlin/disqualifyDelimiter.scope | 30 +++++++++++++++++++ .../common/src/scopeSupportFacets/kotlin.ts | 9 +++--- queries/java.scm | 6 ++-- queries/kotlin.scm | 15 ++++++++++ 4 files changed, 53 insertions(+), 7 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/disqualifyDelimiter.scope diff --git a/data/fixtures/scopes/kotlin/disqualifyDelimiter.scope b/data/fixtures/scopes/kotlin/disqualifyDelimiter.scope new file mode 100644 index 0000000000..d29fc4f298 --- /dev/null +++ b/data/fixtures/scopes/kotlin/disqualifyDelimiter.scope @@ -0,0 +1,30 @@ +1 < 2 +1 > 2 +1 <= 2 +1 >= 2 +when (foo) { x -> 0 } +{ x -> 0 } +--- +[#1 Content] = 0:2-0:3 + >-< +0| 1 < 2 + +[#2 Content] = 1:2-1:3 + >-< +1| 1 > 2 + +[#3 Content] = 2:2-2:4 + >--< +2| 1 <= 2 + +[#4 Content] = 3:2-3:4 + >--< +3| 1 >= 2 + +[#5 Content] = 4:15-4:17 + >--< +4| when (foo) { x -> 0 } + +[#6 Content] = 5:4-5:6 + >--< +5| { x -> 0 } diff --git a/packages/common/src/scopeSupportFacets/kotlin.ts b/packages/common/src/scopeSupportFacets/kotlin.ts index 085386b696..cd1e895681 100644 --- a/packages/common/src/scopeSupportFacets/kotlin.ts +++ b/packages/common/src/scopeSupportFacets/kotlin.ts @@ -52,10 +52,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "argumentList.formal.constructor.singleLine": supported, "argumentList.formal.constructor.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, @@ -298,6 +294,11 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "value.field.enum": notApplicable, "value.iteration.enum": notApplicable, + // Collection items unenclosed + "collectionItem.unenclosed.singleLine": notApplicable, + "collectionItem.unenclosed.multiLine": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, + // Miscellaneous environment: notApplicable, regularExpression: notApplicable, diff --git a/queries/java.scm b/queries/java.scm index 00013ce6b5..eae4d8f12f 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -641,12 +641,12 @@ operator: [ "<" - "<<" - "<<=" - "<=" ">" + "<=" ">=" + "<<" ">>" + "<<=" ">>=" ">>>" ">>>=" diff --git a/queries/kotlin.scm b/queries/kotlin.scm index a175480402..89490cde3e 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -921,3 +921,18 @@ ;; (lambda_literal ;; (lambda_parameters) @argumentOrParameter.iteration ;; ) @argumentOrParameter.iteration.domain + +(comparison_expression + [ + "<" + ">" + "<=" + ">=" + ] @disqualifyDelimiter +) +(lambda_literal + "->" @disqualifyDelimiter +) +(when_entry + "->" @disqualifyDelimiter +) From 7884c596820eb4578754802032629d6bbd9c484d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 16:59:01 +0100 Subject: [PATCH 16/31] catch arguments --- .../kotlin/argument/argument.catch.scope | 22 ++++++++++++++++++ .../kotlin/type/type.argument.catch.scope | 16 ++++++------- queries/kotlin.scm | 23 +++++++++++++++---- 3 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.catch.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.catch.scope b/data/fixtures/scopes/kotlin/argument/argument.catch.scope new file mode 100644 index 0000000000..872f7673d8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.catch.scope @@ -0,0 +1,22 @@ +try { +} catch (e: MyException) { +} catch (e: Exception) { +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 1:9-1:23 + >--------------< +1| } catch (e: MyException) { + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:9-2:21 + >------------< +2| } catch (e: Exception) { + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.catch.scope b/data/fixtures/scopes/kotlin/type/type.argument.catch.scope index 52c261a412..b24ad6a789 100644 --- a/data/fixtures/scopes/kotlin/type/type.argument.catch.scope +++ b/data/fixtures/scopes/kotlin/type/type.argument.catch.scope @@ -8,12 +8,12 @@ try { >-----------< 1| } catch (e: MyException) { -[#1 Removal] = 1:11-1:23 - >------------< +[#1 Removal] = 1:10-1:23 + >-------------< 1| } catch (e: MyException) { -[#1 Leading delimiter] = 1:11-1:12 - >-< +[#1 Leading delimiter] = 1:10-1:12 + >--< 1| } catch (e: MyException) { [#1 Domain] = 1:9-1:23 @@ -27,12 +27,12 @@ try { >---------< 2| } catch (e: Exception) { -[#2 Removal] = 2:11-2:21 - >----------< +[#2 Removal] = 2:10-2:21 + >-----------< 2| } catch (e: Exception) { -[#2 Leading delimiter] = 2:11-2:12 - >-< +[#2 Leading delimiter] = 2:10-2:12 + >--< 2| } catch (e: Exception) { [#2 Domain] = 2:9-2:21 diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 89490cde3e..121334c7a8 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -194,14 +194,29 @@ ) @branch.iteration ;;!! catch (e: Exception) {} -;;! ^ -;;! ^^^^^^^^^^ +;;! ^^^^^^^^^^^^ (catch_block - (simple_identifier) @name @name.domain.start @type.domain.start + (simple_identifier) @argumentOrParameter.start ":" - (_) @type @name.domain.end @type.domain.end + (user_type) @argumentOrParameter.end ) @branch +;;!! catch (e: Exception) {} +;;! ^ +(catch_block + (simple_identifier) @name @name.domain.start + ":" + (user_type) @name.domain.end +) + +;;!! catch (e: Exception) {} +;;! ^^^^^^^^^ +(catch_block + (simple_identifier) @type.domain.start @type.leading.endOf + ":" + (user_type) @type @type.domain.end +) + ;;!! finally {} (finally_block) @branch From 1e09f39758460aaff33dcaaf3fa70925d397de18 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 17:40:06 +0100 Subject: [PATCH 17/31] argument actual --- ...rgument.actual.constructor.multiLine.scope | 44 +++++++++++++++++++ ...gument.actual.constructor.singleLine.scope | 33 ++++++++++++++ .../argument.actual.method.multiLine.scope | 44 +++++++++++++++++++ .../argument.actual.method.singleLine.scope | 33 ++++++++++++++ .../argument/argument.actual.multiLine.scope | 44 +++++++++++++++++++ .../argument/argument.actual.singleLine.scope | 33 ++++++++++++++ .../argument.formal.method.iteration.scope | 12 +++++ 7 files changed, 243 insertions(+) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..cc80c0d324 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine.scope @@ -0,0 +1,44 @@ +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/kotlin/argument/argument.actual.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..6adf6fe178 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.singleLine.scope @@ -0,0 +1,33 @@ +Foo(aaa, bbb) +--- + +[#1 Content] = +[#1 Domain] = 0:4-0:7 + >---< +0| Foo(aaa, bbb) + +[#1 Removal] = 0:4-0:9 + >-----< +0| Foo(aaa, bbb) + +[#1 Trailing delimiter] = 0:7-0:9 + >--< +0| Foo(aaa, bbb) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:9-0:12 + >---< +0| Foo(aaa, bbb) + +[#2 Removal] = 0:7-0:12 + >-----< +0| Foo(aaa, bbb) + +[#2 Leading delimiter] = 0:7-0:9 + >--< +0| Foo(aaa, bbb) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.method.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.method.multiLine.scope new file mode 100644 index 0000000000..7dace79cea --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.method.multiLine.scope @@ -0,0 +1,44 @@ +foo.bar( + 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/kotlin/argument/argument.actual.method.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.method.singleLine.scope new file mode 100644 index 0000000000..d22bd33706 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.method.singleLine.scope @@ -0,0 +1,33 @@ +foo.bar(aaa, bbb) +--- + +[#1 Content] = +[#1 Domain] = 0:8-0:11 + >---< +0| foo.bar(aaa, bbb) + +[#1 Removal] = 0:8-0:13 + >-----< +0| foo.bar(aaa, bbb) + +[#1 Trailing delimiter] = 0:11-0:13 + >--< +0| foo.bar(aaa, bbb) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| foo.bar(aaa, bbb) + +[#2 Removal] = 0:11-0:16 + >-----< +0| foo.bar(aaa, bbb) + +[#2 Leading delimiter] = 0:11-0:13 + >--< +0| foo.bar(aaa, bbb) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.multiLine.scope new file mode 100644 index 0000000000..5ad321caa7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.multiLine.scope @@ -0,0 +1,44 @@ +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/kotlin/argument/argument.actual.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.singleLine.scope new file mode 100644 index 0000000000..b1a9403ff3 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.singleLine.scope @@ -0,0 +1,33 @@ +foo(aaa, bbb) +--- + +[#1 Content] = +[#1 Domain] = 0:4-0:7 + >---< +0| foo(aaa, bbb) + +[#1 Removal] = 0:4-0:9 + >-----< +0| foo(aaa, bbb) + +[#1 Trailing delimiter] = 0:7-0:9 + >--< +0| foo(aaa, bbb) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:9-0:12 + >---< +0| foo(aaa, bbb) + +[#2 Removal] = 0:7-0:12 + >-----< +0| foo(aaa, bbb) + +[#2 Leading delimiter] = 0:7-0:9 + >--< +0| foo(aaa, bbb) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope new file mode 100644 index 0000000000..5776531b87 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope @@ -0,0 +1,12 @@ +class Foo { + fun bar(aaa: Int, bbb: Int) {} +} +--- + +[Content] = 1:12-1:30 + >------------------< +1| fun bar(aaa: Int, bbb: Int) {} + +[Domain] = 1:4-1:34 + >------------------------------< +1| fun bar(aaa: Int, bbb: Int) {} From 237708515f4cb97ee197f9e8b68d447260c02047 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 22:08:03 +0100 Subject: [PATCH 18/31] arguments --- ...rgument.formal.constructor.multiLine.scope | 46 +++++++++++++++++++ ...gument.formal.constructor.multiLine2.scope | 44 ++++++++++++++++++ ...gument.formal.constructor.singleLine.scope | 35 ++++++++++++++ ...ument.formal.constructor.singleLine2.scope | 33 +++++++++++++ .../argument/argument.formal.iteration.scope | 10 ++++ .../argument.formal.lambda.multiLine.scope | 44 ++++++++++++++++++ .../argument.formal.lambda.singleLine.scope | 33 +++++++++++++ .../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/kotlin.scm | 35 +++++++++++++- 12 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..68f06a4a10 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope @@ -0,0 +1,46 @@ +class Foo { + constructor( + aaa: Int, + bbb: Int + ) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:16 + >--------< +2| aaa: Int, + +[#1 Removal] = 2:8-3:8 + >--------- +2| aaa: Int, +3| bbb: Int + --------< + +[#1 Trailing delimiter] = 2:16-3:8 + >- +2| aaa: Int, +3| bbb: Int + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:16 + >--------< +3| bbb: Int + +[#2 Removal] = 2:16-3:16 + >- +2| aaa: Int, +3| bbb: Int + ----------------< + +[#2 Leading delimiter] = 2:16-3:8 + >- +2| aaa: Int, +3| bbb: Int + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope new file mode 100644 index 0000000000..bb410b030a --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope @@ -0,0 +1,44 @@ +class Foo( + aaa: Int, + bbb: Int + ) {} +--- + +[#1 Content] = +[#1 Domain] = 1:8-1:16 + >--------< +1| aaa: Int, + +[#1 Removal] = 1:8-2:8 + >--------- +1| aaa: Int, +2| bbb: Int + --------< + +[#1 Trailing delimiter] = 1:16-2:8 + >- +1| aaa: Int, +2| bbb: Int + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:8-2:16 + >--------< +2| bbb: Int + +[#2 Removal] = 1:16-2:16 + >- +1| aaa: Int, +2| bbb: Int + ----------------< + +[#2 Leading delimiter] = 1:16-2:8 + >- +1| aaa: Int, +2| bbb: Int + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..69f944acd7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope @@ -0,0 +1,35 @@ +class Foo { + constructor(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:16-1:24 + >--------< +1| constructor(aaa: Int, bbb: Int) {} + +[#1 Removal] = 1:16-1:26 + >----------< +1| constructor(aaa: Int, bbb: Int) {} + +[#1 Trailing delimiter] = 1:24-1:26 + >--< +1| constructor(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:26-1:34 + >--------< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Removal] = 1:24-1:34 + >----------< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:24-1:26 + >--< +1| constructor(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope new file mode 100644 index 0000000000..96d00be9c3 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope @@ -0,0 +1,33 @@ +class Foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:10-0:18 + >--------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Removal] = 0:10-0:20 + >----------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Trailing delimiter] = 0:18-0:20 + >--< +0| class Foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:20-0:28 + >--------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Removal] = 0:18-0:28 + >----------< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 0:18-0:20 + >--< +0| class Foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope new file mode 100644 index 0000000000..52e03b6d32 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope @@ -0,0 +1,10 @@ +fun bar(aaa: Int, bbb: Int) {} +--- + +[Content] = 0:8-0:26 + >------------------< +0| fun bar(aaa: Int, bbb: Int) {} + +[Domain] = 0:0-0:30 + >------------------------------< +0| fun bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..d1a3572fde --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.multiLine.scope @@ -0,0 +1,44 @@ +{ + 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/kotlin/argument/argument.formal.lambda.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..ec0eef877e --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.lambda.singleLine.scope @@ -0,0 +1,33 @@ +{ aaa, bbb -> } +--- + +[#1 Content] = +[#1 Domain] = 0:2-0:5 + >---< +0| { aaa, bbb -> } + +[#1 Removal] = 0:2-0:7 + >-----< +0| { aaa, bbb -> } + +[#1 Trailing delimiter] = 0:5-0:7 + >--< +0| { aaa, bbb -> } + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:7-0:10 + >---< +0| { aaa, bbb -> } + +[#2 Removal] = 0:5-0:10 + >-----< +0| { aaa, bbb -> } + +[#2 Leading delimiter] = 0:5-0:7 + >--< +0| { aaa, bbb -> } + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope new file mode 100644 index 0000000000..1fb547588d --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope @@ -0,0 +1,46 @@ +class Foo { + fun bar( + aaa: Int, + bbb: Int + ) {} +} +--- + +[#1 Content] = +[#1 Domain] = 2:8-2:16 + >--------< +2| aaa: Int, + +[#1 Removal] = 2:8-3:8 + >--------- +2| aaa: Int, +3| bbb: Int + --------< + +[#1 Trailing delimiter] = 2:16-3:8 + >- +2| aaa: Int, +3| bbb: Int + --------< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:8-3:16 + >--------< +3| bbb: Int + +[#2 Removal] = 2:16-3:16 + >- +2| aaa: Int, +3| bbb: Int + ----------------< + +[#2 Leading delimiter] = 2:16-3:8 + >- +2| aaa: Int, +3| bbb: Int + --------< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope new file mode 100644 index 0000000000..cb4dfaa764 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope @@ -0,0 +1,35 @@ +class Foo { + fun bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:12-1:20 + >--------< +1| fun bar(aaa: Int, bbb: Int) {} + +[#1 Removal] = 1:12-1:22 + >----------< +1| fun bar(aaa: Int, bbb: Int) {} + +[#1 Trailing delimiter] = 1:20-1:22 + >--< +1| fun bar(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:22-1:30 + >--------< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Removal] = 1:20-1:30 + >----------< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:20-1:22 + >--< +1| fun bar(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope new file mode 100644 index 0000000000..84a107d269 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope @@ -0,0 +1,44 @@ +fun bar( + aaa: Int, + bbb: Int +) {} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:12 + >--------< +1| aaa: Int, + +[#1 Removal] = 1:4-2:4 + >--------- +1| aaa: Int, +2| bbb: Int + ----< + +[#1 Trailing delimiter] = 1:12-2:4 + >- +1| aaa: Int, +2| bbb: Int + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:12 + >--------< +2| bbb: Int + +[#2 Removal] = 1:12-2:12 + >- +1| aaa: Int, +2| bbb: Int + ------------< + +[#2 Leading delimiter] = 1:12-2:4 + >- +1| aaa: Int, +2| bbb: Int + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope new file mode 100644 index 0000000000..b25167938c --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope @@ -0,0 +1,33 @@ +fun bar(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:8-0:16 + >--------< +0| fun bar(aaa: Int, bbb: Int) {} + +[#1 Removal] = 0:8-0:18 + >----------< +0| fun bar(aaa: Int, bbb: Int) {} + +[#1 Trailing delimiter] = 0:16-0:18 + >--< +0| fun bar(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:18-0:26 + >--------< +0| fun bar(aaa: Int, bbb: Int) {} + +[#2 Removal] = 0:16-0:26 + >----------< +0| fun bar(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 0:16-0:18 + >--< +0| fun bar(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = ", " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 121334c7a8..df9d7cdfea 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -707,6 +707,17 @@ ")" @name.iteration.end.startOf @type.iteration.end.startOf ) +( + (function_value_parameters + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) + ;;!! { aaa, bbb -> } ;;! ^^^^^^^^ (lambda_literal @@ -725,6 +736,17 @@ ] ) @argumentList.domain +( + (lambda_parameters + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) + ;;!! class Foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ (class_declaration @@ -741,6 +763,17 @@ ")" @name.iteration.end.startOf @type.iteration.end.startOf ) +( + (primary_constructor + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) + ;;!! foo(aaa, bbb) ;;! ^^^^^^^^ (call_expression @@ -763,7 +796,7 @@ (value_arguments (_)? @_.leading.endOf . - (value_argument) @argumentOrParameter + (_) @argumentOrParameter . (_)? @_.trailing.startOf ) @_dummy From 2192c9450e97c788268e392f6d698aec165d12b9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 22:45:14 +0100 Subject: [PATCH 19/31] More tests --- .../argumentList.formal.empty.scope | 13 +++++ .../argumentList.formal.multiLine.scope | 33 +++++++++++++ .../argumentList.formal.singleLine.scope | 13 +++++ .../kotlin/interior/interior.function.scope | 10 ++++ .../name/name.argument.actual.iteration.scope | 13 +++++ .../name/name.argument.formal.iteration.scope | 13 +++++ .../kotlin/name/name.argument.formal.scope | 48 +++++++++++++++++++ .../scopes/kotlin/name/name.function.scope | 17 +++++++ .../scopes/kotlin/name/name.variable.scope | 12 ++--- .../scopes/kotlin/name/name.variable2.scope | 24 ++++++++++ .../kotlin/statement/statement.for.scope | 10 ---- .../kotlin/statement/statement.variable.scope | 4 +- .../statement/statement.variable2.scope | 10 ++++ .../type/type.argument.formal.iteration.scope | 13 +++++ .../kotlin/type/type.argument.formal.scope | 39 +++++++++++++++ .../scopes/kotlin/value/value.variable3.scope | 20 ++++++++ .../scopes/kotlin/value/value.variable4.scope | 20 ++++++++ .../common/src/scopeSupportFacets/kotlin.ts | 35 +++++++------- 18 files changed, 310 insertions(+), 37 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.empty.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.multiLine.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.formal.singleLine.scope create mode 100644 data/fixtures/scopes/kotlin/interior/interior.function.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.function.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.variable2.scope delete mode 100644 data/fixtures/scopes/kotlin/statement/statement.for.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.variable2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.variable3.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.variable4.scope diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.empty.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.empty.scope new file mode 100644 index 0000000000..27bbd3c96a --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.empty.scope @@ -0,0 +1,13 @@ +fun foo() {} +--- + +[Content] = +[Removal] = 0:8-0:8 + >< +0| fun foo() {} + +[Domain] = 0:0-0:12 + >------------< +0| fun foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.multiLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.multiLine.scope new file mode 100644 index 0000000000..c0711e616d --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.multiLine.scope @@ -0,0 +1,33 @@ +fun foo( + aaa: Int, + bbb: Int +) {} +--- + +[Content] = 1:4-2:12 + >--------- +1| aaa: Int, +2| bbb: Int + ------------< + +[Removal] = 0:8-3:0 + > +0| fun foo( +1| aaa: Int, +2| bbb: Int +3| ) {} + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa: Int, + +[Domain] = 0:0-3:4 + >-------- +0| fun foo( +1| aaa: Int, +2| bbb: Int +3| ) {} + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.singleLine.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.singleLine.scope new file mode 100644 index 0000000000..d0ec120724 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.formal.singleLine.scope @@ -0,0 +1,13 @@ +fun foo(aaa: Int, bbb: Int) {} +--- + +[Content] = +[Removal] = 0:8-0:26 + >------------------< +0| fun foo(aaa: Int, bbb: Int) {} + +[Domain] = 0:0-0:30 + >------------------------------< +0| fun foo(aaa: Int, bbb: Int) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/interior/interior.function.scope b/data/fixtures/scopes/kotlin/interior/interior.function.scope new file mode 100644 index 0000000000..6f92f91543 --- /dev/null +++ b/data/fixtures/scopes/kotlin/interior/interior.function.scope @@ -0,0 +1,10 @@ +fun bar() { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| fun bar() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.actual.iteration.scope b/data/fixtures/scopes/kotlin/name/name.argument.actual.iteration.scope new file mode 100644 index 0000000000..546c765209 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.actual.iteration.scope @@ -0,0 +1,13 @@ +foo(aaa = 0, bbb = 1) +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:21 + >---------------------< +0| foo(aaa = 0, bbb = 1) + + +[#2 Content] = +[#2 Domain] = 0:4-0:20 + >----------------< +0| foo(aaa = 0, bbb = 1) diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.iteration.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.iteration.scope new file mode 100644 index 0000000000..bfafcabc7e --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +fun foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| fun foo(aaa: Int, bbb: Int) {} + + +[#2 Content] = +[#2 Domain] = 0:8-0:26 + >------------------< +0| fun foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.scope new file mode 100644 index 0000000000..e09dd18fb6 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.scope @@ -0,0 +1,48 @@ +fun foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:7 + >---< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Leading delimiter] = 0:3-0:4 + >-< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:8-0:11 + >---< +0| fun foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 0:8-0:16 + >--------< +0| fun foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:18-0:21 + >---< +0| fun foo(aaa: Int, bbb: Int) {} + +[#3 Removal] = 0:17-0:21 + >----< +0| fun foo(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 0:17-0:18 + >-< +0| fun foo(aaa: Int, bbb: Int) {} + +[#3 Domain] = 0:18-0:26 + >--------< +0| fun foo(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.function.scope b/data/fixtures/scopes/kotlin/name/name.function.scope new file mode 100644 index 0000000000..a34a35925c --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.function.scope @@ -0,0 +1,17 @@ +fun bar() {} +--- + +[Content] = +[Removal] = 0:4-0:7 + >---< +0| fun bar() {} + +[Leading delimiter] = 0:3-0:4 + >-< +0| fun bar() {} + +[Domain] = 0:0-0:12 + >------------< +0| fun bar() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.variable.scope b/data/fixtures/scopes/kotlin/name/name.variable.scope index 608e22c538..1cd9475d1d 100644 --- a/data/fixtures/scopes/kotlin/name/name.variable.scope +++ b/data/fixtures/scopes/kotlin/name/name.variable.scope @@ -1,24 +1,24 @@ -val foo = 0 +var foo = 0 --- [Content] = 0:4-0:7 >---< -0| val foo = 0 +0| var foo = 0 [Removal] = 0:4-0:8 >----< -0| val foo = 0 +0| var foo = 0 [Leading delimiter] = 0:3-0:4 >-< -0| val foo = 0 +0| var foo = 0 [Trailing delimiter] = 0:7-0:8 >-< -0| val foo = 0 +0| var foo = 0 [Domain] = 0:0-0:11 >-----------< -0| val foo = 0 +0| var foo = 0 [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.variable2.scope b/data/fixtures/scopes/kotlin/name/name.variable2.scope new file mode 100644 index 0000000000..608e22c538 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.variable2.scope @@ -0,0 +1,24 @@ +val foo = 0 +--- + +[Content] = 0:4-0:7 + >---< +0| val foo = 0 + +[Removal] = 0:4-0:8 + >----< +0| val foo = 0 + +[Leading delimiter] = 0:3-0:4 + >-< +0| val foo = 0 + +[Trailing delimiter] = 0:7-0:8 + >-< +0| val foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| val foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/statement/statement.for.scope b/data/fixtures/scopes/kotlin/statement/statement.for.scope deleted file mode 100644 index 1fd1c04a17..0000000000 --- a/data/fixtures/scopes/kotlin/statement/statement.for.scope +++ /dev/null @@ -1,10 +0,0 @@ -for (i in 0 until size) {} ---- - -[Content] = -[Removal] = -[Domain] = 0:0-0:26 - >--------------------------< -0| for (i in 0 until size) {} - -[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable.scope b/data/fixtures/scopes/kotlin/statement/statement.variable.scope index 3e53923b5e..4934548475 100644 --- a/data/fixtures/scopes/kotlin/statement/statement.variable.scope +++ b/data/fixtures/scopes/kotlin/statement/statement.variable.scope @@ -1,10 +1,10 @@ -val foo = 0 +var foo = 0 --- [Content] = [Removal] = [Domain] = 0:0-0:11 >-----------< -0| val foo = 0 +0| var foo = 0 [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable2.scope b/data/fixtures/scopes/kotlin/statement/statement.variable2.scope new file mode 100644 index 0000000000..3e53923b5e --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.variable2.scope @@ -0,0 +1,10 @@ +val foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| val foo = 0 + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.iteration.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.iteration.scope new file mode 100644 index 0000000000..bfafcabc7e --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +fun foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| fun foo(aaa: Int, bbb: Int) {} + + +[#2 Content] = +[#2 Domain] = 0:8-0:26 + >------------------< +0| fun foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.scope new file mode 100644 index 0000000000..87271526b0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.scope @@ -0,0 +1,39 @@ +fun foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = 0:13-0:16 + >---< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Removal] = 0:11-0:16 + >-----< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Leading delimiter] = 0:11-0:13 + >--< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Domain] = 0:8-0:16 + >--------< +0| fun foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:23-0:26 + >---< +0| fun foo(aaa: Int, bbb: Int) {} + +[#2 Removal] = 0:21-0:26 + >-----< +0| fun foo(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 0:21-0:23 + >--< +0| fun foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 0:18-0:26 + >--------< +0| fun foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.variable3.scope b/data/fixtures/scopes/kotlin/value/value.variable3.scope new file mode 100644 index 0000000000..957dcc3e51 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.variable3.scope @@ -0,0 +1,20 @@ +val foo = 0 +--- + +[Content] = 0:10-0:11 + >-< +0| val foo = 0 + +[Removal] = 0:7-0:11 + >----< +0| val foo = 0 + +[Leading delimiter] = 0:7-0:10 + >---< +0| val foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| val foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.variable4.scope b/data/fixtures/scopes/kotlin/value/value.variable4.scope new file mode 100644 index 0000000000..f7dddc78da --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.variable4.scope @@ -0,0 +1,20 @@ +val foo: Int = 0 +--- + +[Content] = 0:15-0:16 + >-< +0| val foo: Int = 0 + +[Removal] = 0:12-0:16 + >----< +0| val foo: Int = 0 + +[Leading delimiter] = 0:12-0:15 + >---< +0| val foo: Int = 0 + +[Domain] = 0:0-0:16 + >----------------< +0| val foo: Int = 0 + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/kotlin.ts b/packages/common/src/scopeSupportFacets/kotlin.ts index cd1e895681..3e485421ba 100644 --- a/packages/common/src/scopeSupportFacets/kotlin.ts +++ b/packages/common/src/scopeSupportFacets/kotlin.ts @@ -60,9 +60,10 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "branch.try.iteration": supported, "branch.switchCase": supported, "branch.switchCase.iteration": supported, + "branch.ternary": supported, + "branch.ternary.iteration": supported, class: supported, - "class.iteration.block": supported, "class.iteration.document": supported, "comment.block": supported, @@ -73,6 +74,7 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "condition.switchCase": supported, "condition.switchCase.iteration": supported, "condition.while": supported, + "condition.ternary": supported, functionCall: supported, "functionCall.constructor": supported, @@ -110,11 +112,11 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "statement.return": supported, "statement.break": supported, "statement.continue": supported, - "statement.misc": supported, "statement.iteration.document": supported, "statement.iteration.class": supported, "statement.iteration.interface": supported, "statement.iteration.block": supported, + "statement.static": supported, "string.singleLine": supported, "string.multiLine": supported, @@ -140,6 +142,7 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "name.constructor": supported, "name.field.class": supported, "name.field.interface": supported, + "name.field.enum": supported, "name.foreach": supported, "name.function": supported, "name.method": supported, @@ -151,9 +154,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "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, @@ -162,8 +162,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "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.foreach": supported, "value.switch": supported, @@ -171,7 +169,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "value.return": supported, "value.return.lambda": supported, "value.variable": supported, - "value.variable.pattern": supported, "value.typeAlias": supported, "value.iteration.block": supported, "value.iteration.class": supported, @@ -191,7 +188,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "type.variable": supported, "type.typeArgument": supported, "type.typeArgument.iteration": supported, - "type.cast": supported, "type.class": supported, "type.enum": supported, "type.interface": supported, @@ -216,6 +212,7 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "interior.switchCase": supported, "interior.try": supported, "interior.for": supported, + "interior.static": supported, /* UNSUPPORTED */ @@ -269,11 +266,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "branch.loop": notApplicable, "branch.loop.iteration": notApplicable, - // Ternary - "branch.ternary": notApplicable, - "branch.ternary.iteration": notApplicable, - "condition.ternary": notApplicable, - // For loop (C-style) "statement.for": notApplicable, "condition.for": notApplicable, @@ -282,15 +274,10 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "statement.yield": notApplicable, "value.yield": notApplicable, - // Static - "statement.static": notApplicable, - "interior.static": notApplicable, - // Keyword argument assignment pattern "name.assignment.pattern": notApplicable, // Values in enum - "name.field.enum": notApplicable, "value.field.enum": notApplicable, "value.iteration.enum": notApplicable, @@ -299,6 +286,12 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "collectionItem.unenclosed.multiLine": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, + // Map pair + "key.mapPair": notApplicable, + "key.mapPair.iteration": notApplicable, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, + // Miscellaneous environment: notApplicable, regularExpression: notApplicable, @@ -307,4 +300,8 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { pairDelimiter: notApplicable, list: notApplicable, map: notApplicable, + "class.iteration.block": notApplicable, + "type.cast": notApplicable, + "statement.misc": notApplicable, + "value.variable.pattern": notApplicable, }; From f63cb227d1ccd0d041d08b8d893e9bc24c908cf9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Mon, 2 Feb 2026 23:19:40 +0100 Subject: [PATCH 20/31] More tests --- .../argument.actual.singleLine2.scope | 33 +++++++ .../kotlin/name/name.argument.actual.scope | 43 ++++++++ .../kotlin/name/name.argument.formal.scope | 28 +++--- .../kotlin/name/name.variable.pattern.scope | 24 +++++ .../kotlin/statement/statement.variable.scope | 8 +- .../statement/statement.variable2.scope | 8 +- .../statement/statement.variable3.scope | 10 ++ .../statement/statement.variable4.scope | 10 ++ .../scopes/kotlin/type/type.alias.scope | 10 ++ .../value.argument.actual.iteration.scope | 13 +++ .../kotlin/value/value.argument.actual.scope | 39 ++++++++ ...rgument.formal.constructor.iteration.scope | 27 ++++++ ...gument.formal.constructor.iteration2.scope | 13 +++ .../value.argument.formal.constructor.scope | 41 ++++++++ .../value.argument.formal.constructor2.scope | 39 ++++++++ .../value.argument.formal.iteration.scope | 13 +++ ...lue.argument.formal.method.iteration.scope | 27 ++++++ .../value/value.argument.formal.method.scope | 41 ++++++++ .../kotlin/value/value.argument.formal.scope | 39 ++++++++ .../scopes/kotlin/value/value.typeAlias.scope | 20 ++++ queries/kotlin.scm | 97 ++++++++++++++----- 21 files changed, 536 insertions(+), 47 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.singleLine2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.actual.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.variable.pattern.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.variable3.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.variable4.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.alias.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.actual.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration2.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.argument.formal.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.typeAlias.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.singleLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.singleLine2.scope new file mode 100644 index 0000000000..29b3d1db06 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.singleLine2.scope @@ -0,0 +1,33 @@ +foo(aaa = 0, bbb = 1) +--- + +[#1 Content] = +[#1 Domain] = 0:4-0:11 + >-------< +0| foo(aaa = 0, bbb = 1) + +[#1 Removal] = 0:4-0:13 + >---------< +0| foo(aaa = 0, bbb = 1) + +[#1 Trailing delimiter] = 0:11-0:13 + >--< +0| foo(aaa = 0, bbb = 1) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:13-0:20 + >-------< +0| foo(aaa = 0, bbb = 1) + +[#2 Removal] = 0:11-0:20 + >---------< +0| foo(aaa = 0, bbb = 1) + +[#2 Leading delimiter] = 0:11-0:13 + >--< +0| foo(aaa = 0, bbb = 1) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.actual.scope b/data/fixtures/scopes/kotlin/name/name.argument.actual.scope new file mode 100644 index 0000000000..7587d44f94 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.actual.scope @@ -0,0 +1,43 @@ +foo(aaa = 0, bbb = 1) +--- + +[#1 Content] = 0:4-0:7 + >---< +0| foo(aaa = 0, bbb = 1) + +[#1 Removal] = 0:4-0:8 + >----< +0| foo(aaa = 0, bbb = 1) + +[#1 Trailing delimiter] = 0:7-0:8 + >-< +0| foo(aaa = 0, bbb = 1) + +[#1 Domain] = 0:4-0:11 + >-------< +0| foo(aaa = 0, bbb = 1) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:13-0:16 + >---< +0| foo(aaa = 0, bbb = 1) + +[#2 Removal] = 0:13-0:17 + >----< +0| foo(aaa = 0, bbb = 1) + +[#2 Leading delimiter] = 0:12-0:13 + >-< +0| foo(aaa = 0, bbb = 1) + +[#2 Trailing delimiter] = 0:16-0:17 + >-< +0| foo(aaa = 0, bbb = 1) + +[#2 Domain] = 0:13-0:20 + >-------< +0| foo(aaa = 0, bbb = 1) + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.scope index e09dd18fb6..da6507e251 100644 --- a/data/fixtures/scopes/kotlin/name/name.argument.formal.scope +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.scope @@ -1,18 +1,18 @@ -fun foo(aaa: Int, bbb: Int) {} +fun foo(aaa: Int, bbb: Int = 1) {} --- [#1 Content] = [#1 Removal] = 0:4-0:7 >---< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} [#1 Leading delimiter] = 0:3-0:4 >-< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} -[#1 Domain] = 0:0-0:30 - >------------------------------< -0| fun foo(aaa: Int, bbb: Int) {} +[#1 Domain] = 0:0-0:34 + >----------------------------------< +0| fun foo(aaa: Int, bbb: Int = 1) {} [#1 Insertion delimiter] = " " @@ -20,29 +20,29 @@ fun foo(aaa: Int, bbb: Int) {} [#2 Content] = [#2 Removal] = 0:8-0:11 >---< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} [#2 Domain] = 0:8-0:16 >--------< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} [#2 Insertion delimiter] = " " [#3 Content] = 0:18-0:21 >---< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} [#3 Removal] = 0:17-0:21 >----< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} [#3 Leading delimiter] = 0:17-0:18 >-< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, bbb: Int = 1) {} -[#3 Domain] = 0:18-0:26 - >--------< -0| fun foo(aaa: Int, bbb: Int) {} +[#3 Domain] = 0:18-0:30 + >------------< +0| fun foo(aaa: Int, bbb: Int = 1) {} [#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope b/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope new file mode 100644 index 0000000000..41c7420ace --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope @@ -0,0 +1,24 @@ +var (foo, bar) = baz +--- + +[Content] = 0:4-0:14 + >----------< +0| var (foo, bar) = baz + +[Removal] = 0:4-0:15 + >-----------< +0| var (foo, bar) = baz + +[Leading delimiter] = 0:3-0:4 + >-< +0| var (foo, bar) = baz + +[Trailing delimiter] = 0:14-0:15 + >-< +0| var (foo, bar) = baz + +[Domain] = 0:0-0:20 + >--------------------< +0| var (foo, bar) = baz + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable.scope b/data/fixtures/scopes/kotlin/statement/statement.variable.scope index 4934548475..0c4f8800bd 100644 --- a/data/fixtures/scopes/kotlin/statement/statement.variable.scope +++ b/data/fixtures/scopes/kotlin/statement/statement.variable.scope @@ -1,10 +1,10 @@ -var foo = 0 +var foo: Int --- [Content] = [Removal] = -[Domain] = 0:0-0:11 - >-----------< -0| var foo = 0 +[Domain] = 0:0-0:12 + >------------< +0| var foo: Int [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable2.scope b/data/fixtures/scopes/kotlin/statement/statement.variable2.scope index 3e53923b5e..a69afa0fed 100644 --- a/data/fixtures/scopes/kotlin/statement/statement.variable2.scope +++ b/data/fixtures/scopes/kotlin/statement/statement.variable2.scope @@ -1,10 +1,10 @@ -val foo = 0 +val foo: Int --- [Content] = [Removal] = -[Domain] = 0:0-0:11 - >-----------< -0| val foo = 0 +[Domain] = 0:0-0:12 + >------------< +0| val foo: Int [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable3.scope b/data/fixtures/scopes/kotlin/statement/statement.variable3.scope new file mode 100644 index 0000000000..4934548475 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.variable3.scope @@ -0,0 +1,10 @@ +var foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| var foo = 0 + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.variable4.scope b/data/fixtures/scopes/kotlin/statement/statement.variable4.scope new file mode 100644 index 0000000000..3e53923b5e --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.variable4.scope @@ -0,0 +1,10 @@ +val foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| val foo = 0 + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/type/type.alias.scope b/data/fixtures/scopes/kotlin/type/type.alias.scope new file mode 100644 index 0000000000..19275a0f96 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.alias.scope @@ -0,0 +1,10 @@ +typealias Foo = Bar +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| typealias Foo = Bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.actual.iteration.scope b/data/fixtures/scopes/kotlin/value/value.argument.actual.iteration.scope new file mode 100644 index 0000000000..546c765209 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.actual.iteration.scope @@ -0,0 +1,13 @@ +foo(aaa = 0, bbb = 1) +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:21 + >---------------------< +0| foo(aaa = 0, bbb = 1) + + +[#2 Content] = +[#2 Domain] = 0:4-0:20 + >----------------< +0| foo(aaa = 0, bbb = 1) diff --git a/data/fixtures/scopes/kotlin/value/value.argument.actual.scope b/data/fixtures/scopes/kotlin/value/value.argument.actual.scope new file mode 100644 index 0000000000..b7b94700a4 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.actual.scope @@ -0,0 +1,39 @@ +foo(aaa = 0, bbb = 1) +--- + +[#1 Content] = 0:10-0:11 + >-< +0| foo(aaa = 0, bbb = 1) + +[#1 Removal] = 0:7-0:11 + >----< +0| foo(aaa = 0, bbb = 1) + +[#1 Leading delimiter] = 0:7-0:10 + >---< +0| foo(aaa = 0, bbb = 1) + +[#1 Domain] = 0:4-0:11 + >-------< +0| foo(aaa = 0, bbb = 1) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:19-0:20 + >-< +0| foo(aaa = 0, bbb = 1) + +[#2 Removal] = 0:16-0:20 + >----< +0| foo(aaa = 0, bbb = 1) + +[#2 Leading delimiter] = 0:16-0:19 + >---< +0| foo(aaa = 0, bbb = 1) + +[#2 Domain] = 0:13-0:20 + >-------< +0| foo(aaa = 0, bbb = 1) + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..22bb38acb4 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + constructor(aaa: Int = 0, bbb: Int = 1) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| constructor(aaa: Int = 0, bbb: Int = 1) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| constructor(aaa: Int = 0, bbb: Int = 1) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:42 + >--------------------------< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration2.scope new file mode 100644 index 0000000000..25e53ec069 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.iteration2.scope @@ -0,0 +1,13 @@ +class Foo(aaa: Int = 0, bbb: Int = 1) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:40 + >----------------------------------------< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + + +[#2 Content] = +[#2 Domain] = 0:10-0:36 + >--------------------------< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope new file mode 100644 index 0000000000..1f3ac6fbda --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope @@ -0,0 +1,41 @@ +class Foo { + constructor(aaa: Int = 0, bbb: Int = 1) {} +} +--- + +[#1 Content] = 1:27-1:28 + >-< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Removal] = 1:24-1:28 + >----< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Leading delimiter] = 1:24-1:27 + >---< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Domain] = 1:16-1:28 + >------------< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:41-1:42 + >-< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Removal] = 1:38-1:42 + >----< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Leading delimiter] = 1:38-1:41 + >---< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Domain] = 1:30-1:42 + >------------< +1| constructor(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope new file mode 100644 index 0000000000..4d344c58d3 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope @@ -0,0 +1,39 @@ +class Foo(aaa: Int = 0, bbb: Int = 1) {} +--- + +[#1 Content] = 0:21-0:22 + >-< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Removal] = 0:18-0:22 + >----< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Leading delimiter] = 0:18-0:21 + >---< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Domain] = 0:10-0:22 + >------------< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:35-0:36 + >-< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Removal] = 0:32-0:36 + >----< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Leading delimiter] = 0:32-0:35 + >---< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Domain] = 0:24-0:36 + >------------< +0| class Foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.iteration.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.iteration.scope new file mode 100644 index 0000000000..8c959bf6bd --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +fun foo(aaa: Int = 0, bbb: Int = 1) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:38 + >--------------------------------------< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + + +[#2 Content] = +[#2 Domain] = 0:8-0:34 + >--------------------------< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.method.iteration.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..1412c335ad --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + fun bar(aaa: Int = 0, bbb: Int = 1) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:12-1:38 + >--------------------------< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope new file mode 100644 index 0000000000..326a9b1b4d --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope @@ -0,0 +1,41 @@ +class Foo { + fun bar(aaa: Int = 0, bbb: Int = 1) {} +} +--- + +[#1 Content] = 1:23-1:24 + >-< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Removal] = 1:20-1:24 + >----< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Leading delimiter] = 1:20-1:23 + >---< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Domain] = 1:12-1:24 + >------------< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:37-1:38 + >-< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Removal] = 1:34-1:38 + >----< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Leading delimiter] = 1:34-1:37 + >---< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Domain] = 1:26-1:38 + >------------< +1| fun bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.scope new file mode 100644 index 0000000000..f529950380 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.scope @@ -0,0 +1,39 @@ +fun foo(aaa: Int = 0, bbb: Int = 1) {} +--- + +[#1 Content] = 0:19-0:20 + >-< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Removal] = 0:16-0:20 + >----< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Leading delimiter] = 0:16-0:19 + >---< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Domain] = 0:8-0:20 + >------------< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:33-0:34 + >-< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Removal] = 0:30-0:34 + >----< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Leading delimiter] = 0:30-0:33 + >---< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Domain] = 0:22-0:34 + >------------< +0| fun foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.typeAlias.scope b/data/fixtures/scopes/kotlin/value/value.typeAlias.scope new file mode 100644 index 0000000000..9796df7457 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.typeAlias.scope @@ -0,0 +1,20 @@ +typealias Foo = Bar +--- + +[Content] = 0:16-0:19 + >---< +0| typealias Foo = Bar + +[Removal] = 0:13-0:19 + >------< +0| typealias Foo = Bar + +[Leading delimiter] = 0:13-0:16 + >---< +0| typealias Foo = Bar + +[Domain] = 0:0-0:19 + >-------------------< +0| typealias Foo = Bar + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index df9d7cdfea..ad309e22dd 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -427,31 +427,55 @@ ;; (multi_variable_declaration) @name.iteration @type.iteration ;;!! val foo: Int -(property_declaration - (variable_declaration - (simple_identifier) @name @type.leading.endOf - (user_type)? @type - ) - . -) @_.domain +;;! ^^^ +;;! ^^^ +;; (property_declaration +;; (variable_declaration +;; (simple_identifier) @name @type.leading.endOf +;; (user_type)? @type +;; ) +;; ) @_.domain ;;!! val foo: Int = 0 +;;! ^^^ +;;! ^^^ +;;! ^ (property_declaration (variable_declaration (simple_identifier) @name @type.leading.endOf (user_type)? @type ) @value.leading.endOf - "=" + ( + "=" + (_) @value + )? +) @_.domain + +;;!! val (foo, bar) = baz +;;! ^^^^^^^^^^ +;;! ^^^ +(property_declaration + (multi_variable_declaration) @name @value.leading.endOf (_) @value ) @_.domain ;;!! foo = 0 +;;! ^^^ +;;! ^ (assignment (directly_assignable_expression) @name @value.leading.endOf (_) @value . ) @_.domain +;;!! typealias Foo = Bar +;;! ^^^ +;;! ^^^ +(type_alias + (type_identifier) @name @value.leading.endOf + (user_type) @value +) @type @_.domain + ;; (property_declaration ;; "=" ;; . @@ -703,8 +727,8 @@ ) @argumentList.domain @argumentOrParameter.iteration.domain (function_value_parameters - "(" @name.iteration.start.endOf @type.iteration.start.endOf - ")" @name.iteration.end.startOf @type.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 ) ( @@ -759,8 +783,8 @@ ) @argumentList.domain @argumentOrParameter.iteration.domain (primary_constructor - "(" @name.iteration.start.endOf @type.iteration.start.endOf - ")" @name.iteration.end.startOf @type.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 ) ( @@ -788,8 +812,8 @@ ) @argumentList.domain @argumentOrParameter.iteration.domain (value_arguments - "(" @name.iteration.start.endOf @type.iteration.start.endOf - ")" @name.iteration.end.startOf @type.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 ) ( @@ -803,6 +827,15 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! foo(aaa = 0) +;;! ^^^ +;;! ^ +(value_argument + (simple_identifier) @name @value.leading.endOf + "=" + (_) @value +) @_.domain + ;;!! var foo: Map ;;! ^^^^^^^^ (type_arguments @@ -823,20 +856,34 @@ (#single-or-multi-line-delimiter! @type @_dummy ", " ",\n") ) -;;!! fun foo(aaa: Int, bbb: Int) {} -;;! ^^^ ^^^ -;;! ^^^ ^^^ -(parameter - (simple_identifier) @name @type.leading.endOf - (user_type) @type -) @_.domain +;;!! fun Foo(aaa: Int = 0) {} +;;! ^^^ +;;! ^^^ +;;! ^ +(function_value_parameters + (parameter + (simple_identifier) @name @type.leading.endOf + (user_type) @type + ) @_.domain.start @value.leading.endOf + . + ( + "=" + . + (_) @value @_.domain.end + )? +) -;;!! class Foo(aaa: Int, bbb: Int) {} -;;! ^^^ ^^^ -;;! ^^^ ^^^ +;;!! class Foo(aaa: Int = 0) {} +;;! ^^^ +;;! ^^^ +;;! ^ (class_parameter (simple_identifier) @name @type.leading.endOf - (user_type) @type + (user_type) @type @value.leading.endOf + ( + "=" + (_) @value + )? ) @_.domain ;; (constructor_delegation_call From cd8eb0248aa6304633cf01e399a5606716402b2a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 3 Feb 2026 16:36:44 +0100 Subject: [PATCH 21/31] more fixes --- ...gument.actual.constructor.iteration2.scope | 10 + ...gument.actual.constructor.multiLine2.scope | 44 ++++ ...ument.actual.constructor.singleLine2.scope | 33 +++ ...rgument.formal.constructor.iteration.scope | 14 +- ...gument.formal.constructor.iteration2.scope | 14 +- ...rgument.formal.constructor.multiLine.scope | 24 +-- ...gument.formal.constructor.multiLine2.scope | 20 +- ...gument.formal.constructor.singleLine.scope | 26 +-- ...ument.formal.constructor.singleLine2.scope | 22 +- .../argument/argument.formal.iteration.scope | 14 +- .../argument.formal.method.iteration.scope | 14 +- .../argument.formal.method.multiLine.scope | 24 +-- .../argument.formal.method.singleLine.scope | 26 +-- .../argument/argument.formal.multiLine.scope | 24 +-- .../argument/argument.formal.singleLine.scope | 26 +-- ...gumentList.actual.constructor.empty2.scope | 13 ++ ...ntList.actual.constructor.multiLine2.scope | 33 +++ ...tList.actual.constructor.singleLine2.scope | 13 ++ .../condition/condition.switchCase3.scope | 26 +++ .../kotlin/functionCall.constructor2.scope | 17 ++ .../kotlin/functionCallee.constructor2.scope | 17 ++ queries/kotlin.scm | 190 +++++++++++++++++- 22 files changed, 514 insertions(+), 130 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration2.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.actual.constructor.singleLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty2.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine2.scope create mode 100644 data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine2.scope create mode 100644 data/fixtures/scopes/kotlin/condition/condition.switchCase3.scope create mode 100644 data/fixtures/scopes/kotlin/functionCall.constructor2.scope create mode 100644 data/fixtures/scopes/kotlin/functionCallee.constructor2.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration2.scope new file mode 100644 index 0000000000..5a4d5f34b7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.iteration2.scope @@ -0,0 +1,10 @@ +class Foo: Bar(aaa, bbb) +--- + +[Content] = 0:15-0:23 + >--------< +0| class Foo: Bar(aaa, bbb) + +[Domain] = 0:11-0:24 + >-------------< +0| class Foo: Bar(aaa, bbb) diff --git a/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine2.scope new file mode 100644 index 0000000000..182030c9af --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.multiLine2.scope @@ -0,0 +1,44 @@ +class Foo: Bar( + 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/kotlin/argument/argument.actual.constructor.singleLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.singleLine2.scope new file mode 100644 index 0000000000..dcab830225 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.actual.constructor.singleLine2.scope @@ -0,0 +1,33 @@ +class Foo: Bar(aaa, bbb) +--- + +[#1 Content] = +[#1 Domain] = 0:15-0:18 + >---< +0| class Foo: Bar(aaa, bbb) + +[#1 Removal] = 0:15-0:20 + >-----< +0| class Foo: Bar(aaa, bbb) + +[#1 Trailing delimiter] = 0:18-0:20 + >--< +0| class Foo: Bar(aaa, bbb) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:20-0:23 + >---< +0| class Foo: Bar(aaa, bbb) + +[#2 Removal] = 0:18-0:23 + >-----< +0| class Foo: Bar(aaa, bbb) + +[#2 Leading delimiter] = 0:18-0:20 + >--< +0| class Foo: Bar(aaa, bbb) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope index 8a0d372d4c..5e3ae5940e 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope @@ -1,12 +1,12 @@ class Foo { - constructor(aaa: Int, bbb: Int) {} + constructor(aaa: Int, bbb: Int = 0) {} } --- -[Content] = 1:16-1:34 - >------------------< -1| constructor(aaa: Int, bbb: Int) {} +[Content] = 1:16-1:38 + >----------------------< +1| constructor(aaa: Int, bbb: Int = 0) {} -[Domain] = 1:4-1:38 - >----------------------------------< -1| constructor(aaa: Int, bbb: Int) {} +[Domain] = 1:4-1:42 + >--------------------------------------< +1| constructor(aaa: Int, bbb: Int = 0) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope index 3b4393dee0..6113cca17d 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope @@ -1,10 +1,10 @@ -class Foo(aaa: Int, bbb: Int) {} +class Foo(aaa: Int, bbb: Int = 0) {} --- -[Content] = 0:10-0:28 - >------------------< -0| class Foo(aaa: Int, bbb: Int) {} +[Content] = 0:10-0:32 + >----------------------< +0| class Foo(aaa: Int, bbb: Int = 0) {} -[Domain] = 0:0-0:32 - >--------------------------------< -0| class Foo(aaa: Int, bbb: Int) {} +[Domain] = 0:0-0:36 + >------------------------------------< +0| class Foo(aaa: Int, bbb: Int = 0) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope index 68f06a4a10..e899562339 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope @@ -1,7 +1,7 @@ class Foo { constructor( aaa: Int, - bbb: Int + bbb: Int = 0 ) {} } --- @@ -14,33 +14,33 @@ class Foo { [#1 Removal] = 2:8-3:8 >--------- 2| aaa: Int, -3| bbb: Int +3| bbb: Int = 0 --------< [#1 Trailing delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int +3| bbb: Int = 0 --------< -[#1 Insertion delimiter] = ",\n" +[#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 3:8-3:16 - >--------< -3| bbb: Int +[#2 Domain] = 3:8-3:20 + >------------< +3| bbb: Int = 0 -[#2 Removal] = 2:16-3:16 +[#2 Removal] = 2:16-3:20 >- 2| aaa: Int, -3| bbb: Int - ----------------< +3| bbb: Int = 0 + --------------------< [#2 Leading delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int +3| bbb: Int = 0 --------< -[#2 Insertion delimiter] = ",\n" +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope index bb410b030a..1b4e022350 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope @@ -1,6 +1,6 @@ class Foo( aaa: Int, - bbb: Int + bbb: Int = 0 ) {} --- @@ -12,33 +12,33 @@ class Foo( [#1 Removal] = 1:8-2:8 >--------- 1| aaa: Int, -2| bbb: Int +2| bbb: Int = 0 --------< [#1 Trailing delimiter] = 1:16-2:8 >- 1| aaa: Int, -2| bbb: Int +2| bbb: Int = 0 --------< [#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 2:8-2:16 - >--------< -2| bbb: Int +[#2 Domain] = 2:8-2:20 + >------------< +2| bbb: Int = 0 -[#2 Removal] = 1:16-2:16 +[#2 Removal] = 1:16-2:20 >- 1| aaa: Int, -2| bbb: Int - ----------------< +2| bbb: Int = 0 + --------------------< [#2 Leading delimiter] = 1:16-2:8 >- 1| aaa: Int, -2| bbb: Int +2| bbb: Int = 0 --------< [#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope index 69f944acd7..affd57481c 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope @@ -1,35 +1,35 @@ class Foo { - constructor(aaa: Int, bbb: Int) {} + constructor(aaa: Int, bbb: Int = 0) {} } --- [#1 Content] = [#1 Domain] = 1:16-1:24 >--------< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, bbb: Int = 0) {} [#1 Removal] = 1:16-1:26 >----------< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, bbb: Int = 0) {} [#1 Trailing delimiter] = 1:24-1:26 >--< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, bbb: Int = 0) {} -[#1 Insertion delimiter] = ", " +[#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 1:26-1:34 - >--------< -1| constructor(aaa: Int, bbb: Int) {} +[#2 Domain] = 1:26-1:38 + >------------< +1| constructor(aaa: Int, bbb: Int = 0) {} -[#2 Removal] = 1:24-1:34 - >----------< -1| constructor(aaa: Int, bbb: Int) {} +[#2 Removal] = 1:24-1:38 + >--------------< +1| constructor(aaa: Int, bbb: Int = 0) {} [#2 Leading delimiter] = 1:24-1:26 >--< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, bbb: Int = 0) {} -[#2 Insertion delimiter] = ", " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope index 96d00be9c3..0633f7ffe3 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope @@ -1,33 +1,33 @@ -class Foo(aaa: Int, bbb: Int) {} +class Foo(aaa: Int, bbb: Int = 0) {} --- [#1 Content] = [#1 Domain] = 0:10-0:18 >--------< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, bbb: Int = 0) {} [#1 Removal] = 0:10-0:20 >----------< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, bbb: Int = 0) {} [#1 Trailing delimiter] = 0:18-0:20 >--< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, bbb: Int = 0) {} [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 0:20-0:28 - >--------< -0| class Foo(aaa: Int, bbb: Int) {} +[#2 Domain] = 0:20-0:32 + >------------< +0| class Foo(aaa: Int, bbb: Int = 0) {} -[#2 Removal] = 0:18-0:28 - >----------< -0| class Foo(aaa: Int, bbb: Int) {} +[#2 Removal] = 0:18-0:32 + >--------------< +0| class Foo(aaa: Int, bbb: Int = 0) {} [#2 Leading delimiter] = 0:18-0:20 >--< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, bbb: Int = 0) {} [#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope index 52e03b6d32..bf1ca7873d 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope @@ -1,10 +1,10 @@ -fun bar(aaa: Int, bbb: Int) {} +fun bar(aaa: Int, bbb: Int = 0) {} --- -[Content] = 0:8-0:26 - >------------------< -0| fun bar(aaa: Int, bbb: Int) {} +[Content] = 0:8-0:30 + >----------------------< +0| fun bar(aaa: Int, bbb: Int = 0) {} -[Domain] = 0:0-0:30 - >------------------------------< -0| fun bar(aaa: Int, bbb: Int) {} +[Domain] = 0:0-0:34 + >----------------------------------< +0| fun bar(aaa: Int, bbb: Int = 0) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope index 5776531b87..3e23a263bf 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope @@ -1,12 +1,12 @@ class Foo { - fun bar(aaa: Int, bbb: Int) {} + fun bar(aaa: Int, bbb: Int = 0) {} } --- -[Content] = 1:12-1:30 - >------------------< -1| fun bar(aaa: Int, bbb: Int) {} +[Content] = 1:12-1:34 + >----------------------< +1| fun bar(aaa: Int, bbb: Int = 0) {} -[Domain] = 1:4-1:34 - >------------------------------< -1| fun bar(aaa: Int, bbb: Int) {} +[Domain] = 1:4-1:38 + >----------------------------------< +1| fun bar(aaa: Int, bbb: Int = 0) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope index 1fb547588d..f1a0d1e36e 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope @@ -1,7 +1,7 @@ class Foo { fun bar( aaa: Int, - bbb: Int + bbb: Int = 0 ) {} } --- @@ -14,33 +14,33 @@ class Foo { [#1 Removal] = 2:8-3:8 >--------- 2| aaa: Int, -3| bbb: Int +3| bbb: Int = 0 --------< [#1 Trailing delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int +3| bbb: Int = 0 --------< -[#1 Insertion delimiter] = ",\n" +[#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 3:8-3:16 - >--------< -3| bbb: Int +[#2 Domain] = 3:8-3:20 + >------------< +3| bbb: Int = 0 -[#2 Removal] = 2:16-3:16 +[#2 Removal] = 2:16-3:20 >- 2| aaa: Int, -3| bbb: Int - ----------------< +3| bbb: Int = 0 + --------------------< [#2 Leading delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int +3| bbb: Int = 0 --------< -[#2 Insertion delimiter] = ",\n" +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope index cb4dfaa764..b00b32df20 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope @@ -1,35 +1,35 @@ class Foo { - fun bar(aaa: Int, bbb: Int) {} + fun bar(aaa: Int, bbb: Int = 0) {} } --- [#1 Content] = [#1 Domain] = 1:12-1:20 >--------< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, bbb: Int = 0) {} [#1 Removal] = 1:12-1:22 >----------< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, bbb: Int = 0) {} [#1 Trailing delimiter] = 1:20-1:22 >--< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, bbb: Int = 0) {} -[#1 Insertion delimiter] = ", " +[#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 1:22-1:30 - >--------< -1| fun bar(aaa: Int, bbb: Int) {} +[#2 Domain] = 1:22-1:34 + >------------< +1| fun bar(aaa: Int, bbb: Int = 0) {} -[#2 Removal] = 1:20-1:30 - >----------< -1| fun bar(aaa: Int, bbb: Int) {} +[#2 Removal] = 1:20-1:34 + >--------------< +1| fun bar(aaa: Int, bbb: Int = 0) {} [#2 Leading delimiter] = 1:20-1:22 >--< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, bbb: Int = 0) {} -[#2 Insertion delimiter] = ", " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope index 84a107d269..3125a369d9 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope @@ -1,6 +1,6 @@ fun bar( aaa: Int, - bbb: Int + bbb: Int = 0 ) {} --- @@ -12,33 +12,33 @@ fun bar( [#1 Removal] = 1:4-2:4 >--------- 1| aaa: Int, -2| bbb: Int +2| bbb: Int = 0 ----< [#1 Trailing delimiter] = 1:12-2:4 >- 1| aaa: Int, -2| bbb: Int +2| bbb: Int = 0 ----< -[#1 Insertion delimiter] = ",\n" +[#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 2:4-2:12 - >--------< -2| bbb: Int +[#2 Domain] = 2:4-2:16 + >------------< +2| bbb: Int = 0 -[#2 Removal] = 1:12-2:12 +[#2 Removal] = 1:12-2:16 >- 1| aaa: Int, -2| bbb: Int - ------------< +2| bbb: Int = 0 + ----------------< [#2 Leading delimiter] = 1:12-2:4 >- 1| aaa: Int, -2| bbb: Int +2| bbb: Int = 0 ----< -[#2 Insertion delimiter] = ",\n" +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope index b25167938c..eafc639a73 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope @@ -1,33 +1,33 @@ -fun bar(aaa: Int, bbb: Int) {} +fun bar(aaa: Int, bbb: Int = 0) {} --- [#1 Content] = [#1 Domain] = 0:8-0:16 >--------< -0| fun bar(aaa: Int, bbb: Int) {} +0| fun bar(aaa: Int, bbb: Int = 0) {} [#1 Removal] = 0:8-0:18 >----------< -0| fun bar(aaa: Int, bbb: Int) {} +0| fun bar(aaa: Int, bbb: Int = 0) {} [#1 Trailing delimiter] = 0:16-0:18 >--< -0| fun bar(aaa: Int, bbb: Int) {} +0| fun bar(aaa: Int, bbb: Int = 0) {} -[#1 Insertion delimiter] = ", " +[#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 0:18-0:26 - >--------< -0| fun bar(aaa: Int, bbb: Int) {} +[#2 Domain] = 0:18-0:30 + >------------< +0| fun bar(aaa: Int, bbb: Int = 0) {} -[#2 Removal] = 0:16-0:26 - >----------< -0| fun bar(aaa: Int, bbb: Int) {} +[#2 Removal] = 0:16-0:30 + >--------------< +0| fun bar(aaa: Int, bbb: Int = 0) {} [#2 Leading delimiter] = 0:16-0:18 >--< -0| fun bar(aaa: Int, bbb: Int) {} +0| fun bar(aaa: Int, bbb: Int = 0) {} -[#2 Insertion delimiter] = ", " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty2.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty2.scope new file mode 100644 index 0000000000..94f6c2f5db --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.empty2.scope @@ -0,0 +1,13 @@ +class Foo: Bar() +--- + +[Content] = +[Removal] = 0:15-0:15 + >< +0| class Foo: Bar() + +[Domain] = 0:11-0:16 + >-----< +0| class Foo: Bar() + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine2.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine2.scope new file mode 100644 index 0000000000..7233dfa82d --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.multiLine2.scope @@ -0,0 +1,33 @@ +class Foo: Bar( + aaa, + bbb +) +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:15-3:0 + > +0| class Foo: Bar( +1| aaa, +2| bbb +3| ) + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:11-3:1 + >---- +0| class Foo: Bar( +1| aaa, +2| bbb +3| ) + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine2.scope b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine2.scope new file mode 100644 index 0000000000..82864b9d93 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argumentList/argumentList.actual.constructor.singleLine2.scope @@ -0,0 +1,13 @@ +class Foo: Bar(aaa, bbb) +--- + +[Content] = +[Removal] = 0:15-0:23 + >--------< +0| class Foo: Bar(aaa, bbb) + +[Domain] = 0:11-0:24 + >-------------< +0| class Foo: Bar(aaa, bbb) + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/condition/condition.switchCase3.scope b/data/fixtures/scopes/kotlin/condition/condition.switchCase3.scope new file mode 100644 index 0000000000..759b683694 --- /dev/null +++ b/data/fixtures/scopes/kotlin/condition/condition.switchCase3.scope @@ -0,0 +1,26 @@ +when (foo) { + else -> break +} +--- + +[Content] = 1:4-1:8 + >----< +1| else -> break + +[Removal] = 1:4-1:9 + >-----< +1| else -> break + +[Leading delimiter] = 1:0-1:4 + >----< +1| else -> break + +[Trailing delimiter] = 1:8-1:9 + >-< +1| else -> break + +[Domain] = 1:4-1:17 + >-------------< +1| else -> break + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCall.constructor2.scope b/data/fixtures/scopes/kotlin/functionCall.constructor2.scope new file mode 100644 index 0000000000..0af026f8fe --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCall.constructor2.scope @@ -0,0 +1,17 @@ +class Foo: Bar() +--- + +[Content] = +[Domain] = 0:11-0:16 + >-----< +0| class Foo: Bar() + +[Removal] = 0:10-0:16 + >------< +0| class Foo: Bar() + +[Leading delimiter] = 0:10-0:11 + >-< +0| class Foo: Bar() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCallee.constructor2.scope b/data/fixtures/scopes/kotlin/functionCallee.constructor2.scope new file mode 100644 index 0000000000..a0ff063a6f --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCallee.constructor2.scope @@ -0,0 +1,17 @@ +class Foo: Bar() +--- + +[Content] = +[Removal] = 0:11-0:14 + >---< +0| class Foo: Bar() + +[Leading delimiter] = 0:10-0:11 + >-< +0| class Foo: Bar() + +[Domain] = 0:11-0:16 + >-----< +0| class Foo: Bar() + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index ad309e22dd..2ba5ec606f 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -237,7 +237,10 @@ ;;!! 0, 1 -> break ;;! ^ ^ (when_entry - (when_condition) @condition + [ + (when_condition) + "else" + ] @condition (#allow-multiple! @condition) ) @condition.domain @@ -731,17 +734,185 @@ ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) +;;!! foo: Int ( (function_value_parameters (_)? @_.leading.endOf . - (_) @argumentOrParameter + (parameter) @argumentOrParameter + . + [ + "," + ")" + ] . (_)? @_.trailing.startOf - ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") + ) +) + +;;!! foo: Int = 0 +( + (function_value_parameters + (_)? @_.leading.endOf + . + (parameter) @argumentOrParameter.start + . + "=" + . + (_) @argumentOrParameter.end + . + [ + "," + ")" + ] + . + (_)? @_.trailing.startOf + ) ) +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (parameter) @argumentOrParameter.start +;; . +;; ( +;; "=" +;; . +;; (_) @argumentOrParameter.end +;; ) +;; . +;; (_)? @_.trailing.startOf +;; ) +;; ) + +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (parameter) @argumentOrParameter.start +;; . +;; ( +;; "=" +;; . +;; (_) @argumentOrParameter.end +;; )? +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; ;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") +;; ) + +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; [ +;; "," +;; "(" +;; ] +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; (parameter_modifiers)? @argumentOrParameter.start +;; . +;; (parameter) @argumentOrParameter.end +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") +;; ) + +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; [ +;; "," +;; "(" +;; ] +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; (parameter_modifiers)? @argumentOrParameter.start.startOf +;; . +;; (parameter) @argumentOrParameter.start +;; . +;; (_) @argumentOrParameter.end +;; (#not-type? @argumentOrParameter.end "parameter" "parameter_modifiers") +;; . +;; [ +;; (line_comment) +;; (multiline_comment) +;; ] * +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") +;; ) + +;; ( +;; (function_value_parameters +;; ;; (_)? @_.leading.endOf +;; ;; . +;; (_) @argumentOrParameter.start +;; . +;; ( +;; "=" +;; . +;; (_) @argumentOrParameter.end +;; )? +;; ;; . +;; ;; (_)? @_.trailing.startOf +;; ) @_dummy +;; ;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") +;; ) + +;; (function_value_parameters +;; (parameter +;; (simple_identifier) @name @type.leading.endOf +;; (user_type) @type +;; ) @_.domain.start @value.leading.endOf +;; . +;; ( +;; "=" +;; . +;; (_) @value @_.domain.end +;; )? +;; ) + +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (_) @argumentOrParameter +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +;; ) + ;;!! { aaa, bbb -> } ;;! ^^^^^^^^ (lambda_literal @@ -800,8 +971,10 @@ ;;!! foo(aaa, bbb) ;;! ^^^^^^^^ -(call_expression - (call_suffix +;;!! class Foo: Bar(aaa, bbb) +;;! ^^^^^^^^ +(_ + (_ (value_arguments "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf @@ -904,6 +1077,11 @@ (value_arguments) ) @functionCall @functionCallee.domain +;;!! class Foo: Bar() +(constructor_invocation + (user_type) @functionCallee +) @functionCall @functionCallee.domain + ;; ( ;; (function_value_parameters ;; (_)? @_.leading.endOf From e8ebcd1186e954a4cd9a4a92bbc96fa2b093d027 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Tue, 3 Feb 2026 16:45:47 +0100 Subject: [PATCH 22/31] more work --- data/fixtures/recorded/languages/kotlin/chuckBranch.yml | 2 +- .../argument/argument.formal.constructor.multiLine.scope | 4 ++-- .../argument/argument.formal.constructor.singleLine.scope | 4 ++-- .../argument/argument.formal.method.multiLine.scope | 4 ++-- .../argument/argument.formal.method.singleLine.scope | 4 ++-- .../kotlin/argument/argument.formal.multiLine.scope | 4 ++-- .../kotlin/argument/argument.formal.singleLine.scope | 4 ++-- queries/kotlin.scm | 8 +++++--- 8 files changed, 18 insertions(+), 16 deletions(-) diff --git a/data/fixtures/recorded/languages/kotlin/chuckBranch.yml b/data/fixtures/recorded/languages/kotlin/chuckBranch.yml index 2fc3ceb9cd..235df08827 100644 --- a/data/fixtures/recorded/languages/kotlin/chuckBranch.yml +++ b/data/fixtures/recorded/languages/kotlin/chuckBranch.yml @@ -26,7 +26,7 @@ finalState: fun main() { if (true) 0 - 1 + else 1 } selections: - anchor: {line: 3, character: 4} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope index e899562339..f01ba8c282 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope @@ -23,7 +23,7 @@ class Foo { 3| bbb: Int = 0 --------< -[#1 Insertion delimiter] = " " +[#1 Insertion delimiter] = ",\n" [#2 Content] = @@ -43,4 +43,4 @@ class Foo { 3| bbb: Int = 0 --------< -[#2 Insertion delimiter] = " " +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope index affd57481c..48cb7eb3c9 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope @@ -16,7 +16,7 @@ class Foo { >--< 1| constructor(aaa: Int, bbb: Int = 0) {} -[#1 Insertion delimiter] = " " +[#1 Insertion delimiter] = ", " [#2 Content] = @@ -32,4 +32,4 @@ class Foo { >--< 1| constructor(aaa: Int, bbb: Int = 0) {} -[#2 Insertion delimiter] = " " +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope index f1a0d1e36e..1057414161 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope @@ -23,7 +23,7 @@ class Foo { 3| bbb: Int = 0 --------< -[#1 Insertion delimiter] = " " +[#1 Insertion delimiter] = ",\n" [#2 Content] = @@ -43,4 +43,4 @@ class Foo { 3| bbb: Int = 0 --------< -[#2 Insertion delimiter] = " " +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope index b00b32df20..bb3182f5ae 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope @@ -16,7 +16,7 @@ class Foo { >--< 1| fun bar(aaa: Int, bbb: Int = 0) {} -[#1 Insertion delimiter] = " " +[#1 Insertion delimiter] = ", " [#2 Content] = @@ -32,4 +32,4 @@ class Foo { >--< 1| fun bar(aaa: Int, bbb: Int = 0) {} -[#2 Insertion delimiter] = " " +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope index 3125a369d9..985d9594d5 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope @@ -21,7 +21,7 @@ fun bar( 2| bbb: Int = 0 ----< -[#1 Insertion delimiter] = " " +[#1 Insertion delimiter] = ",\n" [#2 Content] = @@ -41,4 +41,4 @@ fun bar( 2| bbb: Int = 0 ----< -[#2 Insertion delimiter] = " " +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope index eafc639a73..f6437d8536 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope @@ -14,7 +14,7 @@ fun bar(aaa: Int, bbb: Int = 0) {} >--< 0| fun bar(aaa: Int, bbb: Int = 0) {} -[#1 Insertion delimiter] = " " +[#1 Insertion delimiter] = ", " [#2 Content] = @@ -30,4 +30,4 @@ fun bar(aaa: Int, bbb: Int = 0) {} >--< 0| fun bar(aaa: Int, bbb: Int = 0) {} -[#2 Insertion delimiter] = " " +[#2 Insertion delimiter] = ", " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 2ba5ec606f..619d0074cd 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -146,7 +146,7 @@ (if_expression "if" @branch.start @branch.removal.start.startOf condition: (_) @condition - consequence: (_) @branch.end @branch.removal.end.endOf + consequence: (_)? @branch.end @branch.removal.end.endOf "else"? @branch.removal.end.startOf alternative: (control_structure_body . @@ -747,7 +747,8 @@ ] . (_)? @_.trailing.startOf - ) + ) @_dummy + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) ;;!! foo: Int = 0 @@ -767,7 +768,8 @@ ] . (_)? @_.trailing.startOf - ) + ) @_dummy + (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") ) ;; ( From ca4b3f5ca74fa1050e7b71b906f7182d9c1e5765 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 10:37:12 +0100 Subject: [PATCH 23/31] more tests --- data/fixtures/scopes/kotlin/class3.scope | 10 +++ data/fixtures/scopes/kotlin/class4.scope | 33 +++++++++ .../scopes/kotlin/name/name.class2.scope | 24 ++++++ .../scopes/kotlin/name/name.class3.scope | 52 +++++++++++++ .../kotlin/statement/statement.class2.scope | 11 +-- .../kotlin/statement/statement.class3.scope | 33 +++++++++ .../scopes/kotlin/type/type.class2.scope | 10 +++ .../scopes/kotlin/type/type.class3.scope | 33 +++++++++ .../scopes/kotlin/value/value.switch2.scope | 20 +++++ .../scopes/kotlin/value/value.switch3.scope | 20 +++++ .../kotlin/value/value.typeAlias2.scope | 20 +++++ queries/kotlin.scm | 73 +++++++++++++++---- 12 files changed, 318 insertions(+), 21 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/class3.scope create mode 100644 data/fixtures/scopes/kotlin/class4.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.class2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.class3.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.class3.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.class2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.class3.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.switch2.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.switch3.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.typeAlias2.scope diff --git a/data/fixtures/scopes/kotlin/class3.scope b/data/fixtures/scopes/kotlin/class3.scope new file mode 100644 index 0000000000..32eea1eb2b --- /dev/null +++ b/data/fixtures/scopes/kotlin/class3.scope @@ -0,0 +1,10 @@ +object Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| object Foo {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/class4.scope b/data/fixtures/scopes/kotlin/class4.scope new file mode 100644 index 0000000000..28390172bb --- /dev/null +++ b/data/fixtures/scopes/kotlin/class4.scope @@ -0,0 +1,33 @@ +class Foo { + companion object Bar {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| companion object Bar {} +2| } + -< + +[#1 Insertion delimiter] = "\n\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:27 + >-----------------------< +1| companion object Bar {} + +[#2 Removal] = 1:0-2:0 + >--------------------------- +1| companion object Bar {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| companion object Bar {} + +[#2 Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/name/name.class2.scope b/data/fixtures/scopes/kotlin/name/name.class2.scope new file mode 100644 index 0000000000..f5dc179a8b --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.class2.scope @@ -0,0 +1,24 @@ +object Foo {} +--- + +[Content] = 0:7-0:10 + >---< +0| object Foo {} + +[Removal] = 0:7-0:11 + >----< +0| object Foo {} + +[Leading delimiter] = 0:6-0:7 + >-< +0| object Foo {} + +[Trailing delimiter] = 0:10-0:11 + >-< +0| object Foo {} + +[Domain] = 0:0-0:13 + >-------------< +0| object Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.class3.scope b/data/fixtures/scopes/kotlin/name/name.class3.scope new file mode 100644 index 0000000000..518f3ca8bb --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.class3.scope @@ -0,0 +1,52 @@ +class Foo { + companion object 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| companion object Bar {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:21-1:24 + >---< +1| companion object Bar {} + +[#2 Removal] = 1:21-1:25 + >----< +1| companion object Bar {} + +[#2 Leading delimiter] = 1:20-1:21 + >-< +1| companion object Bar {} + +[#2 Trailing delimiter] = 1:24-1:25 + >-< +1| companion object Bar {} + +[#2 Domain] = 1:4-1:27 + >-----------------------< +1| companion object Bar {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/statement/statement.class2.scope b/data/fixtures/scopes/kotlin/statement/statement.class2.scope index 2676bb1634..987f60709b 100644 --- a/data/fixtures/scopes/kotlin/statement/statement.class2.scope +++ b/data/fixtures/scopes/kotlin/statement/statement.class2.scope @@ -1,13 +1,10 @@ -@bar -class Foo {} +object Foo {} --- [Content] = [Removal] = -[Domain] = 0:0-1:12 - >---- -0| @bar -1| class Foo {} - ------------< +[Domain] = 0:0-0:13 + >-------------< +0| object Foo {} [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.class3.scope b/data/fixtures/scopes/kotlin/statement/statement.class3.scope new file mode 100644 index 0000000000..81d99eb207 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.class3.scope @@ -0,0 +1,33 @@ +class Foo { + companion object Bar {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| companion object Bar {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:27 + >-----------------------< +1| companion object Bar {} + +[#2 Removal] = 1:0-2:0 + >--------------------------- +1| companion object Bar {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| companion object Bar {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/type/type.class2.scope b/data/fixtures/scopes/kotlin/type/type.class2.scope new file mode 100644 index 0000000000..cac638ce3c --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.class2.scope @@ -0,0 +1,10 @@ +object Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| object Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.class3.scope b/data/fixtures/scopes/kotlin/type/type.class3.scope new file mode 100644 index 0000000000..4ff64c01ca --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.class3.scope @@ -0,0 +1,33 @@ +class Foo { + companion object Bar {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| companion object Bar {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 1:4-1:27 + >-----------------------< +1| companion object Bar {} + +[#2 Removal] = 1:0-2:0 + >--------------------------- +1| companion object Bar {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| companion object Bar {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.switch2.scope b/data/fixtures/scopes/kotlin/value/value.switch2.scope new file mode 100644 index 0000000000..91c3e820f7 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.switch2.scope @@ -0,0 +1,20 @@ +when (val foo = 0) {} +--- + +[Content] = 0:16-0:17 + >-< +0| when (val foo = 0) {} + +[Removal] = 0:13-0:17 + >----< +0| when (val foo = 0) {} + +[Leading delimiter] = 0:13-0:16 + >---< +0| when (val foo = 0) {} + +[Domain] = 0:0-0:21 + >---------------------< +0| when (val foo = 0) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.switch3.scope b/data/fixtures/scopes/kotlin/value/value.switch3.scope new file mode 100644 index 0000000000..c5cf2e1be1 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.switch3.scope @@ -0,0 +1,20 @@ +when (val foo: Int = 0) {} +--- + +[Content] = 0:21-0:22 + >-< +0| when (val foo: Int = 0) {} + +[Removal] = 0:18-0:22 + >----< +0| when (val foo: Int = 0) {} + +[Leading delimiter] = 0:18-0:21 + >---< +0| when (val foo: Int = 0) {} + +[Domain] = 0:0-0:26 + >--------------------------< +0| when (val foo: Int = 0) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.typeAlias2.scope b/data/fixtures/scopes/kotlin/value/value.typeAlias2.scope new file mode 100644 index 0000000000..61252c8a76 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.typeAlias2.scope @@ -0,0 +1,20 @@ +typealias Foo = Bar +--- + +[Content] = 0:19-0:22 + >---< +0| typealias Foo = Bar + +[Removal] = 0:16-0:22 + >------< +0| typealias Foo = Bar + +[Leading delimiter] = 0:16-0:19 + >---< +0| typealias Foo = Bar + +[Domain] = 0:0-0:22 + >----------------------< +0| typealias Foo = Bar + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 619d0074cd..e6e65ab201 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -32,6 +32,8 @@ [ (class_declaration) + (object_declaration) + (companion_object) (function_declaration) (secondary_constructor) (anonymous_initializer) @@ -83,14 +85,6 @@ "}" @interior.end.startOf ) -;; (object_declaration -;; (type_identifier) @name -;; ) @class @name.domain - -;; (companion_object -;; (type_identifier) @name -;; ) @class @name.domain - ;;!! fun foo(): Int {} ;;! ^^^ ;;! ^^^ @@ -220,16 +214,35 @@ ;;!! finally {} (finally_block) @branch -;;!! when (foo) { } -;;! ^^^ +;;!! when (true) { } ;;! ^ +(when_expression + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf +) @branch.iteration.domain @condition.iteration.domain + +;;!! when (true) {} +;;! ^^^ +(when_expression + (when_subject + . + (_) @value + . + ) +) @value.domain + +;;!! when (foo) {} +;;! ^^^ (when_expression (when_subject + (variable_declaration + (simple_identifier) @name + (user_type)? @type + ) @value.leading.endOf + "=" (_) @value ) - "{" @branch.iteration.start.endOf @condition.iteration.start.endOf - "}" @branch.iteration.end.startOf @condition.iteration.end.startOf -) @value.domain @branch.iteration.domain @condition.iteration.domain +) @_.domain ;;!! 0 -> break (when_entry) @branch @@ -342,6 +355,16 @@ (type_identifier) @name ) @class @type @name.domain +;;!! object Foo {} +(object_declaration + (type_identifier) @name +) @class @type @name.domain + +;;!! companion object Foo {} +(companion_object + (type_identifier) @name +) @class @type @name.domain + ;; (class_parameter ;; (simple_identifier) @name ;; ) @_.domain @@ -476,7 +499,19 @@ ;;! ^^^ (type_alias (type_identifier) @name @value.leading.endOf - (user_type) @value + . + "=" + (_) @value +) @type @_.domain + +;;!! typealias Foo = Bar +;;! ^^^^^^ +;;! ^^^ +(type_alias + (type_identifier) @name.start + (type_parameters) @name.end @value.leading.endOf + "=" + (_) @value ) @type @_.domain ;; (property_declaration @@ -933,6 +968,16 @@ ] ) @argumentList.domain +;;!! { aaa: Int, bbb: Int -> } +;;! ^^^ ^^^ +;;! ^^^ ^^^ +(lambda_parameters + (variable_declaration + (simple_identifier) @name @type.leading.endOf + (user_type)? @type + ) @_.domain +) + ( (lambda_parameters (_)? @_.leading.endOf From e01668d81ca3f00a0594ef1d5053fcad6865a0de Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 10:53:28 +0100 Subject: [PATCH 24/31] call --- .../languages/kotlin/changeEveryName.yml | 8 +++--- .../languages/kotlin/changeEveryName2.yml | 8 +++--- .../languages/kotlin/changeName11.yml | 8 +++--- .../languages/kotlin/changeValue10.yml | 25 ------------------- .../functionCall.chain.scope | 0 .../functionCall.constructor.scope | 0 .../functionCall.constructor2.scope | 0 .../functionCall.constructor3.scope | 19 ++++++++++++++ .../functionCall.method.scope | 0 .../{ => functionCall}/functionCall.scope | 0 .../functionCallee.chain.scope | 0 .../functionCallee.constructor.scope | 0 .../functionCallee.constructor2.scope | 0 .../functionCallee.constructor3.scope | 19 ++++++++++++++ .../functionCallee.method.scope | 0 .../{ => functionCallee}/functionCallee.scope | 0 queries/kotlin.scm | 21 +++++++++++++--- 17 files changed, 65 insertions(+), 43 deletions(-) delete mode 100644 data/fixtures/recorded/languages/kotlin/changeValue10.yml rename data/fixtures/scopes/kotlin/{ => functionCall}/functionCall.chain.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCall}/functionCall.constructor.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCall}/functionCall.constructor2.scope (100%) create mode 100644 data/fixtures/scopes/kotlin/functionCall/functionCall.constructor3.scope rename data/fixtures/scopes/kotlin/{ => functionCall}/functionCall.method.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCall}/functionCall.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCallee}/functionCallee.chain.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCallee}/functionCallee.constructor.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCallee}/functionCallee.constructor2.scope (100%) create mode 100644 data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor3.scope rename data/fixtures/scopes/kotlin/{ => functionCallee}/functionCallee.method.scope (100%) rename data/fixtures/scopes/kotlin/{ => functionCallee}/functionCallee.scope (100%) diff --git a/data/fixtures/recorded/languages/kotlin/changeEveryName.yml b/data/fixtures/recorded/languages/kotlin/changeEveryName.yml index e59b5a9eb6..b3201aa534 100644 --- a/data/fixtures/recorded/languages/kotlin/changeEveryName.yml +++ b/data/fixtures/recorded/languages/kotlin/changeEveryName.yml @@ -22,10 +22,8 @@ initialState: finalState: documentContents: |- fun main() { - val (, ) = Pair(1, 2) + val = Pair(1, 2) } selections: - - anchor: {line: 1, character: 9} - active: {line: 1, character: 9} - - anchor: {line: 1, character: 11} - active: {line: 1, character: 11} + - anchor: {line: 1, character: 8} + active: {line: 1, character: 8} diff --git a/data/fixtures/recorded/languages/kotlin/changeEveryName2.yml b/data/fixtures/recorded/languages/kotlin/changeEveryName2.yml index 9737b26b9a..16078ea09e 100644 --- a/data/fixtures/recorded/languages/kotlin/changeEveryName2.yml +++ b/data/fixtures/recorded/languages/kotlin/changeEveryName2.yml @@ -28,12 +28,10 @@ finalState: fun main() { val pairs = listOf(Pair(1, "one"), Pair(2, "two"), Pair(3, "three")) - for ((, ) in pairs) { + for ( in pairs) { println("Number: $number, Name: $name") } } selections: - - anchor: {line: 3, character: 10} - active: {line: 3, character: 10} - - anchor: {line: 3, character: 12} - active: {line: 3, character: 12} + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} diff --git a/data/fixtures/recorded/languages/kotlin/changeName11.yml b/data/fixtures/recorded/languages/kotlin/changeName11.yml index 04984d9979..3ec17696b0 100644 --- a/data/fixtures/recorded/languages/kotlin/changeName11.yml +++ b/data/fixtures/recorded/languages/kotlin/changeName11.yml @@ -25,13 +25,13 @@ initialState: marks: {} finalState: documentContents: |- - fun main() { + fun () { try { val result = 10 / 0 - } catch (: ArithmeticException) { + } catch (e: ArithmeticException) { println("Division by zero!") } } selections: - - anchor: {line: 3, character: 13} - active: {line: 3, character: 13} + - anchor: {line: 0, character: 4} + active: {line: 0, character: 4} diff --git a/data/fixtures/recorded/languages/kotlin/changeValue10.yml b/data/fixtures/recorded/languages/kotlin/changeValue10.yml deleted file mode 100644 index 971cfbdb84..0000000000 --- a/data/fixtures/recorded/languages/kotlin/changeValue10.yml +++ /dev/null @@ -1,25 +0,0 @@ -languageId: kotlin -command: - version: 7 - spokenForm: change value - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: value} - usePrePhraseSnapshot: true -initialState: - documentContents: | - fun double(x: Int) = x * 2 - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: {} -finalState: - documentContents: | - fun double(x: Int) = - selections: - - anchor: {line: 0, character: 21} - active: {line: 0, character: 21} diff --git a/data/fixtures/scopes/kotlin/functionCall.chain.scope b/data/fixtures/scopes/kotlin/functionCall/functionCall.chain.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCall.chain.scope rename to data/fixtures/scopes/kotlin/functionCall/functionCall.chain.scope diff --git a/data/fixtures/scopes/kotlin/functionCall.constructor.scope b/data/fixtures/scopes/kotlin/functionCall/functionCall.constructor.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCall.constructor.scope rename to data/fixtures/scopes/kotlin/functionCall/functionCall.constructor.scope diff --git a/data/fixtures/scopes/kotlin/functionCall.constructor2.scope b/data/fixtures/scopes/kotlin/functionCall/functionCall.constructor2.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCall.constructor2.scope rename to data/fixtures/scopes/kotlin/functionCall/functionCall.constructor2.scope diff --git a/data/fixtures/scopes/kotlin/functionCall/functionCall.constructor3.scope b/data/fixtures/scopes/kotlin/functionCall/functionCall.constructor3.scope new file mode 100644 index 0000000000..79b65cdf7a --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCall/functionCall.constructor3.scope @@ -0,0 +1,19 @@ +class Foo { + constructor(): this() +} +--- + +[Content] = +[Domain] = 1:19-1:25 + >------< +1| constructor(): this() + +[Removal] = 1:18-1:25 + >-------< +1| constructor(): this() + +[Leading delimiter] = 1:18-1:19 + >-< +1| constructor(): this() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCall.method.scope b/data/fixtures/scopes/kotlin/functionCall/functionCall.method.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCall.method.scope rename to data/fixtures/scopes/kotlin/functionCall/functionCall.method.scope diff --git a/data/fixtures/scopes/kotlin/functionCall.scope b/data/fixtures/scopes/kotlin/functionCall/functionCall.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCall.scope rename to data/fixtures/scopes/kotlin/functionCall/functionCall.scope diff --git a/data/fixtures/scopes/kotlin/functionCallee.chain.scope b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.chain.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCallee.chain.scope rename to data/fixtures/scopes/kotlin/functionCallee/functionCallee.chain.scope diff --git a/data/fixtures/scopes/kotlin/functionCallee.constructor.scope b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCallee.constructor.scope rename to data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor.scope diff --git a/data/fixtures/scopes/kotlin/functionCallee.constructor2.scope b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor2.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCallee.constructor2.scope rename to data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor2.scope diff --git a/data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor3.scope b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor3.scope new file mode 100644 index 0000000000..afafd94175 --- /dev/null +++ b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.constructor3.scope @@ -0,0 +1,19 @@ +class Foo { + constructor(): this() +} +--- + +[Content] = +[Removal] = 1:19-1:23 + >----< +1| constructor(): this() + +[Leading delimiter] = 1:18-1:19 + >-< +1| constructor(): this() + +[Domain] = 1:19-1:25 + >------< +1| constructor(): this() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/functionCallee.method.scope b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.method.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCallee.method.scope rename to data/fixtures/scopes/kotlin/functionCallee/functionCallee.method.scope diff --git a/data/fixtures/scopes/kotlin/functionCallee.scope b/data/fixtures/scopes/kotlin/functionCallee/functionCallee.scope similarity index 100% rename from data/fixtures/scopes/kotlin/functionCallee.scope rename to data/fixtures/scopes/kotlin/functionCallee/functionCallee.scope diff --git a/queries/kotlin.scm b/queries/kotlin.scm index e6e65ab201..38a288525b 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -542,10 +542,13 @@ ;;! ^ ;;! ^^^ (for_statement - (variable_declaration - (simple_identifier) @name @type.leading.endOf - (user_type)? @type - ) + [ + (variable_declaration + (simple_identifier) @name @type.leading.endOf + (user_type)? @type + ) + (multi_variable_declaration) @name + ] "in" . (_) @value @@ -1125,10 +1128,20 @@ ) @functionCall @functionCallee.domain ;;!! class Foo: Bar() +;;! ^^^^^ (constructor_invocation (user_type) @functionCallee ) @functionCall @functionCallee.domain +;;!! constructor(): this() +;;! ^^^^^^ +(constructor_delegation_call + [ + "this" + "super" + ] @functionCallee +) @functionCall @functionCallee.domain + ;; ( ;; (function_value_parameters ;; (_)? @_.leading.endOf From a61f8b60200c4350bece6755a9dd7b8df6052fd5 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 11:20:46 +0100 Subject: [PATCH 25/31] map pair --- .../languages/kotlin/changeState8.yml | 2 - .../scopes/kotlin/key.mapPair.iteration.scope | 7 +++ data/fixtures/scopes/kotlin/key.mapPair.scope | 43 +++++++++++++++++++ .../value/value.mapPair.iteration.scope | 13 ++++++ .../scopes/kotlin/value/value.mapPair.scope | 39 +++++++++++++++++ .../common/src/scopeSupportFacets/kotlin.ts | 11 +++-- queries/kotlin.scm | 40 +++++++++++++---- 7 files changed, 138 insertions(+), 17 deletions(-) create mode 100644 data/fixtures/scopes/kotlin/key.mapPair.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/key.mapPair.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.mapPair.iteration.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.mapPair.scope diff --git a/data/fixtures/recorded/languages/kotlin/changeState8.yml b/data/fixtures/recorded/languages/kotlin/changeState8.yml index d90327aa5c..77e2703a8f 100644 --- a/data/fixtures/recorded/languages/kotlin/changeState8.yml +++ b/data/fixtures/recorded/languages/kotlin/changeState8.yml @@ -36,8 +36,6 @@ finalState: documentContents: |- package test - - @Annotation class Test { fun add(x: Int, y: Int) = x + y diff --git a/data/fixtures/scopes/kotlin/key.mapPair.iteration.scope b/data/fixtures/scopes/kotlin/key.mapPair.iteration.scope new file mode 100644 index 0000000000..33ef36ed68 --- /dev/null +++ b/data/fixtures/scopes/kotlin/key.mapPair.iteration.scope @@ -0,0 +1,7 @@ +mapOf(aaa to 0, bbb to 1) +--- + +[Content] = +[Domain] = 0:6-0:24 + >------------------< +0| mapOf(aaa to 0, bbb to 1) diff --git a/data/fixtures/scopes/kotlin/key.mapPair.scope b/data/fixtures/scopes/kotlin/key.mapPair.scope new file mode 100644 index 0000000000..cc62511afb --- /dev/null +++ b/data/fixtures/scopes/kotlin/key.mapPair.scope @@ -0,0 +1,43 @@ +mapOf(aaa to 0, bbb to 1) +--- + +[#1 Content] = 0:6-0:9 + >---< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Removal] = 0:6-0:10 + >----< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Domain] = 0:6-0:14 + >--------< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:16-0:19 + >---< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Removal] = 0:16-0:20 + >----< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Leading delimiter] = 0:15-0:16 + >-< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Trailing delimiter] = 0:19-0:20 + >-< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Domain] = 0:16-0:24 + >--------< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.mapPair.iteration.scope b/data/fixtures/scopes/kotlin/value/value.mapPair.iteration.scope new file mode 100644 index 0000000000..f5bab59979 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.mapPair.iteration.scope @@ -0,0 +1,13 @@ +mapOf(aaa to 0, bbb to 1) +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:25 + >-------------------------< +0| mapOf(aaa to 0, bbb to 1) + + +[#2 Content] = +[#2 Domain] = 0:6-0:24 + >------------------< +0| mapOf(aaa to 0, bbb to 1) diff --git a/data/fixtures/scopes/kotlin/value/value.mapPair.scope b/data/fixtures/scopes/kotlin/value/value.mapPair.scope new file mode 100644 index 0000000000..fcdd57de13 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.mapPair.scope @@ -0,0 +1,39 @@ +mapOf(aaa to 0, bbb to 1) +--- + +[#1 Content] = 0:13-0:14 + >-< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Removal] = 0:9-0:14 + >-----< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Leading delimiter] = 0:9-0:13 + >----< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Domain] = 0:6-0:14 + >--------< +0| mapOf(aaa to 0, bbb to 1) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:23-0:24 + >-< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Removal] = 0:19-0:24 + >-----< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Leading delimiter] = 0:19-0:23 + >----< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Domain] = 0:16-0:24 + >--------< +0| mapOf(aaa to 0, bbb to 1) + +[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/kotlin.ts b/packages/common/src/scopeSupportFacets/kotlin.ts index 3e485421ba..c4e4fa316d 100644 --- a/packages/common/src/scopeSupportFacets/kotlin.ts +++ b/packages/common/src/scopeSupportFacets/kotlin.ts @@ -154,6 +154,9 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "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, @@ -173,6 +176,8 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "value.iteration.block": supported, "value.iteration.class": supported, "value.iteration.document": supported, + "value.mapPair": supported, + "value.mapPair.iteration": supported, "type.argument.formal": supported, "type.argument.formal.iteration": supported, @@ -286,12 +291,6 @@ export const kotlinScopeSupport: LanguageScopeSupportFacetMap = { "collectionItem.unenclosed.multiLine": notApplicable, "collectionItem.unenclosed.iteration": notApplicable, - // Map pair - "key.mapPair": notApplicable, - "key.mapPair.iteration": notApplicable, - "value.mapPair": notApplicable, - "value.mapPair.iteration": notApplicable, - // Miscellaneous environment: notApplicable, regularExpression: notApplicable, diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 38a288525b..18d0f7d935 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -45,6 +45,8 @@ (jump_expression) (when_expression) (try_expression) + (import_list) + (package_header) ;; Disabled on purpose. We have a better definition of this below. ;; (if_expression) @@ -704,12 +706,28 @@ ;; (_) @value.start ;; ) @value.end.endOf @_.domain -;; (infix_expression -;; (_) @collectionKey -;; (simple_identifier) @_dummy -;; (#eq? @_dummy "to") -;; (_) @value -;; ) @_.domain +;;!! aaa to 0 +;;! ^^^ +;;! ^ +(infix_expression + (_) @collectionKey @value.leading.endOf + (simple_identifier) @_dummy + (_) @value + (#eq? @_dummy "to") +) @_.domain + +;;!! mapOf( ) +;;! ^ +(call_expression + (simple_identifier) @_dummy + (call_suffix + (value_arguments + "(" @collectionKey.iteration.start.endOf + ")" @collectionKey.iteration.end.startOf + ) + ) + (#eq? @_dummy "mapOf") +) ;; ;; Function call, callee, arguments, and parameters @@ -721,13 +739,17 @@ ;; ;; (constructor_delegation_call) ;; ] @functionCall -;;!! foo() -;;! ^^^ +;;!! foo() +;;! ^^^^^^^^ +;;! ^^^^^^ (call_expression [ (simple_identifier) (navigation_expression) - ] @functionCallee + ] @functionCallee.start + (call_suffix + (type_arguments) @functionCallee.end + )? ) @functionCall @functionCallee.domain ;; (call_suffix From dee8a3918f2f12ca5472c4430ee3f29dbba69ff9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 14:01:37 +0100 Subject: [PATCH 26/31] arguments --- ...rgument.formal.constructor.iteration.scope | 14 +- ...gument.formal.constructor.iteration2.scope | 14 +- ...rgument.formal.constructor.multiLine.scope | 78 ++++++- ...gument.formal.constructor.multiLine2.scope | 78 ++++++- ...gument.formal.constructor.singleLine.scope | 62 ++++- ...ument.formal.constructor.singleLine2.scope | 62 ++++- .../argument/argument.formal.iteration.scope | 14 +- .../argument.formal.method.iteration.scope | 14 +- .../argument.formal.method.multiLine.scope | 78 ++++++- .../argument.formal.method.singleLine.scope | 62 ++++- .../argument/argument.formal.multiLine.scope | 78 ++++++- .../argument/argument.formal.singleLine.scope | 62 ++++- .../name.argument.formal.constructor.scope | 80 +++++-- .../name.argument.formal.constructor2.scope | 78 +++++-- .../name/name.argument.formal.method.scope | 80 +++++-- .../kotlin/name/name.argument.formal.scope | 78 +++++-- .../type.argument.formal.constructor.scope | 74 ++++-- .../type.argument.formal.constructor2.scope | 78 +++++-- .../type/type.argument.formal.method.scope | 74 ++++-- .../kotlin/type/type.argument.formal.scope | 72 ++++-- .../value.argument.formal.constructor.scope | 34 +-- .../value.argument.formal.constructor2.scope | 34 +-- .../value/value.argument.formal.method.scope | 34 +-- .../kotlin/value/value.argument.formal.scope | 34 +-- queries/kotlin.scm | 219 ++++++++++++++++-- 25 files changed, 1219 insertions(+), 366 deletions(-) diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope index 5e3ae5940e..8a0d372d4c 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration.scope @@ -1,12 +1,12 @@ class Foo { - constructor(aaa: Int, bbb: Int = 0) {} + constructor(aaa: Int, bbb: Int) {} } --- -[Content] = 1:16-1:38 - >----------------------< -1| constructor(aaa: Int, bbb: Int = 0) {} +[Content] = 1:16-1:34 + >------------------< +1| constructor(aaa: Int, bbb: Int) {} -[Domain] = 1:4-1:42 - >--------------------------------------< -1| constructor(aaa: Int, bbb: Int = 0) {} +[Domain] = 1:4-1:38 + >----------------------------------< +1| constructor(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope index 6113cca17d..3b4393dee0 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.iteration2.scope @@ -1,10 +1,10 @@ -class Foo(aaa: Int, bbb: Int = 0) {} +class Foo(aaa: Int, bbb: Int) {} --- -[Content] = 0:10-0:32 - >----------------------< -0| class Foo(aaa: Int, bbb: Int = 0) {} +[Content] = 0:10-0:28 + >------------------< +0| class Foo(aaa: Int, bbb: Int) {} -[Domain] = 0:0-0:36 - >------------------------------------< -0| class Foo(aaa: Int, bbb: Int = 0) {} +[Domain] = 0:0-0:32 + >--------------------------------< +0| class Foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope index f01ba8c282..d1ae0ebaf8 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine.scope @@ -1,7 +1,9 @@ class Foo { constructor( aaa: Int, - bbb: Int = 0 + vararg bbb: Int, + ccc: Int = 0, + vararg ddd: Int = 1 ) {} } --- @@ -14,33 +16,85 @@ class Foo { [#1 Removal] = 2:8-3:8 >--------- 2| aaa: Int, -3| bbb: Int = 0 +3| vararg bbb: Int, --------< [#1 Trailing delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int = 0 +3| vararg bbb: Int, --------< [#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 3:8-3:20 - >------------< -3| bbb: Int = 0 +[#2 Domain] = 3:8-3:23 + >---------------< +3| vararg bbb: Int, -[#2 Removal] = 2:16-3:20 - >- -2| aaa: Int, -3| bbb: Int = 0 - --------------------< +[#2 Removal] = 3:8-4:8 + >---------------- +3| vararg bbb: Int, +4| ccc: Int = 0, + --------< [#2 Leading delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int = 0 +3| vararg bbb: Int, + --------< + +[#2 Trailing delimiter] = 3:23-4:8 + >- +3| vararg bbb: Int, +4| ccc: Int = 0, --------< [#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 4:8-4:20 + >------------< +4| ccc: Int = 0, + +[#3 Removal] = 4:8-5:8 + >------------- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + --------< + +[#3 Leading delimiter] = 3:23-4:8 + >- +3| vararg bbb: Int, +4| ccc: Int = 0, + --------< + +[#3 Trailing delimiter] = 4:20-5:8 + >- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + --------< + +[#3 Insertion delimiter] = ",\n" + + +[#4 Content] = +[#4 Domain] = 5:8-5:27 + >-------------------< +5| vararg ddd: Int = 1 + +[#4 Removal] = 4:20-5:27 + >- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + ---------------------------< + +[#4 Leading delimiter] = 4:20-5:8 + >- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + --------< + +[#4 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope index 1b4e022350..4ccbb86f5b 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.multiLine2.scope @@ -1,6 +1,8 @@ class Foo( aaa: Int, - bbb: Int = 0 + vararg bbb: Int, + ccc: Int = 0, + vararg ddd: Int = 1 ) {} --- @@ -12,33 +14,85 @@ class Foo( [#1 Removal] = 1:8-2:8 >--------- 1| aaa: Int, -2| bbb: Int = 0 +2| vararg bbb: Int, --------< [#1 Trailing delimiter] = 1:16-2:8 >- 1| aaa: Int, -2| bbb: Int = 0 +2| vararg bbb: Int, --------< [#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 2:8-2:20 - >------------< -2| bbb: Int = 0 +[#2 Domain] = 2:8-2:23 + >---------------< +2| vararg bbb: Int, -[#2 Removal] = 1:16-2:20 - >- -1| aaa: Int, -2| bbb: Int = 0 - --------------------< +[#2 Removal] = 2:8-3:8 + >---------------- +2| vararg bbb: Int, +3| ccc: Int = 0, + --------< [#2 Leading delimiter] = 1:16-2:8 >- 1| aaa: Int, -2| bbb: Int = 0 +2| vararg bbb: Int, + --------< + +[#2 Trailing delimiter] = 2:23-3:8 + >- +2| vararg bbb: Int, +3| ccc: Int = 0, --------< [#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 3:8-3:20 + >------------< +3| ccc: Int = 0, + +[#3 Removal] = 3:8-4:8 + >------------- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + --------< + +[#3 Leading delimiter] = 2:23-3:8 + >- +2| vararg bbb: Int, +3| ccc: Int = 0, + --------< + +[#3 Trailing delimiter] = 3:20-4:8 + >- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + --------< + +[#3 Insertion delimiter] = ",\n" + + +[#4 Content] = +[#4 Domain] = 4:8-4:27 + >-------------------< +4| vararg ddd: Int = 1 + +[#4 Removal] = 3:20-4:27 + >- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + ---------------------------< + +[#4 Leading delimiter] = 3:20-4:8 + >- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + --------< + +[#4 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope index 48cb7eb3c9..765f174ebd 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine.scope @@ -1,35 +1,75 @@ class Foo { - constructor(aaa: Int, bbb: Int = 0) {} + constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} } --- [#1 Content] = [#1 Domain] = 1:16-1:24 >--------< -1| constructor(aaa: Int, bbb: Int = 0) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Removal] = 1:16-1:26 >----------< -1| constructor(aaa: Int, bbb: Int = 0) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Trailing delimiter] = 1:24-1:26 >--< -1| constructor(aaa: Int, bbb: Int = 0) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 1:26-1:38 - >------------< -1| constructor(aaa: Int, bbb: Int = 0) {} +[#2 Domain] = 1:26-1:41 + >---------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Removal] = 1:24-1:38 - >--------------< -1| constructor(aaa: Int, bbb: Int = 0) {} +[#2 Removal] = 1:26-1:43 + >-----------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 1:24-1:26 >--< -1| constructor(aaa: Int, bbb: Int = 0) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#2 Trailing delimiter] = 1:41-1:43 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 1:43-1:55 + >------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Removal] = 1:43-1:57 + >--------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Leading delimiter] = 1:41-1:43 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Trailing delimiter] = 1:55-1:57 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 1:57-1:76 + >-------------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 1:55-1:76 + >---------------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 1:55-1:57 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope index 0633f7ffe3..7f8441fcd2 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.constructor.singleLine2.scope @@ -1,33 +1,73 @@ -class Foo(aaa: Int, bbb: Int = 0) {} +class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} --- [#1 Content] = [#1 Domain] = 0:10-0:18 >--------< -0| class Foo(aaa: Int, bbb: Int = 0) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Removal] = 0:10-0:20 >----------< -0| class Foo(aaa: Int, bbb: Int = 0) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Trailing delimiter] = 0:18-0:20 >--< -0| class Foo(aaa: Int, bbb: Int = 0) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 0:20-0:32 - >------------< -0| class Foo(aaa: Int, bbb: Int = 0) {} +[#2 Domain] = 0:20-0:35 + >---------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Removal] = 0:18-0:32 - >--------------< -0| class Foo(aaa: Int, bbb: Int = 0) {} +[#2 Removal] = 0:20-0:37 + >-----------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 0:18-0:20 >--< -0| class Foo(aaa: Int, bbb: Int = 0) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#2 Trailing delimiter] = 0:35-0:37 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:37-0:49 + >------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Removal] = 0:37-0:51 + >--------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Leading delimiter] = 0:35-0:37 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Trailing delimiter] = 0:49-0:51 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 0:51-0:70 + >-------------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 0:49-0:70 + >---------------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 0:49-0:51 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope index bf1ca7873d..52e03b6d32 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.iteration.scope @@ -1,10 +1,10 @@ -fun bar(aaa: Int, bbb: Int = 0) {} +fun bar(aaa: Int, bbb: Int) {} --- -[Content] = 0:8-0:30 - >----------------------< -0| fun bar(aaa: Int, bbb: Int = 0) {} +[Content] = 0:8-0:26 + >------------------< +0| fun bar(aaa: Int, bbb: Int) {} -[Domain] = 0:0-0:34 - >----------------------------------< -0| fun bar(aaa: Int, bbb: Int = 0) {} +[Domain] = 0:0-0:30 + >------------------------------< +0| fun bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope index 3e23a263bf..5776531b87 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration.scope @@ -1,12 +1,12 @@ class Foo { - fun bar(aaa: Int, bbb: Int = 0) {} + fun bar(aaa: Int, bbb: Int) {} } --- -[Content] = 1:12-1:34 - >----------------------< -1| fun bar(aaa: Int, bbb: Int = 0) {} +[Content] = 1:12-1:30 + >------------------< +1| fun bar(aaa: Int, bbb: Int) {} -[Domain] = 1:4-1:38 - >----------------------------------< -1| fun bar(aaa: Int, bbb: Int = 0) {} +[Domain] = 1:4-1:34 + >------------------------------< +1| fun bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope index 1057414161..48a7eeed6c 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.multiLine.scope @@ -1,7 +1,9 @@ class Foo { fun bar( aaa: Int, - bbb: Int = 0 + vararg bbb: Int, + ccc: Int = 0, + vararg ddd: Int = 1 ) {} } --- @@ -14,33 +16,85 @@ class Foo { [#1 Removal] = 2:8-3:8 >--------- 2| aaa: Int, -3| bbb: Int = 0 +3| vararg bbb: Int, --------< [#1 Trailing delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int = 0 +3| vararg bbb: Int, --------< [#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 3:8-3:20 - >------------< -3| bbb: Int = 0 +[#2 Domain] = 3:8-3:23 + >---------------< +3| vararg bbb: Int, -[#2 Removal] = 2:16-3:20 - >- -2| aaa: Int, -3| bbb: Int = 0 - --------------------< +[#2 Removal] = 3:8-4:8 + >---------------- +3| vararg bbb: Int, +4| ccc: Int = 0, + --------< [#2 Leading delimiter] = 2:16-3:8 >- 2| aaa: Int, -3| bbb: Int = 0 +3| vararg bbb: Int, + --------< + +[#2 Trailing delimiter] = 3:23-4:8 + >- +3| vararg bbb: Int, +4| ccc: Int = 0, --------< [#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 4:8-4:20 + >------------< +4| ccc: Int = 0, + +[#3 Removal] = 4:8-5:8 + >------------- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + --------< + +[#3 Leading delimiter] = 3:23-4:8 + >- +3| vararg bbb: Int, +4| ccc: Int = 0, + --------< + +[#3 Trailing delimiter] = 4:20-5:8 + >- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + --------< + +[#3 Insertion delimiter] = ",\n" + + +[#4 Content] = +[#4 Domain] = 5:8-5:27 + >-------------------< +5| vararg ddd: Int = 1 + +[#4 Removal] = 4:20-5:27 + >- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + ---------------------------< + +[#4 Leading delimiter] = 4:20-5:8 + >- +4| ccc: Int = 0, +5| vararg ddd: Int = 1 + --------< + +[#4 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope index bb3182f5ae..7086fbc864 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine.scope @@ -1,35 +1,75 @@ class Foo { - fun bar(aaa: Int, bbb: Int = 0) {} + fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} } --- [#1 Content] = [#1 Domain] = 1:12-1:20 >--------< -1| fun bar(aaa: Int, bbb: Int = 0) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Removal] = 1:12-1:22 >----------< -1| fun bar(aaa: Int, bbb: Int = 0) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Trailing delimiter] = 1:20-1:22 >--< -1| fun bar(aaa: Int, bbb: Int = 0) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 1:22-1:34 - >------------< -1| fun bar(aaa: Int, bbb: Int = 0) {} +[#2 Domain] = 1:22-1:37 + >---------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Removal] = 1:20-1:34 - >--------------< -1| fun bar(aaa: Int, bbb: Int = 0) {} +[#2 Removal] = 1:22-1:39 + >-----------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 1:20-1:22 >--< -1| fun bar(aaa: Int, bbb: Int = 0) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#2 Trailing delimiter] = 1:37-1:39 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 1:39-1:51 + >------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Removal] = 1:39-1:53 + >--------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Leading delimiter] = 1:37-1:39 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Trailing delimiter] = 1:51-1:53 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 1:53-1:72 + >-------------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 1:51-1:72 + >---------------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 1:51-1:53 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope index 985d9594d5..ad4cb8d8ba 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.multiLine.scope @@ -1,6 +1,8 @@ fun bar( aaa: Int, - bbb: Int = 0 + vararg bbb: Int, + ccc: Int = 0, + vararg ddd: Int = 1 ) {} --- @@ -12,33 +14,85 @@ fun bar( [#1 Removal] = 1:4-2:4 >--------- 1| aaa: Int, -2| bbb: Int = 0 +2| vararg bbb: Int, ----< [#1 Trailing delimiter] = 1:12-2:4 >- 1| aaa: Int, -2| bbb: Int = 0 +2| vararg bbb: Int, ----< [#1 Insertion delimiter] = ",\n" [#2 Content] = -[#2 Domain] = 2:4-2:16 - >------------< -2| bbb: Int = 0 +[#2 Domain] = 2:4-2:19 + >---------------< +2| vararg bbb: Int, -[#2 Removal] = 1:12-2:16 - >- -1| aaa: Int, -2| bbb: Int = 0 - ----------------< +[#2 Removal] = 2:4-3:4 + >---------------- +2| vararg bbb: Int, +3| ccc: Int = 0, + ----< [#2 Leading delimiter] = 1:12-2:4 >- 1| aaa: Int, -2| bbb: Int = 0 +2| vararg bbb: Int, + ----< + +[#2 Trailing delimiter] = 2:19-3:4 + >- +2| vararg bbb: Int, +3| ccc: Int = 0, ----< [#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 3:4-3:16 + >------------< +3| ccc: Int = 0, + +[#3 Removal] = 3:4-4:4 + >------------- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + ----< + +[#3 Leading delimiter] = 2:19-3:4 + >- +2| vararg bbb: Int, +3| ccc: Int = 0, + ----< + +[#3 Trailing delimiter] = 3:16-4:4 + >- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + ----< + +[#3 Insertion delimiter] = ",\n" + + +[#4 Content] = +[#4 Domain] = 4:4-4:23 + >-------------------< +4| vararg ddd: Int = 1 + +[#4 Removal] = 3:16-4:23 + >- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + -----------------------< + +[#4 Leading delimiter] = 3:16-4:4 + >- +3| ccc: Int = 0, +4| vararg ddd: Int = 1 + ----< + +[#4 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope index f6437d8536..629a7a0080 100644 --- a/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.singleLine.scope @@ -1,33 +1,73 @@ -fun bar(aaa: Int, bbb: Int = 0) {} +fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} --- [#1 Content] = [#1 Domain] = 0:8-0:16 >--------< -0| fun bar(aaa: Int, bbb: Int = 0) {} +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Removal] = 0:8-0:18 >----------< -0| fun bar(aaa: Int, bbb: Int = 0) {} +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Trailing delimiter] = 0:16-0:18 >--< -0| fun bar(aaa: Int, bbb: Int = 0) {} +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 0:18-0:30 - >------------< -0| fun bar(aaa: Int, bbb: Int = 0) {} +[#2 Domain] = 0:18-0:33 + >---------------< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Removal] = 0:16-0:30 - >--------------< -0| fun bar(aaa: Int, bbb: Int = 0) {} +[#2 Removal] = 0:18-0:35 + >-----------------< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 0:16-0:18 >--< -0| fun bar(aaa: Int, bbb: Int = 0) {} +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#2 Trailing delimiter] = 0:33-0:35 + >--< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:35-0:47 + >------------< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Removal] = 0:35-0:49 + >--------------< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Leading delimiter] = 0:33-0:35 + >--< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Trailing delimiter] = 0:47-0:49 + >--< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 0:49-0:68 + >-------------------< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 0:47-0:68 + >---------------------< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 0:47-0:49 + >--< +0| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope index 44e37cd531..1dac5abd48 100644 --- a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor.scope @@ -1,5 +1,5 @@ class Foo { - constructor(aaa: Int, bbb: Int) {} + constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} } --- @@ -22,7 +22,7 @@ class Foo { [#1 Domain] = 0:0-2:1 >----------- 0| class Foo { -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} 2| } -< @@ -32,15 +32,15 @@ class Foo { [#2 Content] = [#2 Removal] = 1:4-1:15 >-----------< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 1:0-1:4 >----< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Domain] = 1:4-1:38 - >----------------------------------< -1| constructor(aaa: Int, bbb: Int) {} +[#2 Domain] = 1:4-1:80 + >----------------------------------------------------------------------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " @@ -48,29 +48,67 @@ class Foo { [#3 Content] = [#3 Removal] = 1:16-1:19 >---< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Domain] = 1:16-1:24 >--------< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " -[#4 Content] = 1:26-1:29 - >---< -1| constructor(aaa: Int, bbb: Int) {} +[#4 Content] = 1:33-1:36 + >---< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#4 Removal] = 1:25-1:29 - >----< -1| constructor(aaa: Int, bbb: Int) {} +[#4 Removal] = 1:32-1:36 + >----< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#4 Leading delimiter] = 1:25-1:26 - >-< -1| constructor(aaa: Int, bbb: Int) {} +[#4 Leading delimiter] = 1:32-1:33 + >-< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#4 Domain] = 1:26-1:34 - >--------< -1| constructor(aaa: Int, bbb: Int) {} +[#4 Domain] = 1:26-1:41 + >---------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#4 Insertion delimiter] = " " + + +[#5 Content] = 1:43-1:46 + >---< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 1:42-1:46 + >----< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 1:42-1:43 + >-< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 1:43-1:55 + >------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " + + +[#6 Content] = 1:64-1:67 + >---< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Removal] = 1:63-1:67 + >----< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Leading delimiter] = 1:63-1:64 + >-< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Domain] = 1:57-1:76 + >-------------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope index 7fe4e513b6..6e764d4197 100644 --- a/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.constructor2.scope @@ -1,18 +1,18 @@ -class Foo(aaa: Int, bbb: Int) {} +class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} --- [#1 Content] = [#1 Removal] = 0:6-0:9 >---< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Leading delimiter] = 0:5-0:6 >-< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#1 Domain] = 0:0-0:32 - >--------------------------------< -0| class Foo(aaa: Int, bbb: Int) {} +[#1 Domain] = 0:0-0:74 + >--------------------------------------------------------------------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = " " @@ -20,29 +20,67 @@ class Foo(aaa: Int, bbb: Int) {} [#2 Content] = [#2 Removal] = 0:10-0:13 >---< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Domain] = 0:10-0:18 >--------< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " -[#3 Content] = 0:20-0:23 - >---< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Content] = 0:27-0:30 + >---< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Removal] = 0:19-0:23 - >----< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Removal] = 0:26-0:30 + >----< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Leading delimiter] = 0:19-0:20 - >-< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Leading delimiter] = 0:26-0:27 + >-< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Domain] = 0:20-0:28 - >--------< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Domain] = 0:20-0:35 + >---------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " + + +[#4 Content] = 0:37-0:40 + >---< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 0:36-0:40 + >----< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 0:36-0:37 + >-< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Domain] = 0:37-0:49 + >------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 0:58-0:61 + >---< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 0:57-0:61 + >----< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 0:57-0:58 + >-< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 0:51-0:70 + >-------------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope index 053f227429..dabfb505d8 100644 --- a/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.method.scope @@ -1,5 +1,5 @@ class Foo { - fun foo(aaa: Int, bbb: Int) {} + fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} } --- @@ -22,7 +22,7 @@ class Foo { [#1 Domain] = 0:0-2:1 >----------- 0| class Foo { -1| fun foo(aaa: Int, bbb: Int) {} +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} 2| } -< @@ -32,15 +32,15 @@ class Foo { [#2 Content] = [#2 Removal] = 1:8-1:11 >---< -1| fun foo(aaa: Int, bbb: Int) {} +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 1:7-1:8 >-< -1| fun foo(aaa: Int, bbb: Int) {} +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Domain] = 1:4-1:34 - >------------------------------< -1| fun foo(aaa: Int, bbb: Int) {} +[#2 Domain] = 1:4-1:76 + >------------------------------------------------------------------------< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " @@ -48,29 +48,67 @@ class Foo { [#3 Content] = [#3 Removal] = 1:12-1:15 >---< -1| fun foo(aaa: Int, bbb: Int) {} +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Domain] = 1:12-1:20 >--------< -1| fun foo(aaa: Int, bbb: Int) {} +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " -[#4 Content] = 1:22-1:25 - >---< -1| fun foo(aaa: Int, bbb: Int) {} +[#4 Content] = 1:29-1:32 + >---< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#4 Removal] = 1:21-1:25 - >----< -1| fun foo(aaa: Int, bbb: Int) {} +[#4 Removal] = 1:28-1:32 + >----< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#4 Leading delimiter] = 1:21-1:22 - >-< -1| fun foo(aaa: Int, bbb: Int) {} +[#4 Leading delimiter] = 1:28-1:29 + >-< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#4 Domain] = 1:22-1:30 - >--------< -1| fun foo(aaa: Int, bbb: Int) {} +[#4 Domain] = 1:22-1:37 + >---------------< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#4 Insertion delimiter] = " " + + +[#5 Content] = 1:39-1:42 + >---< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 1:38-1:42 + >----< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 1:38-1:39 + >-< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 1:39-1:51 + >------------< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " + + +[#6 Content] = 1:60-1:63 + >---< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Removal] = 1:59-1:63 + >----< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Leading delimiter] = 1:59-1:60 + >-< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Domain] = 1:53-1:72 + >-------------------< +1| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#6 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.scope index da6507e251..e76cbdf9d1 100644 --- a/data/fixtures/scopes/kotlin/name/name.argument.formal.scope +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.scope @@ -1,18 +1,18 @@ -fun foo(aaa: Int, bbb: Int = 1) {} +fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} --- [#1 Content] = [#1 Removal] = 0:4-0:7 >---< -0| fun foo(aaa: Int, bbb: Int = 1) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Leading delimiter] = 0:3-0:4 >-< -0| fun foo(aaa: Int, bbb: Int = 1) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#1 Domain] = 0:0-0:34 - >----------------------------------< -0| fun foo(aaa: Int, bbb: Int = 1) {} +[#1 Domain] = 0:0-0:72 + >------------------------------------------------------------------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = " " @@ -20,29 +20,67 @@ fun foo(aaa: Int, bbb: Int = 1) {} [#2 Content] = [#2 Removal] = 0:8-0:11 >---< -0| fun foo(aaa: Int, bbb: Int = 1) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Domain] = 0:8-0:16 >--------< -0| fun foo(aaa: Int, bbb: Int = 1) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " -[#3 Content] = 0:18-0:21 - >---< -0| fun foo(aaa: Int, bbb: Int = 1) {} +[#3 Content] = 0:25-0:28 + >---< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Removal] = 0:17-0:21 - >----< -0| fun foo(aaa: Int, bbb: Int = 1) {} +[#3 Removal] = 0:24-0:28 + >----< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Leading delimiter] = 0:17-0:18 - >-< -0| fun foo(aaa: Int, bbb: Int = 1) {} +[#3 Leading delimiter] = 0:24-0:25 + >-< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Domain] = 0:18-0:30 - >------------< -0| fun foo(aaa: Int, bbb: Int = 1) {} +[#3 Domain] = 0:18-0:33 + >---------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " + + +[#4 Content] = 0:35-0:38 + >---< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 0:34-0:38 + >----< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 0:34-0:35 + >-< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Domain] = 0:35-0:47 + >------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 0:56-0:59 + >---< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 0:55-0:59 + >----< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 0:55-0:56 + >-< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 0:49-0:68 + >-------------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope index d0c221e6b9..a0ae059943 100644 --- a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor.scope @@ -1,5 +1,5 @@ class Foo { - constructor(aaa: Int, bbb: Int) {} + constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} } --- @@ -8,7 +8,7 @@ class Foo { [#1 Domain] = 0:0-2:1 >----------- 0| class Foo { -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} 2| } -< @@ -17,37 +17,75 @@ class Foo { [#2 Content] = 1:21-1:24 >---< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Removal] = 1:19-1:24 >-----< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 1:19-1:21 >--< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Domain] = 1:16-1:24 >--------< -1| constructor(aaa: Int, bbb: Int) {} +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " -[#3 Content] = 1:31-1:34 - >---< -1| constructor(aaa: Int, bbb: Int) {} +[#3 Content] = 1:38-1:41 + >---< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Removal] = 1:29-1:34 - >-----< -1| constructor(aaa: Int, bbb: Int) {} +[#3 Removal] = 1:36-1:41 + >-----< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Leading delimiter] = 1:29-1:31 - >--< -1| constructor(aaa: Int, bbb: Int) {} +[#3 Leading delimiter] = 1:36-1:38 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Domain] = 1:26-1:34 - >--------< -1| constructor(aaa: Int, bbb: Int) {} +[#3 Domain] = 1:26-1:41 + >---------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " + + +[#4 Content] = 1:48-1:51 + >---< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 1:46-1:51 + >-----< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 1:46-1:48 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Domain] = 1:43-1:55 + >------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 1:69-1:72 + >---< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 1:67-1:72 + >-----< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 1:67-1:69 + >--< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 1:57-1:76 + >-------------------< +1| constructor(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope index f1d1721c04..b104dc6c65 100644 --- a/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.constructor2.scope @@ -1,48 +1,86 @@ -class Foo(aaa: Int, bbb: Int) {} +class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} --- [#1 Content] = [#1 Removal] = -[#1 Domain] = 0:0-0:32 - >--------------------------------< -0| class Foo(aaa: Int, bbb: Int) {} +[#1 Domain] = 0:0-0:74 + >--------------------------------------------------------------------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = " " [#2 Content] = 0:15-0:18 >---< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Removal] = 0:13-0:18 >-----< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 0:13-0:15 >--< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Domain] = 0:10-0:18 >--------< -0| class Foo(aaa: Int, bbb: Int) {} +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " -[#3 Content] = 0:25-0:28 - >---< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Content] = 0:32-0:35 + >---< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Removal] = 0:23-0:28 - >-----< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Removal] = 0:30-0:35 + >-----< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Leading delimiter] = 0:23-0:25 - >--< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Leading delimiter] = 0:30-0:32 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Domain] = 0:20-0:28 - >--------< -0| class Foo(aaa: Int, bbb: Int) {} +[#3 Domain] = 0:20-0:35 + >---------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " + + +[#4 Content] = 0:42-0:45 + >---< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 0:40-0:45 + >-----< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 0:40-0:42 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Domain] = 0:37-0:49 + >------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 0:63-0:66 + >---< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 0:61-0:66 + >-----< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 0:61-0:63 + >--< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 0:51-0:70 + >-------------------< +0| class Foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope index 21a10260ff..b9d9de0fb4 100644 --- a/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.method.scope @@ -1,5 +1,5 @@ class Foo { - fun bar(aaa: Int, bbb: Int) {} + fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} } --- @@ -8,7 +8,7 @@ class Foo { [#1 Domain] = 0:0-2:1 >----------- 0| class Foo { -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} 2| } -< @@ -17,37 +17,75 @@ class Foo { [#2 Content] = 1:17-1:20 >---< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Removal] = 1:15-1:20 >-----< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Leading delimiter] = 1:15-1:17 >--< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Domain] = 1:12-1:20 >--------< -1| fun bar(aaa: Int, bbb: Int) {} +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " -[#3 Content] = 1:27-1:30 - >---< -1| fun bar(aaa: Int, bbb: Int) {} +[#3 Content] = 1:34-1:37 + >---< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Removal] = 1:25-1:30 - >-----< -1| fun bar(aaa: Int, bbb: Int) {} +[#3 Removal] = 1:32-1:37 + >-----< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Leading delimiter] = 1:25-1:27 - >--< -1| fun bar(aaa: Int, bbb: Int) {} +[#3 Leading delimiter] = 1:32-1:34 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#3 Domain] = 1:22-1:30 - >--------< -1| fun bar(aaa: Int, bbb: Int) {} +[#3 Domain] = 1:22-1:37 + >---------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#3 Insertion delimiter] = " " + + +[#4 Content] = 1:44-1:47 + >---< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 1:42-1:47 + >-----< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 1:42-1:44 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Domain] = 1:39-1:51 + >------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = " " + + +[#5 Content] = 1:65-1:68 + >---< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Removal] = 1:63-1:68 + >-----< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Leading delimiter] = 1:63-1:65 + >--< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Domain] = 1:53-1:72 + >-------------------< +1| fun bar(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#5 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.scope index 87271526b0..2fa964a0d3 100644 --- a/data/fixtures/scopes/kotlin/type/type.argument.formal.scope +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.scope @@ -1,39 +1,77 @@ -fun foo(aaa: Int, bbb: Int) {} +fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} --- [#1 Content] = 0:13-0:16 >---< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Removal] = 0:11-0:16 >-----< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Leading delimiter] = 0:11-0:13 >--< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Domain] = 0:8-0:16 >--------< -0| fun foo(aaa: Int, bbb: Int) {} +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#1 Insertion delimiter] = " " -[#2 Content] = 0:23-0:26 - >---< -0| fun foo(aaa: Int, bbb: Int) {} +[#2 Content] = 0:30-0:33 + >---< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Removal] = 0:21-0:26 - >-----< -0| fun foo(aaa: Int, bbb: Int) {} +[#2 Removal] = 0:28-0:33 + >-----< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Leading delimiter] = 0:21-0:23 - >--< -0| fun foo(aaa: Int, bbb: Int) {} +[#2 Leading delimiter] = 0:28-0:30 + >--< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} -[#2 Domain] = 0:18-0:26 - >--------< -0| fun foo(aaa: Int, bbb: Int) {} +[#2 Domain] = 0:18-0:33 + >---------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} [#2 Insertion delimiter] = " " + + +[#3 Content] = 0:40-0:43 + >---< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Removal] = 0:38-0:43 + >-----< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Leading delimiter] = 0:38-0:40 + >--< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Domain] = 0:35-0:47 + >------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 0:61-0:64 + >---< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Removal] = 0:59-0:64 + >-----< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Leading delimiter] = 0:59-0:61 + >--< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Domain] = 0:49-0:68 + >-------------------< +0| fun foo(aaa: Int, vararg bbb: Int, ccc: Int = 0, vararg ddd: Int = 1) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope index 1f3ac6fbda..f4c93229d5 100644 --- a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor.scope @@ -1,41 +1,41 @@ class Foo { - constructor(aaa: Int = 0, bbb: Int = 1) {} + constructor(aaa: Int = 0, vararg bbb: Int = 1) {} } --- [#1 Content] = 1:27-1:28 >-< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Removal] = 1:24-1:28 >----< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Leading delimiter] = 1:24-1:27 >---< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Domain] = 1:16-1:28 >------------< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Insertion delimiter] = " " -[#2 Content] = 1:41-1:42 - >-< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +[#2 Content] = 1:48-1:49 + >-< +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Removal] = 1:38-1:42 - >----< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +[#2 Removal] = 1:45-1:49 + >----< +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Leading delimiter] = 1:38-1:41 - >---< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +[#2 Leading delimiter] = 1:45-1:48 + >---< +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Domain] = 1:30-1:42 - >------------< -1| constructor(aaa: Int = 0, bbb: Int = 1) {} +[#2 Domain] = 1:30-1:49 + >-------------------< +1| constructor(aaa: Int = 0, vararg bbb: Int = 1) {} [#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope index 4d344c58d3..59636efd24 100644 --- a/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.constructor2.scope @@ -1,39 +1,39 @@ -class Foo(aaa: Int = 0, bbb: Int = 1) {} +class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} --- [#1 Content] = 0:21-0:22 >-< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Removal] = 0:18-0:22 >----< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Leading delimiter] = 0:18-0:21 >---< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Domain] = 0:10-0:22 >------------< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Insertion delimiter] = " " -[#2 Content] = 0:35-0:36 - >-< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Content] = 0:42-0:43 + >-< +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Removal] = 0:32-0:36 - >----< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Removal] = 0:39-0:43 + >----< +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Leading delimiter] = 0:32-0:35 - >---< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Leading delimiter] = 0:39-0:42 + >---< +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Domain] = 0:24-0:36 - >------------< -0| class Foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Domain] = 0:24-0:43 + >-------------------< +0| class Foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope index 326a9b1b4d..c9f57b8944 100644 --- a/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.method.scope @@ -1,41 +1,41 @@ class Foo { - fun bar(aaa: Int = 0, bbb: Int = 1) {} + fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} } --- [#1 Content] = 1:23-1:24 >-< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Removal] = 1:20-1:24 >----< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Leading delimiter] = 1:20-1:23 >---< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Domain] = 1:12-1:24 >------------< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Insertion delimiter] = " " -[#2 Content] = 1:37-1:38 - >-< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +[#2 Content] = 1:44-1:45 + >-< +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Removal] = 1:34-1:38 - >----< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +[#2 Removal] = 1:41-1:45 + >----< +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Leading delimiter] = 1:34-1:37 - >---< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +[#2 Leading delimiter] = 1:41-1:44 + >---< +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Domain] = 1:26-1:38 - >------------< -1| fun bar(aaa: Int = 0, bbb: Int = 1) {} +[#2 Domain] = 1:26-1:45 + >-------------------< +1| fun bar(aaa: Int = 0, vararg bbb: Int = 1) {} [#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.argument.formal.scope b/data/fixtures/scopes/kotlin/value/value.argument.formal.scope index f529950380..3232f27f3a 100644 --- a/data/fixtures/scopes/kotlin/value/value.argument.formal.scope +++ b/data/fixtures/scopes/kotlin/value/value.argument.formal.scope @@ -1,39 +1,39 @@ -fun foo(aaa: Int = 0, bbb: Int = 1) {} +fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} --- [#1 Content] = 0:19-0:20 >-< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Removal] = 0:16-0:20 >----< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Leading delimiter] = 0:16-0:19 >---< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Domain] = 0:8-0:20 >------------< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#1 Insertion delimiter] = " " -[#2 Content] = 0:33-0:34 - >-< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Content] = 0:40-0:41 + >-< +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Removal] = 0:30-0:34 - >----< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Removal] = 0:37-0:41 + >----< +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Leading delimiter] = 0:30-0:33 - >---< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Leading delimiter] = 0:37-0:40 + >---< +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} -[#2 Domain] = 0:22-0:34 - >------------< -0| fun foo(aaa: Int = 0, bbb: Int = 1) {} +[#2 Domain] = 0:22-0:41 + >-------------------< +0| fun foo(aaa: Int = 0, vararg bbb: Int = 1) {} [#2 Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 18d0f7d935..b2ff503ebb 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -795,11 +795,29 @@ ) ;;!! foo: Int +;;!! vararg foo: Int ( (function_value_parameters (_)? @_.leading.endOf . - (parameter) @argumentOrParameter + [ + "," + "(" + ] + . + [ + (line_comment) + (multiline_comment) + ] * + . + (parameter_modifiers)? @argumentOrParameter.start + . + (parameter) @argumentOrParameter.end + . + [ + (line_comment) + (multiline_comment) + ] * . [ "," @@ -808,19 +826,59 @@ . (_)? @_.trailing.startOf ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") + (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") ) -;;!! foo: Int = 0 +( + (function_value_parameters + (_)? @_dummy + . + [ + "," + "(" + ] + . + (parameter_modifiers)? @_.domain.start + . + (parameter + (simple_identifier) @name @type.leading.endOf + (user_type) @type + ) @_.domain.end + . + [ + "," + ")" + ] + ) +) + +;; !! foo: Int = 0 +;; !! vararg foo: Int = 0 ( (function_value_parameters (_)? @_.leading.endOf . - (parameter) @argumentOrParameter.start + [ + "," + "(" + ] . - "=" + [ + (line_comment) + (multiline_comment) + ] * + . + (parameter_modifiers)? @argumentOrParameter.start.startOf + . + (parameter) @argumentOrParameter.start . (_) @argumentOrParameter.end + (#not-type? @argumentOrParameter.end parameter parameter_modifiers) + . + [ + (line_comment) + (multiline_comment) + ] * . [ "," @@ -829,9 +887,141 @@ . (_)? @_.trailing.startOf ) @_dummy - (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") + (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") ) +(function_value_parameters + (_)? @_dummy + . + [ + "," + "(" + ] + . + (parameter_modifiers)? @_.domain.start + . + (parameter + (simple_identifier) @name @type.leading.endOf + (user_type) @type + ) @_.domain.start @value.leading.endOf + . + (_) @value @_.domain.end + (#not-type? @_.domain.end parameter parameter_modifiers) + . + [ + "," + ")" + ] +) + +;;!! foo: Int +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (parameter) @argumentOrParameter +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +;; ) + +;;!! vararg foo: Int +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (parameter_modifiers) @argumentOrParameter.start +;; . +;; (parameter) @argumentOrParameter.end +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") +;; ) + +;;!! foo: Int = 0 +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (parameter) @argumentOrParameter.start +;; . +;; "=" +;; . +;; (_) @argumentOrParameter.end +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") +;; ) + +;;!! vararg foo: Int = 0 +;; ( +;; (function_value_parameters +;; (_)? @_.leading.endOf +;; . +;; (parameter_modifiers) @argumentOrParameter.start +;; . +;; (parameter) +;; . +;; "=" +;; . +;; (_) @argumentOrParameter.end +;; . +;; [ +;; "," +;; ")" +;; ] +;; . +;; (_)? @_.trailing.startOf +;; ) @_dummy +;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") +;; ) + +;;!! fun Foo(aaa: Int = 0) {} +;;! ^^^ +;;! ^^^ +;;! ^ +;; (function_value_parameters +;; ;; [ +;; ;; "(" +;; ;; "," +;; ;; (parameter_modifiers)? @_.domain.start.startOf +;; ;; ] +;; ;; . +;; (parameter +;; (simple_identifier) @name @type.leading.endOf +;; (user_type) @type +;; ) @_.domain.start @value.leading.endOf +;; . +;; ( +;; "=" +;; . +;; (_) @value @_.domain.end +;; )? +;; . +;; [ +;; "," +;; ")" +;; ] +;; ) + ;; ( ;; (function_value_parameters ;; (_)? @_.leading.endOf @@ -1101,23 +1291,6 @@ (#single-or-multi-line-delimiter! @type @_dummy ", " ",\n") ) -;;!! fun Foo(aaa: Int = 0) {} -;;! ^^^ -;;! ^^^ -;;! ^ -(function_value_parameters - (parameter - (simple_identifier) @name @type.leading.endOf - (user_type) @type - ) @_.domain.start @value.leading.endOf - . - ( - "=" - . - (_) @value @_.domain.end - )? -) - ;;!! class Foo(aaa: Int = 0) {} ;;! ^^^ ;;! ^^^ From 952fc7cf6392bb0c3c216b3d7ca5e2cca16d3179 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 14:33:05 +0100 Subject: [PATCH 27/31] getter and setter --- .../argument.formal.method.iteration2.scope | 12 ++++++ .../argument.formal.method.singleLine2.scope | 12 ++++++ .../name/name.argument.formal.method2.scope | 41 +++++++++++++++++++ .../namedFunction/namedFunction.method3.scope | 21 ++++++++++ .../namedFunction/namedFunction.method4.scope | 21 ++++++++++ .../kotlin/statement/statement.method3.scope | 33 +++++++++++++++ .../kotlin/statement/statement.method4.scope | 33 +++++++++++++++ .../type/type.argument.formal.method2.scope | 34 +++++++++++++++ .../scopes/kotlin/type/type.return2.scope | 34 +++++++++++++++ queries/kotlin.scm | 30 ++++++++++++++ 10 files changed, 271 insertions(+) create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration2.scope create mode 100644 data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine2.scope create mode 100644 data/fixtures/scopes/kotlin/name/name.argument.formal.method2.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.method3.scope create mode 100644 data/fixtures/scopes/kotlin/namedFunction/namedFunction.method4.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.method3.scope create mode 100644 data/fixtures/scopes/kotlin/statement/statement.method4.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.argument.formal.method2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.return2.scope diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration2.scope new file mode 100644 index 0000000000..3f9d7366e8 --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.iteration2.scope @@ -0,0 +1,12 @@ +class Foo { + set(aaa: Int) {} +} +--- + +[Content] = 1:8-1:16 + >--------< +1| set(aaa: Int) {} + +[Domain] = 1:4-1:20 + >----------------< +1| set(aaa: Int) {} diff --git a/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine2.scope b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine2.scope new file mode 100644 index 0000000000..ff4e03a73a --- /dev/null +++ b/data/fixtures/scopes/kotlin/argument/argument.formal.method.singleLine2.scope @@ -0,0 +1,12 @@ +class Foo { + set(aaa: Int) {} +} +--- + +[Content] = +[Removal] = +[Domain] = 1:8-1:16 + >--------< +1| set(aaa: Int) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.argument.formal.method2.scope b/data/fixtures/scopes/kotlin/name/name.argument.formal.method2.scope new file mode 100644 index 0000000000..e8f6cdbfa9 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.argument.formal.method2.scope @@ -0,0 +1,41 @@ +class Foo { + set(aaa: Int) {} +} +--- + +[#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| set(aaa: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:8-1:11 + >---< +1| set(aaa: Int) {} + +[#2 Domain] = 1:8-1:16 + >--------< +1| set(aaa: Int) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method3.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method3.scope new file mode 100644 index 0000000000..141dece681 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method3.scope @@ -0,0 +1,21 @@ +class Foo { + get(): Int {} +} +--- + +[Content] = +[Domain] = 1:4-1:17 + >-------------< +1| get(): Int {} + +[Removal] = 1:0-2:0 + >----------------- +1| get(): Int {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| get(): Int {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method4.scope b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method4.scope new file mode 100644 index 0000000000..c36c0647b3 --- /dev/null +++ b/data/fixtures/scopes/kotlin/namedFunction/namedFunction.method4.scope @@ -0,0 +1,21 @@ +class Foo { + set(aaa: Int) {} +} +--- + +[Content] = +[Domain] = 1:4-1:20 + >----------------< +1| set(aaa: Int) {} + +[Removal] = 1:0-2:0 + >-------------------- +1| set(aaa: Int) {} +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| set(aaa: Int) {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.method3.scope b/data/fixtures/scopes/kotlin/statement/statement.method3.scope new file mode 100644 index 0000000000..c042339641 --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.method3.scope @@ -0,0 +1,33 @@ +class Foo { + get(): Int {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| get(): Int {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:17 + >-------------< +1| get(): Int {} + +[#2 Removal] = 1:0-2:0 + >----------------- +1| get(): Int {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| get(): Int {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/statement/statement.method4.scope b/data/fixtures/scopes/kotlin/statement/statement.method4.scope new file mode 100644 index 0000000000..f10831488f --- /dev/null +++ b/data/fixtures/scopes/kotlin/statement/statement.method4.scope @@ -0,0 +1,33 @@ +class Foo { + set(aaa: Int) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| set(aaa: Int) {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:20 + >----------------< +1| set(aaa: Int) {} + +[#2 Removal] = 1:0-2:0 + >-------------------- +1| set(aaa: Int) {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| set(aaa: Int) {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/kotlin/type/type.argument.formal.method2.scope b/data/fixtures/scopes/kotlin/type/type.argument.formal.method2.scope new file mode 100644 index 0000000000..1bb14dcd22 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.argument.formal.method2.scope @@ -0,0 +1,34 @@ +class Foo { + set(aaa: Int) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| set(aaa: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:13-1:16 + >---< +1| set(aaa: Int) {} + +[#2 Removal] = 1:11-1:16 + >-----< +1| set(aaa: Int) {} + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| set(aaa: Int) {} + +[#2 Domain] = 1:8-1:16 + >--------< +1| set(aaa: Int) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.return2.scope b/data/fixtures/scopes/kotlin/type/type.return2.scope new file mode 100644 index 0000000000..d64ccff02a --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.return2.scope @@ -0,0 +1,34 @@ +class Foo { + get(): Int {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| get(): Int {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:11-1:14 + >---< +1| get(): Int {} + +[#2 Removal] = 1:9-1:14 + >-----< +1| get(): Int {} + +[#2 Leading delimiter] = 1:9-1:11 + >--< +1| get(): Int {} + +[#2 Domain] = 1:4-1:17 + >-------------< +1| get(): Int {} + +[#2 Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index b2ff503ebb..74843232bd 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -47,6 +47,8 @@ (try_expression) (import_list) (package_header) + (getter) + (setter) ;; Disabled on purpose. We have a better definition of this below. ;; (if_expression) @@ -914,6 +916,12 @@ ] ) +;;!! foo() { -> } +;;! ^^^^^^ +(call_suffix + (annotated_lambda) @argumentOrParameter +) + ;;!! foo: Int ;; ( ;; (function_value_parameters @@ -1304,6 +1312,28 @@ )? ) @_.domain +;;!! get(): Int {} +(getter + ")" @type.leading.endOf + (user_type) @type +) @namedFunction @type.domain + +;;!! set(aaa: Int) {} +;;! ^^^^^^^^ +(setter + (parameter_with_optional_type + (simple_identifier) @name @type.leading.endOf + (user_type) @type + ) @argumentOrParameter @_.domain +) + +;;!! set(aaa: Int) {} +;;! ^^^^^^^^ +;; There is only one parameter allowed, but we treat it as iterable for consistency. +(setter + (parameter_with_optional_type) @argumentOrParameter.iteration +) @namedFunction @argumentOrParameter.iteration.domain + ;; (constructor_delegation_call ;; (value_arguments ;; "(" @argumentOrParameter.iteration.start.endOf From f9d876b33cdefff7f2b5f8de51fbdca6df1c9063 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 14:56:24 +0100 Subject: [PATCH 28/31] function type --- .../scopes/kotlin/type/type.variable3.scope | 20 +++++++++++++++++++ .../scopes/kotlin/type/type.variable4.scope | 20 +++++++++++++++++++ .../scopes/kotlin/value/value.variable5.scope | 20 +++++++++++++++++++ queries/kotlin.scm | 6 +++++- 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/kotlin/type/type.variable3.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.variable4.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.variable5.scope diff --git a/data/fixtures/scopes/kotlin/type/type.variable3.scope b/data/fixtures/scopes/kotlin/type/type.variable3.scope new file mode 100644 index 0000000000..23c7360138 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.variable3.scope @@ -0,0 +1,20 @@ +val foo: suspend () -> Int +--- + +[Content] = 0:9-0:26 + >-----------------< +0| val foo: suspend () -> Int + +[Removal] = 0:7-0:26 + >-------------------< +0| val foo: suspend () -> Int + +[Leading delimiter] = 0:7-0:9 + >--< +0| val foo: suspend () -> Int + +[Domain] = 0:0-0:26 + >--------------------------< +0| val foo: suspend () -> Int + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.variable4.scope b/data/fixtures/scopes/kotlin/type/type.variable4.scope new file mode 100644 index 0000000000..6f020a93bb --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.variable4.scope @@ -0,0 +1,20 @@ +val foo: suspend () -> Int = { 0 } +--- + +[Content] = 0:9-0:26 + >-----------------< +0| val foo: suspend () -> Int = { 0 } + +[Removal] = 0:7-0:26 + >-------------------< +0| val foo: suspend () -> Int = { 0 } + +[Leading delimiter] = 0:7-0:9 + >--< +0| val foo: suspend () -> Int = { 0 } + +[Domain] = 0:0-0:34 + >----------------------------------< +0| val foo: suspend () -> Int = { 0 } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.variable5.scope b/data/fixtures/scopes/kotlin/value/value.variable5.scope new file mode 100644 index 0000000000..fa07c4116c --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.variable5.scope @@ -0,0 +1,20 @@ +val foo: suspend () -> Int = { -> } +--- + +[Content] = 0:29-0:35 + >------< +0| val foo: suspend () -> Int = { -> } + +[Removal] = 0:26-0:35 + >---------< +0| val foo: suspend () -> Int = { -> } + +[Leading delimiter] = 0:26-0:29 + >---< +0| val foo: suspend () -> Int = { -> } + +[Domain] = 0:0-0:35 + >-----------------------------------< +0| val foo: suspend () -> Int = { -> } + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 74843232bd..48dea16896 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -473,7 +473,11 @@ (property_declaration (variable_declaration (simple_identifier) @name @type.leading.endOf - (user_type)? @type + (type_modifiers)? @type.start + [ + (user_type) + (function_type) + ] ? @type.end ) @value.leading.endOf ( "=" From 0d915d568c89970977eb16dfb10fae0599e230a6 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 15:40:39 +0100 Subject: [PATCH 29/31] More tests --- .../languages/kotlin/changeEveryName.yml | 8 ++-- .../languages/kotlin/changeType25.yml | 37 ------------------ .../recorded/languages/kotlin/changeType8.yml | 6 +-- .../recorded/languages/kotlin/changeType9.yml | 6 +-- .../kotlin/name/name.variable.pattern.scope | 26 +++++++------ .../kotlin/name/name.variable.pattern2.scope | 32 +++++++++++++++ .../scopes/kotlin/type/type.return3.scope | 20 ++++++++++ .../scopes/kotlin/type/type.return4.scope | 34 ++++++++++++++++ .../scopes/kotlin/type/type.return5.scope | 20 ++++++++++ .../scopes/kotlin/type/type.variable3.scope | 22 +++++------ .../scopes/kotlin/type/type.variable4.scope | 14 +++---- .../scopes/kotlin/type/type.variable5.scope | 20 ++++++++++ .../scopes/kotlin/type/type.variable6.scope | 39 +++++++++++++++++++ queries/kotlin.scm | 37 +++++++++++++----- 14 files changed, 236 insertions(+), 85 deletions(-) delete mode 100644 data/fixtures/recorded/languages/kotlin/changeType25.yml create mode 100644 data/fixtures/scopes/kotlin/name/name.variable.pattern2.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.return3.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.return4.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.return5.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.variable5.scope create mode 100644 data/fixtures/scopes/kotlin/type/type.variable6.scope diff --git a/data/fixtures/recorded/languages/kotlin/changeEveryName.yml b/data/fixtures/recorded/languages/kotlin/changeEveryName.yml index b3201aa534..e59b5a9eb6 100644 --- a/data/fixtures/recorded/languages/kotlin/changeEveryName.yml +++ b/data/fixtures/recorded/languages/kotlin/changeEveryName.yml @@ -22,8 +22,10 @@ initialState: finalState: documentContents: |- fun main() { - val = Pair(1, 2) + val (, ) = Pair(1, 2) } selections: - - anchor: {line: 1, character: 8} - active: {line: 1, character: 8} + - anchor: {line: 1, character: 9} + active: {line: 1, character: 9} + - anchor: {line: 1, character: 11} + active: {line: 1, character: 11} diff --git a/data/fixtures/recorded/languages/kotlin/changeType25.yml b/data/fixtures/recorded/languages/kotlin/changeType25.yml deleted file mode 100644 index 3acb47bc70..0000000000 --- a/data/fixtures/recorded/languages/kotlin/changeType25.yml +++ /dev/null @@ -1,37 +0,0 @@ -languageId: kotlin -command: - version: 7 - spokenForm: change type - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - fun main() { - try { - val result = 10 / 0 - } catch (e: ArithmeticException) { - println("Division by zero!") - } - } - selections: - - anchor: {line: 4, character: 36} - active: {line: 4, character: 36} - marks: {} -finalState: - documentContents: |- - fun main() { - try { - val result = 10 / 0 - } catch (e: ) { - println("Division by zero!") - } - } - selections: - - anchor: {line: 3, character: 16} - active: {line: 3, character: 16} diff --git a/data/fixtures/recorded/languages/kotlin/changeType8.yml b/data/fixtures/recorded/languages/kotlin/changeType8.yml index a5b3c52fb8..f57ac3bd6f 100644 --- a/data/fixtures/recorded/languages/kotlin/changeType8.yml +++ b/data/fixtures/recorded/languages/kotlin/changeType8.yml @@ -17,7 +17,7 @@ initialState: active: {line: 0, character: 10} marks: {} finalState: - documentContents: "typealias Predicate = " + documentContents: "" selections: - - anchor: {line: 0, character: 25} - active: {line: 0, character: 25} + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/kotlin/changeType9.yml b/data/fixtures/recorded/languages/kotlin/changeType9.yml index 0b57d676b2..9ed082d5a6 100644 --- a/data/fixtures/recorded/languages/kotlin/changeType9.yml +++ b/data/fixtures/recorded/languages/kotlin/changeType9.yml @@ -17,7 +17,7 @@ initialState: active: {line: 0, character: 25} marks: {} finalState: - documentContents: "typealias Predicate = " + documentContents: "" selections: - - anchor: {line: 0, character: 25} - active: {line: 0, character: 25} + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} diff --git a/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope b/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope index 41c7420ace..6cc5a568ef 100644 --- a/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope +++ b/data/fixtures/scopes/kotlin/name/name.variable.pattern.scope @@ -1,24 +1,26 @@ var (foo, bar) = baz --- -[Content] = 0:4-0:14 - >----------< +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:5-0:8 + >---< 0| var (foo, bar) = baz -[Removal] = 0:4-0:15 - >-----------< -0| var (foo, bar) = baz +[#1 Insertion delimiter] = " " + -[Leading delimiter] = 0:3-0:4 - >-< +[#2 Content] = +[#2 Domain] = 0:10-0:13 + >---< 0| var (foo, bar) = baz -[Trailing delimiter] = 0:14-0:15 - >-< +[#2 Removal] = 0:9-0:13 + >----< 0| var (foo, bar) = baz -[Domain] = 0:0-0:20 - >--------------------< +[#2 Leading delimiter] = 0:9-0:10 + >-< 0| var (foo, bar) = baz -[Insertion delimiter] = " " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/name/name.variable.pattern2.scope b/data/fixtures/scopes/kotlin/name/name.variable.pattern2.scope new file mode 100644 index 0000000000..d27d8fa212 --- /dev/null +++ b/data/fixtures/scopes/kotlin/name/name.variable.pattern2.scope @@ -0,0 +1,32 @@ +var (foo: Int, bar: Int) = baz +--- + +[#1 Content] = +[#1 Removal] = 0:5-0:8 + >---< +0| var (foo: Int, bar: Int) = baz + +[#1 Domain] = 0:5-0:13 + >--------< +0| var (foo: Int, bar: Int) = baz + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:15-0:18 + >---< +0| var (foo: Int, bar: Int) = baz + +[#2 Removal] = 0:14-0:18 + >----< +0| var (foo: Int, bar: Int) = baz + +[#2 Leading delimiter] = 0:14-0:15 + >-< +0| var (foo: Int, bar: Int) = baz + +[#2 Domain] = 0:15-0:23 + >--------< +0| var (foo: Int, bar: Int) = baz + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.return3.scope b/data/fixtures/scopes/kotlin/type/type.return3.scope new file mode 100644 index 0000000000..76e7baaa33 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.return3.scope @@ -0,0 +1,20 @@ +fun foo(): @Bar Int {} +--- + +[Content] = 0:11-0:19 + >--------< +0| fun foo(): @Bar Int {} + +[Removal] = 0:9-0:19 + >----------< +0| fun foo(): @Bar Int {} + +[Leading delimiter] = 0:9-0:11 + >--< +0| fun foo(): @Bar Int {} + +[Domain] = 0:0-0:22 + >----------------------< +0| fun foo(): @Bar Int {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.return4.scope b/data/fixtures/scopes/kotlin/type/type.return4.scope new file mode 100644 index 0000000000..bd1990ecc0 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.return4.scope @@ -0,0 +1,34 @@ +class Foo { + set(): Unit {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| set(): Unit {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:11-1:15 + >----< +1| set(): Unit {} + +[#2 Removal] = 1:9-1:15 + >------< +1| set(): Unit {} + +[#2 Leading delimiter] = 1:9-1:11 + >--< +1| set(): Unit {} + +[#2 Domain] = 1:4-1:18 + >--------------< +1| set(): Unit {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.return5.scope b/data/fixtures/scopes/kotlin/type/type.return5.scope new file mode 100644 index 0000000000..71433d1b53 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.return5.scope @@ -0,0 +1,20 @@ +fun(): Int {} +--- + +[Content] = 0:7-0:10 + >---< +0| fun(): Int {} + +[Removal] = 0:5-0:10 + >-----< +0| fun(): Int {} + +[Leading delimiter] = 0:5-0:7 + >--< +0| fun(): Int {} + +[Domain] = 0:0-0:13 + >-------------< +0| fun(): Int {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.variable3.scope b/data/fixtures/scopes/kotlin/type/type.variable3.scope index 23c7360138..efef805860 100644 --- a/data/fixtures/scopes/kotlin/type/type.variable3.scope +++ b/data/fixtures/scopes/kotlin/type/type.variable3.scope @@ -1,20 +1,20 @@ -val foo: suspend () -> Int +val foo: @Bar Int --- -[Content] = 0:9-0:26 - >-----------------< -0| val foo: suspend () -> Int +[Content] = 0:9-0:17 + >--------< +0| val foo: @Bar Int -[Removal] = 0:7-0:26 - >-------------------< -0| val foo: suspend () -> Int +[Removal] = 0:7-0:17 + >----------< +0| val foo: @Bar Int [Leading delimiter] = 0:7-0:9 >--< -0| val foo: suspend () -> Int +0| val foo: @Bar Int -[Domain] = 0:0-0:26 - >--------------------------< -0| val foo: suspend () -> Int +[Domain] = 0:0-0:17 + >-----------------< +0| val foo: @Bar Int [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.variable4.scope b/data/fixtures/scopes/kotlin/type/type.variable4.scope index 6f020a93bb..23c7360138 100644 --- a/data/fixtures/scopes/kotlin/type/type.variable4.scope +++ b/data/fixtures/scopes/kotlin/type/type.variable4.scope @@ -1,20 +1,20 @@ -val foo: suspend () -> Int = { 0 } +val foo: suspend () -> Int --- [Content] = 0:9-0:26 >-----------------< -0| val foo: suspend () -> Int = { 0 } +0| val foo: suspend () -> Int [Removal] = 0:7-0:26 >-------------------< -0| val foo: suspend () -> Int = { 0 } +0| val foo: suspend () -> Int [Leading delimiter] = 0:7-0:9 >--< -0| val foo: suspend () -> Int = { 0 } +0| val foo: suspend () -> Int -[Domain] = 0:0-0:34 - >----------------------------------< -0| val foo: suspend () -> Int = { 0 } +[Domain] = 0:0-0:26 + >--------------------------< +0| val foo: suspend () -> Int [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.variable5.scope b/data/fixtures/scopes/kotlin/type/type.variable5.scope new file mode 100644 index 0000000000..6f020a93bb --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.variable5.scope @@ -0,0 +1,20 @@ +val foo: suspend () -> Int = { 0 } +--- + +[Content] = 0:9-0:26 + >-----------------< +0| val foo: suspend () -> Int = { 0 } + +[Removal] = 0:7-0:26 + >-------------------< +0| val foo: suspend () -> Int = { 0 } + +[Leading delimiter] = 0:7-0:9 + >--< +0| val foo: suspend () -> Int = { 0 } + +[Domain] = 0:0-0:34 + >----------------------------------< +0| val foo: suspend () -> Int = { 0 } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/type/type.variable6.scope b/data/fixtures/scopes/kotlin/type/type.variable6.scope new file mode 100644 index 0000000000..5a2347d172 --- /dev/null +++ b/data/fixtures/scopes/kotlin/type/type.variable6.scope @@ -0,0 +1,39 @@ +val (foo: Int, bar: Int) = baz +--- + +[#1 Content] = 0:10-0:13 + >---< +0| val (foo: Int, bar: Int) = baz + +[#1 Removal] = 0:8-0:13 + >-----< +0| val (foo: Int, bar: Int) = baz + +[#1 Leading delimiter] = 0:8-0:10 + >--< +0| val (foo: Int, bar: Int) = baz + +[#1 Domain] = 0:5-0:13 + >--------< +0| val (foo: Int, bar: Int) = baz + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:20-0:23 + >---< +0| val (foo: Int, bar: Int) = baz + +[#2 Removal] = 0:18-0:23 + >-----< +0| val (foo: Int, bar: Int) = baz + +[#2 Leading delimiter] = 0:18-0:20 + >--< +0| val (foo: Int, bar: Int) = baz + +[#2 Domain] = 0:15-0:23 + >--------< +0| val (foo: Int, bar: Int) = baz + +[#2 Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 48dea16896..6e0e85e6d0 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -95,7 +95,8 @@ (function_declaration (simple_identifier) @name (function_value_parameters) @type.leading.endOf - (user_type)? @type + (type_modifiers)? @type.start + (user_type)? @type.end ) @namedFunction @_.domain ;;!! constructor() {} @@ -104,7 +105,10 @@ ) @namedFunction @name.domain ;;!! fun() {} -(anonymous_function) @anonymousFunction +(anonymous_function + (function_value_parameters) @type.leading.endOf + (user_type)? @type +) @anonymousFunction @type.domain ;;!! {x -> 0} (lambda_literal @@ -485,13 +489,25 @@ )? ) @_.domain -;;!! val (foo, bar) = baz -;;! ^^^^^^^^^^ -;;! ^^^ +;;!! val (foo: Int, bar: Int) = baz +;;! ^^^^^^^^^^^^^^^^^^ +;;! ^^^ (property_declaration - (multi_variable_declaration) @name @value.leading.endOf + (multi_variable_declaration) @name.iteration @type.iteration @value.leading.endOf (_) @value -) @_.domain +) @value.domain @name.iteration.domain @type.iteration.domain + +;;!! val (foo: Int, bar: Int) = baz +;;! ^^^ ^^^ +;;! ^^^ ^^^ +(property_declaration + (multi_variable_declaration + (variable_declaration + (simple_identifier) @name @type.leading.endOf + (user_type)? @type + ) @_.domain + ) +) ;;!! foo = 0 ;;! ^^^ @@ -1331,12 +1347,15 @@ ) @argumentOrParameter @_.domain ) -;;!! set(aaa: Int) {} +;;!! set(aaa: Int): Unit {} ;;! ^^^^^^^^ +;;! ^^^^ ;; There is only one parameter allowed, but we treat it as iterable for consistency. (setter (parameter_with_optional_type) @argumentOrParameter.iteration -) @namedFunction @argumentOrParameter.iteration.domain + ")" @type.leading.endOf + (user_type)? @type +) @namedFunction @type.domain @argumentOrParameter.iteration.domain ;; (constructor_delegation_call ;; (value_arguments From 6943c05a2d551651fad92a9b5a961e265f13b132 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 15:49:58 +0100 Subject: [PATCH 30/31] Clean up --- queries/kotlin.scm | 772 --------------------------------------------- 1 file changed, 772 deletions(-) diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 6e0e85e6d0..e27054f81d 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -1,35 +1,5 @@ ;; https://github.com/fwcd/tree-sitter-kotlin/blob/main/src/grammar.json -;; -;; Declarations and statements -;; - -;; Define @statement based on parent node, because a statement can be an arbitrary expression (with -;; no expression_statement parent node) and we don't want every nested expression to be a statement. -;; (source_file -;; (_) @statement -;; (#not-type? @statement import_list) -;; ) - -;; (import_header) @statement - -;; (statements -;; (_) @statement -;; ) - -;; (control_structure_body -;; (_) @statement -;; (#not-type? @statement statements) -;; ) - -;; (class_body -;; (_) @statement -;; ) - -;; (enum_class_body -;; (_) @statement -;; ) - [ (class_declaration) (object_declaration) @@ -115,10 +85,6 @@ (statements)? @value ) @anonymousFunction @value.domain -;; -;; Literals and comments -;; - ;;!! "Hello world" (string_literal (string_content) @textFragment @@ -131,10 +97,6 @@ (multiline_comment) ] @comment @textFragment -;; -;; Branches and conditions -;; - ;; Top level if statement ( (_ @@ -275,57 +237,6 @@ ) @interior.end.endOf ) @interior.domain -;; (if_expression -;; "if" -;; . -;; "(" -;; . -;; (_) @condition -;; . -;; ")" -;; ) @_.domain - -;; If branch -;; (if_expression -;; "if" @branch.start @branch.removal.start -;; . -;; "(" -;; . -;; (_) -;; . -;; ")" -;; . -;; (control_structure_body) @branch.end @branch.removal.end -;; ( -;; "else" -;; (control_structure_body) @branch.removal.end.startOf -;; )? -;; ) - -;; Else-if branch -;; (if_expression -;; "else" @branch.start @condition.domain.start -;; (control_structure_body -;; (if_expression -;; "if" -;; . -;; "(" -;; . -;; (_) @condition -;; . -;; ")" -;; . -;; (control_structure_body) @branch.end @condition.domain.end -;; ) -;; ) -;; ) - -;; Else branch -;; (if_expression -;; "else" @branch.start -;; (control_structure_body) @branch.end -;; ) - ;;!! while (true) {} ;;! ^^^^ (while_statement @@ -343,21 +254,6 @@ ")" ) @condition.domain -;; -;; Name, value, type, and key -;; - -;; (type_alias -;; "typealias" -;; . -;; (_) @name.start -;; (_)? @name.end -;; . -;; "=" -;; . -;; (_) @value.start @type.start -;; ) @value.end.endOf @type.end.endOf @_.domain - ;;!! class Foo {} (class_declaration (type_identifier) @name @@ -373,103 +269,6 @@ (type_identifier) @name ) @class @type @name.domain -;; (class_parameter -;; (simple_identifier) @name -;; ) @_.domain - -;; (class_parameter -;; ":" -;; . -;; (_) @type.start -;; (_)? @type.end -;; . -;; "=" -;; (_) @value -;; ) @_.domain - -;; ;; Known issue: this won't work with multiple-node types. -;; (class_parameter -;; ":" -;; . -;; (_) @type -;; . -;; ) @_.domain - -;; ;; Function declarations with type constraints -;; (function_declaration -;; ":" -;; . -;; (_) @type.start -;; (_)? @type.end -;; . -;; (type_constraints) -;; ) @_.domain - -;; ;; Function declarations with no type constraints but with body -;; ( -;; (function_declaration -;; ":" -;; . -;; (_) @type -;; . -;; (function_body) -;; ) @_.domain -;; ) -;; ( -;; (function_declaration -;; ":" -;; . -;; (_) @type.start -;; (_) @type.end -;; . -;; (function_body) -;; ) @_.domain -;; (#not-type? @type.end "type_constraints") -;; ) - -;; ;; Function declaration without body or type constraints -;; ( -;; (function_declaration -;; ":" -;; . -;; (_) @type -;; . -;; ) @_.domain -;; ) -;; ( -;; (function_declaration -;; ":" -;; . -;; (_) @type.start -;; (_) @type.end -;; . -;; ) @_.domain -;; (#not-type? @type.end "function_body") -;; (#not-type? @type.end "type_constraints") -;; ) - -;; (variable_declaration -;; (simple_identifier) @name -;; ) @_.domain - -;; (variable_declaration -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf @_.domain - -;; (multi_variable_declaration) @name.iteration @type.iteration - -;;!! val foo: Int -;;! ^^^ -;;! ^^^ -;; (property_declaration -;; (variable_declaration -;; (simple_identifier) @name @type.leading.endOf -;; (user_type)? @type -;; ) -;; ) @_.domain - ;;!! val foo: Int = 0 ;;! ^^^ ;;! ^^^ @@ -538,30 +337,6 @@ (_) @value ) @type @_.domain -;; (property_declaration -;; "=" -;; . -;; (_) @value -;; ) @_.domain - -;; (property_declaration -;; (property_delegate -;; (_) @value -;; ) -;; ) @_.domain - -;; (property_declaration -;; (variable_declaration -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf -;; ) @_.domain - -;; (property_declaration -;; (multi_variable_declaration) @name.iteration @type.iteration -;; ) @name.iteration.domain @type.iteration.domain - ;;!! for (v: Int in values) {} ;;! ^ ;;! ^^^ @@ -578,123 +353,6 @@ (_) @value ) @_.domain -;;!! for (i in 0 until size) {} -;; (for_statement -;; "in" -;; . -;; (_) @value -;; ) @value.domain - -;; (for_statement -;; (variable_declaration -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf -;; ) @type.domain - -;; (for_statement -;; (multi_variable_declaration) @name.iteration @type.iteration -;; ) @name.iteration.domain @type.iteration.domain - -;; (when_subject -;; (variable_declaration -;; (simple_identifier) @name -;; ) -;; ) @name.domain - -;; (when_subject -;; "=" -;; . -;; (_) @value -;; ) @value.domain - -;; (when_subject -;; (variable_declaration -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf -;; ) @type.domain - -;; (getter -;; ":" -;; . -;; (_) @type.start -;; (_)? @type.end -;; (function_body) -;; ) @type.domain - -;; (setter -;; ":" -;; . -;; (_) @type.start -;; (_)? @type.end -;; (function_body) -;; ) @type.domain - -;; (parameter_with_optional_type -;; (simple_identifier) @name -;; ) @name.domain - -;; (parameter_with_optional_type -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf @type.domain - -;; Function parameter without default -;; (function_value_parameters -;; (parameter -;; (simple_identifier) @name -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf @_.domain -;; ) - -;; Function parameter with default -;; (function_value_parameters -;; (parameter -;; (simple_identifier) @name -;; ":" -;; . -;; (_) @type.start -;; ) @type.end.endOf @_.domain.start -;; . -;; "=" -;; . -;; (_) @value @_.domain.end -;; ) - -;; (anonymous_function -;; ":" -;; .u -;; (_) @type.start -;; (_)? @type.end -;; . -;; (function_body) -;; ) @_.domain - -;; ( -;; (anonymous_function -;; ":" -;; . -;; (_) @type -;; . -;; ) @_.domain -;; ) -;; ( -;; (anonymous_function -;; ":" -;; . -;; (_) @type.start -;; (_) @type.end -;; . -;; ) @_.domain -;; (#not-type? @type.end "function_body") -;; ) - ;;!! return 0 ;;! ^ (jump_expression @@ -705,29 +363,6 @@ (_) @value ) @value.domain -;; (jump_expression -;; "return@" -;; . -;; (label) -;; . -;; (_) @value -;; ) @_.domain - -;; (_ -;; (function_body -;; "=" -;; . -;; (_) @value -;; ) -;; ) @_.domain - -;; (value_argument -;; (simple_identifier) @name -;; "=" -;; . -;; (_) @value.start -;; ) @value.end.endOf @_.domain - ;;!! aaa to 0 ;;! ^^^ ;;! ^ @@ -751,16 +386,6 @@ (#eq? @_dummy "mapOf") ) -;; -;; Function call, callee, arguments, and parameters -;; - -;; [ -;; (call_expression) -;; ;; (constructor_invocation) -;; ;; (constructor_delegation_call) -;; ] @functionCall - ;;!! foo() ;;! ^^^^^^^^ ;;! ^^^^^^ @@ -774,32 +399,6 @@ )? ) @functionCall @functionCallee.domain -;; (call_suffix -;; (annotated_lambda) @argumentOrParameter -;; ) - -;; (call_expression -;; (call_suffix) @argumentOrParameter.iteration -;; ) @argumentOrParameter.iteration.domain - -;; (constructor_invocation -;; (user_type) @functionCallee -;; ) @_.domain - -;; (constructor_invocation -;; (value_arguments -;; "(" @argumentOrParameter.iteration.start.endOf -;; ")" @argumentOrParameter.iteration.end.startOf -;; ) -;; ) @argumentOrParameter.iteration.domain - -;; (constructor_delegation_call -;; [ -;; "this" -;; "super" -;; ] @functionCallee -;; ) @_.domain - ;;!! fun foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ (_ @@ -942,257 +541,6 @@ (annotated_lambda) @argumentOrParameter ) -;;!! foo: Int -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (parameter) @argumentOrParameter -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -;; ) - -;;!! vararg foo: Int -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (parameter_modifiers) @argumentOrParameter.start -;; . -;; (parameter) @argumentOrParameter.end -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") -;; ) - -;;!! foo: Int = 0 -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (parameter) @argumentOrParameter.start -;; . -;; "=" -;; . -;; (_) @argumentOrParameter.end -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") -;; ) - -;;!! vararg foo: Int = 0 -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (parameter_modifiers) @argumentOrParameter.start -;; . -;; (parameter) -;; . -;; "=" -;; . -;; (_) @argumentOrParameter.end -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") -;; ) - -;;!! fun Foo(aaa: Int = 0) {} -;;! ^^^ -;;! ^^^ -;;! ^ -;; (function_value_parameters -;; ;; [ -;; ;; "(" -;; ;; "," -;; ;; (parameter_modifiers)? @_.domain.start.startOf -;; ;; ] -;; ;; . -;; (parameter -;; (simple_identifier) @name @type.leading.endOf -;; (user_type) @type -;; ) @_.domain.start @value.leading.endOf -;; . -;; ( -;; "=" -;; . -;; (_) @value @_.domain.end -;; )? -;; . -;; [ -;; "," -;; ")" -;; ] -;; ) - -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (parameter) @argumentOrParameter.start -;; . -;; ( -;; "=" -;; . -;; (_) @argumentOrParameter.end -;; ) -;; . -;; (_)? @_.trailing.startOf -;; ) -;; ) - -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (parameter) @argumentOrParameter.start -;; . -;; ( -;; "=" -;; . -;; (_) @argumentOrParameter.end -;; )? -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; ;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") -;; ) - -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; [ -;; "," -;; "(" -;; ] -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; (parameter_modifiers)? @argumentOrParameter.start -;; . -;; (parameter) @argumentOrParameter.end -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") -;; ) - -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; [ -;; "," -;; "(" -;; ] -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; (parameter_modifiers)? @argumentOrParameter.start.startOf -;; . -;; (parameter) @argumentOrParameter.start -;; . -;; (_) @argumentOrParameter.end -;; (#not-type? @argumentOrParameter.end "parameter" "parameter_modifiers") -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") -;; ) - -;; ( -;; (function_value_parameters -;; ;; (_)? @_.leading.endOf -;; ;; . -;; (_) @argumentOrParameter.start -;; . -;; ( -;; "=" -;; . -;; (_) @argumentOrParameter.end -;; )? -;; ;; . -;; ;; (_)? @_.trailing.startOf -;; ) @_dummy -;; ;; (#single-or-multi-line-delimiter! @argumentOrParameter.start @_dummy ", " ",\n") -;; ) - -;; (function_value_parameters -;; (parameter -;; (simple_identifier) @name @type.leading.endOf -;; (user_type) @type -;; ) @_.domain.start @value.leading.endOf -;; . -;; ( -;; "=" -;; . -;; (_) @value @_.domain.end -;; )? -;; ) - -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; (_) @argumentOrParameter -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -;; ) - ;;!! { aaa, bbb -> } ;;! ^^^^^^^^ (lambda_literal @@ -1357,13 +705,6 @@ (user_type)? @type ) @namedFunction @type.domain @argumentOrParameter.iteration.domain -;; (constructor_delegation_call -;; (value_arguments -;; "(" @argumentOrParameter.iteration.start.endOf -;; ")" @argumentOrParameter.iteration.end.startOf -;; ) -;; ) @argumentOrParameter.iteration.domain - ;;!! BAR, (enum_entry (simple_identifier) @name @@ -1390,119 +731,6 @@ ] @functionCallee ) @functionCall @functionCallee.domain -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; [ -;; "," -;; "(" -;; ] -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; (parameter_modifiers)? @argumentOrParameter.start -;; . -;; (parameter) @argumentOrParameter.end -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") -;; ) - -;; ( -;; (function_value_parameters -;; (_)? @_.leading.endOf -;; . -;; [ -;; "," -;; "(" -;; ] -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; (parameter_modifiers)? @argumentOrParameter.start.startOf -;; . -;; (parameter) @argumentOrParameter.start -;; . -;; (_) @argumentOrParameter.end -;; (#not-type? @argumentOrParameter.end "parameter" "parameter_modifiers") -;; . -;; [ -;; (line_comment) -;; (multiline_comment) -;; ] * -;; . -;; [ -;; "," -;; ")" -;; ] -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter.end @_dummy ", " ",\n") -;; ) - -;; (_ -;; (function_value_parameters) @argumentOrParameter.iteration -;; ) @argumentOrParameter.iteration.domain - -;; ( -;; (primary_constructor -;; (_)? @_.leading.endOf -;; . -;; (class_parameter) @argumentOrParameter -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -;; ) - -;; (class_declaration -;; (primary_constructor) @argumentOrParameter.iteration -;; ) @argumentOrParameter.iteration.domain - -;; (parameter_with_optional_type) @argumentOrParameter - -;; There is only one parameter allowed, but we treat it as iterable for consistency. -;; (setter -;; (parameter_with_optional_type) @argumentOrParameter.iteration -;; ) @argumentOrParameter.iteration.domain - -;; ( -;; (lambda_parameters -;; (_)? @_.leading.endOf -;; . -;; [ -;; (variable_declaration) -;; (multi_variable_declaration) -;; ] @argumentOrParameter -;; . -;; (_)? @_.trailing.startOf -;; ) @_dummy -;; (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") -;; ) - -;; (lambda_literal -;; (lambda_parameters) @argumentOrParameter.iteration -;; ) @argumentOrParameter.iteration.domain - (comparison_expression [ "<" From 5fa4eae1016c411a6f6e8112c8c034df0b8e4207 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Wed, 4 Feb 2026 16:22:32 +0100 Subject: [PATCH 31/31] More tests --- .../languages/kotlin/changeName11.yml | 37 ------------------- .../languages/kotlin/changeValue10.yml | 25 +++++++++++++ .../kotlin/value/value.return.lambda2.scope | 20 ++++++++++ .../kotlin/value/value.return.lambda3.scope | 20 ++++++++++ queries/kotlin.scm | 8 +++- 5 files changed, 71 insertions(+), 39 deletions(-) delete mode 100644 data/fixtures/recorded/languages/kotlin/changeName11.yml create mode 100644 data/fixtures/recorded/languages/kotlin/changeValue10.yml create mode 100644 data/fixtures/scopes/kotlin/value/value.return.lambda2.scope create mode 100644 data/fixtures/scopes/kotlin/value/value.return.lambda3.scope diff --git a/data/fixtures/recorded/languages/kotlin/changeName11.yml b/data/fixtures/recorded/languages/kotlin/changeName11.yml deleted file mode 100644 index 3ec17696b0..0000000000 --- a/data/fixtures/recorded/languages/kotlin/changeName11.yml +++ /dev/null @@ -1,37 +0,0 @@ -languageId: kotlin -command: - version: 7 - spokenForm: change name - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: name} - usePrePhraseSnapshot: true -initialState: - documentContents: |- - fun main() { - try { - val result = 10 / 0 - } catch (e: ArithmeticException) { - println("Division by zero!") - } - } - selections: - - anchor: {line: 4, character: 36} - active: {line: 4, character: 36} - marks: {} -finalState: - documentContents: |- - fun () { - try { - val result = 10 / 0 - } catch (e: ArithmeticException) { - println("Division by zero!") - } - } - selections: - - anchor: {line: 0, character: 4} - active: {line: 0, character: 4} diff --git a/data/fixtures/recorded/languages/kotlin/changeValue10.yml b/data/fixtures/recorded/languages/kotlin/changeValue10.yml new file mode 100644 index 0000000000..971cfbdb84 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeValue10.yml @@ -0,0 +1,25 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: | + fun double(x: Int) = x * 2 + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: | + fun double(x: Int) = + selections: + - anchor: {line: 0, character: 21} + active: {line: 0, character: 21} diff --git a/data/fixtures/scopes/kotlin/value/value.return.lambda2.scope b/data/fixtures/scopes/kotlin/value/value.return.lambda2.scope new file mode 100644 index 0000000000..8bf2946b53 --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.return.lambda2.scope @@ -0,0 +1,20 @@ +fun foo() = 0 +--- + +[Content] = 0:12-0:13 + >-< +0| fun foo() = 0 + +[Removal] = 0:9-0:13 + >----< +0| fun foo() = 0 + +[Leading delimiter] = 0:9-0:12 + >---< +0| fun foo() = 0 + +[Domain] = 0:0-0:13 + >-------------< +0| fun foo() = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/kotlin/value/value.return.lambda3.scope b/data/fixtures/scopes/kotlin/value/value.return.lambda3.scope new file mode 100644 index 0000000000..5364970b5b --- /dev/null +++ b/data/fixtures/scopes/kotlin/value/value.return.lambda3.scope @@ -0,0 +1,20 @@ +fun foo(): Int = 0 +--- + +[Content] = 0:17-0:18 + >-< +0| fun foo(): Int = 0 + +[Removal] = 0:9-0:18 + >---------< +0| fun foo(): Int = 0 + +[Leading delimiter] = 0:9-0:17 + >--------< +0| fun foo(): Int = 0 + +[Domain] = 0:0-0:18 + >------------------< +0| fun foo(): Int = 0 + +[Insertion delimiter] = " " diff --git a/queries/kotlin.scm b/queries/kotlin.scm index e27054f81d..1c7f7bf35f 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -64,9 +64,13 @@ ;;! ^^^ (function_declaration (simple_identifier) @name - (function_value_parameters) @type.leading.endOf + (function_value_parameters) @type.leading.endOf @value.leading.start.endOf (type_modifiers)? @type.start - (user_type)? @type.end + (user_type)? @type.end @value.leading.start.endOf + (function_body + "=" + (_) @value + )? ) @namedFunction @_.domain ;;!! constructor() {}