From 71c720f0cab444748a9bc627f666c8076b67cd03 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 10:03:01 +0100 Subject: [PATCH 01/13] Started updating scala facets --- .../scala/class.iteration.document.scope | 12 + data/fixtures/scopes/scala/class.scope | 10 + .../fixtures/scopes/scala/comment.block.scope | 10 + data/fixtures/scopes/scala/comment.line.scope | 10 + .../scopes/scala/functionCall.chain.scope | 19 ++ .../scala/functionCall.constructor.scope | 10 + .../scopes/scala/functionCall.method.scope | 10 + data/fixtures/scopes/scala/functionCall.scope | 10 + .../scopes/scala/functionCallee.chain.scope | 25 ++ .../scala/functionCallee.constructor.scope | 13 + .../scopes/scala/functionCallee.method.scope | 13 + .../scopes/scala/functionCallee.scope | 13 + .../scala/name/name.iteration.document.scope | 12 + .../namedFunction.iteration.document.scope | 12 + .../scopes/scala/namedFunction.method.scope | 21 ++ .../fixtures/scopes/scala/namedFunction.scope | 10 + .../statement.iteration.document.scope | 12 + .../scopes/scala/string.multiLine.scope | 13 + .../scopes/scala/string.singleLine.scope | 10 + .../scala/textFragment.comment.line.scope | 10 + .../scala/textFragment.string.multiLine.scope | 13 + .../textFragment.string.singleLine.scope | 10 + .../scala/type/type.iteration.document.scope | 12 + .../value/value.iteration.document.scope | 12 + .../common/src/scopeSupportFacets/scala.ts | 286 +++++++++++++++++- queries/scala.scm | 23 +- 26 files changed, 607 insertions(+), 4 deletions(-) create mode 100644 data/fixtures/scopes/scala/class.iteration.document.scope create mode 100644 data/fixtures/scopes/scala/class.scope create mode 100644 data/fixtures/scopes/scala/comment.block.scope create mode 100644 data/fixtures/scopes/scala/comment.line.scope create mode 100644 data/fixtures/scopes/scala/functionCall.chain.scope create mode 100644 data/fixtures/scopes/scala/functionCall.constructor.scope create mode 100644 data/fixtures/scopes/scala/functionCall.method.scope create mode 100644 data/fixtures/scopes/scala/functionCall.scope create mode 100644 data/fixtures/scopes/scala/functionCallee.chain.scope create mode 100644 data/fixtures/scopes/scala/functionCallee.constructor.scope create mode 100644 data/fixtures/scopes/scala/functionCallee.method.scope create mode 100644 data/fixtures/scopes/scala/functionCallee.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.document.scope create mode 100644 data/fixtures/scopes/scala/namedFunction.iteration.document.scope create mode 100644 data/fixtures/scopes/scala/namedFunction.method.scope create mode 100644 data/fixtures/scopes/scala/namedFunction.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.document.scope create mode 100644 data/fixtures/scopes/scala/string.multiLine.scope create mode 100644 data/fixtures/scopes/scala/string.singleLine.scope create mode 100644 data/fixtures/scopes/scala/textFragment.comment.line.scope create mode 100644 data/fixtures/scopes/scala/textFragment.string.multiLine.scope create mode 100644 data/fixtures/scopes/scala/textFragment.string.singleLine.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.document.scope create mode 100644 data/fixtures/scopes/scala/value/value.iteration.document.scope diff --git a/data/fixtures/scopes/scala/class.iteration.document.scope b/data/fixtures/scopes/scala/class.iteration.document.scope new file mode 100644 index 0000000000..813bb62ea9 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/class.scope b/data/fixtures/scopes/scala/class.scope new file mode 100644 index 0000000000..ffbda12f63 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/comment.block.scope b/data/fixtures/scopes/scala/comment.block.scope new file mode 100644 index 0000000000..5e8b51111c --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/comment.line.scope b/data/fixtures/scopes/scala/comment.line.scope new file mode 100644 index 0000000000..7d1477b8a1 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/functionCall.chain.scope b/data/fixtures/scopes/scala/functionCall.chain.scope new file mode 100644 index 0000000000..c73434c70d --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/functionCall.constructor.scope b/data/fixtures/scopes/scala/functionCall.constructor.scope new file mode 100644 index 0000000000..290aa43226 --- /dev/null +++ b/data/fixtures/scopes/scala/functionCall.constructor.scope @@ -0,0 +1,10 @@ +new Foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| new Foo() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/functionCall.method.scope b/data/fixtures/scopes/scala/functionCall.method.scope new file mode 100644 index 0000000000..6ab0ba4c3a --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/functionCall.scope b/data/fixtures/scopes/scala/functionCall.scope new file mode 100644 index 0000000000..00162e317c --- /dev/null +++ b/data/fixtures/scopes/scala/functionCall.scope @@ -0,0 +1,10 @@ +foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/functionCallee.chain.scope b/data/fixtures/scopes/scala/functionCallee.chain.scope new file mode 100644 index 0000000000..b0b9872650 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/functionCallee.constructor.scope b/data/fixtures/scopes/scala/functionCallee.constructor.scope new file mode 100644 index 0000000000..0b7531f0cb --- /dev/null +++ b/data/fixtures/scopes/scala/functionCallee.constructor.scope @@ -0,0 +1,13 @@ +new Foo() +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| new Foo() + +[Domain] = 0:0-0:9 + >---------< +0| new Foo() + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/functionCallee.method.scope b/data/fixtures/scopes/scala/functionCallee.method.scope new file mode 100644 index 0000000000..e77bc361ec --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/functionCallee.scope b/data/fixtures/scopes/scala/functionCallee.scope new file mode 100644 index 0000000000..2b075b5c33 --- /dev/null +++ b/data/fixtures/scopes/scala/functionCallee.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/scala/name/name.iteration.document.scope b/data/fixtures/scopes/scala/name/name.iteration.document.scope new file mode 100644 index 0000000000..ae2a25d6b7 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.iteration.document.scope @@ -0,0 +1,12 @@ + +val foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| val foo +2| + < diff --git a/data/fixtures/scopes/scala/namedFunction.iteration.document.scope b/data/fixtures/scopes/scala/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..ccfd123367 --- /dev/null +++ b/data/fixtures/scopes/scala/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +def foo(): Int = 0 + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| def foo(): Int = 0 +2| + < diff --git a/data/fixtures/scopes/scala/namedFunction.method.scope b/data/fixtures/scopes/scala/namedFunction.method.scope new file mode 100644 index 0000000000..fde8e29ed6 --- /dev/null +++ b/data/fixtures/scopes/scala/namedFunction.method.scope @@ -0,0 +1,21 @@ +class Foo { + def bar(): Int = 1 +} +--- + +[Content] = +[Domain] = 1:4-1:22 + >------------------< +1| def bar(): Int = 1 + +[Removal] = 1:0-2:0 + >---------------------- +1| def bar(): Int = 1 +2| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| def bar(): Int = 1 + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/scala/namedFunction.scope b/data/fixtures/scopes/scala/namedFunction.scope new file mode 100644 index 0000000000..2989945169 --- /dev/null +++ b/data/fixtures/scopes/scala/namedFunction.scope @@ -0,0 +1,10 @@ +def foo(): Int = 1 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| def foo(): Int = 1 + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/scala/statement/statement.iteration.document.scope b/data/fixtures/scopes/scala/statement/statement.iteration.document.scope new file mode 100644 index 0000000000..ae2a25d6b7 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.iteration.document.scope @@ -0,0 +1,12 @@ + +val foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| val foo +2| + < diff --git a/data/fixtures/scopes/scala/string.multiLine.scope b/data/fixtures/scopes/scala/string.multiLine.scope new file mode 100644 index 0000000000..80dbca0966 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/string.singleLine.scope b/data/fixtures/scopes/scala/string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/textFragment.comment.line.scope b/data/fixtures/scopes/scala/textFragment.comment.line.scope new file mode 100644 index 0000000000..6758f81490 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/textFragment.string.multiLine.scope b/data/fixtures/scopes/scala/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..80dbca0966 --- /dev/null +++ b/data/fixtures/scopes/scala/textFragment.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/scala/textFragment.string.singleLine.scope b/data/fixtures/scopes/scala/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/data/fixtures/scopes/scala/textFragment.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/scala/type/type.iteration.document.scope b/data/fixtures/scopes/scala/type/type.iteration.document.scope new file mode 100644 index 0000000000..ae2a25d6b7 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.iteration.document.scope @@ -0,0 +1,12 @@ + +val foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| val foo +2| + < diff --git a/data/fixtures/scopes/scala/value/value.iteration.document.scope b/data/fixtures/scopes/scala/value/value.iteration.document.scope new file mode 100644 index 0000000000..ae2a25d6b7 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.iteration.document.scope @@ -0,0 +1,12 @@ + +val foo + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| val foo +2| + < diff --git a/packages/common/src/scopeSupportFacets/scala.ts b/packages/common/src/scopeSupportFacets/scala.ts index 21d4a4a122..2a1f55b676 100644 --- a/packages/common/src/scopeSupportFacets/scala.ts +++ b/packages/common/src/scopeSupportFacets/scala.ts @@ -1,24 +1,306 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const scalaScopeSupport: LanguageScopeSupportFacetMap = { - ifStatement: supported, disqualifyDelimiter: supported, + anonymousFunction: supported, + list: supported, + map: supported, + attribute: 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.method": supported, + "namedFunction.iteration.class": supported, + "namedFunction.iteration.document": supported, + + ifStatement: supported, + + "statement.class": supported, + "statement.interface": supported, + "statement.enum": supported, + "statement.field.class": supported, + "statement.field.interface": supported, + "statement.function": 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.yield": supported, + "statement.namespace": 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.actual": supported, + "name.argument.actual.iteration": 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.assignment": supported, + "name.class": supported, + "name.interface": supported, + "name.enum": supported, + "name.field.class": supported, + "name.field.interface": supported, + "name.field.enum": 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, + "name.namespace": supported, + + "value.argument.actual": supported, + "value.argument.actual.iteration": supported, + "value.argument.formal": supported, + "value.argument.formal.iteration": supported, + "value.argument.formal.method": supported, + "value.argument.formal.method.iteration": supported, + "value.argument.formal.constructor": supported, + "value.argument.formal.constructor.iteration": supported, + "value.assignment": supported, + "value.foreach": supported, + "value.switch": supported, + "value.field.class": supported, + "value.field.enum": supported, + "value.return": supported, + "value.yield": supported, + "value.return.lambda": supported, + "value.variable": supported, + "value.variable.pattern": supported, + "value.iteration.block": supported, + "value.iteration.class": supported, + "value.iteration.enum": supported, + "value.iteration.document": supported, + "value.mapPair": supported, + "value.mapPair.iteration": supported, + "value.typeAlias": 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, + + "key.mapPair": supported, + "key.mapPair.iteration": supported, + + "interior.class": supported, + "interior.interface": supported, + "interior.enum": supported, + "interior.function": 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, + "interior.namespace": supported, + + /* UNSUPPORTED */ + + fieldAccess: unsupported, + + /* NOT APPLICABLE */ + + // Constructor definition + + "namedFunction.constructor": notApplicable, + "statement.constructor": notApplicable, + "interior.constructor": notApplicable, + "name.constructor": notApplicable, + + // Element and tags + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Resource syntax + "statement.resource": notApplicable, + "interior.resource": notApplicable, + "type.resource": notApplicable, + "type.resource.iteration": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, + "value.resource": notApplicable, + "value.resource.iteration": notApplicable, + + // Pattern destructuring assignment + "name.assignment.pattern": notApplicable, + + // Branches and conditions + "branch.ternary": notApplicable, + "branch.ternary.iteration": notApplicable, + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + "condition.for": notApplicable, + "condition.ternary": notApplicable, + + // For loop + "statement.for": notApplicable, + "interior.for": notApplicable, + + // Control flow keywords not in Scala + "statement.break": notApplicable, + "statement.continue": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Static + "statement.static": notApplicable, + "interior.static": notApplicable, + + // Miscellaneous + pairDelimiter: notApplicable, + regularExpression: notApplicable, + environment: notApplicable, + selector: notApplicable, + unit: notApplicable, }; diff --git a/queries/scala.scm b/queries/scala.scm index 73a706f546..7077312509 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -1,5 +1,15 @@ ;; https://github.com/tree-sitter/tree-sitter-scala/blob/master/src/grammar.json +( + (compilation_unit) @class.iteration @statement.iteration @namedFunction.iteration + (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) +) + +( + (compilation_unit) @name.iteration @value.iteration @type.iteration + (#document-range! @name.iteration @value.iteration @type.iteration) +) + ( (if_expression) @ifStatement @statement (#not-parent-type? @ifStatement if_expression) @@ -28,8 +38,17 @@ ) ] @class @name.domain -;; list.size(), does not count foo.size (field_expression), or foo size (postfix_expression) -(call_expression) @functionCall +;;!! foo() +;; does not count foo.size (field_expression), or foo size (postfix_expression) +(call_expression + function: (_) @functionCallee +) @functionCall @functionCallee.domain + +;;!! new Foo() +(instance_expression + "new" @functionCallee.start + (type_identifier) @functionCallee.end +) @functionCall @functionCallee.domain (lambda_expression) @anonymousFunction From d43bbe2f98b10107586d2a16a7c9118788db6f27 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 11:10:44 +0100 Subject: [PATCH 02/13] statement --- .../scopes/scala/anonymousFunction.scope | 10 ++++ .../scopes/scala/anonymousFunction2.scope | 10 ++++ .../scopes/scala/class.iteration.block.scope | 13 +++++ .../scala/name/name.iteration.class.scope | 13 +++++ .../scala/namedFunction.iteration.class.scope | 13 +++++ .../statement/statement.assignment.scope | 10 ++++ .../scala/statement/statement.class.scope | 10 ++++ .../scala/statement/statement.doWhile.scope | 10 ++++ .../scala/statement/statement.enum.scope | 10 ++++ .../statement/statement.field.class.scope | 33 +++++++++++++ .../statement/statement.field.interface.scope | 33 +++++++++++++ .../scala/statement/statement.foreach.scope | 10 ++++ .../scala/statement/statement.function.scope | 10 ++++ .../scopes/scala/statement/statement.if.scope | 15 ++++++ .../scala/statement/statement.interface.scope | 10 ++++ .../statement/statement.iteration.class.scope | 13 +++++ .../scala/statement/statement.method.scope | 33 +++++++++++++ .../scala/statement/statement.namespace.scope | 10 ++++ .../scala/statement/statement.return.scope | 33 +++++++++++++ .../scala/statement/statement.switch.scope | 10 ++++ .../scala/statement/statement.try.scope | 13 +++++ .../scala/statement/statement.variable.scope | 10 ++++ .../scala/statement/statement.while.scope | 10 ++++ .../scala/textFragment.comment.block.scope | 10 ++++ .../scala/type/type.iteration.class.scope | 13 +++++ .../scala/value/value.iteration.class.scope | 13 +++++ .../scala/value/value.return.lambda.scope | 20 ++++++++ .../scopes/scala/value/value.return.scope | 22 +++++++++ .../common/src/scopeSupportFacets/scala.ts | 23 +++++---- queries/java.scm | 2 +- queries/scala.scm | 48 +++++++++++++++++++ 31 files changed, 482 insertions(+), 11 deletions(-) create mode 100644 data/fixtures/scopes/scala/anonymousFunction.scope create mode 100644 data/fixtures/scopes/scala/anonymousFunction2.scope create mode 100644 data/fixtures/scopes/scala/class.iteration.block.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.class.scope create mode 100644 data/fixtures/scopes/scala/namedFunction.iteration.class.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.assignment.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.class.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.doWhile.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.enum.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.field.class.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.field.interface.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.foreach.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.function.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.if.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.interface.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.class.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.method.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.namespace.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.return.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.switch.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.try.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.variable.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.while.scope create mode 100644 data/fixtures/scopes/scala/textFragment.comment.block.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.class.scope create mode 100644 data/fixtures/scopes/scala/value/value.iteration.class.scope create mode 100644 data/fixtures/scopes/scala/value/value.return.lambda.scope create mode 100644 data/fixtures/scopes/scala/value/value.return.scope diff --git a/data/fixtures/scopes/scala/anonymousFunction.scope b/data/fixtures/scopes/scala/anonymousFunction.scope new file mode 100644 index 0000000000..6ff2c1d6c3 --- /dev/null +++ b/data/fixtures/scopes/scala/anonymousFunction.scope @@ -0,0 +1,10 @@ +() => {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| () => {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/anonymousFunction2.scope b/data/fixtures/scopes/scala/anonymousFunction2.scope new file mode 100644 index 0000000000..5556d41df0 --- /dev/null +++ b/data/fixtures/scopes/scala/anonymousFunction2.scope @@ -0,0 +1,10 @@ +() => 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:7 + >-------< +0| () => 0 + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/class.iteration.block.scope b/data/fixtures/scopes/scala/class.iteration.block.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/scala/class.iteration.block.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/scala/name/name.iteration.class.scope b/data/fixtures/scopes/scala/name/name.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/namedFunction.iteration.class.scope b/data/fixtures/scopes/scala/namedFunction.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.assignment.scope b/data/fixtures/scopes/scala/statement/statement.assignment.scope new file mode 100644 index 0000000000..acdb2b1498 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.class.scope b/data/fixtures/scopes/scala/statement/statement.class.scope new file mode 100644 index 0000000000..a6008d311f --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.doWhile.scope b/data/fixtures/scopes/scala/statement/statement.doWhile.scope new file mode 100644 index 0000000000..74d5b94183 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.enum.scope b/data/fixtures/scopes/scala/statement/statement.enum.scope new file mode 100644 index 0000000000..88dd9cd028 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.enum.scope @@ -0,0 +1,10 @@ +enum Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.field.class.scope b/data/fixtures/scopes/scala/statement/statement.field.class.scope new file mode 100644 index 0000000000..08ded1513a --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.field.class.scope @@ -0,0 +1,33 @@ +class Foo { + val bar = 0 +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| val bar = 0 +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:15 + >-----------< +1| val bar = 0 + +[#2 Removal] = 1:0-2:0 + >--------------- +1| val bar = 0 +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| val bar = 0 + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.field.interface.scope b/data/fixtures/scopes/scala/statement/statement.field.interface.scope new file mode 100644 index 0000000000..62fee90198 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.field.interface.scope @@ -0,0 +1,33 @@ +trait Foo { + val bar: Int +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| trait 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/scala/statement/statement.foreach.scope b/data/fixtures/scopes/scala/statement/statement.foreach.scope new file mode 100644 index 0000000000..0d806bdc6c --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.foreach.scope @@ -0,0 +1,10 @@ +for (v <- values) {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:20 + >--------------------< +0| for (v <- values) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.function.scope b/data/fixtures/scopes/scala/statement/statement.function.scope new file mode 100644 index 0000000000..380503bc98 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.function.scope @@ -0,0 +1,10 @@ +def foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| def foo() {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.if.scope b/data/fixtures/scopes/scala/statement/statement.if.scope new file mode 100644 index 0000000000..14f2507621 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.interface.scope b/data/fixtures/scopes/scala/statement/statement.interface.scope new file mode 100644 index 0000000000..3f12024ea6 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.interface.scope @@ -0,0 +1,10 @@ +trait Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| trait Foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.iteration.class.scope b/data/fixtures/scopes/scala/statement/statement.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.method.scope b/data/fixtures/scopes/scala/statement/statement.method.scope new file mode 100644 index 0000000000..de1c4a1788 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.method.scope @@ -0,0 +1,33 @@ +class Foo { + def bar() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:16 + >------------< +1| def bar() {} + +[#2 Removal] = 1:0-2:0 + >---------------- +1| def bar() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| def bar() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.namespace.scope b/data/fixtures/scopes/scala/statement/statement.namespace.scope new file mode 100644 index 0000000000..881784f194 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.namespace.scope @@ -0,0 +1,10 @@ +package foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| package foo {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.return.scope b/data/fixtures/scopes/scala/statement/statement.return.scope new file mode 100644 index 0000000000..64b8712e49 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.return.scope @@ -0,0 +1,33 @@ +def foo() { + return 0 +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| def foo() { +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/scala/statement/statement.switch.scope b/data/fixtures/scopes/scala/statement/statement.switch.scope new file mode 100644 index 0000000000..054232ac52 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.switch.scope @@ -0,0 +1,10 @@ +foo match {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| foo match {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.try.scope b/data/fixtures/scopes/scala/statement/statement.try.scope new file mode 100644 index 0000000000..35fab05227 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.try.scope @@ -0,0 +1,13 @@ +try {} +catch {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:8 + >------ +0| try {} +1| catch {} + --------< + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/statement/statement.variable.scope b/data/fixtures/scopes/scala/statement/statement.variable.scope new file mode 100644 index 0000000000..4934548475 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.variable.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/scala/statement/statement.while.scope b/data/fixtures/scopes/scala/statement/statement.while.scope new file mode 100644 index 0000000000..5aaf57be8f --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/textFragment.comment.block.scope b/data/fixtures/scopes/scala/textFragment.comment.block.scope new file mode 100644 index 0000000000..af33f95d00 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/type/type.iteration.class.scope b/data/fixtures/scopes/scala/type/type.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.iteration.class.scope b/data/fixtures/scopes/scala/value/value.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.iteration.class.scope @@ -0,0 +1,13 @@ +class Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/data/fixtures/scopes/scala/value/value.return.lambda.scope b/data/fixtures/scopes/scala/value/value.return.lambda.scope new file mode 100644 index 0000000000..8033661ff4 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.return.lambda.scope @@ -0,0 +1,20 @@ +() => 0 +--- + +[Content] = 0:6-0:7 + >-< +0| () => 0 + +[Removal] = 0:5-0:7 + >--< +0| () => 0 + +[Leading delimiter] = 0:5-0:6 + >-< +0| () => 0 + +[Domain] = 0:0-0:7 + >-------< +0| () => 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/value/value.return.scope b/data/fixtures/scopes/scala/value/value.return.scope new file mode 100644 index 0000000000..b8d22b638f --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.return.scope @@ -0,0 +1,22 @@ +def foo() { + 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/packages/common/src/scopeSupportFacets/scala.ts b/packages/common/src/scopeSupportFacets/scala.ts index 2a1f55b676..6b76476fd0 100644 --- a/packages/common/src/scopeSupportFacets/scala.ts +++ b/packages/common/src/scopeSupportFacets/scala.ts @@ -6,9 +6,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const scalaScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, anonymousFunction: supported, - list: supported, - map: supported, - attribute: supported, "argument.actual.singleLine": supported, "argument.actual.multiLine": supported, @@ -113,7 +110,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "statement.variable": supported, "statement.assignment": supported, "statement.return": supported, - "statement.yield": supported, "statement.namespace": supported, "statement.misc": supported, "statement.iteration.document": supported, @@ -171,7 +167,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "value.field.class": supported, "value.field.enum": supported, "value.return": supported, - "value.yield": supported, "value.return.lambda": supported, "value.variable": supported, "value.variable.pattern": supported, @@ -179,8 +174,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "value.iteration.class": supported, "value.iteration.enum": supported, "value.iteration.document": supported, - "value.mapPair": supported, - "value.mapPair.iteration": supported, "value.typeAlias": supported, "type.argument.formal": supported, @@ -207,9 +200,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "type.iteration.interface": supported, "type.iteration.document": supported, - "key.mapPair": supported, - "key.mapPair.iteration": supported, - "interior.class": supported, "interior.interface": supported, "interior.enum": supported, @@ -297,10 +287,23 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "statement.static": notApplicable, "interior.static": notApplicable, + // Literal map and list + list: notApplicable, + map: notApplicable, + "key.mapPair": notApplicable, + "key.mapPair.iteration": notApplicable, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, + + // Yield statement + "statement.yield": notApplicable, + "value.yield": notApplicable, + // Miscellaneous pairDelimiter: notApplicable, regularExpression: notApplicable, environment: notApplicable, selector: notApplicable, unit: notApplicable, + attribute: notApplicable, }; diff --git a/queries/java.scm b/queries/java.scm index 1a898680dc..00013ce6b5 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -546,7 +546,7 @@ (lambda_expression body: (_) @value (#not-type? @value block) -) @_.domain +) @value.domain ;;!! Map foo; ;;! ^^^ ^^^ diff --git a/queries/scala.scm b/queries/scala.scm index 7077312509..5877648187 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -1,5 +1,20 @@ ;; https://github.com/tree-sitter/tree-sitter-scala/blob/master/src/grammar.json +[ + (class_definition) + (var_definition) + (assignment_expression) + (function_definition) + (instance_expression) + (call_expression) + (match_expression) + (return_expression) + (while_expression) + (do_while_expression) + (for_expression) + (try_expression) +] @statement + ( (compilation_unit) @class.iteration @statement.iteration @namedFunction.iteration (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) @@ -38,6 +53,24 @@ ) ] @class @name.domain +;;!! class Foo { } +;;! ^ +(template_body + "{" @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @class.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 +) +(_ + "{" @statement.iteration.start.endOf + "}" @statement.iteration.end.startOf +) + ;;!! foo() ;; does not count foo.size (field_expression), or foo size (postfix_expression) (call_expression @@ -50,8 +83,17 @@ (type_identifier) @functionCallee.end ) @functionCall @functionCallee.domain +;;!! () => {} (lambda_expression) @anonymousFunction +;;!! () => 0 +;;! ^ +(lambda_expression + "=>" + (_) @value + (#not-type? @value block) +) @value.domain + (function_definition name: (_) @name ) @namedFunction @name.domain @@ -123,6 +165,12 @@ return_type: (_) @type ) @_.domain +;;!! return 0 +;;! ^ +(return_expression + (_) @value +) @value.domain + ;;!! case 0 => "zero" ;;! ^^^^^^^^^^^^^^^^ ( From 6067404968f574ce44a5c0d4add74fd53fa077b0 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 11:51:40 +0100 Subject: [PATCH 03/13] Name and value --- .../scopes/scala/name/name.assignment.scope | 20 +++++ .../scopes/scala/name/name.class.scope | 24 ++++++ .../scopes/scala/name/name.enum.scope | 24 ++++++ .../scopes/scala/name/name.field.class.scope | 52 +++++++++++++ .../scopes/scala/name/name.field.enum.scope | 78 +++++++++++++++++++ .../scala/name/name.field.interface.scope | 48 ++++++++++++ .../scopes/scala/name/name.foreach.scope | 20 +++++ .../scopes/scala/name/name.function.scope | 17 ++++ .../scopes/scala/name/name.interface.scope | 24 ++++++ .../scala/name/name.iteration.enum.scope | 13 ++++ .../scopes/scala/name/name.method.scope | 45 +++++++++++ .../scopes/scala/name/name.namespace.scope | 24 ++++++ .../scala/name/name.variable.pattern.scope | 24 ++++++ .../scala/name/name.variable.pattern2.scope | 24 ++++++ .../scopes/scala/name/name.variable.scope | 24 ++++++ .../scopes/scala/name/name.variable2.scope | 24 ++++++ .../scala/statement/statement.variable2.scope | 10 +++ .../scopes/scala/type/type.variable.scope | 20 +++++ .../scopes/scala/type/type.variable2.scope | 20 +++++ .../scopes/scala/value/value.assignment.scope | 20 +++++ .../scala/value/value.field.class.scope | 42 ++++++++++ .../scopes/scala/value/value.foreach.scope | 20 +++++ .../scopes/scala/value/value.switch.scope | 20 +++++ .../scopes/scala/value/value.typeAlias.scope | 20 +++++ .../scopes/scala/value/value.variable.scope | 20 +++++ .../scopes/scala/value/value.variable2.scope | 20 +++++ .../common/src/scopeSupportFacets/scala.ts | 8 +- queries/scala.scm | 50 +++++++++++- 28 files changed, 749 insertions(+), 6 deletions(-) create mode 100644 data/fixtures/scopes/scala/name/name.assignment.scope create mode 100644 data/fixtures/scopes/scala/name/name.class.scope create mode 100644 data/fixtures/scopes/scala/name/name.enum.scope create mode 100644 data/fixtures/scopes/scala/name/name.field.class.scope create mode 100644 data/fixtures/scopes/scala/name/name.field.enum.scope create mode 100644 data/fixtures/scopes/scala/name/name.field.interface.scope create mode 100644 data/fixtures/scopes/scala/name/name.foreach.scope create mode 100644 data/fixtures/scopes/scala/name/name.function.scope create mode 100644 data/fixtures/scopes/scala/name/name.interface.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.enum.scope create mode 100644 data/fixtures/scopes/scala/name/name.method.scope create mode 100644 data/fixtures/scopes/scala/name/name.namespace.scope create mode 100644 data/fixtures/scopes/scala/name/name.variable.pattern.scope create mode 100644 data/fixtures/scopes/scala/name/name.variable.pattern2.scope create mode 100644 data/fixtures/scopes/scala/name/name.variable.scope create mode 100644 data/fixtures/scopes/scala/name/name.variable2.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.variable2.scope create mode 100644 data/fixtures/scopes/scala/type/type.variable.scope create mode 100644 data/fixtures/scopes/scala/type/type.variable2.scope create mode 100644 data/fixtures/scopes/scala/value/value.assignment.scope create mode 100644 data/fixtures/scopes/scala/value/value.field.class.scope create mode 100644 data/fixtures/scopes/scala/value/value.foreach.scope create mode 100644 data/fixtures/scopes/scala/value/value.switch.scope create mode 100644 data/fixtures/scopes/scala/value/value.typeAlias.scope create mode 100644 data/fixtures/scopes/scala/value/value.variable.scope create mode 100644 data/fixtures/scopes/scala/value/value.variable2.scope diff --git a/data/fixtures/scopes/scala/name/name.assignment.scope b/data/fixtures/scopes/scala/name/name.assignment.scope new file mode 100644 index 0000000000..ccbd90c654 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/name/name.class.scope b/data/fixtures/scopes/scala/name/name.class.scope new file mode 100644 index 0000000000..211086562c --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/name/name.enum.scope b/data/fixtures/scopes/scala/name/name.enum.scope new file mode 100644 index 0000000000..09d2849071 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.enum.scope @@ -0,0 +1,24 @@ +enum Foo {} +--- + +[Content] = 0:5-0:8 + >---< +0| enum Foo {} + +[Removal] = 0:5-0:9 + >----< +0| enum Foo {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| enum Foo {} + +[Trailing delimiter] = 0:8-0:9 + >-< +0| enum Foo {} + +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.field.class.scope b/data/fixtures/scopes/scala/name/name.field.class.scope new file mode 100644 index 0000000000..d92efe371a --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.field.class.scope @@ -0,0 +1,52 @@ +class Foo { . + val bar = 0 +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| class Foo { . + +[#1 Removal] = 0:6-0:10 + >----< +0| class Foo { . + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| class Foo { . + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo { . + +[#1 Domain] = 0:0-2:1 + >------------- +0| class Foo { . +1| val bar = 0 +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| val bar = 0 + +[#2 Removal] = 1:8-1:12 + >----< +1| val bar = 0 + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| val bar = 0 + +[#2 Trailing delimiter] = 1:11-1:12 + >-< +1| val bar = 0 + +[#2 Domain] = 1:4-1:15 + >-----------< +1| val bar = 0 + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.field.enum.scope b/data/fixtures/scopes/scala/name/name.field.enum.scope new file mode 100644 index 0000000000..1df71cd6f4 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.field.enum.scope @@ -0,0 +1,78 @@ +enum Foo { + case Bar + case Baz(x: Int) +} +--- + +[#1 Content] = 0:5-0:8 + >---< +0| enum Foo { + +[#1 Removal] = 0:5-0:9 + >----< +0| enum Foo { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| enum Foo { + +[#1 Trailing delimiter] = 0:8-0:9 + >-< +0| enum Foo { + +[#1 Domain] = 0:0-3:1 + >---------- +0| enum Foo { +1| case Bar +2| case Baz(x: Int) +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:9-1:12 + >---< +1| case Bar + +[#2 Removal] = 1:8-1:12 + >----< +1| case Bar + +[#2 Leading delimiter] = 1:8-1:9 + >-< +1| case Bar + +[#2 Domain] = 1:4-1:12 + >--------< +1| case Bar + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 2:9-2:12 + >---< +2| case Baz(x: Int) + +[#3 Leading delimiter] = 2:8-2:9 + >-< +2| case Baz(x: Int) + +[#3 Domain] = 2:4-2:20 + >----------------< +2| case Baz(x: Int) + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = 2:13-2:14 + >-< +2| case Baz(x: Int) + +[#4 Domain] = 2:13-2:19 + >------< +2| case Baz(x: Int) + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.field.interface.scope b/data/fixtures/scopes/scala/name/name.field.interface.scope new file mode 100644 index 0000000000..cc7fddf3dc --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.field.interface.scope @@ -0,0 +1,48 @@ +trait Foo { + val bar: Int +} +--- + +[#1 Content] = 0:6-0:9 + >---< +0| trait Foo { + +[#1 Removal] = 0:6-0:10 + >----< +0| trait Foo { + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| trait Foo { + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| trait Foo { + +[#1 Domain] = 0:0-2:1 + >----------- +0| trait 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/scala/name/name.foreach.scope b/data/fixtures/scopes/scala/name/name.foreach.scope new file mode 100644 index 0000000000..3aef3edf8f --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.foreach.scope @@ -0,0 +1,20 @@ +for (v <- values) {} +--- + +[Content] = 0:5-0:6 + >-< +0| for (v <- values) {} + +[Removal] = 0:5-0:7 + >--< +0| for (v <- values) {} + +[Trailing delimiter] = 0:6-0:7 + >-< +0| for (v <- values) {} + +[Domain] = 0:0-0:20 + >--------------------< +0| for (v <- values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.function.scope b/data/fixtures/scopes/scala/name/name.function.scope new file mode 100644 index 0000000000..1c43aa356f --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.function.scope @@ -0,0 +1,17 @@ +def foo() {} +--- + +[Content] = +[Removal] = 0:4-0:7 + >---< +0| def foo() {} + +[Leading delimiter] = 0:3-0:4 + >-< +0| def foo() {} + +[Domain] = 0:0-0:12 + >------------< +0| def foo() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.interface.scope b/data/fixtures/scopes/scala/name/name.interface.scope new file mode 100644 index 0000000000..572b1f4783 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.interface.scope @@ -0,0 +1,24 @@ +trait Foo {} +--- + +[Content] = 0:6-0:9 + >---< +0| trait Foo {} + +[Removal] = 0:6-0:10 + >----< +0| trait Foo {} + +[Leading delimiter] = 0:5-0:6 + >-< +0| trait Foo {} + +[Trailing delimiter] = 0:9-0:10 + >-< +0| trait Foo {} + +[Domain] = 0:0-0:12 + >------------< +0| trait Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.iteration.enum.scope b/data/fixtures/scopes/scala/name/name.iteration.enum.scope new file mode 100644 index 0000000000..9034c4ee11 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.iteration.enum.scope @@ -0,0 +1,13 @@ +enum Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| enum Foo { } + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| enum Foo { } diff --git a/data/fixtures/scopes/scala/name/name.method.scope b/data/fixtures/scopes/scala/name/name.method.scope new file mode 100644 index 0000000000..a57a1b9a33 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.method.scope @@ -0,0 +1,45 @@ +class Foo { + def 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| def bar() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:8-1:11 + >---< +1| def bar() {} + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| def bar() {} + +[#2 Domain] = 1:4-1:16 + >------------< +1| def bar() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.namespace.scope b/data/fixtures/scopes/scala/name/name.namespace.scope new file mode 100644 index 0000000000..fed70fac47 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.namespace.scope @@ -0,0 +1,24 @@ +package foo {} +--- + +[Content] = 0:8-0:11 + >---< +0| package foo {} + +[Removal] = 0:8-0:12 + >----< +0| package foo {} + +[Leading delimiter] = 0:7-0:8 + >-< +0| package foo {} + +[Trailing delimiter] = 0:11-0:12 + >-< +0| package foo {} + +[Domain] = 0:0-0:14 + >--------------< +0| package foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.variable.pattern.scope b/data/fixtures/scopes/scala/name/name.variable.pattern.scope new file mode 100644 index 0000000000..76bafffc72 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.variable.pattern.scope @@ -0,0 +1,24 @@ +var (a, b) = (0, 1) +--- + +[Content] = 0:4-0:10 + >------< +0| var (a, b) = (0, 1) + +[Removal] = 0:4-0:11 + >-------< +0| var (a, b) = (0, 1) + +[Leading delimiter] = 0:3-0:4 + >-< +0| var (a, b) = (0, 1) + +[Trailing delimiter] = 0:10-0:11 + >-< +0| var (a, b) = (0, 1) + +[Domain] = 0:0-0:19 + >-------------------< +0| var (a, b) = (0, 1) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.variable.pattern2.scope b/data/fixtures/scopes/scala/name/name.variable.pattern2.scope new file mode 100644 index 0000000000..9091d68054 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.variable.pattern2.scope @@ -0,0 +1,24 @@ +val (a, b) = (0, 1) +--- + +[Content] = 0:4-0:10 + >------< +0| val (a, b) = (0, 1) + +[Removal] = 0:4-0:11 + >-------< +0| val (a, b) = (0, 1) + +[Leading delimiter] = 0:3-0:4 + >-< +0| val (a, b) = (0, 1) + +[Trailing delimiter] = 0:10-0:11 + >-< +0| val (a, b) = (0, 1) + +[Domain] = 0:0-0:19 + >-------------------< +0| val (a, b) = (0, 1) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.variable.scope b/data/fixtures/scopes/scala/name/name.variable.scope new file mode 100644 index 0000000000..1cd9475d1d --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.variable.scope @@ -0,0 +1,24 @@ +var foo = 0 +--- + +[Content] = 0:4-0:7 + >---< +0| var foo = 0 + +[Removal] = 0:4-0:8 + >----< +0| var foo = 0 + +[Leading delimiter] = 0:3-0:4 + >-< +0| var foo = 0 + +[Trailing delimiter] = 0:7-0:8 + >-< +0| var foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| var foo = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.variable2.scope b/data/fixtures/scopes/scala/name/name.variable2.scope new file mode 100644 index 0000000000..608e22c538 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.variable2.scope b/data/fixtures/scopes/scala/statement/statement.variable2.scope new file mode 100644 index 0000000000..3e53923b5e --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/type/type.variable.scope b/data/fixtures/scopes/scala/type/type.variable.scope new file mode 100644 index 0000000000..28043523ca --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.variable.scope @@ -0,0 +1,20 @@ +var foo: Int = 0 +--- + +[Content] = 0:9-0:12 + >---< +0| var foo: Int = 0 + +[Removal] = 0:7-0:12 + >-----< +0| var foo: Int = 0 + +[Leading delimiter] = 0:7-0:9 + >--< +0| var foo: Int = 0 + +[Domain] = 0:0-0:16 + >----------------< +0| var foo: Int = 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.variable2.scope b/data/fixtures/scopes/scala/type/type.variable2.scope new file mode 100644 index 0000000000..ded7ac42ef --- /dev/null +++ b/data/fixtures/scopes/scala/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/data/fixtures/scopes/scala/value/value.assignment.scope b/data/fixtures/scopes/scala/value/value.assignment.scope new file mode 100644 index 0000000000..6e89de0927 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.field.class.scope b/data/fixtures/scopes/scala/value/value.field.class.scope new file mode 100644 index 0000000000..ac0682dd71 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.field.class.scope @@ -0,0 +1,42 @@ +class Foo { + var bar = 0 + val baz = 0 +} +--- + +[#1 Content] = 1:14-1:15 + >-< +1| var bar = 0 + +[#1 Removal] = 1:11-1:15 + >----< +1| var bar = 0 + +[#1 Leading delimiter] = 1:11-1:14 + >---< +1| var bar = 0 + +[#1 Domain] = 1:4-1:15 + >-----------< +1| var bar = 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/scala/value/value.foreach.scope b/data/fixtures/scopes/scala/value/value.foreach.scope new file mode 100644 index 0000000000..f199f50891 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.foreach.scope @@ -0,0 +1,20 @@ +for (v <- values) {} +--- + +[Content] = 0:10-0:16 + >------< +0| for (v <- values) {} + +[Removal] = 0:9-0:16 + >-------< +0| for (v <- values) {} + +[Leading delimiter] = 0:9-0:10 + >-< +0| for (v <- values) {} + +[Domain] = 0:0-0:20 + >--------------------< +0| for (v <- values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/value/value.switch.scope b/data/fixtures/scopes/scala/value/value.switch.scope new file mode 100644 index 0000000000..40711ca3ba --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.switch.scope @@ -0,0 +1,20 @@ +foo match {} +--- + +[Content] = 0:0-0:3 + >---< +0| foo match {} + +[Removal] = 0:0-0:4 + >----< +0| foo match {} + +[Trailing delimiter] = 0:3-0:4 + >-< +0| foo match {} + +[Domain] = 0:0-0:12 + >------------< +0| foo match {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/value/value.typeAlias.scope b/data/fixtures/scopes/scala/value/value.typeAlias.scope new file mode 100644 index 0000000000..a6264cfd05 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.typeAlias.scope @@ -0,0 +1,20 @@ +type Foo = Bar +--- + +[Content] = 0:11-0:14 + >---< +0| type Foo = Bar + +[Removal] = 0:8-0:14 + >------< +0| type Foo = Bar + +[Leading delimiter] = 0:8-0:11 + >---< +0| type Foo = Bar + +[Domain] = 0:0-0:14 + >--------------< +0| type Foo = Bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/value/value.variable.scope b/data/fixtures/scopes/scala/value/value.variable.scope new file mode 100644 index 0000000000..06dc0be9f8 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.variable2.scope b/data/fixtures/scopes/scala/value/value.variable2.scope new file mode 100644 index 0000000000..957dcc3e51 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.variable2.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/packages/common/src/scopeSupportFacets/scala.ts b/packages/common/src/scopeSupportFacets/scala.ts index 6b76476fd0..641367c58e 100644 --- a/packages/common/src/scopeSupportFacets/scala.ts +++ b/packages/common/src/scopeSupportFacets/scala.ts @@ -165,14 +165,11 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "value.foreach": supported, "value.switch": supported, "value.field.class": supported, - "value.field.enum": supported, "value.return": supported, "value.return.lambda": supported, "value.variable": supported, - "value.variable.pattern": supported, "value.iteration.block": supported, "value.iteration.class": supported, - "value.iteration.enum": supported, "value.iteration.document": supported, "value.typeAlias": supported, @@ -299,6 +296,10 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "statement.yield": notApplicable, "value.yield": notApplicable, + // Enum value + "value.field.enum": notApplicable, + "value.iteration.enum": notApplicable, + // Miscellaneous pairDelimiter: notApplicable, regularExpression: notApplicable, @@ -306,4 +307,5 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { selector: notApplicable, unit: notApplicable, attribute: notApplicable, + "value.variable.pattern": notApplicable, }; diff --git a/queries/scala.scm b/queries/scala.scm index 5877648187..0d5a810faa 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -1,8 +1,13 @@ ;; https://github.com/tree-sitter/tree-sitter-scala/blob/master/src/grammar.json [ + (package_clause) (class_definition) + (enum_definition) + (trait_definition) (var_definition) + (val_definition) + (val_declaration) (assignment_expression) (function_definition) (instance_expression) @@ -94,19 +99,58 @@ (#not-type? @value block) ) @value.domain +;;!! def foo() {} (function_definition name: (_) @name ) @namedFunction @name.domain +;;!! foo match {} +;;! ^^^ (match_expression value: (_) @value -) @_.domain +) @value.domain -(_ - name: (_) @name +;;!! for (v <- values) {} +(for_expression + (enumerators + (enumerator + (_) @name + "<-" + (_) @value + ) + ) ) @_.domain + +( + (_ + name: (_) @name + ) @name.domain + (#not-type? @name.domain simple_enum_case full_enum_case) +) + (_ pattern: (_) @name +) @name.domain + +(enum_case_definitions + [ + ;;!! case Bar + (simple_enum_case + name: (_) @name + ) + ;;!! case Baz(x: Int) + (full_enum_case + name: (_) @name + ) + ] +) @name.domain + +;;!! foo = 0 +;;! ^^^ +;;! ^ +(assignment_expression + left: (_) @name @value.leading.endOf + right: (_) @value ) @_.domain (_ From 3199d2ef8472d96f6e02ebee7a782854e2b0eb9a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 12:45:34 +0100 Subject: [PATCH 04/13] type --- .../scala/name/name.argument.catch.scope | 47 ++++++++++++++ .../scopes/scala/name/name.foreach2.scope | 13 ++++ .../scala/name/name.iteration.interface.scope | 13 ++++ .../scala/statement/statement.try.scope | 6 +- .../scopes/scala/type/type.alias.scope | 10 +++ .../scala/type/type.argument.catch.scope | 23 +++++++ .../scopes/scala/type/type.class.scope | 10 +++ .../scopes/scala/type/type.enum.scope | 10 +++ .../scopes/scala/type/type.field.class.scope | 55 ++++++++++++++++ .../scala/type/type.field.interface.scope | 55 ++++++++++++++++ .../scopes/scala/type/type.foreach.scope | 20 ++++++ .../scopes/scala/type/type.interface.scope | 10 +++ .../scala/type/type.iteration.interface.scope | 13 ++++ .../scopes/scala/type/type.return.scope | 20 ++++++ .../type/type.typeArgument.iteration.scope | 13 ++++ .../scopes/scala/type/type.typeArgument.scope | 52 +++++++++++++++ .../common/src/scopeSupportFacets/scala.ts | 2 +- queries/scala.scm | 63 ++++++++++++++++++- 18 files changed, 429 insertions(+), 6 deletions(-) create mode 100644 data/fixtures/scopes/scala/name/name.argument.catch.scope create mode 100644 data/fixtures/scopes/scala/name/name.foreach2.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.interface.scope create mode 100644 data/fixtures/scopes/scala/type/type.alias.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.catch.scope create mode 100644 data/fixtures/scopes/scala/type/type.class.scope create mode 100644 data/fixtures/scopes/scala/type/type.enum.scope create mode 100644 data/fixtures/scopes/scala/type/type.field.class.scope create mode 100644 data/fixtures/scopes/scala/type/type.field.interface.scope create mode 100644 data/fixtures/scopes/scala/type/type.foreach.scope create mode 100644 data/fixtures/scopes/scala/type/type.interface.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.interface.scope create mode 100644 data/fixtures/scopes/scala/type/type.return.scope create mode 100644 data/fixtures/scopes/scala/type/type.typeArgument.iteration.scope create mode 100644 data/fixtures/scopes/scala/type/type.typeArgument.scope diff --git a/data/fixtures/scopes/scala/name/name.argument.catch.scope b/data/fixtures/scopes/scala/name/name.argument.catch.scope new file mode 100644 index 0000000000..649ac4f99d --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.catch.scope @@ -0,0 +1,47 @@ +try {} +catch { + case e: Exception => 0 + case e => 0 +} +--- + +[#1 Content] = 2:9-2:10 + >-< +2| case e: Exception => 0 + +[#1 Removal] = 2:8-2:10 + >--< +2| case e: Exception => 0 + +[#1 Leading delimiter] = 2:8-2:9 + >-< +2| case e: Exception => 0 + +[#1 Domain] = 2:4-2:26 + >----------------------< +2| case e: Exception => 0 + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 3:9-3:10 + >-< +3| case e => 0 + +[#2 Removal] = 3:9-3:11 + >--< +3| case e => 0 + +[#2 Leading delimiter] = 3:8-3:9 + >-< +3| case e => 0 + +[#2 Trailing delimiter] = 3:10-3:11 + >-< +3| case e => 0 + +[#2 Domain] = 3:4-3:15 + >-----------< +3| case e => 0 + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.foreach2.scope b/data/fixtures/scopes/scala/name/name.foreach2.scope new file mode 100644 index 0000000000..c55ee73899 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.foreach2.scope @@ -0,0 +1,13 @@ +for (v: Int <- values) {} +--- + +[Content] = +[Removal] = 0:5-0:6 + >-< +0| for (v: Int <- values) {} + +[Domain] = 0:0-0:25 + >-------------------------< +0| for (v: Int <- values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.iteration.interface.scope b/data/fixtures/scopes/scala/name/name.iteration.interface.scope new file mode 100644 index 0000000000..4c8fb724a6 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.iteration.interface.scope @@ -0,0 +1,13 @@ +trait Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| trait Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| trait Foo { } diff --git a/data/fixtures/scopes/scala/statement/statement.try.scope b/data/fixtures/scopes/scala/statement/statement.try.scope index 35fab05227..420e3c3139 100644 --- a/data/fixtures/scopes/scala/statement/statement.try.scope +++ b/data/fixtures/scopes/scala/statement/statement.try.scope @@ -1,13 +1,15 @@ try {} catch {} +finally {} --- [Content] = [Removal] = -[Domain] = 0:0-1:8 +[Domain] = 0:0-2:10 >------ 0| try {} 1| catch {} - --------< +2| finally {} + ----------< [Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/type/type.alias.scope b/data/fixtures/scopes/scala/type/type.alias.scope new file mode 100644 index 0000000000..708ceef5d0 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.alias.scope @@ -0,0 +1,10 @@ +type Foo = Bar +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| type Foo = Bar + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.argument.catch.scope b/data/fixtures/scopes/scala/type/type.argument.catch.scope new file mode 100644 index 0000000000..639c0ea18a --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.catch.scope @@ -0,0 +1,23 @@ +try {} +catch { + case e: Exception => 0 +} +--- + +[Content] = 2:12-2:21 + >---------< +2| case e: Exception => 0 + +[Removal] = 2:10-2:21 + >-----------< +2| case e: Exception => 0 + +[Leading delimiter] = 2:10-2:12 + >--< +2| case e: Exception => 0 + +[Domain] = 2:4-2:26 + >----------------------< +2| case e: Exception => 0 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.class.scope b/data/fixtures/scopes/scala/type/type.class.scope new file mode 100644 index 0000000000..79c274ccc6 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/type/type.enum.scope b/data/fixtures/scopes/scala/type/type.enum.scope new file mode 100644 index 0000000000..70c26e7b58 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.enum.scope @@ -0,0 +1,10 @@ +enum Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.field.class.scope b/data/fixtures/scopes/scala/type/type.field.class.scope new file mode 100644 index 0000000000..3dd8780a46 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.field.class.scope @@ -0,0 +1,55 @@ +class Foo { + val bar: Int = 0 + val baz: Int +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| class Foo { +1| val bar: Int = 0 +2| val baz: Int +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:13-1:16 + >---< +1| val bar: Int = 0 + +[#2 Removal] = 1:11-1:16 + >-----< +1| val bar: Int = 0 + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| val bar: Int = 0 + +[#2 Domain] = 1:4-1:20 + >----------------< +1| val bar: Int = 0 + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:13-2:16 + >---< +2| val baz: Int + +[#3 Removal] = 2:11-2:16 + >-----< +2| val baz: Int + +[#3 Leading delimiter] = 2:11-2:13 + >--< +2| val baz: Int + +[#3 Domain] = 2:4-2:16 + >------------< +2| val baz: Int + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.field.interface.scope b/data/fixtures/scopes/scala/type/type.field.interface.scope new file mode 100644 index 0000000000..dec75a1ecf --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.field.interface.scope @@ -0,0 +1,55 @@ +trait Foo { + val bar: Int + var baz: Int +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >----------- +0| trait Foo { +1| val bar: Int +2| var baz: Int +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 + +[#3 Removal] = 2:11-2:16 + >-----< +2| var baz: Int + +[#3 Leading delimiter] = 2:11-2:13 + >--< +2| var baz: Int + +[#3 Domain] = 2:4-2:16 + >------------< +2| var baz: Int + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.foreach.scope b/data/fixtures/scopes/scala/type/type.foreach.scope new file mode 100644 index 0000000000..95ab1fab84 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.foreach.scope @@ -0,0 +1,20 @@ +for (v: Int <- values) {} +--- + +[Content] = 0:8-0:11 + >---< +0| for (v: Int <- values) {} + +[Removal] = 0:6-0:11 + >-----< +0| for (v: Int <- values) {} + +[Leading delimiter] = 0:6-0:8 + >--< +0| for (v: Int <- values) {} + +[Domain] = 0:0-0:25 + >-------------------------< +0| for (v: Int <- values) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.interface.scope b/data/fixtures/scopes/scala/type/type.interface.scope new file mode 100644 index 0000000000..2489275c89 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.interface.scope @@ -0,0 +1,10 @@ +trait Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| trait Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.iteration.interface.scope b/data/fixtures/scopes/scala/type/type.iteration.interface.scope new file mode 100644 index 0000000000..4c8fb724a6 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.iteration.interface.scope @@ -0,0 +1,13 @@ +trait Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| trait Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| trait Foo { } diff --git a/data/fixtures/scopes/scala/type/type.return.scope b/data/fixtures/scopes/scala/type/type.return.scope new file mode 100644 index 0000000000..d3a056679c --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.return.scope @@ -0,0 +1,20 @@ +def foo(): Int {} +--- + +[Content] = 0:11-0:14 + >---< +0| def foo(): Int {} + +[Removal] = 0:9-0:14 + >-----< +0| def foo(): Int {} + +[Leading delimiter] = 0:9-0:11 + >--< +0| def foo(): Int {} + +[Domain] = 0:0-0:17 + >-----------------< +0| def foo(): Int {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.typeArgument.iteration.scope b/data/fixtures/scopes/scala/type/type.typeArgument.iteration.scope new file mode 100644 index 0000000000..7c646052ad --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.typeArgument.iteration.scope @@ -0,0 +1,13 @@ +var foo: Bar[Int, Int] +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:22 + >----------------------< +0| var foo: Bar[Int, Int] + + +[#2 Content] = +[#2 Domain] = 0:13-0:21 + >--------< +0| var foo: Bar[Int, Int] diff --git a/data/fixtures/scopes/scala/type/type.typeArgument.scope b/data/fixtures/scopes/scala/type/type.typeArgument.scope new file mode 100644 index 0000000000..5489193718 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.typeArgument.scope @@ -0,0 +1,52 @@ +var foo: Bar[Int, Int] +--- + +[#1 Content] = 0:9-0:22 + >-------------< +0| var foo: Bar[Int, Int] + +[#1 Removal] = 0:7-0:22 + >---------------< +0| var foo: Bar[Int, Int] + +[#1 Leading delimiter] = 0:7-0:9 + >--< +0| var foo: Bar[Int, Int] + +[#1 Domain] = 0:0-0:22 + >----------------------< +0| var foo: Bar[Int, Int] + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| var foo: Bar[Int, Int] + +[#2 Removal] = 0:13-0:18 + >-----< +0| var foo: Bar[Int, Int] + +[#2 Trailing delimiter] = 0:16-0:18 + >--< +0| var foo: Bar[Int, Int] + +[#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:18-0:21 + >---< +0| var foo: Bar[Int, Int] + +[#3 Removal] = 0:16-0:21 + >-----< +0| var foo: Bar[Int, Int] + +[#3 Leading delimiter] = 0:16-0:18 + >--< +0| var foo: Bar[Int, Int] + +[#3 Insertion delimiter] = ", " diff --git a/packages/common/src/scopeSupportFacets/scala.ts b/packages/common/src/scopeSupportFacets/scala.ts index 641367c58e..cc7b6ac7dd 100644 --- a/packages/common/src/scopeSupportFacets/scala.ts +++ b/packages/common/src/scopeSupportFacets/scala.ts @@ -187,7 +187,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "type.variable": supported, "type.typeArgument": supported, "type.typeArgument.iteration": supported, - "type.cast": supported, "type.class": supported, "type.enum": supported, "type.interface": supported, @@ -308,4 +307,5 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { unit: notApplicable, attribute: notApplicable, "value.variable.pattern": notApplicable, + "type.cast": notApplicable, }; diff --git a/queries/scala.scm b/queries/scala.scm index 0d5a810faa..f6a4e59b41 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -20,6 +20,12 @@ (try_expression) ] @statement +[ + (class_definition) + (enum_definition) + (trait_definition) +] @type + ( (compilation_unit) @class.iteration @statement.iteration @namedFunction.iteration (#document-range! @class.iteration @statement.iteration @namedFunction.iteration) @@ -114,7 +120,13 @@ (for_expression (enumerators (enumerator - (_) @name + [ + (identifier) @name + (typed_pattern + pattern: (_) @name @type.leading.endOf + type: (_) @type + ) + ] "<-" (_) @value ) @@ -128,7 +140,15 @@ (#not-type? @name.domain simple_enum_case full_enum_case) ) -(_ +;;!! var foo = 0 +;;! ^^^ +(var_definition + pattern: (_) @name +) @name.domain + +;;!! val foo = 0 +;;! ^^^ +(val_definition pattern: (_) @name ) @name.domain @@ -189,6 +209,23 @@ ;;! ^^^^^^^^^^^^^^^^^^^^^^^^ (type_definition) @type +;;!! case e: Exception => 0 +;;!! case e => 0 +(catch_clause + (case_block + (case_clause + pattern: [ + (identifier) @name + (typed_pattern + pattern: (identifier) @name @type.leading.endOf + type: (_) @type + ) + ] + ) @_.domain + ) + (#trim-end! @_.domain) +) + ;;!! def str(bar: String) ;;! ^^^^^^ ;;!! val foo: String = "foo" @@ -199,7 +236,7 @@ . type: (_) @type ) @_.domain - (#not-type? @_.domain type_definition) + (#not-type? @_.domain type_definition typed_pattern) ) ;;!! def str(): String = "bar" @@ -222,6 +259,26 @@ (#trim-end! @branch) ) +;;!! var foo: Bar[Int, Int] +;;! ^^^ ^^^ +( + (type_arguments + (_)? @_.leading.endOf + . + (_) @type + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @type @_dummy ", " ",\n") +) + +;;!! var foo: Bar[Int, Int] +;;! ^^^^^^^^ +(type_arguments + "[" @type.iteration.start.endOf + "]" @type.iteration.end.startOf +) + ;;!! class Foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^ ^^^^^^^^ ( From 3574ba83183f08ca98b677898e4b10982e002305 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 13:01:05 +0100 Subject: [PATCH 05/13] block iteration --- .../scala/name/name.iteration.block.scope | 27 +++++++++++++++++ .../scala/name/name.iteration.block2.scope | 13 ++++++++ .../scala/name/name.iteration.block3.scope | 30 +++++++++++++++++++ .../scala/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 ++++++++ .../statement.iteration.interface.scope | 13 ++++++++ .../scala/type/type.iteration.block.scope | 27 +++++++++++++++++ .../scala/type/type.iteration.block2.scope | 13 ++++++++ .../scala/type/type.iteration.block3.scope | 30 +++++++++++++++++++ .../scala/type/type.iteration.block4.scope | 13 ++++++++ .../scala/value/value.iteration.block.scope | 27 +++++++++++++++++ .../scala/value/value.iteration.block2.scope | 13 ++++++++ .../scala/value/value.iteration.block3.scope | 30 +++++++++++++++++++ .../scala/value/value.iteration.block4.scope | 13 ++++++++ .../common/src/scopeSupportFacets/scala.ts | 2 +- 18 files changed, 346 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/scala/name/name.iteration.block.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.block2.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.block3.scope create mode 100644 data/fixtures/scopes/scala/name/name.iteration.block4.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.block.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.block2.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.block3.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.block4.scope create mode 100644 data/fixtures/scopes/scala/statement/statement.iteration.interface.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.block.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.block2.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.block3.scope create mode 100644 data/fixtures/scopes/scala/type/type.iteration.block4.scope create mode 100644 data/fixtures/scopes/scala/value/value.iteration.block.scope create mode 100644 data/fixtures/scopes/scala/value/value.iteration.block2.scope create mode 100644 data/fixtures/scopes/scala/value/value.iteration.block3.scope create mode 100644 data/fixtures/scopes/scala/value/value.iteration.block4.scope diff --git a/data/fixtures/scopes/scala/name/name.iteration.block.scope b/data/fixtures/scopes/scala/name/name.iteration.block.scope new file mode 100644 index 0000000000..262466235c --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + def bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| def bar() { } diff --git a/data/fixtures/scopes/scala/name/name.iteration.block2.scope b/data/fixtures/scopes/scala/name/name.iteration.block2.scope new file mode 100644 index 0000000000..05cc02fc66 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.iteration.block2.scope @@ -0,0 +1,13 @@ +def foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| def foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| def foo() { } diff --git a/data/fixtures/scopes/scala/name/name.iteration.block3.scope b/data/fixtures/scopes/scala/name/name.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/name/name.iteration.block4.scope b/data/fixtures/scopes/scala/name/name.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.iteration.block.scope b/data/fixtures/scopes/scala/statement/statement.iteration.block.scope new file mode 100644 index 0000000000..262466235c --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + def bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| def bar() { } diff --git a/data/fixtures/scopes/scala/statement/statement.iteration.block2.scope b/data/fixtures/scopes/scala/statement/statement.iteration.block2.scope new file mode 100644 index 0000000000..05cc02fc66 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.iteration.block2.scope @@ -0,0 +1,13 @@ +def foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| def foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| def foo() { } diff --git a/data/fixtures/scopes/scala/statement/statement.iteration.block3.scope b/data/fixtures/scopes/scala/statement/statement.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.iteration.block4.scope b/data/fixtures/scopes/scala/statement/statement.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/statement/statement.iteration.interface.scope b/data/fixtures/scopes/scala/statement/statement.iteration.interface.scope new file mode 100644 index 0000000000..4c8fb724a6 --- /dev/null +++ b/data/fixtures/scopes/scala/statement/statement.iteration.interface.scope @@ -0,0 +1,13 @@ +trait Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| trait Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| trait Foo { } diff --git a/data/fixtures/scopes/scala/type/type.iteration.block.scope b/data/fixtures/scopes/scala/type/type.iteration.block.scope new file mode 100644 index 0000000000..262466235c --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + def bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| def bar() { } diff --git a/data/fixtures/scopes/scala/type/type.iteration.block2.scope b/data/fixtures/scopes/scala/type/type.iteration.block2.scope new file mode 100644 index 0000000000..05cc02fc66 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.iteration.block2.scope @@ -0,0 +1,13 @@ +def foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| def foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| def foo() { } diff --git a/data/fixtures/scopes/scala/type/type.iteration.block3.scope b/data/fixtures/scopes/scala/type/type.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/type/type.iteration.block4.scope b/data/fixtures/scopes/scala/type/type.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.iteration.block.scope b/data/fixtures/scopes/scala/value/value.iteration.block.scope new file mode 100644 index 0000000000..262466235c --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.iteration.block.scope @@ -0,0 +1,27 @@ +class Foo { + def bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| def bar() { } diff --git a/data/fixtures/scopes/scala/value/value.iteration.block2.scope b/data/fixtures/scopes/scala/value/value.iteration.block2.scope new file mode 100644 index 0000000000..05cc02fc66 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.iteration.block2.scope @@ -0,0 +1,13 @@ +def foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| def foo() { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| def foo() { } diff --git a/data/fixtures/scopes/scala/value/value.iteration.block3.scope b/data/fixtures/scopes/scala/value/value.iteration.block3.scope new file mode 100644 index 0000000000..a9cb72326e --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.iteration.block4.scope b/data/fixtures/scopes/scala/value/value.iteration.block4.scope new file mode 100644 index 0000000000..ba0f1535af --- /dev/null +++ b/data/fixtures/scopes/scala/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/packages/common/src/scopeSupportFacets/scala.ts b/packages/common/src/scopeSupportFacets/scala.ts index cc7b6ac7dd..7ca8922693 100644 --- a/packages/common/src/scopeSupportFacets/scala.ts +++ b/packages/common/src/scopeSupportFacets/scala.ts @@ -111,7 +111,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "statement.assignment": supported, "statement.return": supported, "statement.namespace": supported, - "statement.misc": supported, "statement.iteration.document": supported, "statement.iteration.class": supported, "statement.iteration.interface": supported, @@ -308,4 +307,5 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { attribute: notApplicable, "value.variable.pattern": notApplicable, "type.cast": notApplicable, + "statement.misc": notApplicable, }; From cbb8c9213ff6c030368dd60f0a44a68bf4d3e48a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 13:52:26 +0100 Subject: [PATCH 06/13] condition --- .../interior/changeInsideElement2.yml} | 0 ...rgument.actual.constructor.iteration.scope | 10 +++ ...rgument.actual.constructor.multiLine.scope | 44 ++++++++++++ ...gument.actual.constructor.singleLine.scope | 33 +++++++++ .../argument.actual.method.iteration.scope | 10 +++ .../argument.actual.method.multiLine.scope | 44 ++++++++++++ .../argument.actual.method.singleLine.scope | 33 +++++++++ .../argument/argument.actual.multiLine.scope | 64 ++++++++--------- .../scala/argument/argument.catch.scope | 3 + ...rgument.formal.constructor.iteration.scope | 10 +++ ...rgument.formal.constructor.multiLine.scope | 44 ++++++++++++ ...gument.formal.constructor.singleLine.scope | 33 +++++++++ .../argument/argument.formal.iteration.scope | 10 +-- .../argument/argument.formal.iteration2.scope | 14 ++-- .../argument.formal.lambda.iteration.scope | 3 + .../argument.formal.lambda.multiLine.scope | 6 ++ .../argument.formal.lambda.singleLine.scope | 3 + .../argument.formal.method.iteration.scope | 10 +++ .../argument.formal.method.multiLine.scope | 46 +++++++++++++ .../argument.formal.method.singleLine.scope | 33 +++++++++ .../argument/argument.formal.multiLine.scope | 66 +++++++++--------- .../argument/argument.formal.multiLine2.scope | 68 +++++++++---------- .../argument/argument.formal.singleLine.scope | 14 ++-- .../argument.formal.singleLine2.scope | 38 +++++------ .../scala/condition/condition.doWhile.scope | 13 ++++ .../scopes/scala/condition/condition.if.scope | 30 ++++++++ .../condition.switchCase.iteration.scope | 10 +++ .../condition/condition.switchCase.scope | 50 ++++++++++++++ .../scala/condition/condition.while.scope | 13 ++++ queries/scala.scm | 55 ++++++++++++--- 30 files changed, 663 insertions(+), 147 deletions(-) rename data/fixtures/recorded/{languages/javascript/changeInsideElement.yml => modifiers/interior/changeInsideElement2.yml} (100%) create mode 100644 data/fixtures/scopes/scala/argument/argument.actual.constructor.iteration.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.actual.method.iteration.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.catch.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope create mode 100644 data/fixtures/scopes/scala/condition/condition.doWhile.scope create mode 100644 data/fixtures/scopes/scala/condition/condition.if.scope create mode 100644 data/fixtures/scopes/scala/condition/condition.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/scala/condition/condition.switchCase.scope create mode 100644 data/fixtures/scopes/scala/condition/condition.while.scope diff --git a/data/fixtures/recorded/languages/javascript/changeInsideElement.yml b/data/fixtures/recorded/modifiers/interior/changeInsideElement2.yml similarity index 100% rename from data/fixtures/recorded/languages/javascript/changeInsideElement.yml rename to data/fixtures/recorded/modifiers/interior/changeInsideElement2.yml diff --git a/data/fixtures/scopes/scala/argument/argument.actual.constructor.iteration.scope b/data/fixtures/scopes/scala/argument/argument.actual.constructor.iteration.scope new file mode 100644 index 0000000000..9f69e719b1 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.actual.constructor.iteration.scope @@ -0,0 +1,10 @@ +new Foo(aaa, bbb) +--- + +[Content] = 0:8-0:16 + >--------< +0| new Foo(aaa, bbb) + +[Domain] = 0:0-0:17 + >-----------------< +0| new Foo(aaa, bbb) diff --git a/data/fixtures/scopes/scala/argument/argument.actual.constructor.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..e04241925c --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.actual.constructor.multiLine.scope @@ -0,0 +1,44 @@ +new Foo( + aaa, + bbb, +) +--- + +[#1 Content] = +[#1 Domain] = 1:2-1:5 + >---< +1| aaa, + +[#1 Removal] = 1:2-2:2 + >---- +1| aaa, +2| bbb, + --< + +[#1 Trailing delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb, + --< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:2-2:5 + >---< +2| bbb, + +[#2 Removal] = 1:5-2:5 + >- +1| aaa, +2| bbb, + -----< + +[#2 Leading delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb, + --< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.actual.constructor.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..aa86bb983f --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.actual.constructor.singleLine.scope @@ -0,0 +1,33 @@ +new Foo(aaa, bbb) +--- + +[#1 Content] = +[#1 Domain] = 0:8-0:11 + >---< +0| new Foo(aaa, bbb) + +[#1 Removal] = 0:8-0:13 + >-----< +0| new Foo(aaa, bbb) + +[#1 Trailing delimiter] = 0:11-0:13 + >--< +0| new Foo(aaa, bbb) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| new Foo(aaa, bbb) + +[#2 Removal] = 0:11-0:16 + >-----< +0| new Foo(aaa, bbb) + +[#2 Leading delimiter] = 0:11-0:13 + >--< +0| new Foo(aaa, bbb) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argument/argument.actual.method.iteration.scope b/data/fixtures/scopes/scala/argument/argument.actual.method.iteration.scope new file mode 100644 index 0000000000..8b3899b4a1 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/argument/argument.actual.method.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.actual.method.multiLine.scope new file mode 100644 index 0000000000..0a20ae1bad --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.actual.method.multiLine.scope @@ -0,0 +1,44 @@ +foo.bar( + aaa, + bbb, +) +--- + +[#1 Content] = +[#1 Domain] = 1:2-1:5 + >---< +1| aaa, + +[#1 Removal] = 1:2-2:2 + >---- +1| aaa, +2| bbb, + --< + +[#1 Trailing delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb, + --< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:2-2:5 + >---< +2| bbb, + +[#2 Removal] = 1:5-2:5 + >- +1| aaa, +2| bbb, + -----< + +[#2 Leading delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb, + --< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.actual.method.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.actual.method.singleLine.scope new file mode 100644 index 0000000000..d22bd33706 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/argument/argument.actual.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.actual.multiLine.scope index 5ad321caa7..405bfd15fc 100644 --- a/data/fixtures/scopes/scala/argument/argument.actual.multiLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.actual.multiLine.scope @@ -1,44 +1,44 @@ foo( - aaa, - bbb + aaa, + bbb, ) --- [#1 Content] = -[#1 Domain] = 1:4-1:7 - >---< -1| aaa, - -[#1 Removal] = 1:4-2:4 - >---- -1| aaa, -2| bbb - ----< - -[#1 Trailing delimiter] = 1:7-2:4 - >- -1| aaa, -2| bbb - ----< +[#1 Domain] = 1:2-1:5 + >---< +1| aaa, + +[#1 Removal] = 1:2-2:2 + >---- +1| aaa, +2| bbb, + --< + +[#1 Trailing delimiter] = 1:5-2:2 + >- +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 Domain] = 2:2-2:5 + >---< +2| bbb, + +[#2 Removal] = 1:5-2:5 + >- +1| aaa, +2| bbb, + -----< + +[#2 Leading delimiter] = 1:5-2:2 + >- +1| aaa, +2| bbb, + --< [#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.catch.scope b/data/fixtures/scopes/scala/argument/argument.catch.scope new file mode 100644 index 0000000000..e09a6519c7 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.catch.scope @@ -0,0 +1,3 @@ +try {} catch { case e: Exception => } +--- + diff --git a/data/fixtures/scopes/scala/argument/argument.formal.constructor.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..a142b87f7b --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.constructor.iteration.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:29 + >-----------------------------< +0| class Foo(aaa: Int, bbb: Int) diff --git a/data/fixtures/scopes/scala/argument/argument.formal.constructor.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..433e293811 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.constructor.multiLine.scope @@ -0,0 +1,44 @@ +class Foo( + aaa: Int, + bbb: Int, +) +--- + +[#1 Content] = +[#1 Domain] = 1:2-1:10 + >--------< +1| aaa: Int, + +[#1 Removal] = 1:2-2:2 + >--------- +1| aaa: Int, +2| bbb: Int, + --< + +[#1 Trailing delimiter] = 1:10-2:2 + >- +1| aaa: Int, +2| bbb: Int, + --< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 2:2-2:10 + >--------< +2| bbb: Int, + +[#2 Removal] = 1:10-2:10 + >- +1| aaa: Int, +2| bbb: Int, + ----------< + +[#2 Leading delimiter] = 1:10-2:2 + >- +1| aaa: Int, +2| bbb: Int, + --< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.formal.constructor.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..ede9eaa8e6 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.constructor.singleLine.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/scala/argument/argument.formal.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope index 76c933d3d5..ea4830d63d 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope @@ -1,10 +1,10 @@ -def foo(aaa: Int, bbb: Int) = {} +def foo(aaa: Int, bbb: Int): Int = aaa + bbb --- [Content] = 0:8-0:26 >------------------< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb -[Domain] = 0:0-0:32 - >--------------------------------< -0| def foo(aaa: Int, bbb: Int) = {} +[Domain] = 0:0-0:44 + >--------------------------------------------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb diff --git a/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope b/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope index 3b4393dee0..ea4830d63d 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope @@ -1,10 +1,10 @@ -class Foo(aaa: Int, bbb: Int) {} +def foo(aaa: Int, bbb: Int): Int = aaa + bbb --- -[Content] = 0:10-0:28 - >------------------< -0| class Foo(aaa: Int, bbb: Int) {} +[Content] = 0:8-0:26 + >------------------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb -[Domain] = 0:0-0:32 - >--------------------------------< -0| class Foo(aaa: Int, bbb: Int) {} +[Domain] = 0:0-0:44 + >--------------------------------------------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb diff --git a/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..19c0afdedf --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope @@ -0,0 +1,3 @@ +val f = (aaa: Int, bbb: Int) => aaa + bbb +--- + diff --git a/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..6f073ca4a7 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope @@ -0,0 +1,6 @@ +val f = ( + aaa: Int, + bbb: Int, +) => aaa + bbb +--- + diff --git a/data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..19c0afdedf --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope @@ -0,0 +1,3 @@ +val f = (aaa: Int, bbb: Int) => aaa + bbb +--- + diff --git a/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope new file mode 100644 index 0000000000..32909a73e8 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope @@ -0,0 +1,10 @@ +class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +--- + +[Content] = 0:20-0:38 + >------------------< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[Domain] = 0:12-0:56 + >--------------------------------------------< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } diff --git a/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope new file mode 100644 index 0000000000..c61778798c --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope @@ -0,0 +1,46 @@ +class Foo { + def bar( + aaa: Int, + bbb: Int, + ): Int = aaa + bbb +} +--- + +[#1 Content] = +[#1 Domain] = 2:4-2:12 + >--------< +2| aaa: Int, + +[#1 Removal] = 2:4-3:4 + >--------- +2| aaa: Int, +3| bbb: Int, + ----< + +[#1 Trailing delimiter] = 2:12-3:4 + >- +2| aaa: Int, +3| bbb: Int, + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:4-3:12 + >--------< +3| bbb: Int, + +[#2 Removal] = 2:12-3:12 + >- +2| aaa: Int, +3| bbb: Int, + ------------< + +[#2 Leading delimiter] = 2:12-3:4 + >- +2| aaa: Int, +3| bbb: Int, + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope new file mode 100644 index 0000000000..6328f8fbc1 --- /dev/null +++ b/data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope @@ -0,0 +1,33 @@ +class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +--- + +[#1 Content] = +[#1 Domain] = 0:20-0:28 + >--------< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[#1 Removal] = 0:20-0:30 + >----------< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[#1 Trailing delimiter] = 0:28-0:30 + >--< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:30-0:38 + >--------< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[#2 Removal] = 0:28-0:38 + >----------< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[#2 Leading delimiter] = 0:28-0:30 + >--< +0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope index 348a304af1..2b5739e42b 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope @@ -1,44 +1,44 @@ def foo( - aaa: Int, - bbb: Int -) = {} + aaa: Int, + bbb: Int, +): Int = aaa + bbb --- [#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 Domain] = 1:2-1:10 + >--------< +1| aaa: Int, + +[#1 Removal] = 1:2-2:2 + >--------- +1| aaa: Int, +2| bbb: Int, + --< + +[#1 Trailing delimiter] = 1:10-2:2 + >- +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 Domain] = 2:2-2:10 + >--------< +2| bbb: Int, + +[#2 Removal] = 1:10-2:10 + >- +1| aaa: Int, +2| bbb: Int, + ----------< + +[#2 Leading delimiter] = 1:10-2:2 + >- +1| aaa: Int, +2| bbb: Int, + --< [#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope b/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope index 81e45e5c26..2b5739e42b 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope @@ -1,44 +1,44 @@ -class Foo( - aaa: Int, - bbb: Int -) {} +def foo( + aaa: Int, + bbb: Int, +): Int = aaa + bbb --- [#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 Domain] = 1:2-1:10 + >--------< +1| aaa: Int, + +[#1 Removal] = 1:2-2:2 + >--------- +1| aaa: Int, +2| bbb: Int, + --< + +[#1 Trailing delimiter] = 1:10-2:2 + >- +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 Domain] = 2:2-2:10 + >--------< +2| bbb: Int, + +[#2 Removal] = 1:10-2:10 + >- +1| aaa: Int, +2| bbb: Int, + ----------< + +[#2 Leading delimiter] = 1:10-2:2 + >- +1| aaa: Int, +2| bbb: Int, + --< [#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope index 9249bf3e76..09cc664d5f 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope @@ -1,18 +1,18 @@ -def foo(aaa: Int, bbb: Int) = {} +def foo(aaa: Int, bbb: Int): Int = aaa + bbb --- [#1 Content] = [#1 Domain] = 0:8-0:16 >--------< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#1 Removal] = 0:8-0:18 >----------< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#1 Trailing delimiter] = 0:16-0:18 >--< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#1 Insertion delimiter] = ", " @@ -20,14 +20,14 @@ def foo(aaa: Int, bbb: Int) = {} [#2 Content] = [#2 Domain] = 0:18-0:26 >--------< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#2 Removal] = 0:16-0:26 >----------< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#2 Leading delimiter] = 0:16-0:18 >--< -0| def foo(aaa: Int, bbb: Int) = {} +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope b/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope index 96d00be9c3..09cc664d5f 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope @@ -1,33 +1,33 @@ -class Foo(aaa: Int, bbb: Int) {} +def foo(aaa: Int, bbb: Int): Int = aaa + bbb --- [#1 Content] = -[#1 Domain] = 0:10-0:18 - >--------< -0| class Foo(aaa: Int, bbb: Int) {} +[#1 Domain] = 0:8-0:16 + >--------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb -[#1 Removal] = 0:10-0:20 - >----------< -0| class Foo(aaa: Int, bbb: Int) {} +[#1 Removal] = 0:8-0:18 + >----------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb -[#1 Trailing delimiter] = 0:18-0:20 - >--< -0| class Foo(aaa: Int, bbb: Int) {} +[#1 Trailing delimiter] = 0:16-0:18 + >--< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 0:20-0:28 - >--------< -0| class Foo(aaa: Int, bbb: Int) {} +[#2 Domain] = 0:18-0:26 + >--------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb -[#2 Removal] = 0:18-0:28 - >----------< -0| class Foo(aaa: Int, bbb: Int) {} +[#2 Removal] = 0:16-0:26 + >----------< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb -[#2 Leading delimiter] = 0:18-0:20 - >--< -0| class Foo(aaa: Int, bbb: Int) {} +[#2 Leading delimiter] = 0:16-0:18 + >--< +0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/condition/condition.doWhile.scope b/data/fixtures/scopes/scala/condition/condition.doWhile.scope new file mode 100644 index 0000000000..a5db4c6278 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/condition/condition.if.scope b/data/fixtures/scopes/scala/condition/condition.if.scope new file mode 100644 index 0000000000..4f5ac14fc6 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/condition/condition.switchCase.iteration.scope b/data/fixtures/scopes/scala/condition/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..ed41876eba --- /dev/null +++ b/data/fixtures/scopes/scala/condition/condition.switchCase.iteration.scope @@ -0,0 +1,10 @@ +foo match { } +--- + +[Content] = 0:11-0:12 + >-< +0| foo match { } + +[Domain] = 0:0-0:13 + >-------------< +0| foo match { } diff --git a/data/fixtures/scopes/scala/condition/condition.switchCase.scope b/data/fixtures/scopes/scala/condition/condition.switchCase.scope new file mode 100644 index 0000000000..1774709024 --- /dev/null +++ b/data/fixtures/scopes/scala/condition/condition.switchCase.scope @@ -0,0 +1,50 @@ +foo match { + case 1 => {}; + case _ => {} +} +--- + +[#1 Content] = 1:9-1:10 + >-< +1| case 1 => {}; + +[#1 Removal] = 1:9-1:11 + >--< +1| case 1 => {}; + +[#1 Leading delimiter] = 1:8-1:9 + >-< +1| case 1 => {}; + +[#1 Trailing delimiter] = 1:10-1:11 + >-< +1| case 1 => {}; + +[#1 Domain] = 1:4-1:17 + >-------------< +1| case 1 => {}; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:9-2:10 + >-< +2| case _ => {} + +[#2 Removal] = 2:9-2:11 + >--< +2| case _ => {} + +[#2 Leading delimiter] = 2:8-2:9 + >-< +2| case _ => {} + +[#2 Trailing delimiter] = 2:10-2:11 + >-< +2| case _ => {} + +[#2 Domain] = 2:4-2:16 + >------------< +2| case _ => {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/condition/condition.while.scope b/data/fixtures/scopes/scala/condition/condition.while.scope new file mode 100644 index 0000000000..61cd7d9e7a --- /dev/null +++ b/data/fixtures/scopes/scala/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/queries/scala.scm b/queries/scala.scm index f6a4e59b41..50ecb3796f 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -18,6 +18,9 @@ (do_while_expression) (for_expression) (try_expression) + + ;; Disabled on purpose. We have a better definition of this below. + ;; (if_expression) ] @statement [ @@ -36,11 +39,28 @@ (#document-range! @name.iteration @value.iteration @type.iteration) ) +;; Top level if expressions only ( - (if_expression) @ifStatement @statement + (if_expression + condition: (parenthesized_expression + (_) @condition + ) + ) @ifStatement @statement @condition.domain + (#not-parent-type? @ifStatement if_expression) ) +;;!! else if (true) {} +(if_expression + "else" @condition.domain.start + (if_expression + condition: (parenthesized_expression + (_) @condition + ) + consequence: (_) @condition.domain.end + ) +) + [ (string) (interpolated_string_expression) @@ -114,7 +134,11 @@ ;;! ^^^ (match_expression value: (_) @value -) @value.domain + (case_block + "{" @condition.iteration.start.endOf + "}" @condition.iteration.end.startOf + ) +) @value.domain @condition.iteration.domain ;;!! for (v <- values) {} (for_expression @@ -173,14 +197,14 @@ right: (_) @value ) @_.domain -(_ - condition: (_ - . - "(" @condition.start.endOf - ")" @condition.end.startOf - . - ) -) @_.domain +( + (_ + condition: (parenthesized_expression + (_) @condition + ) + ) @_.domain + (#not-type? @_.domain if_expression) +) ;;!! type Vector = (Int, Int) ;;! ^^^^^^^^^^ @@ -252,6 +276,17 @@ (_) @value ) @value.domain +;;!! case 0 => "zero" +;;! ^^^^^^^^^^^^^^^^ +(match_expression + (case_block + (case_clause + pattern: (_) @condition + ) @condition.domain + ) + (#trim-end! @condition.domain) +) + ;;!! case 0 => "zero" ;;! ^^^^^^^^^^^^^^^^ ( From 6f49cf5377f6ba5d1afd952a97aa9861f8150314 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 14:12:51 +0100 Subject: [PATCH 07/13] interior --- .../scala/interior/interior.class.scope | 10 ++++ .../scala/interior/interior.doWhile.scope | 10 ++++ .../scopes/scala/interior/interior.enum.scope | 10 ++++ .../scala/interior/interior.foreach.scope | 10 ++++ .../scala/interior/interior.function.scope | 10 ++++ .../scopes/scala/interior/interior.if.scope | 30 ++++++++++ .../scala/interior/interior.interface.scope | 10 ++++ .../scala/interior/interior.lambda.scope | 10 ++++ .../scala/interior/interior.method.scope | 27 +++++++++ .../scala/interior/interior.namespace.scope | 10 ++++ .../scala/interior/interior.switch.scope | 10 ++++ .../scala/interior/interior.switchCase.scope | 58 +++++++++++++++++++ .../scopes/scala/interior/interior.try.scope | 30 ++++++++++ .../scala/interior/interior.while.scope | 10 ++++ queries/scala.scm | 23 +++++++- 15 files changed, 267 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/scala/interior/interior.class.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.doWhile.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.enum.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.foreach.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.function.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.if.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.interface.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.lambda.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.method.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.namespace.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.switch.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.switchCase.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.try.scope create mode 100644 data/fixtures/scopes/scala/interior/interior.while.scope diff --git a/data/fixtures/scopes/scala/interior/interior.class.scope b/data/fixtures/scopes/scala/interior/interior.class.scope new file mode 100644 index 0000000000..13ef2f4d94 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/interior/interior.doWhile.scope b/data/fixtures/scopes/scala/interior/interior.doWhile.scope new file mode 100644 index 0000000000..1c2166cf2f --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/interior/interior.enum.scope b/data/fixtures/scopes/scala/interior/interior.enum.scope new file mode 100644 index 0000000000..d96875b078 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.enum.scope @@ -0,0 +1,10 @@ +enum Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:10-0:11 + >-< +0| enum Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.foreach.scope b/data/fixtures/scopes/scala/interior/interior.foreach.scope new file mode 100644 index 0000000000..f742305081 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.foreach.scope @@ -0,0 +1,10 @@ +for (v <- values) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:19-0:20 + >-< +0| for (v <- values) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.function.scope b/data/fixtures/scopes/scala/interior/interior.function.scope new file mode 100644 index 0000000000..ae95a54a54 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.function.scope @@ -0,0 +1,10 @@ +def foo() { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| def foo() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.if.scope b/data/fixtures/scopes/scala/interior/interior.if.scope new file mode 100644 index 0000000000..407453929f --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/interior/interior.interface.scope b/data/fixtures/scopes/scala/interior/interior.interface.scope new file mode 100644 index 0000000000..15d6d40b91 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.interface.scope @@ -0,0 +1,10 @@ +trait Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| trait Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.lambda.scope b/data/fixtures/scopes/scala/interior/interior.lambda.scope new file mode 100644 index 0000000000..4503fae070 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.lambda.scope @@ -0,0 +1,10 @@ +() => { } +--- + +[Content] = +[Removal] = +[Domain] = 0:7-0:8 + >-< +0| () => { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.method.scope b/data/fixtures/scopes/scala/interior/interior.method.scope new file mode 100644 index 0000000000..0e86fe4aeb --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.method.scope @@ -0,0 +1,27 @@ +class Foo { + def bar() { } +} +--- + +[#1 Content] = 1:4-1:17 + >-------------< +1| def bar() { } + +[#1 Removal] = +[#1 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:15-1:16 + >-< +1| def bar() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.namespace.scope b/data/fixtures/scopes/scala/interior/interior.namespace.scope new file mode 100644 index 0000000000..663d15a693 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.namespace.scope @@ -0,0 +1,10 @@ +package foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:13-0:14 + >-< +0| package foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.switch.scope b/data/fixtures/scopes/scala/interior/interior.switch.scope new file mode 100644 index 0000000000..92dba1ed33 --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.switch.scope @@ -0,0 +1,10 @@ +foo match { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| foo match { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.switchCase.scope b/data/fixtures/scopes/scala/interior/interior.switchCase.scope new file mode 100644 index 0000000000..4497b3606a --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.switchCase.scope @@ -0,0 +1,58 @@ +foo match { + case 0 => 0 + case 1 => { } + case _ => 1 +} +--- + +[#1 Content] = 1:4-3:15 + >----------- +1| case 0 => 0 +2| case 1 => { } +3| case _ => 1 + ---------------< + +[#1 Removal] = +[#1 Domain] = 0:11-4:0 + > +0| foo match { +1| case 0 => 0 +2| case 1 => { } +3| case _ => 1 +4| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:14-1:15 + >-< +1| case 0 => 0 + +[#2 Removal] = +[#2 Domain] = 1:13-1:15 + >--< +1| case 0 => 0 + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:15-2:16 + >-< +2| case 1 => { } + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 3:14-3:15 + >-< +3| case _ => 1 + +[#4 Removal] = +[#4 Domain] = 3:13-3:15 + >--< +3| case _ => 1 + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.try.scope b/data/fixtures/scopes/scala/interior/interior.try.scope new file mode 100644 index 0000000000..90fe80585a --- /dev/null +++ b/data/fixtures/scopes/scala/interior/interior.try.scope @@ -0,0 +1,30 @@ +try { } +catch { } +finally { } +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:5-0:6 + >-< +0| try { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:7-1:8 + >-< +1| catch { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:9-2:10 + >-< +2| finally { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/interior/interior.while.scope b/data/fixtures/scopes/scala/interior/interior.while.scope new file mode 100644 index 0000000000..1afbe23128 --- /dev/null +++ b/data/fixtures/scopes/scala/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/queries/scala.scm b/queries/scala.scm index 50ecb3796f..b5e0ae6bfe 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -39,7 +39,16 @@ (#document-range! @name.iteration @value.iteration @type.iteration) ) -;; Top level if expressions only +;;!! { } +;;! ^ +(_ + . + "{" @interior.start.endOf + "}" @interior.end.startOf + . +) + +;; level if expressions only ( (if_expression condition: (parenthesized_expression @@ -287,6 +296,18 @@ (#trim-end! @condition.domain) ) +;;!! case 0 => "zero" +;;! ^^^^^^^^^^^^^^^^ +(match_expression + (case_block + (case_clause + "=>" @interior.start.endOf + body: (_) @interior.end.endOf + ) + ) + (#not-type? @interior.end.endOf block) +) + ;;!! case 0 => "zero" ;;! ^^^^^^^^^^^^^^^^ ( From 5175259b78a0dc18e01bc4e74d823ceec29aa8d6 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 14:32:14 +0100 Subject: [PATCH 08/13] argument list --- ...argumentList.actual.method.multiLine.scope | 24 ++++++------- ...entList.actual.constructor.multiLine.scope | 24 ++++++------- ...ntList.actual.constructor.singleLine.scope | 14 ++++---- .../argument.formal.lambda.iteration.scope | 9 ++++- ...rgumentList.actual.constructor.empty.scope | 13 +++++++ ...entList.actual.constructor.multiLine.scope | 33 +++++++++++++++++ ...ntList.actual.constructor.singleLine.scope | 13 +++++++ .../argumentList.actual.method.empty.scope | 13 +++++++ ...argumentList.actual.method.multiLine.scope | 33 +++++++++++++++++ ...rgumentList.actual.method.singleLine.scope | 13 +++++++ ...rgumentList.formal.constructor.empty.scope | 13 +++++++ ...entList.formal.constructor.multiLine.scope | 33 +++++++++++++++++ ...ntList.formal.constructor.singleLine.scope | 13 +++++++ .../argumentList.formal.lambda.empty.scope | 13 +++++++ ...argumentList.formal.lambda.multiLine.scope | 33 +++++++++++++++++ ...rgumentList.formal.lambda.singleLine.scope | 13 +++++++ .../argumentList.formal.method.empty.scope | 15 ++++++++ ...argumentList.formal.method.multiLine.scope | 35 +++++++++++++++++++ ...rgumentList.formal.method.singleLine.scope | 15 ++++++++ queries/scala.scm | 13 ++++++- 20 files changed, 352 insertions(+), 33 deletions(-) create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.empty.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.actual.method.empty.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.empty.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.empty.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.method.empty.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/scala/argumentList/argumentList.formal.method.singleLine.scope diff --git a/data/fixtures/scopes/c/argumentList/argumentList.actual.method.multiLine.scope b/data/fixtures/scopes/c/argumentList/argumentList.actual.method.multiLine.scope index 655292f3dc..8b52ebf6c7 100644 --- a/data/fixtures/scopes/c/argumentList/argumentList.actual.method.multiLine.scope +++ b/data/fixtures/scopes/c/argumentList/argumentList.actual.method.multiLine.scope @@ -1,32 +1,32 @@ foo.bar( - int aaa, - int bbb + aaa, + bbb ); --- -[Content] = 1:4-2:11 - >-------- -1| int aaa, -2| int bbb - -----------< +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< [Removal] = 0:8-3:0 > 0| foo.bar( -1| int aaa, -2| int bbb +1| aaa, +2| bbb 3| ); < [Leading delimiter] = 1:0-1:4 >----< -1| int aaa, +1| aaa, [Domain] = 0:0-3:1 >-------- 0| foo.bar( -1| int aaa, -2| int bbb +1| aaa, +2| bbb 3| ); -< diff --git a/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.multiLine.scope b/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.multiLine.scope index 5fa369312d..ccde799094 100644 --- a/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.multiLine.scope +++ b/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.multiLine.scope @@ -1,32 +1,32 @@ new Foo( - int aaa, - int bbb + aaa, + bbb ); --- -[Content] = 1:4-2:11 - >-------- -1| int aaa, -2| int bbb - -----------< +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< [Removal] = 0:8-3:0 > 0| new Foo( -1| int aaa, -2| int bbb +1| aaa, +2| bbb 3| ); < [Leading delimiter] = 1:0-1:4 >----< -1| int aaa, +1| aaa, [Domain] = 0:0-3:1 >-------- 0| new Foo( -1| int aaa, -2| int bbb +1| aaa, +2| bbb 3| ); -< diff --git a/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.singleLine.scope b/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.singleLine.scope index 0b741fe1b9..b9964e4f92 100644 --- a/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.singleLine.scope +++ b/data/fixtures/scopes/cpp/argumentList/argumentList.actual.constructor.singleLine.scope @@ -1,13 +1,13 @@ -new Foo(int aaa, int bbb); +new Foo(aaa, bbb); --- [Content] = -[Removal] = 0:8-0:24 - >----------------< -0| new Foo(int aaa, int bbb); +[Removal] = 0:8-0:16 + >--------< +0| new Foo(aaa, bbb); -[Domain] = 0:0-0:25 - >-------------------------< -0| new Foo(int aaa, int bbb); +[Domain] = 0:0-0:17 + >-----------------< +0| new Foo(aaa, bbb); [Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope index 19c0afdedf..980732427c 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.lambda.iteration.scope @@ -1,3 +1,10 @@ -val f = (aaa: Int, bbb: Int) => aaa + bbb +(aaa: Int, bbb: Int) => {} --- +[Content] = 0:1-0:19 + >------------------< +0| (aaa: Int, bbb: Int) => {} + +[Domain] = 0:0-0:26 + >--------------------------< +0| (aaa: Int, bbb: Int) => {} diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.empty.scope b/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.empty.scope new file mode 100644 index 0000000000..c13ba27678 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.empty.scope @@ -0,0 +1,13 @@ +new Foo() +--- + +[Content] = +[Removal] = 0:8-0:8 + >< +0| new Foo() + +[Domain] = 0:0-0:9 + >---------< +0| new Foo() + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.multiLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..8aaab05967 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.multiLine.scope @@ -0,0 +1,33 @@ +new Foo( + aaa, + bbb +) +--- + +[Content] = 1:4-2:7 + >---- +1| aaa, +2| bbb + -------< + +[Removal] = 0:8-3:0 + > +0| new Foo( +1| aaa, +2| bbb +3| ) + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa, + +[Domain] = 0:0-3:1 + >-------- +0| new Foo( +1| aaa, +2| bbb +3| ) + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.singleLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..7f7a41d974 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.actual.constructor.singleLine.scope @@ -0,0 +1,13 @@ +new Foo(aaa, bbb) +--- + +[Content] = +[Removal] = 0:8-0:16 + >--------< +0| new Foo(aaa, bbb) + +[Domain] = 0:0-0:17 + >-----------------< +0| new Foo(aaa, bbb) + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.actual.method.empty.scope b/data/fixtures/scopes/scala/argumentList/argumentList.actual.method.empty.scope new file mode 100644 index 0000000000..ed61422204 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/argumentList/argumentList.actual.method.multiLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.actual.method.multiLine.scope new file mode 100644 index 0000000000..fbf6ce60c0 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/argumentList/argumentList.actual.method.singleLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.actual.method.singleLine.scope new file mode 100644 index 0000000000..69cf068256 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/argumentList/argumentList.formal.constructor.empty.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.empty.scope new file mode 100644 index 0000000000..ef9aee1a16 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/argumentList/argumentList.formal.constructor.multiLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..b6169a8c3e --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.multiLine.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/scala/argumentList/argumentList.formal.constructor.singleLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..2c4a96e79b --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.constructor.singleLine.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/scala/argumentList/argumentList.formal.lambda.empty.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.empty.scope new file mode 100644 index 0000000000..b963c1e75e --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.empty.scope @@ -0,0 +1,13 @@ +() => {} +--- + +[Content] = +[Removal] = 0:1-0:1 + >< +0| () => {} + +[Domain] = 0:0-0:8 + >--------< +0| () => {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.multiLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..b9f49f3626 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.multiLine.scope @@ -0,0 +1,33 @@ +( + aaa: Int, + bbb: Int +) => {} +--- + +[Content] = 1:4-2:12 + >--------- +1| aaa: Int, +2| bbb: Int + ------------< + +[Removal] = 0:1-3:0 + > +0| ( +1| aaa: Int, +2| bbb: Int +3| ) => {} + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| aaa: Int, + +[Domain] = 0:0-3:7 + >- +0| ( +1| aaa: Int, +2| bbb: Int +3| ) => {} + -------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.singleLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..9da736c526 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.lambda.singleLine.scope @@ -0,0 +1,13 @@ +(aaa: Int, bbb: Int) => {} +--- + +[Content] = +[Removal] = 0:1-0:19 + >------------------< +0| (aaa: Int, bbb: Int) => {} + +[Domain] = 0:0-0:26 + >--------------------------< +0| (aaa: Int, bbb: Int) => {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.empty.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.empty.scope new file mode 100644 index 0000000000..f9ec3fdb72 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.empty.scope @@ -0,0 +1,15 @@ +class Foo { + def bar() {} +} +--- + +[Content] = +[Removal] = 1:12-1:12 + >< +1| def bar() {} + +[Domain] = 1:4-1:16 + >------------< +1| def bar() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.multiLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.multiLine.scope new file mode 100644 index 0000000000..83eaa52fef --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.multiLine.scope @@ -0,0 +1,35 @@ +class Foo { + def bar( + aaa: Int, + bbb: Int + ) {} +} +--- + +[Content] = 2:8-3:16 + >--------- +2| aaa: Int, +3| bbb: Int + ----------------< + +[Removal] = 1:12-4:4 + > +1| def bar( +2| aaa: Int, +3| bbb: Int +4| ) {} + ----< + +[Leading delimiter] = 2:0-2:8 + >--------< +2| aaa: Int, + +[Domain] = 1:4-4:8 + >-------- +1| def bar( +2| aaa: Int, +3| bbb: Int +4| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.singleLine.scope b/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.singleLine.scope new file mode 100644 index 0000000000..fe3abe9807 --- /dev/null +++ b/data/fixtures/scopes/scala/argumentList/argumentList.formal.method.singleLine.scope @@ -0,0 +1,15 @@ +class Foo { + def bar(aaa: Int, bbb: Int) {} +} +--- + +[Content] = +[Removal] = 1:12-1:30 + >------------------< +1| def bar(aaa: Int, bbb: Int) {} + +[Domain] = 1:4-1:34 + >------------------------------< +1| def bar(aaa: Int, bbb: Int) {} + +[Insertion delimiter] = ", " diff --git a/queries/scala.scm b/queries/scala.scm index b5e0ae6bfe..e4bfb1b6b9 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -385,7 +385,7 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain -;;!! def foo(aaa: Int, bbb: Int) = x +;;!! def foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ (_ (parameters @@ -396,6 +396,17 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +;;!! (aaa: Int, bbb: Int) => {} +;;! ^^^^^^^^^^^^^^^^^^ +(lambda_expression + parameters: (bindings + "(" @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) ;;! ^^^^^^^^ (_ From 60634eb74d1b9eaab032ffa1301631866d663237 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 14:55:57 +0100 Subject: [PATCH 09/13] arguments --- .../name/name.argument.actual.iteration.scope | 13 ++++ .../scala/name/name.argument.actual.scope | 29 +++++++ ...rgument.formal.constructor.iteration.scope | 13 ++++ .../name.argument.formal.constructor.scope | 48 ++++++++++++ .../name/name.argument.formal.iteration.scope | 13 ++++ ...ame.argument.formal.method.iteration.scope | 27 +++++++ .../name/name.argument.formal.method.scope | 76 +++++++++++++++++++ .../scala/name/name.argument.formal.scope | 48 ++++++++++++ ...rgument.formal.constructor.iteration.scope | 13 ++++ .../type.argument.formal.constructor.scope | 48 ++++++++++++ .../type/type.argument.formal.iteration.scope | 13 ++++ ...ype.argument.formal.method.iteration.scope | 27 +++++++ .../type/type.argument.formal.method.scope | 53 +++++++++++++ .../scala/type/type.argument.formal.scope | 39 ++++++++++ .../value.argument.actual.iteration.scope | 13 ++++ .../scala/value/value.argument.actual.scope | 39 ++++++++++ ...rgument.formal.constructor.iteration.scope | 13 ++++ .../value.argument.formal.constructor.scope | 39 ++++++++++ .../value.argument.formal.iteration.scope | 13 ++++ ...lue.argument.formal.method.iteration.scope | 27 +++++++ .../value/value.argument.formal.method.scope | 41 ++++++++++ .../scala/value/value.argument.formal.scope | 39 ++++++++++ queries/scala.scm | 22 +++++- 23 files changed, 705 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/scala/name/name.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.actual.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.formal.method.scope create mode 100644 data/fixtures/scopes/scala/name/name.argument.formal.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.formal.method.scope create mode 100644 data/fixtures/scopes/scala/type/type.argument.formal.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.actual.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.formal.method.scope create mode 100644 data/fixtures/scopes/scala/value/value.argument.formal.scope diff --git a/data/fixtures/scopes/scala/name/name.argument.actual.iteration.scope b/data/fixtures/scopes/scala/name/name.argument.actual.iteration.scope new file mode 100644 index 0000000000..ad840ce1ac --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.actual.iteration.scope @@ -0,0 +1,13 @@ +foo(aaa=0, bbb=1) +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:17 + >-----------------< +0| foo(aaa=0, bbb=1) + + +[#2 Content] = +[#2 Domain] = 0:4-0:16 + >------------< +0| foo(aaa=0, bbb=1) diff --git a/data/fixtures/scopes/scala/name/name.argument.actual.scope b/data/fixtures/scopes/scala/name/name.argument.actual.scope new file mode 100644 index 0000000000..499a30d10c --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.actual.scope @@ -0,0 +1,29 @@ +foo(aaa=0, bbb=1) +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:7 + >---< +0| foo(aaa=0, bbb=1) + +[#1 Domain] = 0:4-0:9 + >-----< +0| foo(aaa=0, bbb=1) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:11-0:14 + >---< +0| foo(aaa=0, bbb=1) + +[#2 Leading delimiter] = 0:10-0:11 + >-< +0| foo(aaa=0, bbb=1) + +[#2 Domain] = 0:11-0:16 + >-----< +0| foo(aaa=0, bbb=1) + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/scala/name/name.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..44868ed858 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.formal.constructor.iteration.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/scala/name/name.argument.formal.constructor.scope b/data/fixtures/scopes/scala/name/name.argument.formal.constructor.scope new file mode 100644 index 0000000000..7fe4e513b6 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.formal.constructor.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/scala/name/name.argument.formal.iteration.scope b/data/fixtures/scopes/scala/name/name.argument.formal.iteration.scope new file mode 100644 index 0000000000..546094f0d9 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +def foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| def foo(aaa: Int, bbb: Int) {} + + +[#2 Content] = +[#2 Domain] = 0:8-0:26 + >------------------< +0| def foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/scala/name/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/scala/name/name.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..78163cdb61 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + def bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar(aaa: Int, bbb: Int) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar(aaa: Int, bbb: Int) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:12-1:30 + >------------------< +1| def bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/scala/name/name.argument.formal.method.scope b/data/fixtures/scopes/scala/name/name.argument.formal.method.scope new file mode 100644 index 0000000000..344d7741f4 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.formal.method.scope @@ -0,0 +1,76 @@ +class Foo { + def bar(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| def bar(aaa: Int, bbb: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:8-1:11 + >---< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Domain] = 1:4-1:34 + >------------------------------< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = 1:12-1:15 + >---< +1| def bar(aaa: Int, bbb: Int) {} + +[#3 Domain] = 1:12-1:20 + >--------< +1| def bar(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 1:22-1:25 + >---< +1| def bar(aaa: Int, bbb: Int) {} + +[#4 Removal] = 1:21-1:25 + >----< +1| def bar(aaa: Int, bbb: Int) {} + +[#4 Leading delimiter] = 1:21-1:22 + >-< +1| def bar(aaa: Int, bbb: Int) {} + +[#4 Domain] = 1:22-1:30 + >--------< +1| def bar(aaa: Int, bbb: Int) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/name/name.argument.formal.scope b/data/fixtures/scopes/scala/name/name.argument.formal.scope new file mode 100644 index 0000000000..ba77d19249 --- /dev/null +++ b/data/fixtures/scopes/scala/name/name.argument.formal.scope @@ -0,0 +1,48 @@ +def foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Removal] = 0:4-0:7 + >---< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Leading delimiter] = 0:3-0:4 + >-< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:8-0:11 + >---< +0| def foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 0:8-0:16 + >--------< +0| def foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 0:18-0:21 + >---< +0| def foo(aaa: Int, bbb: Int) {} + +[#3 Removal] = 0:17-0:21 + >----< +0| def foo(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 0:17-0:18 + >-< +0| def foo(aaa: Int, bbb: Int) {} + +[#3 Domain] = 0:18-0:26 + >--------< +0| def foo(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/scala/type/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..44868ed858 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.formal.constructor.iteration.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/scala/type/type.argument.formal.constructor.scope b/data/fixtures/scopes/scala/type/type.argument.formal.constructor.scope new file mode 100644 index 0000000000..f1d1721c04 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.formal.constructor.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/scala/type/type.argument.formal.iteration.scope b/data/fixtures/scopes/scala/type/type.argument.formal.iteration.scope new file mode 100644 index 0000000000..546094f0d9 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +def foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:30 + >------------------------------< +0| def foo(aaa: Int, bbb: Int) {} + + +[#2 Content] = +[#2 Domain] = 0:8-0:26 + >------------------< +0| def foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/scala/type/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/scala/type/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..78163cdb61 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + def bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar(aaa: Int, bbb: Int) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar(aaa: Int, bbb: Int) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:12-1:30 + >------------------< +1| def bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/scala/type/type.argument.formal.method.scope b/data/fixtures/scopes/scala/type/type.argument.formal.method.scope new file mode 100644 index 0000000000..4613d171a1 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.formal.method.scope @@ -0,0 +1,53 @@ +class Foo { + def bar(aaa: Int, bbb: Int) {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar(aaa: Int, bbb: Int) {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:17-1:20 + >---< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Removal] = 1:15-1:20 + >-----< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 1:15-1:17 + >--< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Domain] = 1:12-1:20 + >--------< +1| def bar(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:27-1:30 + >---< +1| def bar(aaa: Int, bbb: Int) {} + +[#3 Removal] = 1:25-1:30 + >-----< +1| def bar(aaa: Int, bbb: Int) {} + +[#3 Leading delimiter] = 1:25-1:27 + >--< +1| def bar(aaa: Int, bbb: Int) {} + +[#3 Domain] = 1:22-1:30 + >--------< +1| def bar(aaa: Int, bbb: Int) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/type/type.argument.formal.scope b/data/fixtures/scopes/scala/type/type.argument.formal.scope new file mode 100644 index 0000000000..7ad48b43b1 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.argument.formal.scope @@ -0,0 +1,39 @@ +def foo(aaa: Int, bbb: Int) {} +--- + +[#1 Content] = 0:13-0:16 + >---< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Removal] = 0:11-0:16 + >-----< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Leading delimiter] = 0:11-0:13 + >--< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Domain] = 0:8-0:16 + >--------< +0| def foo(aaa: Int, bbb: Int) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:23-0:26 + >---< +0| def foo(aaa: Int, bbb: Int) {} + +[#2 Removal] = 0:21-0:26 + >-----< +0| def foo(aaa: Int, bbb: Int) {} + +[#2 Leading delimiter] = 0:21-0:23 + >--< +0| def foo(aaa: Int, bbb: Int) {} + +[#2 Domain] = 0:18-0:26 + >--------< +0| def foo(aaa: Int, bbb: Int) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/value/value.argument.actual.iteration.scope b/data/fixtures/scopes/scala/value/value.argument.actual.iteration.scope new file mode 100644 index 0000000000..546c765209 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.argument.actual.scope b/data/fixtures/scopes/scala/value/value.argument.actual.scope new file mode 100644 index 0000000000..b7b94700a4 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/value/value.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/scala/value/value.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..25e53ec069 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.argument.formal.constructor.iteration.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/scala/value/value.argument.formal.constructor.scope b/data/fixtures/scopes/scala/value/value.argument.formal.constructor.scope new file mode 100644 index 0000000000..4d344c58d3 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.argument.formal.constructor.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/scala/value/value.argument.formal.iteration.scope b/data/fixtures/scopes/scala/value/value.argument.formal.iteration.scope new file mode 100644 index 0000000000..3f63cc77d7 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.argument.formal.iteration.scope @@ -0,0 +1,13 @@ +def foo(aaa: Int = 0, bbb: Int = 1) {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:38 + >--------------------------------------< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + + +[#2 Content] = +[#2 Domain] = 0:8-0:34 + >--------------------------< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} diff --git a/data/fixtures/scopes/scala/value/value.argument.formal.method.iteration.scope b/data/fixtures/scopes/scala/value/value.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..d72cf2cbc8 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.argument.formal.method.iteration.scope @@ -0,0 +1,27 @@ +class Foo { + def bar(aaa: Int = 0, bbb: Int = 1) {} +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >----------- +0| class Foo { +1| def bar(aaa: Int = 0, bbb: Int = 1) {} +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:11-2:0 + > +0| class Foo { +1| def bar(aaa: Int = 0, bbb: Int = 1) {} +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:12-1:38 + >--------------------------< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} diff --git a/data/fixtures/scopes/scala/value/value.argument.formal.method.scope b/data/fixtures/scopes/scala/value/value.argument.formal.method.scope new file mode 100644 index 0000000000..c9d8debb01 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.argument.formal.method.scope @@ -0,0 +1,41 @@ +class Foo { + def bar(aaa: Int = 0, bbb: Int = 1) {} +} +--- + +[#1 Content] = 1:23-1:24 + >-< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Removal] = 1:20-1:24 + >----< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Leading delimiter] = 1:20-1:23 + >---< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Domain] = 1:12-1:24 + >------------< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:37-1:38 + >-< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Removal] = 1:34-1:38 + >----< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Leading delimiter] = 1:34-1:37 + >---< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Domain] = 1:26-1:38 + >------------< +1| def bar(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scala/value/value.argument.formal.scope b/data/fixtures/scopes/scala/value/value.argument.formal.scope new file mode 100644 index 0000000000..fb621ed9f0 --- /dev/null +++ b/data/fixtures/scopes/scala/value/value.argument.formal.scope @@ -0,0 +1,39 @@ +def foo(aaa: Int = 0, bbb: Int = 1) {} +--- + +[#1 Content] = 0:19-0:20 + >-< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Removal] = 0:16-0:20 + >----< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Leading delimiter] = 0:16-0:19 + >---< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Domain] = 0:8-0:20 + >------------< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:33-0:34 + >-< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Removal] = 0:30-0:34 + >----< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Leading delimiter] = 0:30-0:33 + >---< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Domain] = 0:22-0:34 + >------------< +0| def foo(aaa: Int = 0, bbb: Int = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/queries/scala.scm b/queries/scala.scm index e4bfb1b6b9..eebe8bae7a 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -385,6 +385,11 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +(class_parameters + "(" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf +) + ;;!! def foo(aaa: Int, bbb: Int) {} ;;! ^^^^^^^^^^^^^^^^^^ (_ @@ -396,10 +401,15 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +(parameters + "(" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf +) + ;;!! (aaa: Int, bbb: Int) => {} ;;! ^^^^^^^^^^^^^^^^^^ (lambda_expression - parameters: (bindings + (bindings "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf ")" @argumentList.removal.end.startOf @argumentOrParameter.iteration.end.startOf ) @argumentList @@ -407,6 +417,11 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +(bindings + "(" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf +) + ;;!! foo(aaa, bbb) ;;! ^^^^^^^^ (_ @@ -418,6 +433,11 @@ (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain +(arguments + "(" @name.iteration.start.endOf @value.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf +) + operator: (operator_identifier) @disqualifyDelimiter (enumerator "<-" @disqualifyDelimiter From 180ee8808c52e7153312bd4efae59dd9ba58abf9 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 15:33:07 +0100 Subject: [PATCH 10/13] branch --- .../scala/branch/branch.if.elif.else.scope | 45 ++++++++++++++++ .../scopes/scala/branch/branch.if.else.scope | 30 +++++++++++ .../scala/branch/branch.if.iteration.scope | 12 +++++ .../scopes/scala/branch/branch.if.scope | 10 ++++ .../branch/branch.switchCase.iteration.scope | 10 ++++ .../scala/branch/branch.switchCase.scope | 40 ++++++++++++++ .../scala/branch/branch.try.iteration.scope | 12 +++++ .../scopes/scala/branch/branch.try.scope | 45 ++++++++++++++++ queries/scala.scm | 53 +++++++++++++------ 9 files changed, 240 insertions(+), 17 deletions(-) create mode 100644 data/fixtures/scopes/scala/branch/branch.if.elif.else.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.if.else.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.if.iteration.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.if.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.switchCase.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.try.iteration.scope create mode 100644 data/fixtures/scopes/scala/branch/branch.try.scope diff --git a/data/fixtures/scopes/scala/branch/branch.if.elif.else.scope b/data/fixtures/scopes/scala/branch/branch.if.elif.else.scope new file mode 100644 index 0000000000..8bf55324af --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/branch/branch.if.else.scope b/data/fixtures/scopes/scala/branch/branch.if.else.scope new file mode 100644 index 0000000000..489c0edd09 --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/branch/branch.if.iteration.scope b/data/fixtures/scopes/scala/branch/branch.if.iteration.scope new file mode 100644 index 0000000000..84064bd4fa --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/branch/branch.if.scope b/data/fixtures/scopes/scala/branch/branch.if.scope new file mode 100644 index 0000000000..26855fbbaa --- /dev/null +++ b/data/fixtures/scopes/scala/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/scala/branch/branch.switchCase.iteration.scope b/data/fixtures/scopes/scala/branch/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..ed41876eba --- /dev/null +++ b/data/fixtures/scopes/scala/branch/branch.switchCase.iteration.scope @@ -0,0 +1,10 @@ +foo match { } +--- + +[Content] = 0:11-0:12 + >-< +0| foo match { } + +[Domain] = 0:0-0:13 + >-------------< +0| foo match { } diff --git a/data/fixtures/scopes/scala/branch/branch.switchCase.scope b/data/fixtures/scopes/scala/branch/branch.switchCase.scope new file mode 100644 index 0000000000..224bda36a1 --- /dev/null +++ b/data/fixtures/scopes/scala/branch/branch.switchCase.scope @@ -0,0 +1,40 @@ +foo match { + case 0 => 0 + case _ => {} +} +--- + +[#1 Content] = +[#1 Domain] = 1:4-1:15 + >-----------< +1| case 0 => 0 + +[#1 Removal] = 1:0-2:0 + >--------------- +1| case 0 => 0 +2| case _ => {} + < + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| case 0 => 0 + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:4-2:16 + >------------< +2| case _ => {} + +[#2 Removal] = 2:0-3:0 + >---------------- +2| case _ => {} +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| case _ => {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scala/branch/branch.try.iteration.scope b/data/fixtures/scopes/scala/branch/branch.try.iteration.scope new file mode 100644 index 0000000000..9043468b86 --- /dev/null +++ b/data/fixtures/scopes/scala/branch/branch.try.iteration.scope @@ -0,0 +1,12 @@ +try {} +catch {} +finally {} +--- + +[Content] = +[Domain] = 0:0-2:10 + >------ +0| try {} +1| catch {} +2| finally {} + ----------< diff --git a/data/fixtures/scopes/scala/branch/branch.try.scope b/data/fixtures/scopes/scala/branch/branch.try.scope new file mode 100644 index 0000000000..0f95c0073c --- /dev/null +++ b/data/fixtures/scopes/scala/branch/branch.try.scope @@ -0,0 +1,45 @@ +try {} +catch {} +finally {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:6 + >------< +0| try {} + +[#1 Removal] = 0:0-1:0 + >------ +0| try {} +1| catch {} + < + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:0-1:8 + >--------< +1| catch {} + +[#2 Removal] = 1:0-2:0 + >-------- +1| catch {} +2| finally {} + < + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:0-2:10 + >----------< +2| finally {} + +[#3 Removal] = 1:8-2:10 + > +1| catch {} +2| finally {} + ----------< + +[#3 Insertion delimiter] = "\n" diff --git a/queries/scala.scm b/queries/scala.scm index eebe8bae7a..12eaf376c3 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -51,25 +51,39 @@ ;; level if expressions only ( (if_expression + "if" @branch.start @branch.removal.start condition: (parenthesized_expression (_) @condition ) + consequence: (_) @branch.end @branch.removal.end + "else"? @branch.removal.end.startOf + alternative: (if_expression)? @branch.removal.end.startOf ) @ifStatement @statement @condition.domain - (#not-parent-type? @ifStatement if_expression) ) +( + (if_expression) @branch.iteration + (#not-parent-type? @branch.iteration if_expression) +) + ;;!! else if (true) {} (if_expression - "else" @condition.domain.start + "else" @branch.start @condition.domain.start (if_expression condition: (parenthesized_expression (_) @condition ) - consequence: (_) @condition.domain.end + consequence: (_) @branch.end @condition.domain.end ) ) +;;!! else {} +(if_expression + "else" @branch.start + alternative: (block) @branch.end +) + [ (string) (interpolated_string_expression) @@ -144,10 +158,10 @@ (match_expression value: (_) @value (case_block - "{" @condition.iteration.start.endOf - "}" @condition.iteration.end.startOf + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf ) -) @value.domain @condition.iteration.domain +) @value.domain @branch.iteration.domain @condition.iteration.domain ;;!! for (v <- values) {} (for_expression @@ -286,18 +300,18 @@ ) @value.domain ;;!! case 0 => "zero" -;;! ^^^^^^^^^^^^^^^^ +;;! ^ (match_expression (case_block (case_clause pattern: (_) @condition - ) @condition.domain + ) @branch @condition.domain ) - (#trim-end! @condition.domain) + (#trim-end! @branch @condition.domain) ) -;;!! case 0 => "zero" -;;! ^^^^^^^^^^^^^^^^ +;;!! case 0 => 0 +;;! ^^ (match_expression (case_block (case_clause @@ -308,12 +322,17 @@ (#not-type? @interior.end.endOf block) ) -;;!! case 0 => "zero" -;;! ^^^^^^^^^^^^^^^^ -( - (case_clause) @branch - (#trim-end! @branch) -) +;;!! try {} +(try_expression + "try" @branch.start + body: (_) @branch.end +) @branch.iteration + +;;!! catch {} +(catch_clause) @branch + +;;!! catch {} +(finally_clause) @branch ;;!! var foo: Bar[Int, Int] ;;! ^^^ ^^^ From e6df47f07b628cf67ec3e8e2a9e496f96d73a49e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 15:44:13 +0100 Subject: [PATCH 11/13] collection item --- .../collectionItem.unenclosed.iteration.scope | 10 +++ .../collectionItem.unenclosed.multiLine.scope | 85 +++++++++++++++++++ ...collectionItem.unenclosed.singleLine.scope | 85 +++++++++++++++++++ queries/scala.scm | 19 +++++ 4 files changed, 199 insertions(+) create mode 100644 data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.iteration.scope create mode 100644 data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.multiLine.scope create mode 100644 data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.singleLine.scope diff --git a/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.iteration.scope b/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.iteration.scope new file mode 100644 index 0000000000..b6c7f07452 --- /dev/null +++ b/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.iteration.scope @@ -0,0 +1,10 @@ +var a, b, c = 0 +--- + +[Content] = 0:4-0:11 + >-------< +0| var a, b, c = 0 + +[Domain] = 0:0-0:15 + >---------------< +0| var a, b, c = 0 diff --git a/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.multiLine.scope b/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.multiLine.scope new file mode 100644 index 0000000000..f6cba4b177 --- /dev/null +++ b/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.multiLine.scope @@ -0,0 +1,85 @@ +var a, + b, + c = 0 +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:5 + >-----< +0| var a, + +[#1 Removal] = 0:0-0:6 + >------< +0| var a, + +[#1 Trailing delimiter] = 0:5-0:6 + >-< +0| var a, + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:4-0:5 + >-< +0| var a, + +[#2 Removal] = 0:4-1:4 + >-- +0| var a, +1| b, + ----< + +[#2 Trailing delimiter] = 0:5-1:4 + >- +0| var a, +1| b, + ----< + +[#2 Insertion delimiter] = ",\n" + + +[#3 Content] = +[#3 Domain] = 1:4-1:5 + >-< +1| b, + +[#3 Removal] = 1:4-2:4 + >-- +1| b, +2| c = 0 + ----< + +[#3 Leading delimiter] = 0:5-1:4 + >- +0| var a, +1| b, + ----< + +[#3 Trailing delimiter] = 1:5-2:4 + >- +1| b, +2| c = 0 + ----< + +[#3 Insertion delimiter] = ",\n" + + +[#4 Content] = +[#4 Domain] = 2:4-2:5 + >-< +2| c = 0 + +[#4 Removal] = 1:5-2:5 + >- +1| b, +2| c = 0 + -----< + +[#4 Leading delimiter] = 1:5-2:4 + >- +1| b, +2| c = 0 + ----< + +[#4 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.singleLine.scope b/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.singleLine.scope new file mode 100644 index 0000000000..b1a1f108bf --- /dev/null +++ b/data/fixtures/scopes/scala/collectionItem/collectionItem.unenclosed.singleLine.scope @@ -0,0 +1,85 @@ +var a, b, c = 0 +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:5 + >-----< +0| var a, b, c = 0 + +[#1 Removal] = 0:0-0:7 + >-------< +0| var a, b, c = 0 + +[#1 Trailing delimiter] = 0:5-0:7 + >--< +0| var a, b, c = 0 + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:4-0:5 + >-< +0| var a, b, c = 0 + +[#2 Removal] = 0:4-0:7 + >---< +0| var a, b, c = 0 + +[#2 Trailing delimiter] = 0:5-0:7 + >--< +0| var a, b, c = 0 + +[#2 Insertion delimiter] = ", " + + +[#3 Content] = +[#3 Domain] = 0:7-0:8 + >-< +0| var a, b, c = 0 + +[#3 Removal] = 0:7-0:10 + >---< +0| var a, b, c = 0 + +[#3 Leading delimiter] = 0:5-0:7 + >--< +0| var a, b, c = 0 + +[#3 Trailing delimiter] = 0:8-0:10 + >--< +0| var a, b, c = 0 + +[#3 Insertion delimiter] = ", " + + +[#4 Content] = +[#4 Domain] = 0:10-0:11 + >-< +0| var a, b, c = 0 + +[#4 Removal] = 0:8-0:11 + >---< +0| var a, b, c = 0 + +[#4 Leading delimiter] = 0:8-0:10 + >--< +0| var a, b, c = 0 + +[#4 Insertion delimiter] = ", " + + +[#5 Content] = +[#5 Domain] = 0:10-0:15 + >-----< +0| var a, b, c = 0 + +[#5 Removal] = 0:8-0:15 + >-------< +0| var a, b, c = 0 + +[#5 Leading delimiter] = 0:8-0:10 + >--< +0| var a, b, c = 0 + +[#5 Insertion delimiter] = ", " diff --git a/queries/scala.scm b/queries/scala.scm index 12eaf376c3..b23458e82f 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -334,6 +334,25 @@ ;;!! catch {} (finally_clause) @branch +;;!! var a, b, c = 0 +;;! ^^^^^^^ +(_ + (identifiers) @collectionItem.iteration +) @collectionItem.iteration.domain + +;;!! var a, b, c = 0 +;;! ^ ^ ^ +( + (identifiers + (_)? @_.leading.endOf + . + (_) @collectionItem + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @collectionItem @_dummy ", " ",\n") +) + ;;!! var foo: Bar[Int, Int] ;;! ^^^ ^^^ ( From df95d91e58dd346aff29b5aea2d6bc9aca19f2b6 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 16:06:11 +0100 Subject: [PATCH 12/13] more tests --- .../recorded/languages/scala/chuckTypeRed.yml | 33 ------------- .../languages/scala/chuckTypeRed2.yml | 33 ------------- .../languages/scala/chuckTypeSun2.yml | 29 ------------ .../languages/scala/chuckTypeSun4.yml | 33 ------------- .../recorded/languages/scala/clearTypeRed.yml | 33 ------------- .../languages/scala/clearTypeRed2.yml | 33 ------------- .../languages/scala/clearTypeSun2.yml | 29 ------------ .../languages/scala/clearTypeSun4.yml | 33 ------------- .../scala/argument/argument.catch.scope | 3 -- .../argument.formal.lambda.multiLine.scope | 46 +++++++++++++++++-- .../argument.formal.lambda.singleLine.scope | 32 ++++++++++++- .../scopes/scala/type/type.variable3.scope | 22 +++++++++ .../common/src/scopeSupportFacets/scala.ts | 2 +- queries/scala.scm | 45 ++++++++++++++++-- 14 files changed, 138 insertions(+), 268 deletions(-) delete mode 100644 data/fixtures/recorded/languages/scala/chuckTypeRed.yml delete mode 100644 data/fixtures/recorded/languages/scala/chuckTypeRed2.yml delete mode 100644 data/fixtures/recorded/languages/scala/chuckTypeSun2.yml delete mode 100644 data/fixtures/recorded/languages/scala/chuckTypeSun4.yml delete mode 100644 data/fixtures/recorded/languages/scala/clearTypeRed.yml delete mode 100644 data/fixtures/recorded/languages/scala/clearTypeRed2.yml delete mode 100644 data/fixtures/recorded/languages/scala/clearTypeSun2.yml delete mode 100644 data/fixtures/recorded/languages/scala/clearTypeSun4.yml delete mode 100644 data/fixtures/scopes/scala/argument/argument.catch.scope create mode 100644 data/fixtures/scopes/scala/type/type.variable3.scope diff --git a/data/fixtures/recorded/languages/scala/chuckTypeRed.yml b/data/fixtures/recorded/languages/scala/chuckTypeRed.yml deleted file mode 100644 index 15b53b2313..0000000000 --- a/data/fixtures/recorded/languages/scala/chuckTypeRed.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: chuck type red - action: - name: remove - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: r} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy() { - def example(foo: List[String]): List[String] = foo - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.r: - start: {line: 1, character: 24} - end: {line: 1, character: 30} -finalState: - documentContents: | - class TypesAhoy() { - def example(foo): List[String] = foo - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/scala/chuckTypeRed2.yml b/data/fixtures/recorded/languages/scala/chuckTypeRed2.yml deleted file mode 100644 index dcd3ef9cfd..0000000000 --- a/data/fixtures/recorded/languages/scala/chuckTypeRed2.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: chuck type red - action: - name: remove - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: r} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy() { - val foo: List[String] = List("foo") - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.r: - start: {line: 1, character: 16} - end: {line: 1, character: 22} -finalState: - documentContents: | - class TypesAhoy() { - val foo = List("foo") - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/scala/chuckTypeSun2.yml b/data/fixtures/recorded/languages/scala/chuckTypeSun2.yml deleted file mode 100644 index f9d1c333b7..0000000000 --- a/data/fixtures/recorded/languages/scala/chuckTypeSun2.yml +++ /dev/null @@ -1,29 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: chuck type sun - action: - name: remove - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: s} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy(foo: List[String]) {} - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.s: - start: {line: 0, character: 26} - end: {line: 0, character: 32} -finalState: - documentContents: | - class TypesAhoy(foo) {} - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/scala/chuckTypeSun4.yml b/data/fixtures/recorded/languages/scala/chuckTypeSun4.yml deleted file mode 100644 index 10ace885a6..0000000000 --- a/data/fixtures/recorded/languages/scala/chuckTypeSun4.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: chuck type sun - action: - name: remove - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: s} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy() { - def example(foo: List[String]): List[String] = foo - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.s: - start: {line: 1, character: 39} - end: {line: 1, character: 45} -finalState: - documentContents: | - class TypesAhoy() { - def example(foo: List[String]) = foo - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} diff --git a/data/fixtures/recorded/languages/scala/clearTypeRed.yml b/data/fixtures/recorded/languages/scala/clearTypeRed.yml deleted file mode 100644 index 3b8c0693cb..0000000000 --- a/data/fixtures/recorded/languages/scala/clearTypeRed.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: change type red - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: r} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy() { - def example(foo: List[String]): List[String] = foo - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.r: - start: {line: 1, character: 24} - end: {line: 1, character: 30} -finalState: - documentContents: | - class TypesAhoy() { - def example(foo: ): List[String] = foo - } - selections: - - anchor: {line: 1, character: 19} - active: {line: 1, character: 19} diff --git a/data/fixtures/recorded/languages/scala/clearTypeRed2.yml b/data/fixtures/recorded/languages/scala/clearTypeRed2.yml deleted file mode 100644 index 2737e77a43..0000000000 --- a/data/fixtures/recorded/languages/scala/clearTypeRed2.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: change type red - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: r} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy() { - val foo: List[String] = List("foo") - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.r: - start: {line: 1, character: 16} - end: {line: 1, character: 22} -finalState: - documentContents: | - class TypesAhoy() { - val foo: = List("foo") - } - selections: - - anchor: {line: 1, character: 11} - active: {line: 1, character: 11} diff --git a/data/fixtures/recorded/languages/scala/clearTypeSun2.yml b/data/fixtures/recorded/languages/scala/clearTypeSun2.yml deleted file mode 100644 index 5afe1616ca..0000000000 --- a/data/fixtures/recorded/languages/scala/clearTypeSun2.yml +++ /dev/null @@ -1,29 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: change type sun - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: s} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy(foo: List[String]) {} - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.s: - start: {line: 0, character: 26} - end: {line: 0, character: 32} -finalState: - documentContents: | - class TypesAhoy(foo: ) {} - selections: - - anchor: {line: 0, character: 21} - active: {line: 0, character: 21} diff --git a/data/fixtures/recorded/languages/scala/clearTypeSun4.yml b/data/fixtures/recorded/languages/scala/clearTypeSun4.yml deleted file mode 100644 index 13b5cf688b..0000000000 --- a/data/fixtures/recorded/languages/scala/clearTypeSun4.yml +++ /dev/null @@ -1,33 +0,0 @@ -languageId: scala -command: - version: 6 - spokenForm: change type sun - action: - name: clearAndSetSelection - target: - type: primitive - modifiers: - - type: containingScope - scopeType: {type: type} - mark: {type: decoratedSymbol, symbolColor: default, character: s} - usePrePhraseSnapshot: false -initialState: - documentContents: | - class TypesAhoy() { - def example(foo: List[String]): List[String] = foo - } - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 0} - marks: - default.s: - start: {line: 1, character: 39} - end: {line: 1, character: 45} -finalState: - documentContents: | - class TypesAhoy() { - def example(foo: List[String]): = foo - } - selections: - - anchor: {line: 1, character: 34} - active: {line: 1, character: 34} diff --git a/data/fixtures/scopes/scala/argument/argument.catch.scope b/data/fixtures/scopes/scala/argument/argument.catch.scope deleted file mode 100644 index e09a6519c7..0000000000 --- a/data/fixtures/scopes/scala/argument/argument.catch.scope +++ /dev/null @@ -1,3 +0,0 @@ -try {} catch { case e: Exception => } ---- - diff --git a/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope index 6f073ca4a7..526f78a84b 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.lambda.multiLine.scope @@ -1,6 +1,44 @@ -val f = ( - aaa: Int, - bbb: Int, -) => aaa + bbb +( + 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/scala/argument/argument.formal.lambda.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope index 19c0afdedf..de236c647e 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.lambda.singleLine.scope @@ -1,3 +1,33 @@ -val f = (aaa: Int, bbb: Int) => aaa + bbb +(aaa: Int, bbb: Int) => {} --- +[#1 Content] = +[#1 Domain] = 0:1-0:9 + >--------< +0| (aaa: Int, bbb: Int) => {} + +[#1 Removal] = 0:1-0:11 + >----------< +0| (aaa: Int, bbb: Int) => {} + +[#1 Trailing delimiter] = 0:9-0:11 + >--< +0| (aaa: Int, bbb: Int) => {} + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:11-0:19 + >--------< +0| (aaa: Int, bbb: Int) => {} + +[#2 Removal] = 0:9-0:19 + >----------< +0| (aaa: Int, bbb: Int) => {} + +[#2 Leading delimiter] = 0:9-0:11 + >--< +0| (aaa: Int, bbb: Int) => {} + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/type/type.variable3.scope b/data/fixtures/scopes/scala/type/type.variable3.scope new file mode 100644 index 0000000000..434e4aa5d5 --- /dev/null +++ b/data/fixtures/scopes/scala/type/type.variable3.scope @@ -0,0 +1,22 @@ +foo match { + case foo: Foo => 0 +} +--- + +[Content] = 1:14-1:17 + >---< +1| case foo: Foo => 0 + +[Removal] = 1:12-1:17 + >-----< +1| case foo: Foo => 0 + +[Leading delimiter] = 1:12-1:14 + >--< +1| case foo: Foo => 0 + +[Domain] = 1:9-1:17 + >--------< +1| case foo: Foo => 0 + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/scala.ts b/packages/common/src/scopeSupportFacets/scala.ts index 7ca8922693..c6b27a08ef 100644 --- a/packages/common/src/scopeSupportFacets/scala.ts +++ b/packages/common/src/scopeSupportFacets/scala.ts @@ -28,7 +28,6 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "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, @@ -308,4 +307,5 @@ export const scalaScopeSupport: LanguageScopeSupportFacetMap = { "value.variable.pattern": notApplicable, "type.cast": notApplicable, "statement.misc": notApplicable, + "argument.catch": notApplicable, }; diff --git a/queries/scala.scm b/queries/scala.scm index b23458e82f..a106b10bd0 100644 --- a/queries/scala.scm +++ b/queries/scala.scm @@ -299,15 +299,41 @@ (_) @value ) @value.domain -;;!! case 0 => "zero" +;;!! case 0 => 0 +;;! ^^^^^^^^^^^ +(match_expression + (case_block + (case_clause) @branch + ) + (#trim-end! @branch) +) + +;;!! case 0 => 0 ;;! ^ (match_expression (case_block (case_clause pattern: (_) @condition - ) @branch @condition.domain + ) @condition.domain + ) + (#not-type? @condition typed_pattern) + (#trim-end! @condition.domain) +) + +;;!! case foo: Int => 0 +;;! ^^^ +;;! ^^^ +(match_expression + (case_block + (case_clause + pattern: (typed_pattern + pattern: (_) @condition @type.leading.endOf + type: (_) @type + ) @type.domain + ) @condition.domain ) - (#trim-end! @branch @condition.domain) + (#not-type? @condition typed_pattern) + (#trim-end! @condition.domain) ) ;;!! case 0 => 0 @@ -399,6 +425,19 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! (aaa: Int, bbb: Int) => {} +;;! ^^^^^^^^ ^^^^^^^^ +(lambda_expression + (bindings + (_)? @_.leading.endOf + . + (_) @argumentOrParameter + . + (_)? @_.trailing.startOf + ) @_dummy + (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") +) + ;;!! foo(aaa, bbb) ;;! ^^^ ^^^ ( From 32074496f2a9c64ec98fd2c89c6e342c87822d0a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sat, 31 Jan 2026 16:10:18 +0100 Subject: [PATCH 13/13] Cleanup tests --- .../argument/argument.formal.iteration.scope | 10 +-- .../argument/argument.formal.iteration2.scope | 10 --- .../argument.formal.method.iteration.scope | 16 +++-- .../argument.formal.method.multiLine.scope | 68 +++++++++---------- .../argument.formal.method.singleLine.scope | 40 +++++------ .../argument/argument.formal.multiLine.scope | 2 +- .../argument/argument.formal.multiLine2.scope | 44 ------------ .../argument/argument.formal.singleLine.scope | 14 ++-- .../argument.formal.singleLine2.scope | 33 --------- 9 files changed, 77 insertions(+), 160 deletions(-) delete mode 100644 data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope delete mode 100644 data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope delete mode 100644 data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope diff --git a/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope index ea4830d63d..a5973b0b02 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.iteration.scope @@ -1,10 +1,10 @@ -def foo(aaa: Int, bbb: Int): Int = aaa + bbb +def foo(aaa: Int, bbb: Int) {} --- [Content] = 0:8-0:26 >------------------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} -[Domain] = 0:0-0:44 - >--------------------------------------------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +[Domain] = 0:0-0:30 + >------------------------------< +0| def foo(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope b/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope deleted file mode 100644 index ea4830d63d..0000000000 --- a/data/fixtures/scopes/scala/argument/argument.formal.iteration2.scope +++ /dev/null @@ -1,10 +0,0 @@ -def foo(aaa: Int, bbb: Int): Int = aaa + bbb ---- - -[Content] = 0:8-0:26 - >------------------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[Domain] = 0:0-0:44 - >--------------------------------------------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb diff --git a/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope b/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope index 32909a73e8..e3df88540e 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.method.iteration.scope @@ -1,10 +1,12 @@ -class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +class Foo { + def bar(aaa: Int, bbb: Int) {} +} --- -[Content] = 0:20-0:38 - >------------------< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[Content] = 1:12-1:30 + >------------------< +1| def bar(aaa: Int, bbb: Int) {} -[Domain] = 0:12-0:56 - >--------------------------------------------< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[Domain] = 1:4-1:34 + >------------------------------< +1| def bar(aaa: Int, bbb: Int) {} diff --git a/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope index c61778798c..82b540e144 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.method.multiLine.scope @@ -1,46 +1,46 @@ class Foo { - def bar( - aaa: Int, - bbb: Int, - ): Int = aaa + bbb + def bar( + aaa: Int, + bbb: Int + ) {} } --- [#1 Content] = -[#1 Domain] = 2:4-2:12 - >--------< -2| aaa: Int, - -[#1 Removal] = 2:4-3:4 - >--------- -2| aaa: Int, -3| bbb: Int, - ----< - -[#1 Trailing delimiter] = 2:12-3:4 - >- -2| aaa: Int, -3| bbb: Int, - ----< +[#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:4-3:12 - >--------< -3| bbb: Int, - -[#2 Removal] = 2:12-3:12 - >- -2| aaa: Int, -3| bbb: Int, - ------------< - -[#2 Leading delimiter] = 2:12-3:4 - >- -2| aaa: Int, -3| bbb: Int, - ----< +[#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/scala/argument/argument.formal.method.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope index 6328f8fbc1..8f9bb81317 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.method.singleLine.scope @@ -1,33 +1,35 @@ -class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +class Foo { + def bar(aaa: Int, bbb: Int) {} +} --- [#1 Content] = -[#1 Domain] = 0:20-0:28 - >--------< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[#1 Domain] = 1:12-1:20 + >--------< +1| def bar(aaa: Int, bbb: Int) {} -[#1 Removal] = 0:20-0:30 - >----------< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[#1 Removal] = 1:12-1:22 + >----------< +1| def bar(aaa: Int, bbb: Int) {} -[#1 Trailing delimiter] = 0:28-0:30 - >--< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[#1 Trailing delimiter] = 1:20-1:22 + >--< +1| def bar(aaa: Int, bbb: Int) {} [#1 Insertion delimiter] = ", " [#2 Content] = -[#2 Domain] = 0:30-0:38 - >--------< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[#2 Domain] = 1:22-1:30 + >--------< +1| def bar(aaa: Int, bbb: Int) {} -[#2 Removal] = 0:28-0:38 - >----------< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[#2 Removal] = 1:20-1:30 + >----------< +1| def bar(aaa: Int, bbb: Int) {} -[#2 Leading delimiter] = 0:28-0:30 - >--< -0| class Foo { def bar(aaa: Int, bbb: Int): Int = aaa + bbb } +[#2 Leading delimiter] = 1:20-1:22 + >--< +1| def bar(aaa: Int, bbb: Int) {} [#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope index 2b5739e42b..58374be8fc 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.multiLine.scope @@ -1,7 +1,7 @@ def foo( aaa: Int, bbb: Int, -): Int = aaa + bbb +) {} --- [#1 Content] = diff --git a/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope b/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope deleted file mode 100644 index 2b5739e42b..0000000000 --- a/data/fixtures/scopes/scala/argument/argument.formal.multiLine2.scope +++ /dev/null @@ -1,44 +0,0 @@ -def foo( - aaa: Int, - bbb: Int, -): Int = aaa + bbb ---- - -[#1 Content] = -[#1 Domain] = 1:2-1:10 - >--------< -1| aaa: Int, - -[#1 Removal] = 1:2-2:2 - >--------- -1| aaa: Int, -2| bbb: Int, - --< - -[#1 Trailing delimiter] = 1:10-2:2 - >- -1| aaa: Int, -2| bbb: Int, - --< - -[#1 Insertion delimiter] = ",\n" - - -[#2 Content] = -[#2 Domain] = 2:2-2:10 - >--------< -2| bbb: Int, - -[#2 Removal] = 1:10-2:10 - >- -1| aaa: Int, -2| bbb: Int, - ----------< - -[#2 Leading delimiter] = 1:10-2:2 - >- -1| aaa: Int, -2| bbb: Int, - --< - -[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope b/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope index 09cc664d5f..f605329446 100644 --- a/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope +++ b/data/fixtures/scopes/scala/argument/argument.formal.singleLine.scope @@ -1,18 +1,18 @@ -def foo(aaa: Int, bbb: Int): Int = aaa + bbb +def foo(aaa: Int, bbb: Int) {} --- [#1 Content] = [#1 Domain] = 0:8-0:16 >--------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} [#1 Removal] = 0:8-0:18 >----------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} [#1 Trailing delimiter] = 0:16-0:18 >--< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} [#1 Insertion delimiter] = ", " @@ -20,14 +20,14 @@ def foo(aaa: Int, bbb: Int): Int = aaa + bbb [#2 Content] = [#2 Domain] = 0:18-0:26 >--------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} [#2 Removal] = 0:16-0:26 >----------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} [#2 Leading delimiter] = 0:16-0:18 >--< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb +0| def foo(aaa: Int, bbb: Int) {} [#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope b/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope deleted file mode 100644 index 09cc664d5f..0000000000 --- a/data/fixtures/scopes/scala/argument/argument.formal.singleLine2.scope +++ /dev/null @@ -1,33 +0,0 @@ -def foo(aaa: Int, bbb: Int): Int = aaa + bbb ---- - -[#1 Content] = -[#1 Domain] = 0:8-0:16 - >--------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[#1 Removal] = 0:8-0:18 - >----------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[#1 Trailing delimiter] = 0:16-0:18 - >--< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[#1 Insertion delimiter] = ", " - - -[#2 Content] = -[#2 Domain] = 0:18-0:26 - >--------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[#2 Removal] = 0:16-0:26 - >----------< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[#2 Leading delimiter] = 0:16-0:18 - >--< -0| def foo(aaa: Int, bbb: Int): Int = aaa + bbb - -[#2 Insertion delimiter] = ", "