diff --git a/data/fixtures/scopes/talon/argument.actual.iteration.scope b/data/fixtures/scopes/talon/argument.actual.iteration.scope new file mode 100644 index 0000000000..89bf334e53 --- /dev/null +++ b/data/fixtures/scopes/talon/argument.actual.iteration.scope @@ -0,0 +1,10 @@ +command: user.do_something(123, 456) +--- + +[Range] = 0:27-0:35 + >--------< +0| command: user.do_something(123, 456) + +[Domain] = 0:26-0:36 + >----------< +0| command: user.do_something(123, 456) diff --git a/data/fixtures/scopes/talon/argument.actual.iteration2.scope b/data/fixtures/scopes/talon/argument.actual.iteration2.scope new file mode 100644 index 0000000000..3ff40d44d3 --- /dev/null +++ b/data/fixtures/scopes/talon/argument.actual.iteration2.scope @@ -0,0 +1,7 @@ +command: key(enter) +--- + +[Range] = +[Domain] = 0:13-0:18 + >-----< +0| command: key(enter) diff --git a/data/fixtures/scopes/talon/argument.actual.scope b/data/fixtures/scopes/talon/argument.actual.scope new file mode 100644 index 0000000000..a1e82496d0 --- /dev/null +++ b/data/fixtures/scopes/talon/argument.actual.scope @@ -0,0 +1,33 @@ +command: user.do_something(123, 456) +--- + +[#1 Content] = +[#1 Domain] = 0:27-0:30 + >---< +0| command: user.do_something(123, 456) + +[#1 Removal] = 0:27-0:32 + >-----< +0| command: user.do_something(123, 456) + +[#1 Trailing delimiter] = 0:30-0:32 + >--< +0| command: user.do_something(123, 456) + +[#1 Insertion delimiter] = ", " + + +[#2 Content] = +[#2 Domain] = 0:32-0:35 + >---< +0| command: user.do_something(123, 456) + +[#2 Removal] = 0:30-0:35 + >-----< +0| command: user.do_something(123, 456) + +[#2 Leading delimiter] = 0:30-0:32 + >--< +0| command: user.do_something(123, 456) + +[#2 Insertion delimiter] = ", " diff --git a/data/fixtures/scopes/talon/argument.actual2.scope b/data/fixtures/scopes/talon/argument.actual2.scope new file mode 100644 index 0000000000..50d17e72ce --- /dev/null +++ b/data/fixtures/scopes/talon/argument.actual2.scope @@ -0,0 +1,10 @@ +command: key(enter) +--- + +[Content] = +[Removal] = +[Domain] = 0:13-0:18 + >-----< +0| command: key(enter) + +[Insertion delimiter] = " " diff --git a/data/fixtures/scopes/talon/comment.line.scope b/data/fixtures/scopes/talon/comment.line.scope new file mode 100644 index 0000000000..42719cdbb8 --- /dev/null +++ b/data/fixtures/scopes/talon/comment.line.scope @@ -0,0 +1,10 @@ +# Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| # Hello world + +[Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/talon/name.assignment.scope b/data/fixtures/scopes/talon/name.assignment.scope new file mode 100644 index 0000000000..30d3997d69 --- /dev/null +++ b/data/fixtures/scopes/talon/name.assignment.scope @@ -0,0 +1,39 @@ +command: + value = 123 +--- + +[#1 Content] = +[#1 Removal] = 0:0-0:7 + >-------< +0| command: + +[#1 Domain] = 0:0-1:15 + >-------- +0| command: +1| value = 123 + ---------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:9 + >-----< +1| value = 123 + +[#2 Removal] = 1:4-1:10 + >------< +1| value = 123 + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| value = 123 + +[#2 Trailing delimiter] = 1:9-1:10 + >-< +1| value = 123 + +[#2 Domain] = 1:4-1:15 + >-----------< +1| value = 123 + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/talon/name.variable.scope b/data/fixtures/scopes/talon/name.variable.scope new file mode 100644 index 0000000000..30d3997d69 --- /dev/null +++ b/data/fixtures/scopes/talon/name.variable.scope @@ -0,0 +1,39 @@ +command: + value = 123 +--- + +[#1 Content] = +[#1 Removal] = 0:0-0:7 + >-------< +0| command: + +[#1 Domain] = 0:0-1:15 + >-------- +0| command: +1| value = 123 + ---------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:4-1:9 + >-----< +1| value = 123 + +[#2 Removal] = 1:4-1:10 + >------< +1| value = 123 + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| value = 123 + +[#2 Trailing delimiter] = 1:9-1:10 + >-< +1| value = 123 + +[#2 Domain] = 1:4-1:15 + >-----------< +1| value = 123 + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/talon/statement.iteration.block.scope b/data/fixtures/scopes/talon/statement.iteration.block.scope new file mode 100644 index 0000000000..138ee103ab --- /dev/null +++ b/data/fixtures/scopes/talon/statement.iteration.block.scope @@ -0,0 +1,16 @@ +command: + value = 123 +--- + +[#1 Range] = +[#1 Domain] = 0:0-1:15 + >-------- +0| command: +1| value = 123 + ---------------< + + +[#2 Range] = +[#2 Domain] = 1:4-1:15 + >-----------< +1| value = 123 diff --git a/data/fixtures/scopes/talon/statement.iteration.document.scope b/data/fixtures/scopes/talon/statement.iteration.document.scope new file mode 100644 index 0000000000..8bdffafc86 --- /dev/null +++ b/data/fixtures/scopes/talon/statement.iteration.document.scope @@ -0,0 +1,17 @@ +command: + value = 123 + +--- + +[#1 Range] = +[#1 Domain] = 0:0-1:15 + >-------- +0| command: +1| value = 123 + ---------------< + + +[#2 Range] = +[#2 Domain] = 1:4-1:15 + >-----------< +1| value = 123 diff --git a/data/fixtures/scopes/talon/statement.scope b/data/fixtures/scopes/talon/statement.scope new file mode 100644 index 0000000000..cbece6d612 --- /dev/null +++ b/data/fixtures/scopes/talon/statement.scope @@ -0,0 +1,26 @@ +command: user.do_something() +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:28 + >----------------------------< +0| command: user.do_something() + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:9-0:28 + >-------------------< +0| command: user.do_something() + +[#2 Removal] = 0:8-0:28 + >--------------------< +0| command: user.do_something() + +[#2 Leading delimiter] = 0:8-0:9 + >-< +0| command: user.do_something() + +[#2 Insertion delimiter] = "\n" diff --git a/data/fixtures/scopes/talon/value.assignment.scope b/data/fixtures/scopes/talon/value.assignment.scope new file mode 100644 index 0000000000..68672dbeda --- /dev/null +++ b/data/fixtures/scopes/talon/value.assignment.scope @@ -0,0 +1,44 @@ +command: + value = 123 +--- + +[#1 Content] = 1:4-1:15 + >-----------< +1| value = 123 + +[#1 Removal] = 0:8-1:15 + > +0| command: +1| value = 123 + ---------------< + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| value = 123 + +[#1 Domain] = 0:0-1:15 + >-------- +0| command: +1| value = 123 + ---------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:12-1:15 + >---< +1| value = 123 + +[#2 Removal] = 1:11-1:15 + >----< +1| value = 123 + +[#2 Leading delimiter] = 1:11-1:12 + >-< +1| value = 123 + +[#2 Domain] = 1:4-1:15 + >-----------< +1| value = 123 + +[#2 Insertion delimiter] = " " diff --git a/data/fixtures/scopes/talon/value.variable.scope b/data/fixtures/scopes/talon/value.variable.scope new file mode 100644 index 0000000000..68672dbeda --- /dev/null +++ b/data/fixtures/scopes/talon/value.variable.scope @@ -0,0 +1,44 @@ +command: + value = 123 +--- + +[#1 Content] = 1:4-1:15 + >-----------< +1| value = 123 + +[#1 Removal] = 0:8-1:15 + > +0| command: +1| value = 123 + ---------------< + +[#1 Leading delimiter] = 1:0-1:4 + >----< +1| value = 123 + +[#1 Domain] = 0:0-1:15 + >-------- +0| command: +1| value = 123 + ---------------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:12-1:15 + >---< +1| value = 123 + +[#2 Removal] = 1:11-1:15 + >----< +1| value = 123 + +[#2 Leading delimiter] = 1:11-1:12 + >-< +1| value = 123 + +[#2 Domain] = 1:4-1:15 + >-----------< +1| value = 123 + +[#2 Insertion delimiter] = " " diff --git a/packages/common/src/scopeSupportFacets/talon.ts b/packages/common/src/scopeSupportFacets/talon.ts index c2fc3e46fe..39ced3b085 100644 --- a/packages/common/src/scopeSupportFacets/talon.ts +++ b/packages/common/src/scopeSupportFacets/talon.ts @@ -1,11 +1,174 @@ import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; -const { supported } = ScopeSupportFacetLevel; +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const talonScopeSupport: LanguageScopeSupportFacetMap = { command: supported, "interior.command": supported, "name.field": supported, "value.field": supported, + "comment.line": supported, + "name.assignment": supported, + "name.variable": supported, + statement: supported, + "statement.iteration.block": supported, + "statement.iteration.document": supported, + "value.variable": supported, + "value.assignment": supported, + "argument.actual": supported, + "argument.actual.iteration": supported, + + // Unsupported + + fieldAccess: unsupported, + "string.singleLine": unsupported, + "string.multiLine": unsupported, + "textFragment.comment.line": unsupported, + "textFragment.string.singleLine": unsupported, + "textFragment.string.multiLine": unsupported, + "value.argument.actual": unsupported, + "value.argument.actual.iteration": unsupported, + + // 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, + "collectionItem.unenclosed": notApplicable, + "collectionItem.unenclosed.iteration": 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, + disqualifyDelimiter: notApplicable, + element: notApplicable, + endTag: notApplicable, + environment: notApplicable, + functionCall: notApplicable, + "functionCall.constructor": notApplicable, + functionCallee: 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.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, + list: 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.pattern": notApplicable, + "name.class": notApplicable, + "name.constructor": 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.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, + switchStatementSubject: notApplicable, + tags: notApplicable, + "textFragment.comment.block": notApplicable, + "textFragment.element": 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.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.attribute": 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.pattern": notApplicable, + "value.yield": notApplicable, }; diff --git a/queries/talon.scm b/queries/talon.scm index da5a8b68d4..c0e554aad9 100644 --- a/queries/talon.scm +++ b/queries/talon.scm @@ -169,7 +169,7 @@ ;;!! print("hello", "world") ;;! ^^^^^^^ ^^^^^^^ (action - arguments: (_ + arguments: (argument_list (_)? @_.leading.endOf . (_) @argumentOrParameter @@ -179,9 +179,16 @@ (#insertion-delimiter! @argumentOrParameter ", ") ) +(argument_list + . + "(" @argumentOrParameter.iteration.start.endOf + ")" @argumentOrParameter.iteration.end.startOf + . +) @argumentOrParameter.iteration.domain + ;;!! key(enter) ;;! ^^^^^ -arguments: (_) @argumentOrParameter.iteration +arguments: (implicit_string) @argumentOrParameter.iteration ;;!! # foo ;;! ^^^^^