diff --git a/data/fixtures/scopes/scm/argument.actual.iteration.scope b/data/fixtures/scopes/scm/argument.actual.iteration.scope new file mode 100644 index 0000000000..6c7217cc2b --- /dev/null +++ b/data/fixtures/scopes/scm/argument.actual.iteration.scope @@ -0,0 +1,10 @@ +(#not-parent-type? @statement variable_declaration) +--- + +[Range] = 0:19-0:50 + >-------------------------------< +0| (#not-parent-type? @statement variable_declaration) + +[Domain] = 0:0-0:51 + >---------------------------------------------------< +0| (#not-parent-type? @statement variable_declaration) diff --git a/data/fixtures/scopes/scm/argument.actual.scope b/data/fixtures/scopes/scm/argument.actual.scope new file mode 100644 index 0000000000..294ac53f40 --- /dev/null +++ b/data/fixtures/scopes/scm/argument.actual.scope @@ -0,0 +1,37 @@ +(#not-parent-type? @statement variable_declaration) +--- + +[#1 Content] = +[#1 Domain] = 0:19-0:29 + >----------< +0| (#not-parent-type? @statement variable_declaration) + +[#1 Removal] = 0:19-0:30 + >-----------< +0| (#not-parent-type? @statement variable_declaration) + +[#1 Leading delimiter] = 0:18-0:19 + >-< +0| (#not-parent-type? @statement variable_declaration) + +[#1 Trailing delimiter] = 0:29-0:30 + >-< +0| (#not-parent-type? @statement variable_declaration) + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:30-0:50 + >--------------------< +0| (#not-parent-type? @statement variable_declaration) + +[#2 Removal] = 0:29-0:50 + >---------------------< +0| (#not-parent-type? @statement variable_declaration) + +[#2 Leading delimiter] = 0:29-0:30 + >-< +0| (#not-parent-type? @statement variable_declaration) + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scm/comment.line.scope b/data/fixtures/scopes/scm/comment.line.scope new file mode 100644 index 0000000000..ddbb630645 --- /dev/null +++ b/data/fixtures/scopes/scm/comment.line.scope @@ -0,0 +1,10 @@ +;; Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| ;; Hello world + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/scm/functionCall.scope b/data/fixtures/scopes/scm/functionCall.scope new file mode 100644 index 0000000000..9f69fa6ea4 --- /dev/null +++ b/data/fixtures/scopes/scm/functionCall.scope @@ -0,0 +1,10 @@ +(#not-parent-type? @statement variable_declaration) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:51 + >---------------------------------------------------< +0| (#not-parent-type? @statement variable_declaration) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scm/functionCallee.scope b/data/fixtures/scopes/scm/functionCallee.scope new file mode 100644 index 0000000000..cad5277e94 --- /dev/null +++ b/data/fixtures/scopes/scm/functionCallee.scope @@ -0,0 +1,17 @@ +(#not-parent-type? @statement variable_declaration) +--- + +[Content] = +[Removal] = 0:2-0:18 + >----------------< +0| (#not-parent-type? @statement variable_declaration) + +[Trailing delimiter] = 0:18-0:19 + >-< +0| (#not-parent-type? @statement variable_declaration) + +[Domain] = 0:0-0:51 + >---------------------------------------------------< +0| (#not-parent-type? @statement variable_declaration) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scm/list.scope b/data/fixtures/scopes/scm/list.scope new file mode 100644 index 0000000000..86aea79532 --- /dev/null +++ b/data/fixtures/scopes/scm/list.scope @@ -0,0 +1,35 @@ +[ + (foo) + (bar) +] @list +--- + +[Content] = 0:0-3:1 + >- +0| [ +1| (foo) +2| (bar) +3| ] @list + -< + +[Removal] = 0:0-3:2 + >- +0| [ +1| (foo) +2| (bar) +3| ] @list + --< + +[Trailing delimiter] = 3:1-3:2 + >-< +3| ] @list + +[Domain] = 0:0-3:7 + >- +0| [ +1| (foo) +2| (bar) +3| ] @list + -------< + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scm/string.singleLine.scope b/data/fixtures/scopes/scm/string.singleLine.scope new file mode 100644 index 0000000000..7dab95d697 --- /dev/null +++ b/data/fixtures/scopes/scm/string.singleLine.scope @@ -0,0 +1,10 @@ +"hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| "hello world" + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scm/textFragment.comment.line.scope b/data/fixtures/scopes/scm/textFragment.comment.line.scope new file mode 100644 index 0000000000..6ba8e375cc --- /dev/null +++ b/data/fixtures/scopes/scm/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +;; Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| ;; Hello world + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/scm/textFragment.string.singleLine.scope b/data/fixtures/scopes/scm/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..44e114388a --- /dev/null +++ b/data/fixtures/scopes/scm/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:12 + >-----------< +0| "hello world" + +[Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/scm.ts b/packages/common/src/scopeSupportFacets/scm.ts index 5148616fa7..f5ade133a0 100644 --- a/packages/common/src/scopeSupportFacets/scm.ts +++ b/packages/common/src/scopeSupportFacets/scm.ts @@ -1,9 +1,172 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -// eslint-disable-next-line @typescript-eslint/no-unused-vars -const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; +const { supported, notApplicable } = ScopeSupportFacetLevel; export const scmScopeSupport: LanguageScopeSupportFacetMap = { statement: supported, + + "argument.actual": supported, + "argument.actual.iteration": supported, + "comment.line": supported, + functionCall: supported, + functionCallee: supported, + "string.singleLine": supported, + "textFragment.comment.line": supported, + "textFragment.string.singleLine": supported, + list: supported, + + // Not applicable + + anonymousFunction: notApplicable, + "argument.actual.constructor": notApplicable, + "argument.actual.constructor.iteration": notApplicable, + "argument.actual.method": notApplicable, + "argument.actual.method.iteration": notApplicable, + "argument.formal": notApplicable, + "argument.formal.constructor": notApplicable, + "argument.formal.constructor.iteration": notApplicable, + "argument.formal.iteration": notApplicable, + "argument.formal.method": notApplicable, + "argument.formal.method.iteration": notApplicable, + attribute: notApplicable, + "branch.if": notApplicable, + "branch.if.iteration": notApplicable, + "branch.loop": notApplicable, + "branch.switchCase": notApplicable, + "branch.switchCase.iteration": notApplicable, + "branch.ternary": notApplicable, + "branch.try": notApplicable, + "branch.try.iteration": notApplicable, + class: notApplicable, + "class.iteration.block": notApplicable, + "class.iteration.document": notApplicable, + className: notApplicable, + "className.iteration.block": notApplicable, + "className.iteration.document": notApplicable, + command: notApplicable, + "comment.block": notApplicable, + "condition.doWhile": notApplicable, + "condition.for": notApplicable, + "condition.if": notApplicable, + "condition.switchCase": notApplicable, + "condition.switchCase.iteration": notApplicable, + "condition.ternary": notApplicable, + "condition.while": notApplicable, + "collectionItem.unenclosed": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, + disqualifyDelimiter: notApplicable, + element: notApplicable, + endTag: notApplicable, + environment: notApplicable, + fieldAccess: notApplicable, + "functionCall.constructor": notApplicable, + "functionCallee.constructor": notApplicable, + functionName: notApplicable, + "functionName.constructor": notApplicable, + "functionName.iteration.block": notApplicable, + "functionName.iteration.document": notApplicable, + "functionName.method": notApplicable, + "functionName.method.iteration.class": notApplicable, + ifStatement: notApplicable, + "interior.cell": notApplicable, + "interior.class": notApplicable, + "interior.command": notApplicable, + "interior.element": notApplicable, + "interior.function": notApplicable, + "interior.if": notApplicable, + "interior.lambda": notApplicable, + "interior.loop": notApplicable, + "interior.resource": notApplicable, + "interior.switchCase": notApplicable, + "interior.ternary": notApplicable, + "interior.try": notApplicable, + "key.attribute": notApplicable, + "key.mapPair": notApplicable, + "key.mapPair.iteration": notApplicable, + map: notApplicable, + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "name.argument.formal": notApplicable, + "name.argument.formal.constructor": notApplicable, + "name.argument.formal.constructor.iteration": notApplicable, + "name.argument.formal.iteration": notApplicable, + "name.argument.formal.method": notApplicable, + "name.argument.formal.method.iteration": notApplicable, + "name.assignment": notApplicable, + "name.assignment.pattern": notApplicable, + "name.class": notApplicable, + "name.constructor": notApplicable, + "name.field": notApplicable, + "name.foreach": notApplicable, + "name.function": notApplicable, + "name.iteration.block": notApplicable, + "name.iteration.document": notApplicable, + "name.method": notApplicable, + "name.resource": notApplicable, + "name.resource.iteration": notApplicable, + "name.variable": notApplicable, + "name.variable.pattern": notApplicable, + namedFunction: notApplicable, + "namedFunction.constructor": notApplicable, + "namedFunction.iteration.block": notApplicable, + "namedFunction.iteration.document": notApplicable, + "namedFunction.method": notApplicable, + "namedFunction.method.iteration.class": notApplicable, + notebookCell: notApplicable, + pairDelimiter: notApplicable, + regularExpression: notApplicable, + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + startTag: notApplicable, + "statement.class": notApplicable, + "statement.iteration.block": notApplicable, + "statement.iteration.document": notApplicable, + "string.multiLine": notApplicable, + switchStatementSubject: notApplicable, + tags: notApplicable, + "textFragment.comment.block": notApplicable, + "textFragment.element": notApplicable, + "textFragment.string.multiLine": notApplicable, + "type.alias": notApplicable, + "type.argument.formal": notApplicable, + "type.argument.formal.constructor": notApplicable, + "type.argument.formal.constructor.iteration": notApplicable, + "type.argument.formal.iteration": notApplicable, + "type.argument.formal.method": notApplicable, + "type.argument.formal.method.iteration": notApplicable, + "type.cast": notApplicable, + "type.class": notApplicable, + "type.enum": notApplicable, + "type.field": notApplicable, + "type.field.iteration": notApplicable, + "type.foreach": notApplicable, + "type.interface": notApplicable, + "type.return": notApplicable, + "type.typeArgument": notApplicable, + "type.typeArgument.iteration": notApplicable, + "type.variable": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + "value.argument.formal": notApplicable, + "value.argument.formal.constructor": notApplicable, + "value.argument.formal.constructor.iteration": notApplicable, + "value.argument.formal.iteration": notApplicable, + "value.argument.formal.method": notApplicable, + "value.argument.formal.method.iteration": notApplicable, + "value.assignment": notApplicable, + "value.attribute": notApplicable, + "value.field": notApplicable, + "value.foreach": notApplicable, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, + "value.resource": notApplicable, + "value.resource.iteration": notApplicable, + "value.return": notApplicable, + "value.return.lambda": notApplicable, + "value.typeAlias": notApplicable, + "value.variable": notApplicable, + "value.variable.pattern": notApplicable, + "value.yield": notApplicable, }; diff --git a/queries/scm.collections.scm b/queries/scm.collections.scm index f3a30ffb49..fbd7fb9e25 100644 --- a/queries/scm.collections.scm +++ b/queries/scm.collections.scm @@ -1,38 +1,39 @@ ;;!! (aaa (bbb) (ccc)) ;;! ^^^^^ ^^^^^ ;;! *************** -( - (named_node - "(" @collectionItem.iteration.start.endOf - name: _ - _ @collectionItem - ")" @collectionItem.iteration.end.startOf - ) +(named_node + name: _ + (_) @collectionItem +) + +(named_node + "(" @collectionItem.iteration.start.endOf + ")" @collectionItem.iteration.end.startOf ) ;;!! ((aaa) (bbb)) ;;! ^^^^^ ^^^^^ ;;! *********** -( - (grouping - "(" @collectionItem.iteration.start.endOf - (_) @collectionItem - ")" @collectionItem.iteration.end.startOf - ) +(grouping + (_) @collectionItem +) + +(grouping + "(" @collectionItem.iteration.start.endOf + ")" @collectionItem.iteration.end.startOf ) -;; collectionItem: ;;!! [(aaa) (bbb)] @ccc ;;! ^^^^^ ^^^^^ ;;! *********** -;; list: +(list + (_) @collectionItem +) + ;;!! [(aaa) (bbb)] @ccc ;;! ^^^^^^^^^^^^^ ;;! ------------------ -( - (list - "[" @list.start @collectionItem.iteration.start.endOf - (_) @collectionItem - "]" @list.end @collectionItem.iteration.end.startOf - ) @list.domain -) +(list + "[" @list.start @collectionItem.iteration.start.endOf + "]" @list.end @collectionItem.iteration.end.startOf +) @list.domain diff --git a/queries/scm.scm b/queries/scm.scm index 737fea6129..7897bdf7c4 100644 --- a/queries/scm.scm +++ b/queries/scm.scm @@ -15,6 +15,7 @@ (anonymous_node name: (_) @string @textFragment + (#child-range! @textFragment 0 -1 true true) ) ;; functionCall: @@ -40,7 +41,11 @@ (parameters (_) @argumentOrParameter ) -) @_.iteration +) + +(predicate + (parameters) @argumentOrParameter.iteration +) @argumentOrParameter.iteration.domain ;;!! (aaa) @bbb ;;! ^^^