From d50f434d35cb9490751d94acefc08e362c7ae283 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 10:35:36 +0100 Subject: [PATCH 01/21] Started adding missing php facets --- .../scopes/php/anonymousFunction.scope | 11 + .../scopes/php/anonymousFunction2.scope | 11 + data/fixtures/scopes/php/class.scope | 16 + .../php/functionCall/functionCall.chain.scope | 20 ++ .../functionCall.constructor.scope | 11 + .../functionCall/functionCall.method.scope | 11 + .../php/functionCall/functionCall.scope | 11 + .../functionCallee/functionCallee.chain.scope | 26 ++ .../functionCallee.constructor.scope | 14 + .../functionCallee.method.scope | 14 + .../php/functionCallee/functionCallee.scope | 14 + data/fixtures/scopes/php/list.scope | 16 + data/fixtures/scopes/php/map.scope | 16 + .../php/namedFunction.constructor.scope | 22 ++ .../scopes/php/namedFunction.method.scope | 22 ++ data/fixtures/scopes/php/namedFunction.scope | 16 + .../scopes/php/string.multiLine.scope | 20 ++ .../php/textFragment.comment.block.scope | 16 + .../php/textFragment.comment.line.scope | 16 + .../php/textFragment.string.multiLine.scope | 14 + packages/common/src/scopeSupportFacets/php.ts | 311 ++++++++++++++++-- queries/php.scm | 52 ++- 22 files changed, 636 insertions(+), 44 deletions(-) create mode 100644 data/fixtures/scopes/php/anonymousFunction.scope create mode 100644 data/fixtures/scopes/php/anonymousFunction2.scope create mode 100644 data/fixtures/scopes/php/class.scope create mode 100644 data/fixtures/scopes/php/functionCall/functionCall.chain.scope create mode 100644 data/fixtures/scopes/php/functionCall/functionCall.constructor.scope create mode 100644 data/fixtures/scopes/php/functionCall/functionCall.method.scope create mode 100644 data/fixtures/scopes/php/functionCall/functionCall.scope create mode 100644 data/fixtures/scopes/php/functionCallee/functionCallee.chain.scope create mode 100644 data/fixtures/scopes/php/functionCallee/functionCallee.constructor.scope create mode 100644 data/fixtures/scopes/php/functionCallee/functionCallee.method.scope create mode 100644 data/fixtures/scopes/php/functionCallee/functionCallee.scope create mode 100644 data/fixtures/scopes/php/list.scope create mode 100644 data/fixtures/scopes/php/map.scope create mode 100644 data/fixtures/scopes/php/namedFunction.constructor.scope create mode 100644 data/fixtures/scopes/php/namedFunction.method.scope create mode 100644 data/fixtures/scopes/php/namedFunction.scope create mode 100644 data/fixtures/scopes/php/string.multiLine.scope create mode 100644 data/fixtures/scopes/php/textFragment.comment.block.scope create mode 100644 data/fixtures/scopes/php/textFragment.comment.line.scope create mode 100644 data/fixtures/scopes/php/textFragment.string.multiLine.scope diff --git a/data/fixtures/scopes/php/anonymousFunction.scope b/data/fixtures/scopes/php/anonymousFunction.scope new file mode 100644 index 0000000000..d56626e8d2 --- /dev/null +++ b/data/fixtures/scopes/php/anonymousFunction.scope @@ -0,0 +1,11 @@ +-------------< +1| function() {}; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/anonymousFunction2.scope b/data/fixtures/scopes/php/anonymousFunction2.scope new file mode 100644 index 0000000000..3fcf9c76d8 --- /dev/null +++ b/data/fixtures/scopes/php/anonymousFunction2.scope @@ -0,0 +1,11 @@ + 0; +--- + +[Content] = +[Removal] = +[Domain] = 1:0-1:9 + >---------< +1| fn() => 0; + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/class.scope b/data/fixtures/scopes/php/class.scope new file mode 100644 index 0000000000..c08f090e81 --- /dev/null +++ b/data/fixtures/scopes/php/class.scope @@ -0,0 +1,16 @@ +------------< +1| class Foo {} + +[Removal] = 0:5-1:12 + > +0| bar(); +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 1:0-1:5 + >-----< +1| foo()->bar(); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:0-1:12 + >------------< +1| foo()->bar(); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCall/functionCall.constructor.scope b/data/fixtures/scopes/php/functionCall/functionCall.constructor.scope new file mode 100644 index 0000000000..fad3277d22 --- /dev/null +++ b/data/fixtures/scopes/php/functionCall/functionCall.constructor.scope @@ -0,0 +1,11 @@ +---------< +1| new Foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCall/functionCall.method.scope b/data/fixtures/scopes/php/functionCall/functionCall.method.scope new file mode 100644 index 0000000000..d9bca919a2 --- /dev/null +++ b/data/fixtures/scopes/php/functionCall/functionCall.method.scope @@ -0,0 +1,11 @@ +bar(); +--- + +[Content] = +[Removal] = +[Domain] = 1:0-1:11 + >-----------< +1| $foo->bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCall/functionCall.scope b/data/fixtures/scopes/php/functionCall/functionCall.scope new file mode 100644 index 0000000000..3d8f6efec0 --- /dev/null +++ b/data/fixtures/scopes/php/functionCall/functionCall.scope @@ -0,0 +1,11 @@ +-----< +1| foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCallee/functionCallee.chain.scope b/data/fixtures/scopes/php/functionCallee/functionCallee.chain.scope new file mode 100644 index 0000000000..dd55efae14 --- /dev/null +++ b/data/fixtures/scopes/php/functionCallee/functionCallee.chain.scope @@ -0,0 +1,26 @@ +bar(); +--- + +[#1 Content] = +[#1 Removal] = 1:0-1:3 + >---< +1| foo()->bar(); + +[#1 Domain] = 1:0-1:5 + >-----< +1| foo()->bar(); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:0-1:10 + >----------< +1| foo()->bar(); + +[#2 Domain] = 1:0-1:12 + >------------< +1| foo()->bar(); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCallee/functionCallee.constructor.scope b/data/fixtures/scopes/php/functionCallee/functionCallee.constructor.scope new file mode 100644 index 0000000000..71e6291354 --- /dev/null +++ b/data/fixtures/scopes/php/functionCallee/functionCallee.constructor.scope @@ -0,0 +1,14 @@ +-------< +1| new Foo(); + +[Domain] = 1:0-1:9 + >---------< +1| new Foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCallee/functionCallee.method.scope b/data/fixtures/scopes/php/functionCallee/functionCallee.method.scope new file mode 100644 index 0000000000..312f1b5313 --- /dev/null +++ b/data/fixtures/scopes/php/functionCallee/functionCallee.method.scope @@ -0,0 +1,14 @@ +bar(); +--- + +[Content] = +[Removal] = 1:0-1:9 + >---------< +1| $foo->bar(); + +[Domain] = 1:0-1:11 + >-----------< +1| $foo->bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCallee/functionCallee.scope b/data/fixtures/scopes/php/functionCallee/functionCallee.scope new file mode 100644 index 0000000000..0f3018b578 --- /dev/null +++ b/data/fixtures/scopes/php/functionCallee/functionCallee.scope @@ -0,0 +1,14 @@ +---< +1| foo(); + +[Domain] = 1:0-1:5 + >-----< +1| foo(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/list.scope b/data/fixtures/scopes/php/list.scope new file mode 100644 index 0000000000..b475672847 --- /dev/null +++ b/data/fixtures/scopes/php/list.scope @@ -0,0 +1,16 @@ +----------< +1| [aaa, bbb] + +[Removal] = 0:5-1:10 + > +0| 0, "bbb" => 1] +--- + +[Content] = +[Domain] = 1:0-1:24 + >------------------------< +1| ["aaa" => 0, "bbb" => 1] + +[Removal] = 0:5-1:24 + > +0| 0, "bbb" => 1] + ------------------------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/namedFunction.constructor.scope b/data/fixtures/scopes/php/namedFunction.constructor.scope new file mode 100644 index 0000000000..a101e2e071 --- /dev/null +++ b/data/fixtures/scopes/php/namedFunction.constructor.scope @@ -0,0 +1,22 @@ +-------------------------< +2| function __construct() {} + +[Removal] = 2:0-3:0 + >----------------------------- +2| function __construct() {} +3| } + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| function __construct() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/php/namedFunction.method.scope b/data/fixtures/scopes/php/namedFunction.method.scope new file mode 100644 index 0000000000..5d88b620ec --- /dev/null +++ b/data/fixtures/scopes/php/namedFunction.method.scope @@ -0,0 +1,22 @@ +-----------------< +2| function bar() {} + +[Removal] = 2:0-3:0 + >--------------------- +2| function bar() {} +3| } + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| function bar() {} + +[Insertion delimiter] = "\n\n" diff --git a/data/fixtures/scopes/php/namedFunction.scope b/data/fixtures/scopes/php/namedFunction.scope new file mode 100644 index 0000000000..a82d4e0ad7 --- /dev/null +++ b/data/fixtures/scopes/php/namedFunction.scope @@ -0,0 +1,16 @@ +-----------------< +1| function foo() {} + +[Removal] = 0:5-1:17 + > +0| ------ +1| "Hello +2| world" + ------< + +[Removal] = 0:5-2:6 + > +0| -----------------< +1| /* Hello world */ + +[Removal] = 0:5-1:17 + > +0| --------------< +1| // hello world + +[Removal] = 0:5-1:14 + > +0| ----- +1| "hello +2| world" + -----< + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/php.ts b/packages/common/src/scopeSupportFacets/php.ts index 9d88b3eaa0..e5f9d2bba1 100644 --- a/packages/common/src/scopeSupportFacets/php.ts +++ b/packages/common/src/scopeSupportFacets/php.ts @@ -1,13 +1,42 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported, notApplicable } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const phpScopeSupport: LanguageScopeSupportFacetMap = { - "comment.line": supported, - "comment.block": supported, - "textFragment.string.singleLine": supported, + disqualifyDelimiter: supported, + list: supported, + map: supported, + ifStatement: supported, + anonymousFunction: supported, + class: supported, + "class.iteration.document": supported, + + namedFunction: supported, + "namedFunction.constructor": supported, + "namedFunction.method": supported, + "namedFunction.iteration.document": supported, + "namedFunction.iteration.class": supported, + + functionCall: supported, + "functionCall.constructor": supported, + "functionCall.method": supported, + "functionCall.chain": supported, + functionCallee: supported, + "functionCallee.constructor": supported, + "functionCallee.method": supported, + "functionCallee.chain": 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, @@ -17,55 +46,275 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "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, - "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.actual.singleLine": supported, - "argument.actual.multiLine": supported, - "argument.actual.iteration": supported, + "argumentList.actual.empty": supported, + "argumentList.actual.singleLine": supported, + "argumentList.actual.multiLine": supported, + "argumentList.actual.constructor.empty": supported, + "argumentList.actual.constructor.singleLine": supported, + "argumentList.actual.constructor.multiLine": supported, + "argumentList.actual.method.empty": supported, + "argumentList.actual.method.singleLine": supported, + "argumentList.actual.method.multiLine": supported, + "argumentList.formal.empty": supported, + "argumentList.formal.singleLine": supported, + "argumentList.formal.multiLine": supported, + "argumentList.formal.constructor.empty": supported, + "argumentList.formal.constructor.singleLine": supported, + "argumentList.formal.constructor.multiLine": supported, + "argumentList.formal.method.empty": supported, + "argumentList.formal.method.singleLine": supported, + "argumentList.formal.method.multiLine": supported, + "argumentList.formal.lambda.empty": supported, + "argumentList.formal.lambda.singleLine": supported, + "argumentList.formal.lambda.multiLine": supported, - "name.variable.initialized": supported, + "branch.if": supported, + "branch.if.elif.else": supported, + "branch.if.else": supported, + "branch.if.iteration": supported, + "branch.try": supported, + "branch.try.iteration": supported, + "branch.switchCase": supported, + "branch.switchCase.iteration": supported, + "branch.ternary": supported, + "branch.ternary.iteration": supported, + + "comment.line": supported, + "comment.block": supported, + + "condition.if": supported, + "condition.while": supported, + "condition.doWhile": supported, + "condition.for": supported, + "condition.switchCase": supported, + "condition.switchCase.iteration": supported, + "condition.ternary": supported, + + "statement.class": supported, + "statement.interface": supported, + "statement.enum": supported, + "statement.field.class": supported, + "statement.function": supported, + "statement.constructor": supported, + "statement.method": supported, + "statement.functionCall": supported, + "statement.if": supported, + "statement.try": supported, + "statement.switch": supported, + "statement.for": supported, + "statement.foreach": supported, + "statement.while": supported, + "statement.doWhile": supported, + "statement.assignment": supported, + "statement.assignment.compound": supported, + "statement.variable.uninitialized": supported, + "statement.variable.initialized": supported, + "statement.return": supported, + "statement.yield": supported, + "statement.throw": supported, + "statement.break": supported, + "statement.continue": supported, + "statement.import": supported, + "statement.namespace": supported, + "statement.static": 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.line": supported, + "textFragment.comment.block": supported, + "textFragment.string.singleLine": supported, + "textFragment.string.multiLine": supported, + + "name.argument.actual": supported, + "name.argument.actual.iteration": supported, + "name.argument.formal": supported, + "name.argument.formal.iteration": supported, + "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, + "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, + "name.argument.formal.lambda": supported, + "name.argument.formal.lambda.iteration": supported, + "name.argument.catch": supported, "name.assignment": supported, + "name.assignment.compound": supported, + "name.variable.uninitialized": supported, + "name.variable.initialized": supported, + "name.foreach": supported, + "name.function": supported, + "name.constructor": supported, + "name.method": supported, + "name.class": supported, + "name.interface": supported, + "name.enum": supported, + "name.field.class": supported, + "name.field.interface": supported, + "name.field.enum": supported, + "name.namespace": supported, + "name.iteration.document": supported, + "name.iteration.class": supported, + "name.iteration.interface": supported, + "name.iteration.enum": supported, + "name.iteration.block": supported, "key.mapPair": supported, + "key.mapPair.iteration": supported, - "value.variable": supported, - "value.assignment": supported, + "value.argument.actual": supported, + "value.argument.actual.iteration": supported, + "value.argument.formal": supported, + "value.argument.formal.iteration": supported, + "value.argument.formal.constructor": supported, + "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.method": supported, + "value.argument.formal.method.iteration": supported, "value.mapPair": supported, + "value.mapPair.iteration": supported, + "value.assignment": supported, + "value.assignment.compound": supported, + "value.variable": supported, + "value.foreach": supported, "value.return": supported, "value.yield": supported, + "value.throw": supported, + "value.switch": supported, + "value.field.class": supported, + "value.field.interface": supported, + "value.field.enum": supported, + "value.iteration.document": supported, + "value.iteration.class": supported, + "value.iteration.enum": supported, + "value.iteration.block": supported, "type.argument.formal": supported, "type.argument.formal.iteration": supported, + "type.argument.formal.constructor": supported, + "type.argument.formal.constructor.iteration": supported, + "type.argument.formal.method": supported, + "type.argument.formal.method.iteration": supported, + "type.argument.formal.lambda": supported, + "type.argument.formal.lambda.iteration": supported, "type.argument.catch": supported, - "type.cast": supported, + "type.return": supported, + "type.return.method": supported, + "type.foreach": supported, "type.field.class": supported, + "type.field.interface": supported, + "type.constant": supported, + "type.variable.uninitialized": supported, + "type.variable.initialized": supported, + "type.class": supported, + "type.interface": supported, + "type.enum": supported, + "type.cast": supported, + "type.iteration.document": supported, + "type.iteration.class": supported, + "type.iteration.interface": supported, + "type.iteration.block": supported, - "name.argument.formal": supported, - "name.argument.formal.iteration": supported, - "name.argument.catch": supported, - "name.field.class": supported, + "interior.class": supported, + "interior.interface": supported, + "interior.enum": supported, + "interior.function": supported, + "interior.constructor": supported, + "interior.method": supported, + "interior.lambda": supported, + "interior.if": supported, + "interior.try": supported, + "interior.switch": supported, + "interior.switchCase": supported, + "interior.for": supported, + "interior.foreach": supported, + "interior.while": supported, + "interior.doWhile": supported, + "interior.namespace": supported, + "interior.static": supported, - "string.singleLine": supported, + /* UNSUPPORTED */ - disqualifyDelimiter: supported, + fieldAccess: unsupported, + + /* NOT APPLunICABLE */ + + // Not a language construct in PHP + "type.typeArgument": notApplicable, + "type.typeArgument.iteration": notApplicable, + "type.alias": notApplicable, + "statement.typeAlias": notApplicable, + "name.typeAlias": notApplicable, + "value.typeAlias": notApplicable, + + // Not used by PHP syntax + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + notebookCell: notApplicable, + "interior.cell": notApplicable, + environment: notApplicable, + selector: notApplicable, + unit: notApplicable, + pairDelimiter: notApplicable, + + // XML/HTML facets + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + + // Unsupported branch kind + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + + // Unsupported statement categories + "statement.resource": notApplicable, + "statement.package": notApplicable, + "name.resource": notApplicable, + "value.resource": notApplicable, + "type.resource": notApplicable, + "interior.resource": notApplicable, - /* NOT APPLICABLE */ + // Pattern destructuring + "statement.variable.destructuring": notApplicable, + "statement.assignment.destructuring": notApplicable, + "name.variable.destructuring": notApplicable, + "name.assignment.destructuring": notApplicable, + "value.variable.destructuring": notApplicable, + "value.assignment.destructuring": notApplicable, - // Constant + // Const declaration style "statement.constant": notApplicable, "name.constant": notApplicable, "value.constant": notApplicable, - "type.constant": notApplicable, - // Throw statement - "statement.throw": notApplicable, - "value.throw": notApplicable, + // Unenclosed collection items + "collectionItem.unenclosed.singleLine": notApplicable, + "collectionItem.unenclosed.multiLine": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, - // Miscellaneous - "name.variable.uninitialized": notApplicable, + // Generic / enum call variants + "functionCall.generic": notApplicable, + "functionCallee.generic": notApplicable, + "functionCall.enum": notApplicable, + "functionCallee.enum": notApplicable, }; diff --git a/queries/php.scm b/queries/php.scm index 6e762e1c67..d79ae4aa37 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -6,7 +6,6 @@ [ (break_statement) (class_declaration) - (compound_statement) (const_declaration) (continue_statement) (declare_statement) @@ -21,7 +20,6 @@ (function_static_declaration) (global_declaration) (goto_statement) - (if_statement) (interface_declaration) (named_label_statement) (namespace_definition) @@ -32,6 +30,12 @@ (try_statement) (unset_statement) (while_statement) + + ;; Disabled on purpose. We don't consider these to be statements. + ;; (compound_statement) + + ;; Disabled on purpose. We have a better definition of these below. + ;; (if_statement) ] @statement [ @@ -65,14 +69,22 @@ (if_statement) @ifStatement -[ - (array_creation_expression) -] @list +;;!! [aaa, bbb] +(array_creation_expression) @list +;;!! ["aaa" => 0, "bbb" => 1]; +(array_creation_expression + (array_element_initializer + "=>" + ) +) @map + +;;!! class Foo {} (class_declaration name: (_) @name ) @class @name.domain +;;!! function foo() {} [ (function_definition) (method_declaration) @@ -89,10 +101,11 @@ ";"? @namedFunction.end ) -[ - (anonymous_function) - (arrow_function) -] @anonymousFunction +;;!! function() {} +(anonymous_function) @anonymousFunction + +;;!! fn() => 0; +(arrow_function) @anonymousFunction [ (function_definition @@ -103,10 +116,23 @@ ) ] @name.domain -[ - (function_call_expression) - (object_creation_expression) -] @functionCall +;;!! foo() +(function_call_expression + function: (_) @functionCallee +) @functionCall @functionCallee.domain + +;;!! foo()->bar() +(member_call_expression + object: (_) @functionCallee.start + name: (_) @functionCallee.end +) @functionCall @functionCallee.domain + +;;!! new Foo() +(object_creation_expression + "new" @functionCallee.start + . + (_) @functionCallee.end +) @functionCall @functionCallee.domain ;;!! $value = 2; ;;! ^^^^^^ From f55154f3f26b428835307a973de81bae2405ea80 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 10:41:53 +0100 Subject: [PATCH 02/21] document iteration --- .../scopes/php/class.iteration.document.scope | 14 ++++++++++++++ .../scopes/php/name/name.iteration.document.scope | 14 ++++++++++++++ .../php/namedFunction.iteration.document.scope | 14 ++++++++++++++ .../statement/statement.iteration.document.scope | 14 ++++++++++++++ .../php/value/value.iteration.document.scope | 14 ++++++++++++++ queries/java.scm | 4 ++-- queries/php.scm | 10 ++++++++++ 7 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 data/fixtures/scopes/php/class.iteration.document.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.document.scope create mode 100644 data/fixtures/scopes/php/namedFunction.iteration.document.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.document.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.document.scope diff --git a/data/fixtures/scopes/php/class.iteration.document.scope b/data/fixtures/scopes/php/class.iteration.document.scope new file mode 100644 index 0000000000..ac763c63c2 --- /dev/null +++ b/data/fixtures/scopes/php/class.iteration.document.scope @@ -0,0 +1,14 @@ + + +0| +1| +0| +1| +0| +1| +0| +1| +0| +1| Date: Thu, 26 Feb 2026 11:00:54 +0100 Subject: [PATCH 03/21] statement --- data/fixtures/scopes/php/ifStatement.scope | 23 +++++++ .../php/namedFunction.iteration.class.scope | 16 +++++ .../statement.assignment.compound.scope | 16 +++++ .../php/statement/statement.assignment.scope | 16 +++++ .../php/statement/statement.break.scope | 41 ++++++++++++ .../php/statement/statement.class.scope | 16 +++++ .../php/statement/statement.constructor.scope | 41 ++++++++++++ .../php/statement/statement.continue.scope | 41 ++++++++++++ .../php/statement/statement.doWhile.scope | 16 +++++ .../scopes/php/statement/statement.enum.scope | 16 +++++ .../php/statement/statement.field.class.scope | 62 +++++++++++++++++++ .../scopes/php/statement/statement.for.scope | 16 +++++ .../php/statement/statement.foreach.scope | 16 +++++ .../php/statement/statement.function.scope | 16 +++++ .../statement/statement.functionCall.scope | 16 +++++ .../scopes/php/statement/statement.if.scope | 23 +++++++ .../php/statement/statement.import.scope | 16 +++++ .../php/statement/statement.interface.scope | 16 +++++ .../statement/statement.iteration.class.scope | 16 +++++ .../statement.iteration.interface.scope | 16 +++++ .../php/statement/statement.method.scope | 41 ++++++++++++ .../php/statement/statement.namespace.scope | 16 +++++ .../php/statement/statement.return.scope | 41 ++++++++++++ .../php/statement/statement.switch.scope | 16 +++++ .../php/statement/statement.throw.scope | 16 +++++ .../scopes/php/statement/statement.try.scope | 23 +++++++ .../statement.variable.initialized.scope | 16 +++++ .../php/statement/statement.while.scope | 16 +++++ .../php/statement/statement.yield.scope | 16 +++++ packages/common/src/scopeSupportFacets/php.ts | 8 ++- queries/php.scm | 31 +++++++++- 31 files changed, 690 insertions(+), 5 deletions(-) create mode 100644 data/fixtures/scopes/php/ifStatement.scope create mode 100644 data/fixtures/scopes/php/namedFunction.iteration.class.scope create mode 100644 data/fixtures/scopes/php/statement/statement.assignment.compound.scope create mode 100644 data/fixtures/scopes/php/statement/statement.assignment.scope create mode 100644 data/fixtures/scopes/php/statement/statement.break.scope create mode 100644 data/fixtures/scopes/php/statement/statement.class.scope create mode 100644 data/fixtures/scopes/php/statement/statement.constructor.scope create mode 100644 data/fixtures/scopes/php/statement/statement.continue.scope create mode 100644 data/fixtures/scopes/php/statement/statement.doWhile.scope create mode 100644 data/fixtures/scopes/php/statement/statement.enum.scope create mode 100644 data/fixtures/scopes/php/statement/statement.field.class.scope create mode 100644 data/fixtures/scopes/php/statement/statement.for.scope create mode 100644 data/fixtures/scopes/php/statement/statement.foreach.scope create mode 100644 data/fixtures/scopes/php/statement/statement.function.scope create mode 100644 data/fixtures/scopes/php/statement/statement.functionCall.scope create mode 100644 data/fixtures/scopes/php/statement/statement.if.scope create mode 100644 data/fixtures/scopes/php/statement/statement.import.scope create mode 100644 data/fixtures/scopes/php/statement/statement.interface.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.class.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.interface.scope create mode 100644 data/fixtures/scopes/php/statement/statement.method.scope create mode 100644 data/fixtures/scopes/php/statement/statement.namespace.scope create mode 100644 data/fixtures/scopes/php/statement/statement.return.scope create mode 100644 data/fixtures/scopes/php/statement/statement.switch.scope create mode 100644 data/fixtures/scopes/php/statement/statement.throw.scope create mode 100644 data/fixtures/scopes/php/statement/statement.try.scope create mode 100644 data/fixtures/scopes/php/statement/statement.variable.initialized.scope create mode 100644 data/fixtures/scopes/php/statement/statement.while.scope create mode 100644 data/fixtures/scopes/php/statement/statement.yield.scope diff --git a/data/fixtures/scopes/php/ifStatement.scope b/data/fixtures/scopes/php/ifStatement.scope new file mode 100644 index 0000000000..7cff4f10ee --- /dev/null +++ b/data/fixtures/scopes/php/ifStatement.scope @@ -0,0 +1,23 @@ +------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -------< + +[Removal] = 0:5-3:7 + > +0| ----- +0| -< +1| class Foo { } diff --git a/data/fixtures/scopes/php/statement/statement.assignment.compound.scope b/data/fixtures/scopes/php/statement/statement.assignment.compound.scope new file mode 100644 index 0000000000..80073a0c08 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.assignment.compound.scope @@ -0,0 +1,16 @@ +----------< +1| $foo += 0; + +[Removal] = 0:5-1:10 + > +0| ---------< +1| $foo = 0; + +[Removal] = 0:5-1:9 + > +0| -------------- +1| while (true) { +2| break; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ------< +2| break; + +[#2 Removal] = 2:0-3:0 + >---------- +2| break; +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| break; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.class.scope b/data/fixtures/scopes/php/statement/statement.class.scope new file mode 100644 index 0000000000..3705617a44 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.class.scope @@ -0,0 +1,16 @@ +------------< +1| class Foo {} + +[Removal] = 0:5-1:12 + > +0| ----------- +1| class Foo { +2| function __construct() {} +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| -------------------------< +2| function __construct() {} + +[#2 Removal] = 2:0-3:0 + >----------------------------- +2| function __construct() {} +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| function __construct() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.continue.scope b/data/fixtures/scopes/php/statement/statement.continue.scope new file mode 100644 index 0000000000..539eb93876 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.continue.scope @@ -0,0 +1,41 @@ +-------------- +1| while (true) { +2| continue; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---------< +2| continue; + +[#2 Removal] = 2:0-3:0 + >------------- +2| continue; +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| continue; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.doWhile.scope b/data/fixtures/scopes/php/statement/statement.doWhile.scope new file mode 100644 index 0000000000..ab0d105f20 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.doWhile.scope @@ -0,0 +1,16 @@ +-------------------< +1| do {} while (true); + +[Removal] = 0:5-1:19 + > +0| -----------< +1| enum Foo {} + +[Removal] = 0:5-1:11 + > +0| ----------- +1| class Foo { +2| public $bar; +3| public $baz = 0; +4| } + -< + +[#1 Removal] = 0:5-4:1 + > +0| ------------< +2| public $bar; + +[#2 Removal] = 2:0-3:0 + >---------------- +2| public $bar; +3| public $baz = 0; + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| public $bar; + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:4-3:20 + >----------------< +3| public $baz = 0; + +[#3 Removal] = 3:0-4:0 + >-------------------- +3| public $baz = 0; +4| } + < + +[#3 Leading delimiter] = 3:0-3:4 + >----< +3| public $baz = 0; + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.for.scope b/data/fixtures/scopes/php/statement/statement.for.scope new file mode 100644 index 0000000000..0aa01989b7 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.for.scope @@ -0,0 +1,16 @@ +---------------------------------< +1| for ($i = 0; $i < $size; $i++) {} + +[Removal] = 0:5-1:33 + > +0| --------------------------< +1| foreach ($values as $v) {} + +[Removal] = 0:5-1:26 + > +0| -----------------< +1| function foo() {} + +[Removal] = 0:5-1:17 + > +0| ------< +1| foo(); + +[Removal] = 0:5-1:6 + > +0| ------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -------< + +[Removal] = 0:5-3:7 + > +0| ------------< +1| use foo\bar; + +[Removal] = 0:5-1:12 + > +0| ----------------< +1| interface Foo {} + +[Removal] = 0:5-1:16 + > +0| ----- +0| -< +1| class Foo { } diff --git a/data/fixtures/scopes/php/statement/statement.iteration.interface.scope b/data/fixtures/scopes/php/statement/statement.iteration.interface.scope new file mode 100644 index 0000000000..c4a2eaf7ba --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.iteration.interface.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| interface Foo { } diff --git a/data/fixtures/scopes/php/statement/statement.method.scope b/data/fixtures/scopes/php/statement/statement.method.scope new file mode 100644 index 0000000000..3d4d11df87 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.method.scope @@ -0,0 +1,41 @@ +----------- +1| class Foo { +2| function bar() {} +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| -----------------< +2| function bar() {} + +[#2 Removal] = 2:0-3:0 + >--------------------- +2| function bar() {} +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| function bar() {} + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.namespace.scope b/data/fixtures/scopes/php/statement/statement.namespace.scope new file mode 100644 index 0000000000..ccff9b98f0 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.namespace.scope @@ -0,0 +1,16 @@ +------------------< +1| namespace Foo\Bar; + +[Removal] = 0:5-1:18 + > +0| ---------------- +1| function foo() { +2| return 0; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---------< +2| return 0; + +[#2 Removal] = 2:0-3:0 + >------------- +2| return 0; +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| return 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.switch.scope b/data/fixtures/scopes/php/statement/statement.switch.scope new file mode 100644 index 0000000000..95bcbe5c72 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.switch.scope @@ -0,0 +1,16 @@ +----------------< +1| switch ($foo) {} + +[Removal] = 0:5-1:16 + > +0| -----------< +1| throw $foo; + +[Removal] = 0:5-1:11 + > +0| ------ +1| try {} +2| catch (Exception $e) {} +3| finally {} + ----------< + +[Removal] = 0:5-3:10 + > +0| ---------< +1| $foo = 0; + +[Removal] = 0:5-1:9 + > +0| ---------------< +1| while (true) {} + +[Removal] = 0:5-1:15 + > +0| --------< +1| yield 0; + +[Removal] = 0:5-1:8 + > +0| Date: Thu, 26 Feb 2026 11:04:41 +0100 Subject: [PATCH 04/21] pair --- .../php/key/key.mapPair.iteration.scope | 8 ++++++++ .../php/value/value.mapPair.iteration.scope | 16 ++++++++++++++++ queries/php.scm | 19 +++++++++++-------- 3 files changed, 35 insertions(+), 8 deletions(-) create mode 100644 data/fixtures/scopes/php/key/key.mapPair.iteration.scope create mode 100644 data/fixtures/scopes/php/value/value.mapPair.iteration.scope diff --git a/data/fixtures/scopes/php/key/key.mapPair.iteration.scope b/data/fixtures/scopes/php/key/key.mapPair.iteration.scope new file mode 100644 index 0000000000..22acf5bb40 --- /dev/null +++ b/data/fixtures/scopes/php/key/key.mapPair.iteration.scope @@ -0,0 +1,8 @@ + 0, "bbb" => 1] +--- + +[Content] = +[Domain] = 1:1-1:23 + >----------------------< +1| ["aaa" => 0, "bbb" => 1] diff --git a/data/fixtures/scopes/php/value/value.mapPair.iteration.scope b/data/fixtures/scopes/php/value/value.mapPair.iteration.scope new file mode 100644 index 0000000000..be607fcbf5 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.mapPair.iteration.scope @@ -0,0 +1,16 @@ + 0, "bbb" => 1] +--- + +[#1 Content] = +[#1 Domain] = 0:0-1:24 + >----- +0| 0, "bbb" => 1] + ------------------------< + + +[#2 Content] = +[#2 Domain] = 1:1-1:23 + >----------------------< +1| ["aaa" => 0, "bbb" => 1] diff --git a/queries/php.scm b/queries/php.scm index 84a8fb3be6..180de71c27 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -98,11 +98,22 @@ ;;!! ["aaa" => 0, "bbb" => 1]; (array_creation_expression + "[" @collectionKey.iteration.start.endOf @value.iteration.start.endOf (array_element_initializer "=>" ) + "]" @collectionKey.iteration.end.startOf @value.iteration.end.startOf ) @map +;;!! ['num' => 1]; +;;! ^^^^^ +;;! ^ +(array_element_initializer + (_) @collectionKey @value.leading.endOf + "=>" + (_) @value @collectionKey.trailing.startOf +) @_.domain + ;;!! class Foo {} (class_declaration name: (_) @name @@ -263,14 +274,6 @@ (#not-parent-type? @argumentOrParameter.iteration.domain binary_expression) ) -;;!! ['num' => 1]; -;;! ^^^^^ -;;! ^ -(array_element_initializer - (_) @collectionKey @value.leading.endOf - (_) @value @collectionKey.trailing.startOf -) @_.domain - ;;!! return 2; ;;! ^ (return_statement From c77fb0bd6caa076f97ab93c0671f06876018265e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 11:35:58 +0100 Subject: [PATCH 05/21] name --- .../php/name/name.assignment.compound.scope | 21 +++++++ .../fixtures/scopes/php/name/name.class.scope | 25 ++++++++ .../scopes/php/name/name.constructor.scope | 46 +++++++++++++++ data/fixtures/scopes/php/name/name.enum.scope | 25 ++++++++ .../scopes/php/name/name.function.scope | 18 ++++++ .../scopes/php/name/name.interface.scope | 25 ++++++++ .../php/name/name.iteration.class.scope | 16 ++++++ .../scopes/php/name/name.iteration.enum.scope | 16 ++++++ .../php/name/name.iteration.interface.scope | 16 ++++++ .../scopes/php/name/name.method.scope | 46 +++++++++++++++ .../scopes/php/name/name.namespace.scope | 21 +++++++ packages/common/src/scopeSupportFacets/php.ts | 8 ++- queries/php.scm | 57 +++++++++++++++---- 13 files changed, 327 insertions(+), 13 deletions(-) create mode 100644 data/fixtures/scopes/php/name/name.assignment.compound.scope create mode 100644 data/fixtures/scopes/php/name/name.class.scope create mode 100644 data/fixtures/scopes/php/name/name.constructor.scope create mode 100644 data/fixtures/scopes/php/name/name.enum.scope create mode 100644 data/fixtures/scopes/php/name/name.function.scope create mode 100644 data/fixtures/scopes/php/name/name.interface.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.class.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.enum.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.interface.scope create mode 100644 data/fixtures/scopes/php/name/name.method.scope create mode 100644 data/fixtures/scopes/php/name/name.namespace.scope diff --git a/data/fixtures/scopes/php/name/name.assignment.compound.scope b/data/fixtures/scopes/php/name/name.assignment.compound.scope new file mode 100644 index 0000000000..944388ef15 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.assignment.compound.scope @@ -0,0 +1,21 @@ +----< +1| $foo += 0; + +[Removal] = 1:0-1:8 + >--------< +1| $foo += 0; + +[Trailing delimiter] = 1:4-1:8 + >----< +1| $foo += 0; + +[Domain] = 1:0-1:10 + >----------< +1| $foo += 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.class.scope b/data/fixtures/scopes/php/name/name.class.scope new file mode 100644 index 0000000000..9e8d0416ea --- /dev/null +++ b/data/fixtures/scopes/php/name/name.class.scope @@ -0,0 +1,25 @@ +---< +1| class Foo {} + +[Removal] = 1:6-1:10 + >----< +1| class Foo {} + +[Leading delimiter] = 1:5-1:6 + >-< +1| class Foo {} + +[Trailing delimiter] = 1:9-1:10 + >-< +1| class Foo {} + +[Domain] = 1:0-1:12 + >------------< +1| class Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.constructor.scope b/data/fixtures/scopes/php/name/name.constructor.scope new file mode 100644 index 0000000000..015e884f5c --- /dev/null +++ b/data/fixtures/scopes/php/name/name.constructor.scope @@ -0,0 +1,46 @@ +---< +1| class Foo { + +[#1 Removal] = 1:6-1:10 + >----< +1| class Foo { + +[#1 Leading delimiter] = 1:5-1:6 + >-< +1| class Foo { + +[#1 Trailing delimiter] = 1:9-1:10 + >-< +1| class Foo { + +[#1 Domain] = 1:0-3:1 + >----------- +1| class Foo { +2| function __construct() {} +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:13-2:24 + >-----------< +2| function __construct() {} + +[#2 Leading delimiter] = 2:12-2:13 + >-< +2| function __construct() {} + +[#2 Domain] = 2:4-2:29 + >-------------------------< +2| function __construct() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.enum.scope b/data/fixtures/scopes/php/name/name.enum.scope new file mode 100644 index 0000000000..9a163eb1f9 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.enum.scope @@ -0,0 +1,25 @@ +---< +1| enum Foo {} + +[Removal] = 1:5-1:9 + >----< +1| enum Foo {} + +[Leading delimiter] = 1:4-1:5 + >-< +1| enum Foo {} + +[Trailing delimiter] = 1:8-1:9 + >-< +1| enum Foo {} + +[Domain] = 1:0-1:11 + >-----------< +1| enum Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.function.scope b/data/fixtures/scopes/php/name/name.function.scope new file mode 100644 index 0000000000..a20e5c20bd --- /dev/null +++ b/data/fixtures/scopes/php/name/name.function.scope @@ -0,0 +1,18 @@ +---< +1| function foo() {} + +[Leading delimiter] = 1:8-1:9 + >-< +1| function foo() {} + +[Domain] = 1:0-1:17 + >-----------------< +1| function foo() {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.interface.scope b/data/fixtures/scopes/php/name/name.interface.scope new file mode 100644 index 0000000000..9b11f0aaef --- /dev/null +++ b/data/fixtures/scopes/php/name/name.interface.scope @@ -0,0 +1,25 @@ +---< +1| interface Foo {} + +[Removal] = 1:10-1:14 + >----< +1| interface Foo {} + +[Leading delimiter] = 1:9-1:10 + >-< +1| interface Foo {} + +[Trailing delimiter] = 1:13-1:14 + >-< +1| interface Foo {} + +[Domain] = 1:0-1:16 + >----------------< +1| interface Foo {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.iteration.class.scope b/data/fixtures/scopes/php/name/name.iteration.class.scope new file mode 100644 index 0000000000..98de453bf1 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.class.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| class Foo { } diff --git a/data/fixtures/scopes/php/name/name.iteration.enum.scope b/data/fixtures/scopes/php/name/name.iteration.enum.scope new file mode 100644 index 0000000000..8535615cde --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.enum.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| enum Foo { } diff --git a/data/fixtures/scopes/php/name/name.iteration.interface.scope b/data/fixtures/scopes/php/name/name.iteration.interface.scope new file mode 100644 index 0000000000..c4a2eaf7ba --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.interface.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| interface Foo { } diff --git a/data/fixtures/scopes/php/name/name.method.scope b/data/fixtures/scopes/php/name/name.method.scope new file mode 100644 index 0000000000..87da0c9e58 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.method.scope @@ -0,0 +1,46 @@ +---< +1| class Foo { + +[#1 Removal] = 1:6-1:10 + >----< +1| class Foo { + +[#1 Leading delimiter] = 1:5-1:6 + >-< +1| class Foo { + +[#1 Trailing delimiter] = 1:9-1:10 + >-< +1| class Foo { + +[#1 Domain] = 1:0-3:1 + >----------- +1| class Foo { +2| function bar() {} +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:13-2:16 + >---< +2| function bar() {} + +[#2 Leading delimiter] = 2:12-2:13 + >-< +2| function bar() {} + +[#2 Domain] = 2:4-2:21 + >-----------------< +2| function bar() {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.namespace.scope b/data/fixtures/scopes/php/name/name.namespace.scope new file mode 100644 index 0000000000..b877215631 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.namespace.scope @@ -0,0 +1,21 @@ +-------< +1| namespace Foo\Bar; + +[Removal] = 1:9-1:17 + >--------< +1| namespace Foo\Bar; + +[Leading delimiter] = 1:9-1:10 + >-< +1| namespace Foo\Bar; + +[Domain] = 1:0-1:18 + >------------------< +1| namespace Foo\Bar; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/php.ts b/packages/common/src/scopeSupportFacets/php.ts index a809c33a55..a17cf91066 100644 --- a/packages/common/src/scopeSupportFacets/php.ts +++ b/packages/common/src/scopeSupportFacets/php.ts @@ -146,7 +146,6 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "name.argument.catch": supported, "name.assignment": supported, "name.assignment.compound": supported, - "name.variable.uninitialized": supported, "name.variable.initialized": supported, "name.foreach": supported, "name.function": supported, @@ -209,7 +208,6 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "type.field.class": supported, "type.field.interface": supported, "type.constant": supported, - "type.variable.uninitialized": supported, "type.variable.initialized": supported, "type.class": supported, "type.interface": supported, @@ -315,8 +313,12 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "functionCall.enum": notApplicable, "functionCallee.enum": notApplicable, + // Uninitialized variables + "statement.variable.uninitialized": notApplicable, + "name.variable.uninitialized": notApplicable, + "type.variable.uninitialized": notApplicable, + // Miscellaneous "statement.misc": notApplicable, - "statement.variable.uninitialized": notApplicable, "statement.static": notApplicable, }; diff --git a/queries/php.scm b/queries/php.scm index 180de71c27..852ec95507 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -118,17 +118,29 @@ (class_declaration name: (_) @name body: (_ - "{" @statement.iteration.start.endOf @namedFunction.iteration.start.endOf - "}" @statement.iteration.end.startOf @namedFunction.iteration.end.startOf + "{" @namedFunction.iteration.start.endOf + "}" @namedFunction.iteration.end.startOf ) ) @class @name.domain +;;!! class Foo { } +;;!! interface Foo { } +(declaration_list + "{" @statement.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf + "}" @statement.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf +) + ;;!! interface Foo {} (interface_declaration name: (_) @name +) @name.domain + +;;!! enum Foo {} +(enum_declaration + name: (_) @name body: (_ - "{" @statement.iteration.start.endOf - "}" @statement.iteration.end.startOf + "{" @name.iteration.start.endOf + "}" @name.iteration.end.startOf ) ) @name.domain @@ -182,9 +194,15 @@ (_) @functionCallee.end ) @functionCall @functionCallee.domain -;;!! $value = 2; -;;! ^^^^^^ -;;! ^ +;;!! namespace Foo\Bar; +;;! ^^^^^^^ +(namespace_definition + name: (_) @name +) @name.domain + +;;!! $foo = 0; +;;! ^^^ +;;! ^ (_ (assignment_expression left: (_) @name @value.leading.endOf @@ -194,9 +212,9 @@ ";"? @_.domain.end ) -;;!! $value += 2; -;;! ^^^^^^ -;;! ^ +;;!! $foo += 0; +;;! ^^^ +;;! ^ (_ (augmented_assignment_expression left: (_) @name @value.leading.endOf @@ -339,6 +357,25 @@ ) @name.removal.start.startOf ) @_.domain @statement +;;!! const bar = 0; +;;! ^^^ +;;! ^ +(const_declaration + (const_element + (name) @name @value.leading.endOf + (_) @value + ) +) @_.domain + +;;!! case foo = 0; +;;! ^^^ +;;! ^ +(enum_case + "case" @name.removal.start.startOf + name: (_) @name @value.leading.endOf @name.removal.end.endOf + value: (_)? @value @name.removal.end.startOf +) + (_ operator: [ "<" From 8b03cce525e53f143b75ab11be9b9e382202f10a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 12:43:32 +0100 Subject: [PATCH 06/21] name and value --- .../scopes/php/name/name.field.enum.scope | 49 +++++++++++++++++ .../php/name/name.field.interface.scope | 53 +++++++++++++++++++ .../scopes/php/name/name.foreach.scope | 21 ++++++++ .../php/value/value.assignment.compound.scope | 21 ++++++++ .../scopes/php/value/value.field.class.scope | 23 ++++++++ .../scopes/php/value/value.field.enum.scope | 23 ++++++++ .../php/value/value.field.interface.scope | 23 ++++++++ .../scopes/php/value/value.foreach.scope | 21 ++++++++ .../scopes/php/value/value.switch.scope | 14 +++++ .../scopes/php/value/value.throw.scope | 21 ++++++++ queries/php.scm | 50 +++++++++++------ 11 files changed, 304 insertions(+), 15 deletions(-) create mode 100644 data/fixtures/scopes/php/name/name.field.enum.scope create mode 100644 data/fixtures/scopes/php/name/name.field.interface.scope create mode 100644 data/fixtures/scopes/php/name/name.foreach.scope create mode 100644 data/fixtures/scopes/php/value/value.assignment.compound.scope create mode 100644 data/fixtures/scopes/php/value/value.field.class.scope create mode 100644 data/fixtures/scopes/php/value/value.field.enum.scope create mode 100644 data/fixtures/scopes/php/value/value.field.interface.scope create mode 100644 data/fixtures/scopes/php/value/value.foreach.scope create mode 100644 data/fixtures/scopes/php/value/value.switch.scope create mode 100644 data/fixtures/scopes/php/value/value.throw.scope diff --git a/data/fixtures/scopes/php/name/name.field.enum.scope b/data/fixtures/scopes/php/name/name.field.enum.scope new file mode 100644 index 0000000000..4703e20cc0 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.field.enum.scope @@ -0,0 +1,49 @@ +---< +1| enum Foo: int { + +[#1 Removal] = 1:4-1:8 + >----< +1| enum Foo: int { + +[#1 Leading delimiter] = 1:4-1:5 + >-< +1| enum Foo: int { + +[#1 Domain] = 1:0-3:1 + >--------------- +1| enum Foo: int { +2| case Bar = 1; +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:9-2:12 + >---< +2| case Bar = 1; + +[#2 Removal] = 2:4-2:15 + >-----------< +2| case Bar = 1; + +[#2 Leading delimiter] = 2:8-2:9 + >-< +2| case Bar = 1; + +[#2 Trailing delimiter] = 2:12-2:13 + >-< +2| case Bar = 1; + +[#2 Domain] = 2:4-2:17 + >-------------< +2| case Bar = 1; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.field.interface.scope b/data/fixtures/scopes/php/name/name.field.interface.scope new file mode 100644 index 0000000000..d8d23a8f93 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.field.interface.scope @@ -0,0 +1,53 @@ +---< +1| interface Foo { + +[#1 Removal] = 1:10-1:14 + >----< +1| interface Foo { + +[#1 Leading delimiter] = 1:9-1:10 + >-< +1| interface Foo { + +[#1 Trailing delimiter] = 1:13-1:14 + >-< +1| interface Foo { + +[#1 Domain] = 1:0-3:1 + >--------------- +1| interface Foo { +2| public const bar = 1; +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:17-2:20 + >---< +2| public const bar = 1; + +[#2 Removal] = 2:4-2:23 + >-------------------< +2| public const bar = 1; + +[#2 Leading delimiter] = 2:16-2:17 + >-< +2| public const bar = 1; + +[#2 Trailing delimiter] = 2:20-2:21 + >-< +2| public const bar = 1; + +[#2 Domain] = 2:4-2:25 + >---------------------< +2| public const bar = 1; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.foreach.scope b/data/fixtures/scopes/php/name/name.foreach.scope new file mode 100644 index 0000000000..42e7d4227f --- /dev/null +++ b/data/fixtures/scopes/php/name/name.foreach.scope @@ -0,0 +1,21 @@ +--< +1| foreach ($values as $v) {} + +[Removal] = 1:19-1:22 + >---< +1| foreach ($values as $v) {} + +[Leading delimiter] = 1:19-1:20 + >-< +1| foreach ($values as $v) {} + +[Domain] = 1:0-1:26 + >--------------------------< +1| foreach ($values as $v) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.assignment.compound.scope b/data/fixtures/scopes/php/value/value.assignment.compound.scope new file mode 100644 index 0000000000..ec8bd19c14 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.assignment.compound.scope @@ -0,0 +1,21 @@ +-< +1| $foo += 0; + +[Removal] = 1:4-1:9 + >-----< +1| $foo += 0; + +[Leading delimiter] = 1:4-1:8 + >----< +1| $foo += 0; + +[Domain] = 1:0-1:10 + >----------< +1| $foo += 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.field.class.scope b/data/fixtures/scopes/php/value/value.field.class.scope new file mode 100644 index 0000000000..7927d23a4b --- /dev/null +++ b/data/fixtures/scopes/php/value/value.field.class.scope @@ -0,0 +1,23 @@ +-< +2| public $bar = 0; + +[Removal] = 2:15-2:19 + >----< +2| public $bar = 0; + +[Leading delimiter] = 2:15-2:18 + >---< +2| public $bar = 0; + +[Domain] = 2:4-2:20 + >----------------< +2| public $bar = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.field.enum.scope b/data/fixtures/scopes/php/value/value.field.enum.scope new file mode 100644 index 0000000000..71749442d1 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.field.enum.scope @@ -0,0 +1,23 @@ +-< +2| case bar = 0; + +[Removal] = 2:12-2:16 + >----< +2| case bar = 0; + +[Leading delimiter] = 2:12-2:15 + >---< +2| case bar = 0; + +[Domain] = 2:4-2:17 + >-------------< +2| case bar = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.field.interface.scope b/data/fixtures/scopes/php/value/value.field.interface.scope new file mode 100644 index 0000000000..c24cbf7264 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.field.interface.scope @@ -0,0 +1,23 @@ +-< +2| public const bar = 0; + +[Removal] = 2:20-2:24 + >----< +2| public const bar = 0; + +[Leading delimiter] = 2:20-2:23 + >---< +2| public const bar = 0; + +[Domain] = 2:4-2:25 + >---------------------< +2| public const bar = 0; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.foreach.scope b/data/fixtures/scopes/php/value/value.foreach.scope new file mode 100644 index 0000000000..303bc7163a --- /dev/null +++ b/data/fixtures/scopes/php/value/value.foreach.scope @@ -0,0 +1,21 @@ +-------< +1| foreach ($values as $v) {} + +[Removal] = 1:9-1:17 + >--------< +1| foreach ($values as $v) {} + +[Trailing delimiter] = 1:16-1:17 + >-< +1| foreach ($values as $v) {} + +[Domain] = 1:0-1:26 + >--------------------------< +1| foreach ($values as $v) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.switch.scope b/data/fixtures/scopes/php/value/value.switch.scope new file mode 100644 index 0000000000..37cfe5982a --- /dev/null +++ b/data/fixtures/scopes/php/value/value.switch.scope @@ -0,0 +1,14 @@ +----< +1| switch ($foo) {} + +[Domain] = 1:0-1:16 + >----------------< +1| switch ($foo) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.throw.scope b/data/fixtures/scopes/php/value/value.throw.scope new file mode 100644 index 0000000000..4daab86bee --- /dev/null +++ b/data/fixtures/scopes/php/value/value.throw.scope @@ -0,0 +1,21 @@ +----< +1| throw $foo; + +[Removal] = 1:5-1:10 + >-----< +1| throw $foo; + +[Leading delimiter] = 1:5-1:6 + >-< +1| throw $foo; + +[Domain] = 1:0-1:10 + >----------< +1| throw $foo; + +[Insertion delimiter] = " " diff --git a/queries/php.scm b/queries/php.scm index 852ec95507..f5c9141b72 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -146,9 +146,13 @@ ;;!! function foo() {} [ - (function_definition) - (method_declaration) -] @namedFunction + (function_definition + name: (_) @name + ) + (method_declaration + name: (_) @name + ) +] @namedFunction @name.domain (expression_statement (assignment_expression @@ -167,15 +171,6 @@ ;;!! fn() => 0; (arrow_function) @anonymousFunction -[ - (function_definition - name: (_) @name - ) - (method_declaration - name: (_) @name - ) -] @name.domain - ;;!! foo() (function_call_expression function: (_) @functionCallee @@ -200,6 +195,31 @@ name: (_) @name ) @name.domain +;;!! foreach ($values as $v) {} +;;! ^^^^^^^ +;;! ^^ +(foreach_statement + (_) @value + . + "as" + . + (_) @name +) @_.domain + +;;!! throw $foo; +;;! ^^^^ +(throw_expression + (_) @value +) @value.domain + +;;!! switch ($foo) {} +;;! ^^^^^ +(switch_statement + condition: (_ + (_) @value + ) +) @value.domain + ;;!! $foo = 0; ;;! ^^^ ;;! ^ @@ -363,9 +383,9 @@ (const_declaration (const_element (name) @name @value.leading.endOf - (_) @value + (_) @value @name.removal.end.startOf ) -) @_.domain +) @name.removal.start.startOf @_.domain ;;!! case foo = 0; ;;! ^^^ @@ -374,7 +394,7 @@ "case" @name.removal.start.startOf name: (_) @name @value.leading.endOf @name.removal.end.endOf value: (_)? @value @name.removal.end.startOf -) +) @_.domain (_ operator: [ From 2190ff03d3a696c46b298085369f94356786c540 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 13:42:55 +0100 Subject: [PATCH 07/21] condition --- .../php/condition/condition.doWhile.scope | 14 +++++ .../scopes/php/condition/condition.for.scope | 21 +++++++ .../scopes/php/condition/condition.if.scope | 31 ++++++++++ .../condition.switchCase.iteration.scope | 8 +++ .../php/condition/condition.switchCase.scope | 23 +++++++ .../php/condition/condition.ternary.scope | 21 +++++++ .../php/condition/condition.while.scope | 14 +++++ queries/php.scm | 60 ++++++++++++++++++- 8 files changed, 190 insertions(+), 2 deletions(-) create mode 100644 data/fixtures/scopes/php/condition/condition.doWhile.scope create mode 100644 data/fixtures/scopes/php/condition/condition.for.scope create mode 100644 data/fixtures/scopes/php/condition/condition.if.scope create mode 100644 data/fixtures/scopes/php/condition/condition.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/php/condition/condition.switchCase.scope create mode 100644 data/fixtures/scopes/php/condition/condition.ternary.scope create mode 100644 data/fixtures/scopes/php/condition/condition.while.scope diff --git a/data/fixtures/scopes/php/condition/condition.doWhile.scope b/data/fixtures/scopes/php/condition/condition.doWhile.scope new file mode 100644 index 0000000000..c877a09543 --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.doWhile.scope @@ -0,0 +1,14 @@ +----< +1| do {} while (true); + +[Domain] = 1:0-1:19 + >-------------------< +1| do {} while (true); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/condition/condition.for.scope b/data/fixtures/scopes/php/condition/condition.for.scope new file mode 100644 index 0000000000..31b46a0f1a --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.for.scope @@ -0,0 +1,21 @@ +----------< +1| for ($i = 0; $i < $size; $i++) {} + +[Removal] = 1:12-1:23 + >-----------< +1| for ($i = 0; $i < $size; $i++) {} + +[Leading delimiter] = 1:12-1:13 + >-< +1| for ($i = 0; $i < $size; $i++) {} + +[Domain] = 1:0-1:33 + >---------------------------------< +1| for ($i = 0; $i < $size; $i++) {} + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/condition/condition.if.scope b/data/fixtures/scopes/php/condition/condition.if.scope new file mode 100644 index 0000000000..196bcaf9c6 --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.if.scope @@ -0,0 +1,31 @@ +----< +1| if (true) {} + +[#1 Domain] = 1:0-3:7 + >------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:9-2:14 + >-----< +2| else if (false) {} + +[#2 Domain] = 2:0-2:18 + >------------------< +2| else if (false) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/condition/condition.switchCase.iteration.scope b/data/fixtures/scopes/php/condition/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..db996238f9 --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.switchCase.iteration.scope @@ -0,0 +1,8 @@ +-< +1| switch ($foo) { } diff --git a/data/fixtures/scopes/php/condition/condition.switchCase.scope b/data/fixtures/scopes/php/condition/condition.switchCase.scope new file mode 100644 index 0000000000..385845c9a3 --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.switchCase.scope @@ -0,0 +1,23 @@ +-< +2| case 0: break; + +[Removal] = 2:8-2:10 + >--< +2| case 0: break; + +[Leading delimiter] = 2:8-2:9 + >-< +2| case 0: break; + +[Domain] = 2:4-2:18 + >--------------< +2| case 0: break; + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/condition/condition.ternary.scope b/data/fixtures/scopes/php/condition/condition.ternary.scope new file mode 100644 index 0000000000..55b2de65f4 --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.ternary.scope @@ -0,0 +1,21 @@ +----< +1| true ? 0 : 1 + +[Removal] = 1:0-1:5 + >-----< +1| true ? 0 : 1 + +[Trailing delimiter] = 1:4-1:5 + >-< +1| true ? 0 : 1 + +[Domain] = 1:0-1:12 + >------------< +1| true ? 0 : 1 + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/condition/condition.while.scope b/data/fixtures/scopes/php/condition/condition.while.scope new file mode 100644 index 0000000000..4e1103ce27 --- /dev/null +++ b/data/fixtures/scopes/php/condition/condition.while.scope @@ -0,0 +1,14 @@ +----< +1| while (true) {} + +[Domain] = 1:0-1:15 + >---------------< +1| while (true) {} + +[Insertion delimiter] = " " diff --git a/queries/php.scm b/queries/php.scm index f5c9141b72..9310c4b245 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -88,11 +88,28 @@ (comment) @comment @textFragment ;;!! if (true) {} else {} +;;! ^^^^ ( - (if_statement) @ifStatement @statement + (if_statement + condition: (_ + (_) @condition + ) + ) @ifStatement @statement @condition.domain (#not-parent-type? @ifStatement else_clause) ) +;;!! else if (true) {} +;;! ^^^^ +(else_clause + "else" @condition.domain.start + (if_statement + condition: (_ + (_) @condition + ) + body: (_) @condition.domain.end + ) +) + ;;!! [aaa, bbb] (array_creation_expression) @list @@ -212,14 +229,53 @@ (_) @value ) @value.domain -;;!! switch ($foo) {} +;;!! switch ($foo) { } ;;! ^^^^^ +;;! ^ (switch_statement condition: (_ (_) @value ) + body: (_ + "{" @condition.iteration.start.endOf + "}" @condition.iteration.end.startOf + ) ) @value.domain +;;!! case 0: break; +;;! ^ +(case_statement + value: (_) @condition +) @condition.domain + +;;!! do {} while (true); +;;! ^^^^ +(do_statement + condition: (_ + (_) @condition + ) +) @condition.domain + +;;!! while (true) {} +;;! ^^^^ +(while_statement + condition: (_ + (_) @condition + ) +) @condition.domain + +;;!! for ($i = 0; $i < $size; $i++) {} +;;! ^^^^^^^^^^ +(for_statement + condition: (_) @condition +) @condition.domain + +;;!! true ? 0 : 1 +;;! ^^^^ +(conditional_expression + condition: (_) @condition +) @condition.domain + ;;!! $foo = 0; ;;! ^^^ ;;! ^ From 61a0ebbd3c0caeb08a5f1b81cc6282d16b1b2901 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 13:53:34 +0100 Subject: [PATCH 08/21] interior --- .../scopes/php/interior/interior.class.scope | 11 +++ .../php/interior/interior.constructor.scope | 28 ++++++++ .../php/interior/interior.doWhile.scope | 11 +++ .../scopes/php/interior/interior.enum.scope | 11 +++ .../scopes/php/interior/interior.for.scope | 11 +++ .../php/interior/interior.foreach.scope | 11 +++ .../php/interior/interior.function.scope | 11 +++ .../scopes/php/interior/interior.if.scope | 31 +++++++++ .../php/interior/interior.interface.scope | 11 +++ .../scopes/php/interior/interior.lambda.scope | 11 +++ .../scopes/php/interior/interior.method.scope | 28 ++++++++ .../php/interior/interior.namespace.scope | 11 +++ .../scopes/php/interior/interior.switch.scope | 11 +++ .../php/interior/interior.switchCase.scope | 69 +++++++++++++++++++ .../php/interior/interior.switchCase2.scope | 41 +++++++++++ .../scopes/php/interior/interior.try.scope | 31 +++++++++ .../scopes/php/interior/interior.while.scope | 11 +++ .../scopes/php/name/name.namespace.scope | 22 +++--- .../php/statement/statement.namespace.scope | 14 ++-- packages/common/src/scopeSupportFacets/php.ts | 6 +- queries/php.scm | 20 ++++++ 21 files changed, 393 insertions(+), 18 deletions(-) create mode 100644 data/fixtures/scopes/php/interior/interior.class.scope create mode 100644 data/fixtures/scopes/php/interior/interior.constructor.scope create mode 100644 data/fixtures/scopes/php/interior/interior.doWhile.scope create mode 100644 data/fixtures/scopes/php/interior/interior.enum.scope create mode 100644 data/fixtures/scopes/php/interior/interior.for.scope create mode 100644 data/fixtures/scopes/php/interior/interior.foreach.scope create mode 100644 data/fixtures/scopes/php/interior/interior.function.scope create mode 100644 data/fixtures/scopes/php/interior/interior.if.scope create mode 100644 data/fixtures/scopes/php/interior/interior.interface.scope create mode 100644 data/fixtures/scopes/php/interior/interior.lambda.scope create mode 100644 data/fixtures/scopes/php/interior/interior.method.scope create mode 100644 data/fixtures/scopes/php/interior/interior.namespace.scope create mode 100644 data/fixtures/scopes/php/interior/interior.switch.scope create mode 100644 data/fixtures/scopes/php/interior/interior.switchCase.scope create mode 100644 data/fixtures/scopes/php/interior/interior.switchCase2.scope create mode 100644 data/fixtures/scopes/php/interior/interior.try.scope create mode 100644 data/fixtures/scopes/php/interior/interior.while.scope diff --git a/data/fixtures/scopes/php/interior/interior.class.scope b/data/fixtures/scopes/php/interior/interior.class.scope new file mode 100644 index 0000000000..7f19718052 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.class.scope @@ -0,0 +1,11 @@ +-< +1| class Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.constructor.scope b/data/fixtures/scopes/php/interior/interior.constructor.scope new file mode 100644 index 0000000000..17f0ef4b0e --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.constructor.scope @@ -0,0 +1,28 @@ +--------------------------< +2| function __construct() { } + +[#1 Removal] = +[#1 Domain] = 1:11-3:0 + > +1| class Foo { +2| function __construct() { } +3| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:28-2:29 + >-< +2| function __construct() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.doWhile.scope b/data/fixtures/scopes/php/interior/interior.doWhile.scope new file mode 100644 index 0000000000..f474dd202c --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.doWhile.scope @@ -0,0 +1,11 @@ +-< +1| do { } while (true); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.enum.scope b/data/fixtures/scopes/php/interior/interior.enum.scope new file mode 100644 index 0000000000..73130b1772 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.enum.scope @@ -0,0 +1,11 @@ +-< +1| enum Foo: int { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.for.scope b/data/fixtures/scopes/php/interior/interior.for.scope new file mode 100644 index 0000000000..d6b08144c3 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.for.scope @@ -0,0 +1,11 @@ +-< +1| for ($i = 0; $i < $size; ++$i) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.foreach.scope b/data/fixtures/scopes/php/interior/interior.foreach.scope new file mode 100644 index 0000000000..16387c8b15 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.foreach.scope @@ -0,0 +1,11 @@ +-< +1| foreach ($values as $v) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.function.scope b/data/fixtures/scopes/php/interior/interior.function.scope new file mode 100644 index 0000000000..a1ab073b17 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.function.scope @@ -0,0 +1,11 @@ +-< +1| function foo() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.if.scope b/data/fixtures/scopes/php/interior/interior.if.scope new file mode 100644 index 0000000000..1954c0dbae --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.if.scope @@ -0,0 +1,31 @@ +-< +1| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:17-2:18 + >-< +2| else if (false) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 3:6-3:7 + >-< +3| else { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.interface.scope b/data/fixtures/scopes/php/interior/interior.interface.scope new file mode 100644 index 0000000000..daec607460 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.interface.scope @@ -0,0 +1,11 @@ +-< +1| interface Foo { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.lambda.scope b/data/fixtures/scopes/php/interior/interior.lambda.scope new file mode 100644 index 0000000000..910115d565 --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.lambda.scope @@ -0,0 +1,11 @@ +-< +1| function() { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.method.scope b/data/fixtures/scopes/php/interior/interior.method.scope new file mode 100644 index 0000000000..017786fd5f --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.method.scope @@ -0,0 +1,28 @@ +------------------< +2| function bar() { } + +[#1 Removal] = +[#1 Domain] = 1:11-3:0 + > +1| class Foo { +2| function bar() { } +3| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:20-2:21 + >-< +2| function bar() { } + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.namespace.scope b/data/fixtures/scopes/php/interior/interior.namespace.scope new file mode 100644 index 0000000000..dc7c24e36a --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.namespace.scope @@ -0,0 +1,11 @@ +-< +1| namespace Foo\Bar { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.switch.scope b/data/fixtures/scopes/php/interior/interior.switch.scope new file mode 100644 index 0000000000..f1a43658ad --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.switch.scope @@ -0,0 +1,11 @@ +-< +1| switch ($foo) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.switchCase.scope b/data/fixtures/scopes/php/interior/interior.switchCase.scope new file mode 100644 index 0000000000..404fe2ad9c --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.switchCase.scope @@ -0,0 +1,69 @@ +------- +2| case 0: +3| bar; +4| break; +5| default: +6| bar; +7| break; + --------------< + +[#1 Removal] = +[#1 Domain] = 1:15-8:0 + > +1| switch ($foo) { +2| case 0: +3| bar; +4| break; +5| default: +6| bar; +7| break; +8| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 3:8-4:14 + >---- +3| bar; +4| break; + --------------< + +[#2 Removal] = +[#2 Domain] = 2:11-4:14 + > +2| case 0: +3| bar; +4| break; + --------------< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 6:8-7:14 + >---- +6| bar; +7| break; + --------------< + +[#3 Removal] = +[#3 Domain] = 5:12-7:14 + > +5| default: +6| bar; +7| break; + --------------< + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.switchCase2.scope b/data/fixtures/scopes/php/interior/interior.switchCase2.scope new file mode 100644 index 0000000000..f2a518ba6e --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.switchCase2.scope @@ -0,0 +1,41 @@ +----------- +2| case 0: { } +3| default: { } + ----------------< + +[#1 Removal] = +[#1 Domain] = 1:15-4:0 + > +1| switch ($foo) { +2| case 0: { } +3| default: { } +4| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:13-2:14 + >-< +2| case 0: { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 3:14-3:15 + >-< +3| default: { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.try.scope b/data/fixtures/scopes/php/interior/interior.try.scope new file mode 100644 index 0000000000..4ba0c6ce4d --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.try.scope @@ -0,0 +1,31 @@ +-< +1| try { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 2:22-2:23 + >-< +2| catch (Exception $e) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 3:9-3:10 + >-< +3| finally { } + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/interior/interior.while.scope b/data/fixtures/scopes/php/interior/interior.while.scope new file mode 100644 index 0000000000..8a892e955d --- /dev/null +++ b/data/fixtures/scopes/php/interior/interior.while.scope @@ -0,0 +1,11 @@ +-< +1| while (true) { } + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.namespace.scope b/data/fixtures/scopes/php/name/name.namespace.scope index b877215631..9939a73102 100644 --- a/data/fixtures/scopes/php/name/name.namespace.scope +++ b/data/fixtures/scopes/php/name/name.namespace.scope @@ -1,21 +1,25 @@ -------< -1| namespace Foo\Bar; +1| namespace Foo\Bar {} -[Removal] = 1:9-1:17 - >--------< -1| namespace Foo\Bar; +[Removal] = 1:10-1:18 + >--------< +1| namespace Foo\Bar {} [Leading delimiter] = 1:9-1:10 >-< -1| namespace Foo\Bar; +1| namespace Foo\Bar {} -[Domain] = 1:0-1:18 - >------------------< -1| namespace Foo\Bar; +[Trailing delimiter] = 1:17-1:18 + >-< +1| namespace Foo\Bar {} + +[Domain] = 1:0-1:20 + >--------------------< +1| namespace Foo\Bar {} [Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/statement/statement.namespace.scope b/data/fixtures/scopes/php/statement/statement.namespace.scope index ccff9b98f0..bff35a99c3 100644 --- a/data/fixtures/scopes/php/statement/statement.namespace.scope +++ b/data/fixtures/scopes/php/statement/statement.namespace.scope @@ -1,16 +1,16 @@ ------------------< -1| namespace Foo\Bar; +[Domain] = 1:0-1:20 + >--------------------< +1| namespace Foo\Bar {} -[Removal] = 0:5-1:18 +[Removal] = 0:5-1:20 > 0| Date: Thu, 26 Feb 2026 14:23:04 +0100 Subject: [PATCH 09/21] branch --- .../php/branch/branch.if.elif.else.scope | 46 ++++++++++++++++ .../scopes/php/branch/branch.if.else.scope | 31 +++++++++++ .../php/branch/branch.if.iteration.scope | 13 +++++ .../scopes/php/branch/branch.if.scope | 11 ++++ .../branch/branch.switchCase.iteration.scope | 8 +++ .../scopes/php/branch/branch.switchCase.scope | 26 +++++++++ .../php/branch/branch.switchCase2.scope | 26 +++++++++ .../php/branch/branch.ternary.iteration.scope | 8 +++ .../scopes/php/branch/branch.ternary.scope | 38 +++++++++++++ .../php/branch/branch.try.iteration.scope | 13 +++++ .../scopes/php/branch/branch.try.scope | 46 ++++++++++++++++ queries/php.scm | 54 ++++++++++++++++--- 12 files changed, 313 insertions(+), 7 deletions(-) create mode 100644 data/fixtures/scopes/php/branch/branch.if.elif.else.scope create mode 100644 data/fixtures/scopes/php/branch/branch.if.else.scope create mode 100644 data/fixtures/scopes/php/branch/branch.if.iteration.scope create mode 100644 data/fixtures/scopes/php/branch/branch.if.scope create mode 100644 data/fixtures/scopes/php/branch/branch.switchCase.iteration.scope create mode 100644 data/fixtures/scopes/php/branch/branch.switchCase.scope create mode 100644 data/fixtures/scopes/php/branch/branch.switchCase2.scope create mode 100644 data/fixtures/scopes/php/branch/branch.ternary.iteration.scope create mode 100644 data/fixtures/scopes/php/branch/branch.ternary.scope create mode 100644 data/fixtures/scopes/php/branch/branch.try.iteration.scope create mode 100644 data/fixtures/scopes/php/branch/branch.try.scope diff --git a/data/fixtures/scopes/php/branch/branch.if.elif.else.scope b/data/fixtures/scopes/php/branch/branch.if.elif.else.scope new file mode 100644 index 0000000000..be0c4d1353 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.if.elif.else.scope @@ -0,0 +1,46 @@ +------------< +1| if (true) {} + +[#1 Removal] = 1:0-2:5 + >------------ +1| if (true) {} +2| else if (false) {} + -----< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:0-2:18 + >------------------< +2| else if (false) {} + +[#2 Removal] = 2:0-3:0 + >------------------ +2| else if (false) {} +3| else {} + < + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:0-3:7 + >-------< +3| else {} + +[#3 Removal] = 2:18-3:7 + > +2| else if (false) {} +3| else {} + -------< + +[#3 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/branch/branch.if.else.scope b/data/fixtures/scopes/php/branch/branch.if.else.scope new file mode 100644 index 0000000000..64fe44263f --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.if.else.scope @@ -0,0 +1,31 @@ +------------< +1| if (true) {} + +[#1 Removal] = 1:0-2:0 + >------------ +1| if (true) {} +2| else {} + < + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:0-2:7 + >-------< +2| else {} + +[#2 Removal] = 1:12-2:7 + > +1| if (true) {} +2| else {} + -------< + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/branch/branch.if.iteration.scope b/data/fixtures/scopes/php/branch/branch.if.iteration.scope new file mode 100644 index 0000000000..efbd899481 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.if.iteration.scope @@ -0,0 +1,13 @@ +------------ +1| if (true) {} +2| else if (false) {} +3| else {} + -------< diff --git a/data/fixtures/scopes/php/branch/branch.if.scope b/data/fixtures/scopes/php/branch/branch.if.scope new file mode 100644 index 0000000000..5ae6fa60ca --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.if.scope @@ -0,0 +1,11 @@ +------------< +1| if (true) {} + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/branch/branch.switchCase.iteration.scope b/data/fixtures/scopes/php/branch/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..db996238f9 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.switchCase.iteration.scope @@ -0,0 +1,8 @@ +-< +1| switch ($foo) { } diff --git a/data/fixtures/scopes/php/branch/branch.switchCase.scope b/data/fixtures/scopes/php/branch/branch.switchCase.scope new file mode 100644 index 0000000000..07b32abfe0 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.switchCase.scope @@ -0,0 +1,26 @@ +------- +2| case 0: +3| break; + --------------< + +[Removal] = 2:0-4:0 + >----------- +2| case 0: +3| break; +4| } + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| case 0: + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/branch/branch.switchCase2.scope b/data/fixtures/scopes/php/branch/branch.switchCase2.scope new file mode 100644 index 0000000000..c6b04681a8 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.switchCase2.scope @@ -0,0 +1,26 @@ +-------- +2| default: +3| break; + --------------< + +[Removal] = 2:0-4:0 + >------------ +2| default: +3| break; +4| } + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| default: + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/branch/branch.ternary.iteration.scope b/data/fixtures/scopes/php/branch/branch.ternary.iteration.scope new file mode 100644 index 0000000000..53e108ac1f --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.ternary.iteration.scope @@ -0,0 +1,8 @@ +------------< +1| true ? 0 : 1 diff --git a/data/fixtures/scopes/php/branch/branch.ternary.scope b/data/fixtures/scopes/php/branch/branch.ternary.scope new file mode 100644 index 0000000000..bfa6e05fd1 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.ternary.scope @@ -0,0 +1,38 @@ +-< +1| true ? 0 : 1 + +[#1 Removal] = 1:7-1:9 + >--< +1| true ? 0 : 1 + +[#1 Leading delimiter] = 1:6-1:7 + >-< +1| true ? 0 : 1 + +[#1 Trailing delimiter] = 1:8-1:9 + >-< +1| true ? 0 : 1 + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:11-1:12 + >-< +1| true ? 0 : 1 + +[#2 Removal] = 1:10-1:12 + >--< +1| true ? 0 : 1 + +[#2 Leading delimiter] = 1:10-1:11 + >-< +1| true ? 0 : 1 + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/branch/branch.try.iteration.scope b/data/fixtures/scopes/php/branch/branch.try.iteration.scope new file mode 100644 index 0000000000..9ff7147230 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.try.iteration.scope @@ -0,0 +1,13 @@ +------ +1| try {} +2| catch (Exception $e) {} +3| finally {} + ----------< diff --git a/data/fixtures/scopes/php/branch/branch.try.scope b/data/fixtures/scopes/php/branch/branch.try.scope new file mode 100644 index 0000000000..2041fc9174 --- /dev/null +++ b/data/fixtures/scopes/php/branch/branch.try.scope @@ -0,0 +1,46 @@ +------< +1| try {} + +[#1 Removal] = 1:0-2:0 + >------ +1| try {} +2| catch (Exception $e) {} + < + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 2:0-2:23 + >-----------------------< +2| catch (Exception $e) {} + +[#2 Removal] = 2:0-3:0 + >----------------------- +2| catch (Exception $e) {} +3| finally {} + < + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 3:0-3:10 + >----------< +3| finally {} + +[#3 Removal] = 2:23-3:10 + > +2| catch (Exception $e) {} +3| finally {} + ----------< + +[#3 Insertion delimiter] = "\n" diff --git a/queries/php.scm b/queries/php.scm index 003da6c61b..8f1622fb5f 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -87,29 +87,46 @@ (comment) @comment @textFragment +;;!! if (true) {} else {} +( + (if_statement) @ifStatement @statement @branch.iteration + (#not-parent-type? @ifStatement else_clause) +) + ;;!! if (true) {} else {} ;;! ^^^^ ( (if_statement + "if" @branch.start @branch.removal.start condition: (_ (_) @condition ) - ) @ifStatement @statement @condition.domain - (#not-parent-type? @ifStatement else_clause) + body: (_) @branch.end @branch.removal.end + alternative: (else_clause + "else" @branch.removal.end.startOf + (if_statement)? @branch.removal.end.startOf + )? + ) @condition.domain + (#not-parent-type? @condition.domain else_clause) ) ;;!! else if (true) {} ;;! ^^^^ (else_clause - "else" @condition.domain.start + "else" @condition.domain.start @branch.start (if_statement condition: (_ (_) @condition ) - body: (_) @condition.domain.end + body: (_) @condition.domain.end @branch.end ) ) +;;!! else {} +(else_clause + body: (compound_statement) +) @branch + ;;!! [aaa, bbb] (array_creation_expression) @list @@ -237,8 +254,8 @@ (_) @value ) body: (_ - "{" @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 @@ -268,6 +285,11 @@ (#not-type? @_dummy compound_statement) ) +[ + (case_statement) + (default_statement) +] @branch + ;;!! do {} while (true); ;;! ^^^^ (do_statement @@ -292,9 +314,27 @@ ;;!! true ? 0 : 1 ;;! ^^^^ +;;! ^ ^ (conditional_expression condition: (_) @condition -) @condition.domain + body: (_) @branch +) @condition.domain @branch.iteration + +(conditional_expression + alternative: (_) @branch +) + +;;!! try {} catch () {} finally {} +;;! +(try_statement + "try" @branch.start + body: (_) @branch.end +) @branch.iteration + +[ + (catch_clause) + (finally_clause) +] @branch ;;!! $foo = 0; ;;! ^^^ From 10d1ef61c377f256e55eb5fdef2f10a85ae92d26 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 14:32:33 +0100 Subject: [PATCH 10/21] argument actual --- .../name/name.argument.actual.iteration.scope | 16 ++++++++ .../php/name/name.argument.actual.scope | 40 +++++++++++++++++++ .../value.argument.actual.iteration.scope | 16 ++++++++ .../php/value/value.argument.actual.scope | 40 +++++++++++++++++++ .../php/value/value.iteration.class.scope | 16 ++++++++ .../php/value/value.iteration.enum.scope | 16 ++++++++ queries/php.scm | 20 +++++++--- 7 files changed, 158 insertions(+), 6 deletions(-) create mode 100644 data/fixtures/scopes/php/name/name.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/php/name/name.argument.actual.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.actual.iteration.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.actual.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.class.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.enum.scope diff --git a/data/fixtures/scopes/php/name/name.argument.actual.iteration.scope b/data/fixtures/scopes/php/name/name.argument.actual.iteration.scope new file mode 100644 index 0000000000..611503e6d4 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.actual.iteration.scope @@ -0,0 +1,16 @@ +----- +0| --------------< +1| foo(aaa: 0, bbb: 1); diff --git a/data/fixtures/scopes/php/name/name.argument.actual.scope b/data/fixtures/scopes/php/name/name.argument.actual.scope new file mode 100644 index 0000000000..a71ab38090 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.actual.scope @@ -0,0 +1,40 @@ +---< +1| foo(aaa: 0, bbb: 1); + +[#1 Removal] = 1:4-1:9 + >-----< +1| foo(aaa: 0, bbb: 1); + +[#1 Trailing delimiter] = 1:7-1:9 + >--< +1| foo(aaa: 0, bbb: 1); + +[#1 Domain] = 1:4-1:10 + >------< +1| foo(aaa: 0, bbb: 1); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:12-1:15 + >---< +1| foo(aaa: 0, bbb: 1); + +[#2 Removal] = 1:12-1:17 + >-----< +1| foo(aaa: 0, bbb: 1); + +[#2 Trailing delimiter] = 1:15-1:17 + >--< +1| foo(aaa: 0, bbb: 1); + +[#2 Domain] = 1:12-1:18 + >------< +1| foo(aaa: 0, bbb: 1); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.argument.actual.iteration.scope b/data/fixtures/scopes/php/value/value.argument.actual.iteration.scope new file mode 100644 index 0000000000..611503e6d4 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.actual.iteration.scope @@ -0,0 +1,16 @@ +----- +0| --------------< +1| foo(aaa: 0, bbb: 1); diff --git a/data/fixtures/scopes/php/value/value.argument.actual.scope b/data/fixtures/scopes/php/value/value.argument.actual.scope new file mode 100644 index 0000000000..96ccef2d17 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.actual.scope @@ -0,0 +1,40 @@ +-< +1| foo(aaa: 0, bbb: 1); + +[#1 Removal] = 1:7-1:10 + >---< +1| foo(aaa: 0, bbb: 1); + +[#1 Leading delimiter] = 1:7-1:9 + >--< +1| foo(aaa: 0, bbb: 1); + +[#1 Domain] = 1:4-1:10 + >------< +1| foo(aaa: 0, bbb: 1); + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:17-1:18 + >-< +1| foo(aaa: 0, bbb: 1); + +[#2 Removal] = 1:15-1:18 + >---< +1| foo(aaa: 0, bbb: 1); + +[#2 Leading delimiter] = 1:15-1:17 + >--< +1| foo(aaa: 0, bbb: 1); + +[#2 Domain] = 1:12-1:18 + >------< +1| foo(aaa: 0, bbb: 1); + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.iteration.class.scope b/data/fixtures/scopes/php/value/value.iteration.class.scope new file mode 100644 index 0000000000..98de453bf1 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.iteration.class.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| class Foo { } diff --git a/data/fixtures/scopes/php/value/value.iteration.enum.scope b/data/fixtures/scopes/php/value/value.iteration.enum.scope new file mode 100644 index 0000000000..8535615cde --- /dev/null +++ b/data/fixtures/scopes/php/value/value.iteration.enum.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| enum Foo { } diff --git a/queries/php.scm b/queries/php.scm index 8f1622fb5f..76115afd6c 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -173,8 +173,8 @@ (enum_declaration name: (_) @name body: (_ - "{" @name.iteration.start.endOf - "}" @name.iteration.end.startOf + "{" @name.iteration.start.endOf @value.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf ) ) @name.domain @@ -410,8 +410,8 @@ (binary_expression (function_call_expression (arguments - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf + "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf + ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf ) ) ) @argumentOrParameter.iteration.domain @@ -421,13 +421,21 @@ ( (_ (arguments - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf + "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf + ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf ) ) @argumentOrParameter.iteration.domain (#not-parent-type? @argumentOrParameter.iteration.domain binary_expression) ) +;;!! foo(aaa: 0, bbb: 1); +;;! ^^^ ^^^ +;;! ^ ^ +(argument + name: (_) @name @value.leading.endOf + (_) @value @name.trailing.startOf +) @_.domain + ;;!! return 2; ;;! ^ (return_statement From 2b59e676ef9c30b71ff3873bc36c77577a4ef884 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 14:42:29 +0100 Subject: [PATCH 11/21] formal argument --- ...rgument.formal.constructor.iteration.scope | 29 +++++++ .../name.argument.formal.constructor.scope | 78 +++++++++++++++++++ .../name/name.argument.formal.iteration.scope | 12 ++- ...ame.argument.formal.lambda.iteration.scope | 16 ++++ .../name/name.argument.formal.lambda.scope | 34 ++++++++ ...ame.argument.formal.method.iteration.scope | 29 +++++++ .../name/name.argument.formal.method.scope | 78 +++++++++++++++++++ ...rgument.formal.constructor.iteration.scope | 29 +++++++ .../value.argument.formal.constructor.scope | 42 ++++++++++ .../value.argument.formal.iteration.scope | 16 ++++ ...lue.argument.formal.method.iteration.scope | 29 +++++++ .../value/value.argument.formal.method.scope | 42 ++++++++++ .../php/value/value.argument.formal.scope | 40 ++++++++++ queries/php.scm | 22 +++--- 14 files changed, 484 insertions(+), 12 deletions(-) create mode 100644 data/fixtures/scopes/php/name/name.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/php/name/name.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/php/name/name.argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/php/name/name.argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/php/name/name.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/php/name/name.argument.formal.method.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.iteration.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.method.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.scope diff --git a/data/fixtures/scopes/php/name/name.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/php/name/name.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..8ff0a3da3f --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.formal.constructor.iteration.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| function __construct($aaa, $bbb = 0) {} +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:25-2:39 + >--------------< +2| function __construct($aaa, $bbb = 0) {} diff --git a/data/fixtures/scopes/php/name/name.argument.formal.constructor.scope b/data/fixtures/scopes/php/name/name.argument.formal.constructor.scope new file mode 100644 index 0000000000..32beb6003c --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.formal.constructor.scope @@ -0,0 +1,78 @@ +---< +1| class Foo { + +[#1 Removal] = 1:6-1:10 + >----< +1| class Foo { + +[#1 Leading delimiter] = 1:5-1:6 + >-< +1| class Foo { + +[#1 Trailing delimiter] = 1:9-1:10 + >-< +1| class Foo { + +[#1 Domain] = 1:0-3:1 + >----------- +1| class Foo { +2| function __construct($aaa, $bbb = 0) {} +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:13-2:24 + >-----------< +2| function __construct($aaa, $bbb = 0) {} + +[#2 Leading delimiter] = 2:12-2:13 + >-< +2| function __construct($aaa, $bbb = 0) {} + +[#2 Domain] = 2:4-2:43 + >---------------------------------------< +2| function __construct($aaa, $bbb = 0) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:25-2:29 + >----< +2| function __construct($aaa, $bbb = 0) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 2:31-2:35 + >----< +2| function __construct($aaa, $bbb = 0) {} + +[#4 Removal] = 2:31-2:36 + >-----< +2| function __construct($aaa, $bbb = 0) {} + +[#4 Leading delimiter] = 2:30-2:31 + >-< +2| function __construct($aaa, $bbb = 0) {} + +[#4 Trailing delimiter] = 2:35-2:36 + >-< +2| function __construct($aaa, $bbb = 0) {} + +[#4 Domain] = 2:31-2:39 + >--------< +2| function __construct($aaa, $bbb = 0) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.argument.formal.iteration.scope b/data/fixtures/scopes/php/name/name.argument.formal.iteration.scope index 49c858ecaf..8d15e705ba 100644 --- a/data/fixtures/scopes/php/name/name.argument.formal.iteration.scope +++ b/data/fixtures/scopes/php/name/name.argument.formal.iteration.scope @@ -2,7 +2,15 @@ function foo(int $aaa, int $bbb) {} --- -[Content] = -[Domain] = 1:13-1:31 +[#1 Content] = +[#1 Domain] = 0:0-1:35 + >----- +0| ------------------< 1| function foo(int $aaa, int $bbb) {} diff --git a/data/fixtures/scopes/php/name/name.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/php/name/name.argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..01edba0cb6 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.formal.lambda.iteration.scope @@ -0,0 +1,16 @@ +----- +0| --------------< +1| function($aaa, $bbb = 0) {}; diff --git a/data/fixtures/scopes/php/name/name.argument.formal.lambda.scope b/data/fixtures/scopes/php/name/name.argument.formal.lambda.scope new file mode 100644 index 0000000000..09f7cc851f --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.formal.lambda.scope @@ -0,0 +1,34 @@ +----< +1| function($aaa, $bbb = 0) {}; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:15-1:19 + >----< +1| function($aaa, $bbb = 0) {}; + +[#2 Removal] = 1:15-1:20 + >-----< +1| function($aaa, $bbb = 0) {}; + +[#2 Leading delimiter] = 1:14-1:15 + >-< +1| function($aaa, $bbb = 0) {}; + +[#2 Trailing delimiter] = 1:19-1:20 + >-< +1| function($aaa, $bbb = 0) {}; + +[#2 Domain] = 1:15-1:23 + >--------< +1| function($aaa, $bbb = 0) {}; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/name/name.argument.formal.method.iteration.scope b/data/fixtures/scopes/php/name/name.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..91880ef713 --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.formal.method.iteration.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| function bar($aaa, $bbb = 0) {} +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:17-2:31 + >--------------< +2| function bar($aaa, $bbb = 0) {} diff --git a/data/fixtures/scopes/php/name/name.argument.formal.method.scope b/data/fixtures/scopes/php/name/name.argument.formal.method.scope new file mode 100644 index 0000000000..87ad34461e --- /dev/null +++ b/data/fixtures/scopes/php/name/name.argument.formal.method.scope @@ -0,0 +1,78 @@ +---< +1| class Foo { + +[#1 Removal] = 1:6-1:10 + >----< +1| class Foo { + +[#1 Leading delimiter] = 1:5-1:6 + >-< +1| class Foo { + +[#1 Trailing delimiter] = 1:9-1:10 + >-< +1| class Foo { + +[#1 Domain] = 1:0-3:1 + >----------- +1| class Foo { +2| function bar($aaa, $bbb = 0) {} +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 2:13-2:16 + >---< +2| function bar($aaa, $bbb = 0) {} + +[#2 Leading delimiter] = 2:12-2:13 + >-< +2| function bar($aaa, $bbb = 0) {} + +[#2 Domain] = 2:4-2:35 + >-------------------------------< +2| function bar($aaa, $bbb = 0) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Removal] = +[#3 Domain] = 2:17-2:21 + >----< +2| function bar($aaa, $bbb = 0) {} + +[#3 Insertion delimiter] = " " + + +[#4 Content] = 2:23-2:27 + >----< +2| function bar($aaa, $bbb = 0) {} + +[#4 Removal] = 2:23-2:28 + >-----< +2| function bar($aaa, $bbb = 0) {} + +[#4 Leading delimiter] = 2:22-2:23 + >-< +2| function bar($aaa, $bbb = 0) {} + +[#4 Trailing delimiter] = 2:27-2:28 + >-< +2| function bar($aaa, $bbb = 0) {} + +[#4 Domain] = 2:23-2:31 + >--------< +2| function bar($aaa, $bbb = 0) {} + +[#4 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/php/value/value.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..450e857c3f --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.constructor.iteration.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| function __construct($aaa = 0, $bbb = 1) {} +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:25-2:43 + >------------------< +2| function __construct($aaa = 0, $bbb = 1) {} diff --git a/data/fixtures/scopes/php/value/value.argument.formal.constructor.scope b/data/fixtures/scopes/php/value/value.argument.formal.constructor.scope new file mode 100644 index 0000000000..c189c05d5c --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.constructor.scope @@ -0,0 +1,42 @@ +-< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#1 Removal] = 2:29-2:33 + >----< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#1 Leading delimiter] = 2:29-2:32 + >---< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#1 Domain] = 2:25-2:33 + >--------< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:42-2:43 + >-< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#2 Removal] = 2:39-2:43 + >----< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#2 Leading delimiter] = 2:39-2:42 + >---< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#2 Domain] = 2:35-2:43 + >--------< +2| function __construct($aaa = 0, $bbb = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.argument.formal.iteration.scope b/data/fixtures/scopes/php/value/value.argument.formal.iteration.scope new file mode 100644 index 0000000000..0b4336e850 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.iteration.scope @@ -0,0 +1,16 @@ +----- +0| ------------------< +1| function foo($aaa = 0, $bbb = 1) {} diff --git a/data/fixtures/scopes/php/value/value.argument.formal.method.iteration.scope b/data/fixtures/scopes/php/value/value.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..260c48897f --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.method.iteration.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| function bar($aaa = 0, $bbb = 1) {} +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:17-2:35 + >------------------< +2| function bar($aaa = 0, $bbb = 1) {} diff --git a/data/fixtures/scopes/php/value/value.argument.formal.method.scope b/data/fixtures/scopes/php/value/value.argument.formal.method.scope new file mode 100644 index 0000000000..a56a5a1bb5 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.method.scope @@ -0,0 +1,42 @@ +-< +2| function bar($aaa = 0, $bbb = 1) {} + +[#1 Removal] = 2:21-2:25 + >----< +2| function bar($aaa = 0, $bbb = 1) {} + +[#1 Leading delimiter] = 2:21-2:24 + >---< +2| function bar($aaa = 0, $bbb = 1) {} + +[#1 Domain] = 2:17-2:25 + >--------< +2| function bar($aaa = 0, $bbb = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:34-2:35 + >-< +2| function bar($aaa = 0, $bbb = 1) {} + +[#2 Removal] = 2:31-2:35 + >----< +2| function bar($aaa = 0, $bbb = 1) {} + +[#2 Leading delimiter] = 2:31-2:34 + >---< +2| function bar($aaa = 0, $bbb = 1) {} + +[#2 Domain] = 2:27-2:35 + >--------< +2| function bar($aaa = 0, $bbb = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.argument.formal.scope b/data/fixtures/scopes/php/value/value.argument.formal.scope new file mode 100644 index 0000000000..3f154f636a --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.scope @@ -0,0 +1,40 @@ +-< +1| function foo($aaa = 0, $bbb = 1) {} + +[#1 Removal] = 1:17-1:21 + >----< +1| function foo($aaa = 0, $bbb = 1) {} + +[#1 Leading delimiter] = 1:17-1:20 + >---< +1| function foo($aaa = 0, $bbb = 1) {} + +[#1 Domain] = 1:13-1:21 + >--------< +1| function foo($aaa = 0, $bbb = 1) {} + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:30-1:31 + >-< +1| function foo($aaa = 0, $bbb = 1) {} + +[#2 Removal] = 1:27-1:31 + >----< +1| function foo($aaa = 0, $bbb = 1) {} + +[#2 Leading delimiter] = 1:27-1:30 + >---< +1| function foo($aaa = 0, $bbb = 1) {} + +[#2 Domain] = 1:23-1:31 + >--------< +1| function foo($aaa = 0, $bbb = 1) {} + +[#2 Insertion delimiter] = " " diff --git a/queries/php.scm b/queries/php.scm index 76115afd6c..ce50c342d1 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -436,14 +436,24 @@ (_) @value @name.trailing.startOf ) @_.domain -;;!! return 2; +;;!! (int $aaa = 0) +;;! ^^^ +;;! ^^^^ +;;! ^ +(simple_parameter + type: (_)? @type + name: (_) @name @value.leading.endOf + default_value: (_)? @value +) @_.domain + +;;!! return 0; ;;! ^ (return_statement "return" @_.leading.endOf (_) @value ) @_.domain -;;!! yield 2; +;;!! yield 0; ;;! ^ (_ (yield_expression @@ -454,14 +464,6 @@ ";"? @_.domain.end ) -;;!! (string $str) -;;! ^^^^^^ -;;! ^^^^ -(simple_parameter - type: (_) @type - name: (_) @name -) @_.domain - ;;!! (array ...$nums) ;;! ^^^^^ ;;! ^^^^^ From ecf24ae59aaac500b4801d54b41e2b79fb68d61c Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 16:33:52 +0100 Subject: [PATCH 12/21] argument list --- ...rgumentList.actual.constructor.empty.scope | 14 +++++ ...entList.actual.constructor.multiLine.scope | 34 ++++++++++++ ...ntList.actual.constructor.singleLine.scope | 14 +++++ .../argumentList.actual.empty.scope | 14 +++++ .../argumentList.actual.method.empty.scope | 14 +++++ ...argumentList.actual.method.multiLine.scope | 34 ++++++++++++ ...rgumentList.actual.method.singleLine.scope | 14 +++++ .../argumentList.actual.multiLine.scope | 34 ++++++++++++ .../argumentList.actual.singleLine.scope | 14 +++++ ...rgumentList.formal.constructor.empty.scope | 16 ++++++ ...entList.formal.constructor.multiLine.scope | 36 +++++++++++++ ...ntList.formal.constructor.singleLine.scope | 16 ++++++ .../argumentList.formal.empty.scope | 14 +++++ .../argumentList.formal.lambda.empty.scope | 14 +++++ .../argumentList.formal.lambda.empty2.scope | 14 +++++ ...argumentList.formal.lambda.multiLine.scope | 34 ++++++++++++ ...rgumentList.formal.lambda.multiLine2.scope | 34 ++++++++++++ ...rgumentList.formal.lambda.singleLine.scope | 14 +++++ ...gumentList.formal.lambda.singleLine2.scope | 14 +++++ .../argumentList.formal.method.empty.scope | 16 ++++++ ...argumentList.formal.method.multiLine.scope | 36 +++++++++++++ ...rgumentList.formal.method.singleLine.scope | 16 ++++++ .../argumentList.formal.multiLine.scope | 34 ++++++++++++ .../argumentList.formal.singleLine.scope | 14 +++++ queries/php.scm | 54 +++++++++++-------- 25 files changed, 541 insertions(+), 21 deletions(-) create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.method.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.method.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.method.singleLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.actual.singleLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.singleLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty2.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine2.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine2.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.method.empty.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.method.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.method.singleLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.multiLine.scope create mode 100644 data/fixtures/scopes/php/argumentList/argumentList.formal.singleLine.scope diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.empty.scope new file mode 100644 index 0000000000..3290a8b2fa --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.empty.scope @@ -0,0 +1,14 @@ +< +1| new Foo(); + +[Domain] = 1:0-1:9 + >---------< +1| new Foo(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.multiLine.scope new file mode 100644 index 0000000000..2f2f370c7b --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.multiLine.scope @@ -0,0 +1,34 @@ +---- +2| aaa, +3| bbb + -------< + +[Removal] = 1:8-4:0 + > +1| new Foo( +2| aaa, +3| bbb +4| ); + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| aaa, + +[Domain] = 1:0-4:1 + >-------- +1| new Foo( +2| aaa, +3| bbb +4| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.singleLine.scope new file mode 100644 index 0000000000..bc77898c31 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.constructor.singleLine.scope @@ -0,0 +1,14 @@ +--------< +1| new Foo(aaa, bbb); + +[Domain] = 1:0-1:17 + >-----------------< +1| new Foo(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.empty.scope new file mode 100644 index 0000000000..04f5dcd757 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.empty.scope @@ -0,0 +1,14 @@ +< +1| foo(); + +[Domain] = 1:0-1:5 + >-----< +1| foo(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.method.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.method.empty.scope new file mode 100644 index 0000000000..23d10679f9 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.method.empty.scope @@ -0,0 +1,14 @@ +bar(); +--- + +[Content] = +[Removal] = 1:10-1:10 + >< +1| $foo->bar(); + +[Domain] = 1:0-1:11 + >-----------< +1| $foo->bar(); + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.method.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.method.multiLine.scope new file mode 100644 index 0000000000..c5567d7521 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.method.multiLine.scope @@ -0,0 +1,34 @@ +bar( + aaa, + bbb +); +--- + +[Content] = 2:4-3:7 + >---- +2| aaa, +3| bbb + -------< + +[Removal] = 1:10-4:0 + > +1| $foo->bar( +2| aaa, +3| bbb +4| ); + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| aaa, + +[Domain] = 1:0-4:1 + >---------- +1| $foo->bar( +2| aaa, +3| bbb +4| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.method.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.method.singleLine.scope new file mode 100644 index 0000000000..de75a76ba6 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.method.singleLine.scope @@ -0,0 +1,14 @@ +bar(aaa, bbb); +--- + +[Content] = +[Removal] = 1:10-1:18 + >--------< +1| $foo->bar(aaa, bbb); + +[Domain] = 1:0-1:19 + >-------------------< +1| $foo->bar(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.multiLine.scope new file mode 100644 index 0000000000..3def60e39e --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.multiLine.scope @@ -0,0 +1,34 @@ +---- +2| aaa, +3| bbb + -------< + +[Removal] = 1:4-4:0 + > +1| foo( +2| aaa, +3| bbb +4| ); + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| aaa, + +[Domain] = 1:0-4:1 + >---- +1| foo( +2| aaa, +3| bbb +4| ); + -< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.actual.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.actual.singleLine.scope new file mode 100644 index 0000000000..f0c671d91b --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.actual.singleLine.scope @@ -0,0 +1,14 @@ +--------< +1| foo(aaa, bbb); + +[Domain] = 1:0-1:13 + >-------------< +1| foo(aaa, bbb); + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.empty.scope new file mode 100644 index 0000000000..01864297e5 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.empty.scope @@ -0,0 +1,16 @@ +< +2| function __construct() {} + +[Domain] = 2:4-2:29 + >-------------------------< +2| function __construct() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.multiLine.scope new file mode 100644 index 0000000000..9818f28d32 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.multiLine.scope @@ -0,0 +1,36 @@ +----- +3| $aaa, +4| $bbb + ------------< + +[Removal] = 2:25-5:4 + > +2| function __construct( +3| $aaa, +4| $bbb +5| ) {} + ----< + +[Leading delimiter] = 3:0-3:8 + >--------< +3| $aaa, + +[Domain] = 2:4-5:8 + >--------------------- +2| function __construct( +3| $aaa, +4| $bbb +5| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.singleLine.scope new file mode 100644 index 0000000000..40bcee21b2 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.constructor.singleLine.scope @@ -0,0 +1,16 @@ +----------< +2| function __construct($aaa, $bbb) {} + +[Domain] = 2:4-2:39 + >-----------------------------------< +2| function __construct($aaa, $bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.empty.scope new file mode 100644 index 0000000000..ac3729d833 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.empty.scope @@ -0,0 +1,14 @@ +< +1| function foo() {} + +[Domain] = 1:0-1:17 + >-----------------< +1| function foo() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty.scope new file mode 100644 index 0000000000..e1aed2fbff --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty.scope @@ -0,0 +1,14 @@ +< +1| function() {}; + +[Domain] = 1:0-1:13 + >-------------< +1| function() {}; + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty2.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty2.scope new file mode 100644 index 0000000000..6421093e1f --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.empty2.scope @@ -0,0 +1,14 @@ + 0; +--- + +[Content] = +[Removal] = 1:3-1:3 + >< +1| fn() => 0; + +[Domain] = 1:0-1:9 + >---------< +1| fn() => 0; + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..b904cf2344 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine.scope @@ -0,0 +1,34 @@ +----- +2| $aaa, +3| $bbb + --------< + +[Removal] = 1:9-4:0 + > +1| function( +2| $aaa, +3| $bbb +4| ) {}; + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| $aaa, + +[Domain] = 1:0-4:4 + >--------- +1| function( +2| $aaa, +3| $bbb +4| ) {}; + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine2.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine2.scope new file mode 100644 index 0000000000..f80b9685cb --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.multiLine2.scope @@ -0,0 +1,34 @@ + 0; +--- + +[Content] = 2:4-3:8 + >----- +2| $aaa, +3| $bbb + --------< + +[Removal] = 1:3-4:0 + > +1| fn( +2| $aaa, +3| $bbb +4| ) => 0; + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| $aaa, + +[Domain] = 1:0-4:6 + >--- +1| fn( +2| $aaa, +3| $bbb +4| ) => 0; + ------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..ba2a2fc47a --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine.scope @@ -0,0 +1,14 @@ +----------< +1| function($aaa, $bbb) {}; + +[Domain] = 1:0-1:23 + >-----------------------< +1| function($aaa, $bbb) {}; + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine2.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine2.scope new file mode 100644 index 0000000000..e316de2583 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.lambda.singleLine2.scope @@ -0,0 +1,14 @@ + 0; +--- + +[Content] = +[Removal] = 1:3-1:13 + >----------< +1| fn($aaa, $bbb) => 0; + +[Domain] = 1:0-1:19 + >-------------------< +1| fn($aaa, $bbb) => 0; + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.method.empty.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.method.empty.scope new file mode 100644 index 0000000000..b0d071c1e2 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.method.empty.scope @@ -0,0 +1,16 @@ +< +2| function bar() {} + +[Domain] = 2:4-2:21 + >-----------------< +2| function bar() {} + +[Insertion delimiter] = "" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.method.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.method.multiLine.scope new file mode 100644 index 0000000000..c587306aef --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.method.multiLine.scope @@ -0,0 +1,36 @@ +----- +3| $aaa, +4| $bbb + ------------< + +[Removal] = 2:17-5:4 + > +2| function bar( +3| $aaa, +4| $bbb +5| ) {} + ----< + +[Leading delimiter] = 3:0-3:8 + >--------< +3| $aaa, + +[Domain] = 2:4-5:8 + >------------- +2| function bar( +3| $aaa, +4| $bbb +5| ) {} + --------< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.method.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.method.singleLine.scope new file mode 100644 index 0000000000..b2dcb13a6c --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.method.singleLine.scope @@ -0,0 +1,16 @@ +----------< +2| function bar($aaa, $bbb) {} + +[Domain] = 2:4-2:31 + >---------------------------< +2| function bar($aaa, $bbb) {} + +[Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.multiLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.multiLine.scope new file mode 100644 index 0000000000..170bf60fc2 --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.multiLine.scope @@ -0,0 +1,34 @@ +----- +2| $aaa, +3| $bbb + --------< + +[Removal] = 1:13-4:0 + > +1| function foo( +2| $aaa, +3| $bbb +4| ) {} + < + +[Leading delimiter] = 2:0-2:4 + >----< +2| $aaa, + +[Domain] = 1:0-4:4 + >------------- +1| function foo( +2| $aaa, +3| $bbb +4| ) {} + ----< + +[Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argumentList/argumentList.formal.singleLine.scope b/data/fixtures/scopes/php/argumentList/argumentList.formal.singleLine.scope new file mode 100644 index 0000000000..77c8f837de --- /dev/null +++ b/data/fixtures/scopes/php/argumentList/argumentList.formal.singleLine.scope @@ -0,0 +1,14 @@ +----------< +1| function foo($aaa, $bbb) {} + +[Domain] = 1:0-1:27 + >---------------------------< +1| function foo($aaa, $bbb) {} + +[Insertion delimiter] = ", " diff --git a/queries/php.scm b/queries/php.scm index ce50c342d1..f8d106183b 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -370,8 +370,8 @@ name: (_) @name ) @_.domain -;;!! function foo($name) {} -;;! ^^^^^ +;;!! function foo($aaa, $bbb) {} +;;! ^^^^ ^^^^ ( (formal_parameters (_)? @_.leading.endOf @@ -398,34 +398,46 @@ (#single-or-multi-line-delimiter! @argumentOrParameter @_dummy ", " ",\n") ) +;;!! function foo($aaa, $bbb) {} +;;! ^^^^^^^^^^ (_ (formal_parameters - "(" @argumentOrParameter.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf - ) -) @argumentOrParameter.iteration.domain - -;;!! foo.bar(a, b); -;;! ^^^^ + "(" @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.bar(aaa, bbb); +;;! ^^^^^^^^ (binary_expression (function_call_expression (arguments - "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf - ) + "(" @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) ) -) @argumentOrParameter.iteration.domain +) @argumentList.domain @argumentOrParameter.iteration.domain -;;!! foo(a, b); -;;! ^^^^ -( +;;!! foo(aaa, bbb); +;;! ^^^^^^^^ +(expression_statement (_ (arguments - "(" @argumentOrParameter.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf - ")" @argumentOrParameter.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf - ) - ) @argumentOrParameter.iteration.domain - (#not-parent-type? @argumentOrParameter.iteration.domain binary_expression) + "(" @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 +) + +(arguments + "(" @name.iteration.start.endOf @value.iteration.start.endOf + ")" @name.iteration.end.startOf @value.iteration.end.startOf ) ;;!! foo(aaa: 0, bbb: 1); From 2d749a984385c1ec0dd092b784bb1b41acc22fc8 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 16:38:29 +0100 Subject: [PATCH 13/21] arguments --- .../argument.formal.lambda.iteration.scope | 11 +++++ .../argument.formal.lambda.multiLine.scope | 45 +++++++++++++++++++ .../argument.formal.lambda.singleLine.scope | 34 ++++++++++++++ .../php/name/name.iteration.block.scope | 23 ++++++++++ queries/php.scm | 6 ++- 5 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 data/fixtures/scopes/php/argument/argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/php/argument/argument.formal.lambda.multiLine.scope create mode 100644 data/fixtures/scopes/php/argument/argument.formal.lambda.singleLine.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.block.scope diff --git a/data/fixtures/scopes/php/argument/argument.formal.lambda.iteration.scope b/data/fixtures/scopes/php/argument/argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..80af447c27 --- /dev/null +++ b/data/fixtures/scopes/php/argument/argument.formal.lambda.iteration.scope @@ -0,0 +1,11 @@ +----------< +1| function($aaa, $bbb) {}; + +[Domain] = 1:0-1:23 + >-----------------------< +1| function($aaa, $bbb) {}; diff --git a/data/fixtures/scopes/php/argument/argument.formal.lambda.multiLine.scope b/data/fixtures/scopes/php/argument/argument.formal.lambda.multiLine.scope new file mode 100644 index 0000000000..e2db6c9ec8 --- /dev/null +++ b/data/fixtures/scopes/php/argument/argument.formal.lambda.multiLine.scope @@ -0,0 +1,45 @@ +----< +2| $aaa, + +[#1 Removal] = 2:4-3:4 + >----- +2| $aaa, +3| $bbb + ----< + +[#1 Trailing delimiter] = 2:8-3:4 + >- +2| $aaa, +3| $bbb + ----< + +[#1 Insertion delimiter] = ",\n" + + +[#2 Content] = +[#2 Domain] = 3:4-3:8 + >----< +3| $bbb + +[#2 Removal] = 2:8-3:8 + >- +2| $aaa, +3| $bbb + --------< + +[#2 Leading delimiter] = 2:8-3:4 + >- +2| $aaa, +3| $bbb + ----< + +[#2 Insertion delimiter] = ",\n" diff --git a/data/fixtures/scopes/php/argument/argument.formal.lambda.singleLine.scope b/data/fixtures/scopes/php/argument/argument.formal.lambda.singleLine.scope new file mode 100644 index 0000000000..f72b84b904 --- /dev/null +++ b/data/fixtures/scopes/php/argument/argument.formal.lambda.singleLine.scope @@ -0,0 +1,34 @@ +----< +1| function($aaa, $bbb) {}; + +[#1 Removal] = 1:9-1:15 + >------< +1| function($aaa, $bbb) {}; + +[#1 Trailing delimiter] = 1:13-1:15 + >--< +1| function($aaa, $bbb) {}; + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 1:15-1:19 + >----< +1| function($aaa, $bbb) {}; + +[#2 Removal] = 1:13-1:19 + >------< +1| function($aaa, $bbb) {}; + +[#2 Leading delimiter] = 1:13-1:15 + >--< +1| function($aaa, $bbb) {}; + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/php/name/name.iteration.block.scope b/data/fixtures/scopes/php/name/name.iteration.block.scope new file mode 100644 index 0000000000..6bd0a4634a --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.block.scope @@ -0,0 +1,23 @@ +----- +0| +1| class Foo { +2| function bar() { } +3| } + < diff --git a/queries/php.scm b/queries/php.scm index f8d106183b..745662ed75 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -485,10 +485,12 @@ ) @_.domain ;;!! catch (Exception $e) {} +;;! ^^^^^^^^^^^^ ;;! ^^^^^^^^^ +;;! ^^ (catch_clause - type: (_) @type @_.domain.start - name: (_) @name @_.domain.end + type: (_) @type @argumentOrParameter.start @_.domain.start + name: (_) @name @argumentOrParameter.end @_.domain.end ) (formal_parameters From 1e10f63e51e325b451b1bdaac3a4d4b9e33140dd Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 17:03:25 +0100 Subject: [PATCH 14/21] type --- .../scopes/java/type/type.return.scope | 38 ----------- ...rgument.formal.constructor.iteration.scope | 29 +++++++++ .../type.argument.formal.constructor.scope | 65 +++++++++++++++++++ .../type/type.argument.formal.iteration.scope | 12 +++- ...ype.argument.formal.lambda.iteration.scope | 16 +++++ .../type/type.argument.formal.lambda.scope | 44 +++++++++++++ ...ype.argument.formal.method.iteration.scope | 29 +++++++++ .../type/type.argument.formal.method.scope | 65 +++++++++++++++++++ .../fixtures/scopes/php/type/type.class.scope | 16 +++++ data/fixtures/scopes/php/type/type.enum.scope | 16 +++++ .../scopes/php/type/type.field.class.scope | 31 +++++++-- .../php/type/type.field.interface.scope | 46 +++++++++++++ .../scopes/php/type/type.interface.scope | 16 +++++ .../php/type/type.iteration.class.scope | 16 +++++ .../php/type/type.iteration.document.scope | 14 ++++ .../php/type/type.iteration.interface.scope | 16 +++++ .../scopes/php/type/type.return.method.scope | 42 ++++++++++++ .../scopes/php/type/type.return.scope | 21 ++++++ .../common/src/scopeSupportFacets/java.ts | 2 +- packages/common/src/scopeSupportFacets/php.ts | 6 +- queries/php.scm | 44 ++++++++----- 21 files changed, 517 insertions(+), 67 deletions(-) delete mode 100644 data/fixtures/scopes/java/type/type.return.scope create mode 100644 data/fixtures/scopes/php/type/type.argument.formal.constructor.iteration.scope create mode 100644 data/fixtures/scopes/php/type/type.argument.formal.constructor.scope create mode 100644 data/fixtures/scopes/php/type/type.argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/php/type/type.argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/php/type/type.argument.formal.method.iteration.scope create mode 100644 data/fixtures/scopes/php/type/type.argument.formal.method.scope create mode 100644 data/fixtures/scopes/php/type/type.class.scope create mode 100644 data/fixtures/scopes/php/type/type.enum.scope create mode 100644 data/fixtures/scopes/php/type/type.field.interface.scope create mode 100644 data/fixtures/scopes/php/type/type.interface.scope create mode 100644 data/fixtures/scopes/php/type/type.iteration.class.scope create mode 100644 data/fixtures/scopes/php/type/type.iteration.document.scope create mode 100644 data/fixtures/scopes/php/type/type.iteration.interface.scope create mode 100644 data/fixtures/scopes/php/type/type.return.method.scope create mode 100644 data/fixtures/scopes/php/type/type.return.scope diff --git a/data/fixtures/scopes/java/type/type.return.scope b/data/fixtures/scopes/java/type/type.return.scope deleted file mode 100644 index 74a68959c5..0000000000 --- a/data/fixtures/scopes/java/type/type.return.scope +++ /dev/null @@ -1,38 +0,0 @@ -public class Foo { - public int foo() {} -} ---- - -[#1 Content] = -[#1 Removal] = -[#1 Domain] = 0:0-2:1 - >------------------ -0| public class Foo { -1| public int foo() {} -2| } - -< - -[#1 Insertion delimiter] = " " - - -[#2 Content] = 1:11-1:14 - >---< -1| public int foo() {} - -[#2 Removal] = 1:11-1:15 - >----< -1| public int foo() {} - -[#2 Leading delimiter] = 1:10-1:11 - >-< -1| public int foo() {} - -[#2 Trailing delimiter] = 1:14-1:15 - >-< -1| public int foo() {} - -[#2 Domain] = 1:4-1:23 - >-------------------< -1| public int foo() {} - -[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.argument.formal.constructor.iteration.scope b/data/fixtures/scopes/php/type/type.argument.formal.constructor.iteration.scope new file mode 100644 index 0000000000..1d0263565c --- /dev/null +++ b/data/fixtures/scopes/php/type/type.argument.formal.constructor.iteration.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| public function __construct(int $aaa, int $bbb) {} +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:32-2:50 + >------------------< +2| public function __construct(int $aaa, int $bbb) {} diff --git a/data/fixtures/scopes/php/type/type.argument.formal.constructor.scope b/data/fixtures/scopes/php/type/type.argument.formal.constructor.scope new file mode 100644 index 0000000000..05d067d1a1 --- /dev/null +++ b/data/fixtures/scopes/php/type/type.argument.formal.constructor.scope @@ -0,0 +1,65 @@ +----------- +1| class Foo { +2| public function __construct(int $aaa, int $bbb) {} +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---< +2| public function __construct(int $aaa, int $bbb) {} + +[#2 Removal] = 2:32-2:36 + >----< +2| public function __construct(int $aaa, int $bbb) {} + +[#2 Trailing delimiter] = 2:35-2:36 + >-< +2| public function __construct(int $aaa, int $bbb) {} + +[#2 Domain] = 2:32-2:40 + >--------< +2| public function __construct(int $aaa, int $bbb) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:42-2:45 + >---< +2| public function __construct(int $aaa, int $bbb) {} + +[#3 Removal] = 2:42-2:46 + >----< +2| public function __construct(int $aaa, int $bbb) {} + +[#3 Leading delimiter] = 2:41-2:42 + >-< +2| public function __construct(int $aaa, int $bbb) {} + +[#3 Trailing delimiter] = 2:45-2:46 + >-< +2| public function __construct(int $aaa, int $bbb) {} + +[#3 Domain] = 2:42-2:50 + >--------< +2| public function __construct(int $aaa, int $bbb) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.argument.formal.iteration.scope b/data/fixtures/scopes/php/type/type.argument.formal.iteration.scope index 49c858ecaf..8d15e705ba 100644 --- a/data/fixtures/scopes/php/type/type.argument.formal.iteration.scope +++ b/data/fixtures/scopes/php/type/type.argument.formal.iteration.scope @@ -2,7 +2,15 @@ function foo(int $aaa, int $bbb) {} --- -[Content] = -[Domain] = 1:13-1:31 +[#1 Content] = +[#1 Domain] = 0:0-1:35 + >----- +0| ------------------< 1| function foo(int $aaa, int $bbb) {} diff --git a/data/fixtures/scopes/php/type/type.argument.formal.lambda.iteration.scope b/data/fixtures/scopes/php/type/type.argument.formal.lambda.iteration.scope new file mode 100644 index 0000000000..0d7e55e69c --- /dev/null +++ b/data/fixtures/scopes/php/type/type.argument.formal.lambda.iteration.scope @@ -0,0 +1,16 @@ + 0; +--- + +[#1 Content] = +[#1 Domain] = 0:0-1:28 + >----- +0| 0; + ----------------------------< + + +[#2 Content] = +[#2 Domain] = 1:3-1:21 + >------------------< +1| fn(int $aaa, int $bbb) => 0; diff --git a/data/fixtures/scopes/php/type/type.argument.formal.lambda.scope b/data/fixtures/scopes/php/type/type.argument.formal.lambda.scope new file mode 100644 index 0000000000..2d65e4539a --- /dev/null +++ b/data/fixtures/scopes/php/type/type.argument.formal.lambda.scope @@ -0,0 +1,44 @@ + 0; +--- + +[#1 Content] = 1:3-1:6 + >---< +1| fn(int $aaa, int $bbb) => 0; + +[#1 Removal] = 1:3-1:7 + >----< +1| fn(int $aaa, int $bbb) => 0; + +[#1 Trailing delimiter] = 1:6-1:7 + >-< +1| fn(int $aaa, int $bbb) => 0; + +[#1 Domain] = 1:3-1:11 + >--------< +1| fn(int $aaa, int $bbb) => 0; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:13-1:16 + >---< +1| fn(int $aaa, int $bbb) => 0; + +[#2 Removal] = 1:13-1:17 + >----< +1| fn(int $aaa, int $bbb) => 0; + +[#2 Leading delimiter] = 1:12-1:13 + >-< +1| fn(int $aaa, int $bbb) => 0; + +[#2 Trailing delimiter] = 1:16-1:17 + >-< +1| fn(int $aaa, int $bbb) => 0; + +[#2 Domain] = 1:13-1:21 + >--------< +1| fn(int $aaa, int $bbb) => 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.argument.formal.method.iteration.scope b/data/fixtures/scopes/php/type/type.argument.formal.method.iteration.scope new file mode 100644 index 0000000000..596c2a36c6 --- /dev/null +++ b/data/fixtures/scopes/php/type/type.argument.formal.method.iteration.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| public function bar(int $aaa, int $bbb) {} +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:24-2:42 + >------------------< +2| public function bar(int $aaa, int $bbb) {} diff --git a/data/fixtures/scopes/php/type/type.argument.formal.method.scope b/data/fixtures/scopes/php/type/type.argument.formal.method.scope new file mode 100644 index 0000000000..7ba2c8b36c --- /dev/null +++ b/data/fixtures/scopes/php/type/type.argument.formal.method.scope @@ -0,0 +1,65 @@ +----------- +1| class Foo { +2| public function bar(int $aaa, int $bbb) {} +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---< +2| public function bar(int $aaa, int $bbb) {} + +[#2 Removal] = 2:24-2:28 + >----< +2| public function bar(int $aaa, int $bbb) {} + +[#2 Trailing delimiter] = 2:27-2:28 + >-< +2| public function bar(int $aaa, int $bbb) {} + +[#2 Domain] = 2:24-2:32 + >--------< +2| public function bar(int $aaa, int $bbb) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:34-2:37 + >---< +2| public function bar(int $aaa, int $bbb) {} + +[#3 Removal] = 2:34-2:38 + >----< +2| public function bar(int $aaa, int $bbb) {} + +[#3 Leading delimiter] = 2:33-2:34 + >-< +2| public function bar(int $aaa, int $bbb) {} + +[#3 Trailing delimiter] = 2:37-2:38 + >-< +2| public function bar(int $aaa, int $bbb) {} + +[#3 Domain] = 2:34-2:42 + >--------< +2| public function bar(int $aaa, int $bbb) {} + +[#3 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.class.scope b/data/fixtures/scopes/php/type/type.class.scope new file mode 100644 index 0000000000..dbe86809d0 --- /dev/null +++ b/data/fixtures/scopes/php/type/type.class.scope @@ -0,0 +1,16 @@ +------------< +1| class Foo {} + +[Removal] = 0:5-1:12 + > +0| -----------< +1| enum Foo {} + +[Removal] = 0:5-1:11 + > +0| ----------- +1| class Foo { +2| public string $bar; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ------< 2| public string $bar; -[Removal] = 2:11-2:18 +[#2 Removal] = 2:11-2:18 >-------< 2| public string $bar; -[Leading delimiter] = 2:10-2:11 +[#2 Leading delimiter] = 2:10-2:11 >-< 2| public string $bar; -[Trailing delimiter] = 2:17-2:18 +[#2 Trailing delimiter] = 2:17-2:18 >-< 2| public string $bar; -[Domain] = 2:4-2:23 +[#2 Domain] = 2:4-2:23 >-------------------< 2| public string $bar; -[Insertion delimiter] = " " +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.field.interface.scope b/data/fixtures/scopes/php/type/type.field.interface.scope new file mode 100644 index 0000000000..e977980a7a --- /dev/null +++ b/data/fixtures/scopes/php/type/type.field.interface.scope @@ -0,0 +1,46 @@ +--------------- +1| interface Foo { +2| public const int bar = 0; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---< +2| public const int bar = 0; + +[#2 Removal] = 2:17-2:21 + >----< +2| public const int bar = 0; + +[#2 Leading delimiter] = 2:16-2:17 + >-< +2| public const int bar = 0; + +[#2 Trailing delimiter] = 2:20-2:21 + >-< +2| public const int bar = 0; + +[#2 Domain] = 2:4-2:29 + >-------------------------< +2| public const int bar = 0; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.interface.scope b/data/fixtures/scopes/php/type/type.interface.scope new file mode 100644 index 0000000000..e5a214b7dc --- /dev/null +++ b/data/fixtures/scopes/php/type/type.interface.scope @@ -0,0 +1,16 @@ +----------------< +1| interface Foo {} + +[Removal] = 0:5-1:16 + > +0| ----- +0| -< +1| class Foo { } diff --git a/data/fixtures/scopes/php/type/type.iteration.document.scope b/data/fixtures/scopes/php/type/type.iteration.document.scope new file mode 100644 index 0000000000..ac763c63c2 --- /dev/null +++ b/data/fixtures/scopes/php/type/type.iteration.document.scope @@ -0,0 +1,14 @@ + + +0| +1| ----- +0| -< +1| interface Foo { } diff --git a/data/fixtures/scopes/php/type/type.return.method.scope b/data/fixtures/scopes/php/type/type.return.method.scope new file mode 100644 index 0000000000..f110ae17fc --- /dev/null +++ b/data/fixtures/scopes/php/type/type.return.method.scope @@ -0,0 +1,42 @@ +----------- +1| class Foo { +2| public function bar(): int {} +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---< +2| public function bar(): int {} + +[#2 Removal] = 2:25-2:30 + >-----< +2| public function bar(): int {} + +[#2 Leading delimiter] = 2:25-2:27 + >--< +2| public function bar(): int {} + +[#2 Domain] = 2:4-2:33 + >-----------------------------< +2| public function bar(): int {} + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/type/type.return.scope b/data/fixtures/scopes/php/type/type.return.scope new file mode 100644 index 0000000000..6ab204a2ea --- /dev/null +++ b/data/fixtures/scopes/php/type/type.return.scope @@ -0,0 +1,21 @@ +---< +1| function foo(): int {} + +[Removal] = 1:14-1:19 + >-----< +1| function foo(): int {} + +[Leading delimiter] = 1:14-1:16 + >--< +1| function foo(): int {} + +[Domain] = 1:0-1:22 + >----------------------< +1| function foo(): int {} + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/java.ts b/packages/common/src/scopeSupportFacets/java.ts index 013f0bb1e8..ad0a41da3b 100644 --- a/packages/common/src/scopeSupportFacets/java.ts +++ b/packages/common/src/scopeSupportFacets/java.ts @@ -195,7 +195,6 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "type.foreach": supported, "type.field.class": supported, "type.field.interface": supported, - "type.return": supported, "type.return.method": supported, "type.constant": supported, "type.variable.uninitialized": supported, @@ -251,6 +250,7 @@ export const javaScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.formal": notApplicable, "type.argument.formal.iteration": notApplicable, "interior.function": notApplicable, + "type.return": notApplicable, // Element and tags element: notApplicable, diff --git a/packages/common/src/scopeSupportFacets/php.ts b/packages/common/src/scopeSupportFacets/php.ts index a6661271d9..c99e2fb08b 100644 --- a/packages/common/src/scopeSupportFacets/php.ts +++ b/packages/common/src/scopeSupportFacets/php.ts @@ -204,11 +204,8 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "type.argument.catch": supported, "type.return": supported, "type.return.method": supported, - "type.foreach": supported, "type.field.class": supported, "type.field.interface": supported, - "type.constant": supported, - "type.variable.initialized": supported, "type.class": supported, "type.interface": supported, "type.enum": supported, @@ -300,6 +297,7 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "statement.constant": notApplicable, "name.constant": notApplicable, "value.constant": notApplicable, + "type.constant": notApplicable, // Unenclosed collection items "collectionItem.unenclosed.singleLine": notApplicable, @@ -323,4 +321,6 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { // Miscellaneous "statement.misc": notApplicable, + "type.variable.initialized": notApplicable, + "type.foreach": notApplicable, }; diff --git a/queries/php.scm b/queries/php.scm index 745662ed75..910ccc4f1b 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -45,8 +45,8 @@ ) ( - (program) @name.iteration @value.iteration - (#document-range! @name.iteration @value.iteration) + (program) @name.iteration @value.iteration @type.iteration + (#document-range! @name.iteration @value.iteration @type.iteration) ) ;;!! { } @@ -155,38 +155,46 @@ "{" @namedFunction.iteration.start.endOf "}" @namedFunction.iteration.end.startOf ) -) @class @name.domain +) @class @type @name.domain ;;!! class Foo { } ;;!! interface Foo { } (declaration_list - "{" @statement.iteration.start.endOf @name.iteration.start.endOf @value.iteration.start.endOf - "}" @statement.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf + "{" @statement.iteration.start.endOf + "}" @statement.iteration.end.startOf +) +(declaration_list + "{" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) ;;!! interface Foo {} (interface_declaration name: (_) @name -) @name.domain +) @type @name.domain ;;!! enum Foo {} (enum_declaration name: (_) @name body: (_ - "{" @name.iteration.start.endOf @value.iteration.start.endOf - "}" @name.iteration.end.startOf @value.iteration.end.startOf + "{" @name.iteration.start.endOf @value.iteration.start.endOf @type.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf @type.iteration.end.startOf ) -) @name.domain +) @type @name.domain ;;!! function foo() {} [ (function_definition name: (_) @name + parameters: (_)? @type.leading.endOf + return_type: (_)? @type ) (method_declaration name: (_) @name + parameters: (_)? @type.leading.endOf + return_type: (_)? @type ) -] @namedFunction @name.domain +] @namedFunction @_.domain (expression_statement (assignment_expression @@ -498,16 +506,16 @@ ")" @type.iteration.end.startOf @name.iteration.end.startOf @value.iteration.end.startOf ) @_.domain -;;!! (string) $str; -;;! ^^^^^^ +;;!! (int) $str; +;;! ^^^ (cast_expression type: (_) @type value: (_) @_.removal.end.startOf ) @_.removal.start.startOf @_.domain -;;!! public string $value; -;;! ^^^^^^ -;;! ^^^^^^ +;;!! public int $foo; +;;! ^^^ +;;! ^^^^ (property_declaration (_)? @name.removal.start.startOf type: (_)? @type @name.removal.start.startOf @@ -517,10 +525,12 @@ ) @name.removal.start.startOf ) @_.domain @statement -;;!! const bar = 0; +;;!! const int foo = 0; ;;! ^^^ -;;! ^ +;;! ^^^ +;;! ^ (const_declaration + type: (_)? @type (const_element (name) @name @value.leading.endOf (_) @value @name.removal.end.startOf From db39cf7f7e8bbfaa53a941e81520cfa93bdced5b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 17:03:41 +0100 Subject: [PATCH 15/21] catch argument --- .../scopes/php/argument/argument.catch.scope | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 data/fixtures/scopes/php/argument/argument.catch.scope diff --git a/data/fixtures/scopes/php/argument/argument.catch.scope b/data/fixtures/scopes/php/argument/argument.catch.scope new file mode 100644 index 0000000000..e548698aa1 --- /dev/null +++ b/data/fixtures/scopes/php/argument/argument.catch.scope @@ -0,0 +1,12 @@ +------------< +2| catch (Exception $e) {} + +[Insertion delimiter] = " " From c58785d29bdb1377e5a01284d48ef925f501abf3 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 17:12:01 +0100 Subject: [PATCH 16/21] block iteration --- .../php/name/name.iteration.block.scope | 6 ++++ .../php/name/name.iteration.block2.scope | 16 ++++++++++ .../php/name/name.iteration.block3.scope | 32 +++++++++++++++++++ .../php/name/name.iteration.block4.scope | 16 ++++++++++ .../statement/statement.iteration.block.scope | 29 +++++++++++++++++ .../statement.iteration.block2.scope | 16 ++++++++++ .../statement.iteration.block3.scope | 32 +++++++++++++++++++ .../statement.iteration.block4.scope | 16 ++++++++++ .../php/value/value.iteration.block.scope | 29 +++++++++++++++++ .../php/value/value.iteration.block2.scope | 16 ++++++++++ .../php/value/value.iteration.block3.scope | 32 +++++++++++++++++++ .../php/value/value.iteration.block4.scope | 16 ++++++++++ packages/common/src/scopeSupportFacets/php.ts | 2 +- queries/php.scm | 7 ++++ 14 files changed, 264 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/php/name/name.iteration.block2.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.block3.scope create mode 100644 data/fixtures/scopes/php/name/name.iteration.block4.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.block.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.block2.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.block3.scope create mode 100644 data/fixtures/scopes/php/statement/statement.iteration.block4.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.block.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.block2.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.block3.scope create mode 100644 data/fixtures/scopes/php/value/value.iteration.block4.scope diff --git a/data/fixtures/scopes/php/name/name.iteration.block.scope b/data/fixtures/scopes/php/name/name.iteration.block.scope index 6bd0a4634a..39725a0bb0 100644 --- a/data/fixtures/scopes/php/name/name.iteration.block.scope +++ b/data/fixtures/scopes/php/name/name.iteration.block.scope @@ -21,3 +21,9 @@ class Foo { 2| function bar() { } 3| } < + + +[#3 Content] = +[#3 Domain] = 2:20-2:21 + >-< +2| function bar() { } diff --git a/data/fixtures/scopes/php/name/name.iteration.block2.scope b/data/fixtures/scopes/php/name/name.iteration.block2.scope new file mode 100644 index 0000000000..5dfac32c5e --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.block2.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| function foo() { } diff --git a/data/fixtures/scopes/php/name/name.iteration.block3.scope b/data/fixtures/scopes/php/name/name.iteration.block3.scope new file mode 100644 index 0000000000..0393267d7d --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.block3.scope @@ -0,0 +1,32 @@ +----- +0| -< +1| if (true) { } + + +[#3 Content] = +[#3 Domain] = 2:17-2:18 + >-< +2| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 3:6-3:7 + >-< +3| else { } diff --git a/data/fixtures/scopes/php/name/name.iteration.block4.scope b/data/fixtures/scopes/php/name/name.iteration.block4.scope new file mode 100644 index 0000000000..cc0bcdb62e --- /dev/null +++ b/data/fixtures/scopes/php/name/name.iteration.block4.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| while (true) { } diff --git a/data/fixtures/scopes/php/statement/statement.iteration.block.scope b/data/fixtures/scopes/php/statement/statement.iteration.block.scope new file mode 100644 index 0000000000..39725a0bb0 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.iteration.block.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| function bar() { } +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:20-2:21 + >-< +2| function bar() { } diff --git a/data/fixtures/scopes/php/statement/statement.iteration.block2.scope b/data/fixtures/scopes/php/statement/statement.iteration.block2.scope new file mode 100644 index 0000000000..5dfac32c5e --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.iteration.block2.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| function foo() { } diff --git a/data/fixtures/scopes/php/statement/statement.iteration.block3.scope b/data/fixtures/scopes/php/statement/statement.iteration.block3.scope new file mode 100644 index 0000000000..0393267d7d --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.iteration.block3.scope @@ -0,0 +1,32 @@ +----- +0| -< +1| if (true) { } + + +[#3 Content] = +[#3 Domain] = 2:17-2:18 + >-< +2| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 3:6-3:7 + >-< +3| else { } diff --git a/data/fixtures/scopes/php/statement/statement.iteration.block4.scope b/data/fixtures/scopes/php/statement/statement.iteration.block4.scope new file mode 100644 index 0000000000..cc0bcdb62e --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.iteration.block4.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| while (true) { } diff --git a/data/fixtures/scopes/php/value/value.iteration.block.scope b/data/fixtures/scopes/php/value/value.iteration.block.scope new file mode 100644 index 0000000000..39725a0bb0 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.iteration.block.scope @@ -0,0 +1,29 @@ +----- +0| +1| class Foo { +2| function bar() { } +3| } + < + + +[#3 Content] = +[#3 Domain] = 2:20-2:21 + >-< +2| function bar() { } diff --git a/data/fixtures/scopes/php/value/value.iteration.block2.scope b/data/fixtures/scopes/php/value/value.iteration.block2.scope new file mode 100644 index 0000000000..5dfac32c5e --- /dev/null +++ b/data/fixtures/scopes/php/value/value.iteration.block2.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| function foo() { } diff --git a/data/fixtures/scopes/php/value/value.iteration.block3.scope b/data/fixtures/scopes/php/value/value.iteration.block3.scope new file mode 100644 index 0000000000..0393267d7d --- /dev/null +++ b/data/fixtures/scopes/php/value/value.iteration.block3.scope @@ -0,0 +1,32 @@ +----- +0| -< +1| if (true) { } + + +[#3 Content] = +[#3 Domain] = 2:17-2:18 + >-< +2| else if (false) { } + + +[#4 Content] = +[#4 Domain] = 3:6-3:7 + >-< +3| else { } diff --git a/data/fixtures/scopes/php/value/value.iteration.block4.scope b/data/fixtures/scopes/php/value/value.iteration.block4.scope new file mode 100644 index 0000000000..cc0bcdb62e --- /dev/null +++ b/data/fixtures/scopes/php/value/value.iteration.block4.scope @@ -0,0 +1,16 @@ +----- +0| -< +1| while (true) { } diff --git a/packages/common/src/scopeSupportFacets/php.ts b/packages/common/src/scopeSupportFacets/php.ts index c99e2fb08b..138f11c36e 100644 --- a/packages/common/src/scopeSupportFacets/php.ts +++ b/packages/common/src/scopeSupportFacets/php.ts @@ -213,7 +213,6 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "type.iteration.document": supported, "type.iteration.class": supported, "type.iteration.interface": supported, - "type.iteration.block": supported, "interior.class": supported, "interior.interface": supported, @@ -323,4 +322,5 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "statement.misc": notApplicable, "type.variable.initialized": notApplicable, "type.foreach": notApplicable, + "type.iteration.block": notApplicable, }; diff --git a/queries/php.scm b/queries/php.scm index 910ccc4f1b..02f56b3e4a 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -58,6 +58,13 @@ . ) +;;!! { } +;;! ^ +(compound_statement + "{" @name.iteration.start.endOf @value.iteration.start.endOf @statement.iteration.start.endOf + "}" @name.iteration.end.startOf @value.iteration.end.startOf @statement.iteration.end.startOf +) + [ (shell_command_expression) (string) From 59fe1229750576514f2fa3358318ecd4f79f6f0d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 17:32:48 +0100 Subject: [PATCH 17/21] Restore Java --- queries/java.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/queries/java.scm b/queries/java.scm index bf876be3a3..5eacffd201 100644 --- a/queries/java.scm +++ b/queries/java.scm @@ -95,8 +95,8 @@ ) ( - (program) @name.iteration @value.iteration - (#document-range! @name.iteration @value.iteration) + (program) @name.iteration @value.iteration @type.iteration + (#document-range! @name.iteration @value.iteration @type.iteration) ) ;;!! class MyClass { } From 5194e1e98dff05e1b6f25a70948921d79d8005ee Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 17:47:38 +0100 Subject: [PATCH 18/21] restore function call matching --- queries/php.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/queries/php.scm b/queries/php.scm index 02f56b3e4a..088120ad16 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -439,7 +439,7 @@ ;;!! foo(aaa, bbb); ;;! ^^^^^^^^ -(expression_statement +( (_ (arguments "(" @argumentList.removal.start.endOf @argumentOrParameter.iteration.start.endOf @@ -448,6 +448,7 @@ (#empty-single-multi-delimiter! @argumentList @argumentList "" ", " ",\n") (#child-range! @argumentList 1 -2) ) @argumentList.domain @argumentOrParameter.iteration.domain + (#not-parent-type? @argumentList.domain binary_expression) ) (arguments From 62e761be0a42693cbaa19dceb40afc8d92c787e5 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 17:51:04 +0100 Subject: [PATCH 19/21] nullsafe_member_call_expression --- .../php/functionCall/functionCall.method2.scope | 11 +++++++++++ .../functionCallee/functionCallee.method2.scope | 14 ++++++++++++++ queries/php.scm | 6 ++++++ 3 files changed, 31 insertions(+) create mode 100644 data/fixtures/scopes/php/functionCall/functionCall.method2.scope create mode 100644 data/fixtures/scopes/php/functionCallee/functionCallee.method2.scope diff --git a/data/fixtures/scopes/php/functionCall/functionCall.method2.scope b/data/fixtures/scopes/php/functionCall/functionCall.method2.scope new file mode 100644 index 0000000000..3bb6dcf906 --- /dev/null +++ b/data/fixtures/scopes/php/functionCall/functionCall.method2.scope @@ -0,0 +1,11 @@ +bar(); +--- + +[Content] = +[Removal] = +[Domain] = 1:0-1:12 + >------------< +1| $foo?->bar(); + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/functionCallee/functionCallee.method2.scope b/data/fixtures/scopes/php/functionCallee/functionCallee.method2.scope new file mode 100644 index 0000000000..550dd1557d --- /dev/null +++ b/data/fixtures/scopes/php/functionCallee/functionCallee.method2.scope @@ -0,0 +1,14 @@ +bar(); +--- + +[Content] = +[Removal] = 1:0-1:10 + >----------< +1| $foo?->bar(); + +[Domain] = 1:0-1:12 + >------------< +1| $foo?->bar(); + +[Insertion delimiter] = " " diff --git a/queries/php.scm b/queries/php.scm index 088120ad16..6561487ac7 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -231,6 +231,12 @@ name: (_) @functionCallee.end ) @functionCall @functionCallee.domain +;;!! foo()?->bar() +(nullsafe_member_call_expression + object: (_) @functionCallee.start + name: (_) @functionCallee.end +) @functionCall @functionCallee.domain + ;;!! new Foo() (object_creation_expression "new" @functionCallee.start From a8bb3e8ba37969eff3976158740218f2a763188f Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 18:43:26 +0100 Subject: [PATCH 20/21] trim trailing --- queries/php.scm | 1 - 1 file changed, 1 deletion(-) diff --git a/queries/php.scm b/queries/php.scm index 6561487ac7..c5ae6f7647 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -346,7 +346,6 @@ ) ;;!! try {} catch () {} finally {} -;;! (try_statement "try" @branch.start body: (_) @branch.end From 58f81aea9a329516eabd32822ec36921083d1727 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Thu, 26 Feb 2026 19:38:55 +0100 Subject: [PATCH 21/21] More facets --- .../statement/statement.field.interface.scope | 41 +++++++++++++++++++ .../statement.field.interface2.scope | 41 +++++++++++++++++++ .../php/statement/statement.update.scope | 16 ++++++++ ...lue.argument.formal.lambda.iteration.scope | 16 ++++++++ .../value/value.argument.formal.lambda.scope | 40 ++++++++++++++++++ .../php/value/value.return.lambda.scope | 21 ++++++++++ packages/common/src/scopeSupportFacets/php.ts | 7 ++++ queries/php.scm | 5 ++- 8 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 data/fixtures/scopes/php/statement/statement.field.interface.scope create mode 100644 data/fixtures/scopes/php/statement/statement.field.interface2.scope create mode 100644 data/fixtures/scopes/php/statement/statement.update.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.lambda.iteration.scope create mode 100644 data/fixtures/scopes/php/value/value.argument.formal.lambda.scope create mode 100644 data/fixtures/scopes/php/value/value.return.lambda.scope diff --git a/data/fixtures/scopes/php/statement/statement.field.interface.scope b/data/fixtures/scopes/php/statement/statement.field.interface.scope new file mode 100644 index 0000000000..7136723c1c --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.field.interface.scope @@ -0,0 +1,41 @@ +--------------- +1| interface Foo { +2| public const bar = 0; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| ---------------------< +2| public const bar = 0; + +[#2 Removal] = 2:0-3:0 + >------------------------- +2| public const bar = 0; +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| public const bar = 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.field.interface2.scope b/data/fixtures/scopes/php/statement/statement.field.interface2.scope new file mode 100644 index 0000000000..3daf6e24e5 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.field.interface2.scope @@ -0,0 +1,41 @@ +--------------- +1| interface Foo { +2| public const int bar = 0; +3| } + -< + +[#1 Removal] = 0:5-3:1 + > +0| -------------------------< +2| public const int bar = 0; + +[#2 Removal] = 2:0-3:0 + >----------------------------- +2| public const int bar = 0; +3| } + < + +[#2 Leading delimiter] = 2:0-2:4 + >----< +2| public const int bar = 0; + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/php/statement/statement.update.scope b/data/fixtures/scopes/php/statement/statement.update.scope new file mode 100644 index 0000000000..4b7a5d7c21 --- /dev/null +++ b/data/fixtures/scopes/php/statement/statement.update.scope @@ -0,0 +1,16 @@ +-------< +1| $foo++; + +[Removal] = 0:5-1:7 + > +0| ----- +0| ------------------< +1| function ($aaa = 0, $bbb = 1) {}; diff --git a/data/fixtures/scopes/php/value/value.argument.formal.lambda.scope b/data/fixtures/scopes/php/value/value.argument.formal.lambda.scope new file mode 100644 index 0000000000..1e9de44ec1 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.argument.formal.lambda.scope @@ -0,0 +1,40 @@ +-< +1| function ($aaa = 0, $bbb = 1) {}; + +[#1 Removal] = 1:14-1:18 + >----< +1| function ($aaa = 0, $bbb = 1) {}; + +[#1 Leading delimiter] = 1:14-1:17 + >---< +1| function ($aaa = 0, $bbb = 1) {}; + +[#1 Domain] = 1:10-1:18 + >--------< +1| function ($aaa = 0, $bbb = 1) {}; + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:27-1:28 + >-< +1| function ($aaa = 0, $bbb = 1) {}; + +[#2 Removal] = 1:24-1:28 + >----< +1| function ($aaa = 0, $bbb = 1) {}; + +[#2 Leading delimiter] = 1:24-1:27 + >---< +1| function ($aaa = 0, $bbb = 1) {}; + +[#2 Domain] = 1:20-1:28 + >--------< +1| function ($aaa = 0, $bbb = 1) {}; + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/php/value/value.return.lambda.scope b/data/fixtures/scopes/php/value/value.return.lambda.scope new file mode 100644 index 0000000000..4aa2dcbae0 --- /dev/null +++ b/data/fixtures/scopes/php/value/value.return.lambda.scope @@ -0,0 +1,21 @@ + 0; +--- + +[Content] = 1:8-1:9 + >-< +1| fn() => 0; + +[Removal] = 1:7-1:9 + >--< +1| fn() => 0; + +[Leading delimiter] = 1:7-1:8 + >-< +1| fn() => 0; + +[Domain] = 1:0-1:9 + >---------< +1| fn() => 0; + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/php.ts b/packages/common/src/scopeSupportFacets/php.ts index 138f11c36e..dd2e3220eb 100644 --- a/packages/common/src/scopeSupportFacets/php.ts +++ b/packages/common/src/scopeSupportFacets/php.ts @@ -99,6 +99,7 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "statement.interface": supported, "statement.enum": supported, "statement.field.class": supported, + "statement.field.interface": supported, "statement.function": supported, "statement.constructor": supported, "statement.method": supported, @@ -112,6 +113,7 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "statement.doWhile": supported, "statement.assignment": supported, "statement.assignment.compound": supported, + "statement.update": supported, "statement.variable.initialized": supported, "statement.return": supported, "statement.yield": supported, @@ -173,6 +175,8 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "value.argument.formal.iteration": supported, "value.argument.formal.constructor": supported, "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.lambda": supported, + "value.argument.formal.lambda.iteration": supported, "value.argument.formal.method": supported, "value.argument.formal.method.iteration": supported, "value.mapPair": supported, @@ -182,6 +186,7 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": supported, "value.foreach": supported, "value.return": supported, + "value.return.lambda": supported, "value.yield": supported, "value.throw": supported, "value.switch": supported, @@ -323,4 +328,6 @@ export const phpScopeSupport: LanguageScopeSupportFacetMap = { "type.variable.initialized": notApplicable, "type.foreach": notApplicable, "type.iteration.block": notApplicable, + "class.iteration.class": notApplicable, + regularExpression: notApplicable, }; diff --git a/queries/php.scm b/queries/php.scm index c5ae6f7647..0ab470dcc7 100644 --- a/queries/php.scm +++ b/queries/php.scm @@ -218,7 +218,10 @@ (anonymous_function) @anonymousFunction ;;!! fn() => 0; -(arrow_function) @anonymousFunction +;;! ^ +(arrow_function + body: (_) @value +) @anonymousFunction @value.domain ;;!! foo() (function_call_expression