From 5249da98ec9dcb48293089329bcf959a76ad452f Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 8 Aug 2026 21:23:45 -0400 Subject: [PATCH 01/13] get repo ready for swift support dev --- .gitignore | 3 +++ .../lib-common/src/extensionDependencies.ts | 1 + .../languageScopeSupport.ts | 2 ++ .../src/scopeSupportFacets/swift.ts | 20 +++++++++++++++++++ .../fixtures/scopes/swift/ifStatement.scope | 4 ++++ .../scopes/swift/statement.class.scope | 4 ++++ .../scopes/swift/statement.enum.scope | 4 ++++ .../scopes/swift/statement.field.class.scope | 4 ++++ .../swift/statement.field.interface.scope | 2 ++ .../scopes/swift/statement.interface.scope | 4 ++++ .../cursorless-test-project/Package.swift | 8 ++++++++ resources/queries/swift.scm | 3 +++ 12 files changed, 59 insertions(+) create mode 100644 packages/lib-common/src/scopeSupportFacets/swift.ts create mode 100644 resources/fixtures/scopes/swift/ifStatement.scope create mode 100644 resources/fixtures/scopes/swift/statement.class.scope create mode 100644 resources/fixtures/scopes/swift/statement.enum.scope create mode 100644 resources/fixtures/scopes/swift/statement.field.class.scope create mode 100644 resources/fixtures/scopes/swift/statement.field.interface.scope create mode 100644 resources/fixtures/scopes/swift/statement.interface.scope create mode 100644 resources/playground/swift/cursorless-test-project/Package.swift create mode 100644 resources/queries/swift.scm diff --git a/.gitignore b/.gitignore index fa67b4db01..b97bc3633a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ node_modules/ *.vsix .DS_Store .luacheckcache + +# Swift Test Project +/resources/playground/swift/cursorless-test-project/.build \ No newline at end of file diff --git a/packages/lib-common/src/extensionDependencies.ts b/packages/lib-common/src/extensionDependencies.ts index a62060bc0c..b6674c1df8 100644 --- a/packages/lib-common/src/extensionDependencies.ts +++ b/packages/lib-common/src/extensionDependencies.ts @@ -1,4 +1,5 @@ export const extensionDependencies = [ // Cursorless access to Tree sitter "pokey.parse-tree", + "swiftlang.swift-vscode" ]; diff --git a/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts b/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts index 39d5d106f7..ac6beb2ca9 100644 --- a/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts +++ b/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts @@ -27,6 +27,7 @@ import { scalaScopeSupport } from "./scala"; import { scmScopeSupport } from "./scm"; import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { scssScopeSupport } from "./scss"; +import { swiftScopeSupport } from "./swift"; import { talonScopeSupport } from "./talon"; import { talonListScopeSupport } from "./talonList"; import { typescriptScopeSupport } from "./typescript"; @@ -64,6 +65,7 @@ export const languageScopeSupport: StringRecord = scala: scalaScopeSupport, scm: scmScopeSupport, scss: scssScopeSupport, + swift: swiftScopeSupport, "talon-list": talonListScopeSupport, talon: talonScopeSupport, typescript: typescriptScopeSupport, diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts new file mode 100644 index 0000000000..00f02a1f54 --- /dev/null +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -0,0 +1,20 @@ +import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; +import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; + +const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; + +export const swiftScopeSupport: LanguageScopeSupportFacetMap = { + ifStatement: supported, + "statement.class": supported, + "statement.interface": supported, + "statement.enum": supported, + "statement.field.class": supported, + "statement.field.interface": supported, + "statement.variable.uninitialized": supported, + "statement.variable.initialized": supported, + namedFunction: supported, + "comment.line": supported, + "string.singleLine": supported, + "branch.if": supported, + class: supported, +} \ No newline at end of file diff --git a/resources/fixtures/scopes/swift/ifStatement.scope b/resources/fixtures/scopes/swift/ifStatement.scope new file mode 100644 index 0000000000..80a2191be8 --- /dev/null +++ b/resources/fixtures/scopes/swift/ifStatement.scope @@ -0,0 +1,4 @@ +if foo { + +} +--- diff --git a/resources/fixtures/scopes/swift/statement.class.scope b/resources/fixtures/scopes/swift/statement.class.scope new file mode 100644 index 0000000000..33b512a803 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.class.scope @@ -0,0 +1,4 @@ +class ClassName { + +} +--- diff --git a/resources/fixtures/scopes/swift/statement.enum.scope b/resources/fixtures/scopes/swift/statement.enum.scope new file mode 100644 index 0000000000..fcf61444ed --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.enum.scope @@ -0,0 +1,4 @@ +enum EnumerationName { + +} +--- diff --git a/resources/fixtures/scopes/swift/statement.field.class.scope b/resources/fixtures/scopes/swift/statement.field.class.scope new file mode 100644 index 0000000000..1faeaa3d0b --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.field.class.scope @@ -0,0 +1,4 @@ +class AnotherClassName { + let classConstantFieldOfCommonType = 42 +} +--- diff --git a/resources/fixtures/scopes/swift/statement.field.interface.scope b/resources/fixtures/scopes/swift/statement.field.interface.scope new file mode 100644 index 0000000000..99cdb66333 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.field.interface.scope @@ -0,0 +1,2 @@ + var requiredSetGetMember: Type = { get set } +--- diff --git a/resources/fixtures/scopes/swift/statement.interface.scope b/resources/fixtures/scopes/swift/statement.interface.scope new file mode 100644 index 0000000000..5ed7ae25bf --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.interface.scope @@ -0,0 +1,4 @@ +protocol ProtocolName { + +} +--- diff --git a/resources/playground/swift/cursorless-test-project/Package.swift b/resources/playground/swift/cursorless-test-project/Package.swift new file mode 100644 index 0000000000..09374339a2 --- /dev/null +++ b/resources/playground/swift/cursorless-test-project/Package.swift @@ -0,0 +1,8 @@ +// swift-tools-version: 6.2 +// The swift-tools-version declares the minimum version of Swift required to build this package. + +import PackageDescription + +let package = Package( + name: "cursorless-test-project" +) diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm new file mode 100644 index 0000000000..97140d8161 --- /dev/null +++ b/resources/queries/swift.scm @@ -0,0 +1,3 @@ +;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json + +;; class Foo {}; struct Foo {} From 607252b580e401b9777eca401503912d7cbb5530 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Thu, 13 Aug 2026 23:17:33 -0400 Subject: [PATCH 02/13] scm p1 --- .../src/scopeSupportFacets/swift.ts | 6 +++ .../swift/cursorless-test-project/test.swift | 43 ++++++++++++++++ resources/queries/swift.scm | 49 ++++++++++++++++++- 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 resources/playground/swift/cursorless-test-project/test.swift diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 00f02a1f54..018a09dd34 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -13,8 +13,14 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.variable.uninitialized": supported, "statement.variable.initialized": supported, namedFunction: supported, + "name.variable.initialized": supported, + "name.variable.uninitialized": supported, + "name.class": supported, + "name.interface": supported, + "name.enum": supported, "comment.line": supported, "string.singleLine": supported, "branch.if": supported, class: supported, + "textFragment.comment.line": supported } \ No newline at end of file diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift new file mode 100644 index 0000000000..8ad14c8669 --- /dev/null +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -0,0 +1,43 @@ +struct ExamplesStruct { + static let constant = "hello world" + public var publicVariable: UInt128 = 0 + var uninitializedVariable: String? + internal static func exampleFunction(exampleLabel: String) -> String { + if exampleLabel.isEmpty { + return "goodbye world" + } else { + return constant + ", " + exampleLabel + "!" + } + } + public mutating func secondExampleFunction(exampleLabel: String, times: any UnsignedInteger) { + let cast: UInt128 = numericCast(times) + publicVariable += cast + let fizz = publicVariable % 3 == 0 + let buzz = publicVariable % 5 == 0 + if (fizz || buzz) { + print((fizz ? "fizz" : "") + (buzz ? "buzz" : "")) + } + for _ in 0 ..< cast { + print(ExamplesStruct.exampleFunction(exampleLabel: exampleLabel)) + } + } +} + +enum ExampleEnum { + case exampleCaseOne + case exampleCaseTwo +} +/* + These Examples are Pissing me off... + I'm the original + Multiline walker +*/ + +enum ExampleCompactEnum { + case compactCaseOne, compactCaseTwo +} + +protocol ExampleProtocol { + var setGetMember: String? { set get } + var getOnlyNumber: Double! {get} // using an explicit unwrap type like this is legal, but poor practice in real code +} \ No newline at end of file diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 97140d8161..0db202c180 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,3 +1,50 @@ ;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json -;; class Foo {}; struct Foo {} +;; Comment +(comment) @comment @textFragment +;; Protocol decl. +(protocol_declaration + name: (_) @name + body: (protocol_body + "{" @interior.start.endOf + "}" @interior.end.startOf + . + ) +) @statement + +;;if statement -- todo seperate main if branch from else and else if branches +(if_statement) @ifStatement @statement @branch + +;; generic property delc. -- todo a lot on this ngl +(property_declaration + name: (_) @name +) @statement + +;; Generic interior +(_ + + "{" @interior.start.endOf + "}" @interior.end.startOf + . + +) + +;; Non-enum class (struct/class) decl. +(class_declaration + name: (_) @name + body: (class_body + "{" @interior.start.endOf + "}" @interior.end.startOf + . + ) +) @statement + +;; Enum "class: decl. +(class_declaration + name: (_) @name + body: (enum_class_body + "{" @interior.start.endOf + "}" @interior.end.startOf + . + ) +) @statement From 98e710616c6bba0e9da5b9cb4462eb2605290dba Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Fri, 14 Aug 2026 23:03:00 -0400 Subject: [PATCH 03/13] scm p2; added rust and java playgrounds for behavior reference --- .../src/scopeSupportFacets/swift.ts | 2 + resources/playground/Java.java | 5 +++ resources/playground/rust.rs | 7 ++++ .../swift/cursorless-test-project/test.swift | 6 ++- resources/queries/swift.scm | 39 ++++++++++++++++--- 5 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 resources/playground/rust.rs diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 018a09dd34..eab8d98aa9 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -21,6 +21,8 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "comment.line": supported, "string.singleLine": supported, "branch.if": supported, + "branch.if.else": supported, + "condition.if": supported, class: supported, "textFragment.comment.line": supported } \ No newline at end of file diff --git a/resources/playground/Java.java b/resources/playground/Java.java index 2001b365a2..0b65e8e8d2 100644 --- a/resources/playground/Java.java +++ b/resources/playground/Java.java @@ -2,5 +2,10 @@ public class Java { private Java(String name) { String value = "hello"; System.out.println(value); + if (true) { + //1 + } else if (false) { + //2 + } } } diff --git a/resources/playground/rust.rs b/resources/playground/rust.rs new file mode 100644 index 0000000000..70bc5084d3 --- /dev/null +++ b/resources/playground/rust.rs @@ -0,0 +1,7 @@ +fn hello() { + if true { + //1 + } else if false { + //2 + } +} \ No newline at end of file diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index 8ad14c8669..9364627f62 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -5,8 +5,12 @@ struct ExamplesStruct { internal static func exampleFunction(exampleLabel: String) -> String { if exampleLabel.isEmpty { return "goodbye world" - } else { + } else if (publicVariable % 2 == 0) { return constant + ", " + exampleLabel + "!" + } else if (publicVariable % 3 == 0){ + return constant + ", " + exampleLabel + "?!" + } else { + return constant + ", " + exampleLabel + "..." } } public mutating func secondExampleFunction(exampleLabel: String, times: any UnsignedInteger) { diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 0db202c180..b10b0d196c 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -13,7 +13,34 @@ ) @statement ;;if statement -- todo seperate main if branch from else and else if branches -(if_statement) @ifStatement @statement @branch +( + (if_statement) @ifStatement @statement @branch.domain + (#not-parent-type? @ifStatement if_statement) +) + +( + (if_statement + "if" @branch.start.startOf @branch.removal.start + condition: (_) @condition + (statements) @interior.start.startOf @interior.end.endOf + . + "}" @branch.end.endOf @branch.removal.end + (else)? @branch.removal.end.startOf + ) @condition.domain + (#not-parent-type? @condition.domain if_statement) +) + +( + (if_statement + (else) @branch.start @condition.domain.start + (if_statement + condition: (_) @condition + (statements) @interior.start.startOf @interior.end.endOf + . + "}" @branch.end.endOf @condition.domain.end + ) + ) +) ;; generic property delc. -- todo a lot on this ngl (property_declaration @@ -21,13 +48,13 @@ ) @statement ;; Generic interior -(_ +;;(_ - "{" @interior.start.endOf - "}" @interior.end.startOf - . +;; "{" @interior.start.endOf +;; "}" @interior.end.startOf +;; . -) +;;) ;; Non-enum class (struct/class) decl. (class_declaration From 29bc9c76b9669ab2f295d7c50efade103a9c8465 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Thu, 20 Aug 2026 00:37:22 -0400 Subject: [PATCH 04/13] start filling out swift.ts with notApplicable and unsupported facet entries file structure is unconventional but it's how I'd like to keep it for now until swift support is nearing completion, at which point it can be made more similar to the other facet definition files I guess? --- .../src/scopeSupportFacets/swift.ts | 226 +++++++++++++++++- resources/queries/swift.scm | 5 +- 2 files changed, 219 insertions(+), 12 deletions(-) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index eab8d98aa9..d101c4a23b 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -4,25 +4,229 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const swiftScopeSupport: LanguageScopeSupportFacetMap = { + /* SUPPORTED OR UNSUPPORTED (PLANNED) */ + + // if/else/elif ifStatement: supported, + "branch.if": supported, + "branch.if.else": supported, + "branch.if.elif.else": unsupported, + "branch.if.iteration": unsupported, + "condition.if": supported, + "interior.if": supported, + + // for loop -- TODO: are swift for loops 'standard' for loops, for-each loops, or both? + "statement.for": unsupported, + "statement.foreach": unsupported, + "condition.for": unsupported, + "name.foreach": unsupported, + "value.foreach": unsupported, + "type.foreach": unsupported, + + // switch + "statement.switch": unsupported, + "branch.switchCase": unsupported, + "branch.switchCase.iteration": unsupported, + "condition.switchCase": unsupported, + "value.switch": unsupported, + "interior.switch": unsupported, + "interior.switchCase": unsupported, + + // control transfer + "statement.return": unsupported, + "value.return": unsupported, + "value.return.lambda": unsupported, + "statement.throw": unsupported, + "value.throw": unsupported, + "statement.break": unsupported, + "statement.continue": unsupported, + + // enum + "statement.enum": supported, + "name.enum": supported, + + // class + class: supported, "statement.class": supported, + "name.class": supported, + + // protocol (equivalent to interfaces in other languages) "statement.interface": supported, - "statement.enum": supported, + "name.interface": supported, + + // named function + namedFunction: supported, + + // function calls + functionCall: unsupported, + "functionCall.constructor": unsupported, + "functionCall.method": unsupported, + "functionCall.chain": unsupported, + "functionCall.generic": unsupported, + "functionCall.enum": unsupported, + + // function callee + functionCallee: unsupported, + "functionCallee.constructor": unsupported, + "functionCallee.method": unsupported, + "functionCallee.chain": unsupported, + "functionCallee.generic": unsupported, + "functionCallee.enum": unsupported, + + // argument (actual) + "argument.actual.singleLine": unsupported, + "argument.actual.multiLine": unsupported, + "argument.actual.iteration": unsupported, + "argument.actual.method.singleLine": unsupported, + "argument.actual.method.multiLine": unsupported, + "argument.actual.method.iteration": unsupported, + "argument.actual.constructor.singleLine": unsupported, + "argument.actual.constructor.multiLine": unsupported, + "argument.actual.constructor.iteration": unsupported, + "argument.actual.enum.singleLine": unsupported, + "argument.actual.enum.multiLine": unsupported, + "argument.actual.enum.iteration": unsupported, + + // argument (formal) + "argument.formal.singleLine": unsupported, + "argument.formal.multiLine": unsupported, + "argument.formal.iteration": unsupported, + "argument.formal.method.singleLine": unsupported, + "argument.formal.method.multiLine": unsupported, + "argument.formal.method.iteration": unsupported, + "argument.formal.constructor.singleLine": unsupported, + "argument.formal.constructor.multiLine": unsupported, + "argument.formal.constructor.iteration": unsupported, + "argument.formal.lambda.singleLine": unsupported, + "argument.formal.lambda.multiLine": unsupported, + "argument.formal.lambda.iteration": unsupported, + "argument.formal.catch": unsupported, + + // argument list (actual) + "argumentList.actual.empty": unsupported, + "argumentList.actual.singleLine": unsupported, + "argumentList.actual.multiLine": unsupported, + "argumentList.actual.method.empty": unsupported, + "argumentList.actual.method.singleLine": unsupported, + "argumentList.actual.method.multiLine": unsupported, + "argumentList.actual.constructor.empty": unsupported, + "argumentList.actual.constructor.singleLine": unsupported, + "argumentList.actual.constructor.multiLine": unsupported, + "argumentList.actual.enum.empty": unsupported, + "argumentList.actual.enum.singleLine": unsupported, + "argumentList.actual.enum.multiLine": unsupported, + + // argument list (formal) + "argumentList.formal.empty": unsupported, + "argumentList.formal.singleLine": unsupported, + "argumentList.formal.multiLine": unsupported, + "argumentList.formal.lambda.empty": unsupported, + "argumentList.formal.lambda.singleLine": unsupported, + "argumentList.formal.lambda.multiLine": unsupported, + "argumentList.formal.method.empty": unsupported, + "argumentList.formal.method.singleLine": unsupported, + "argumentList.formal.method.multiLine": unsupported, + "argumentList.formal.constructor.empty": unsupported, + "argumentList.formal.constructor.singleLine": unsupported, + "argumentList.formal.constructor.multiLine": unsupported, + + // named variable/member/field "statement.field.class": supported, "statement.field.interface": supported, "statement.variable.uninitialized": supported, "statement.variable.initialized": supported, - namedFunction: supported, "name.variable.initialized": supported, "name.variable.uninitialized": supported, - "name.class": supported, - "name.interface": supported, - "name.enum": supported, + + // variable/member/field value (RHS) + "value.field.class": unsupported, + "value.field.interface": unsupported, + "value.field.enum": unsupported, + + // comments "comment.line": supported, "string.singleLine": supported, - "branch.if": supported, - "branch.if.else": supported, - "condition.if": supported, - class: supported, - "textFragment.comment.line": supported -} \ No newline at end of file + "textFragment.comment.line": supported, + "comment.block": unsupported, + + // document-wide iteration + "statement.iteration.document": unsupported, + "class.iteration.document": unsupported, + "namedFunction.iteration.document": unsupported, + "name.iteration.document": unsupported, + "value.iteration.document": unsupported, + "type.iteration.document": unsupported, + + // per-class iteration + "statement.iteration.class": unsupported, + "class.iteration.class": unsupported, + "namedFunction.iteration.class": unsupported, + "name.iteration.class": unsupported, + "value.iteration.class": unsupported, + "type.iteration.class": unsupported, + + // per-protocol iteration + "statement.iteration.interface": unsupported, + "name.iteration.interface": unsupported, + "type.iteration.interface": unsupported, + + // per-block iteration + "statement.iteration.block": unsupported, + "name.iteration.block": unsupported, + "value.iteration.block": unsupported, + "type.iteration.block": unsupported, + + // misc + "statement.assignment.compound": unsupported, + "statement.typeAlias": unsupported, + "statement.misc": unsupported, + + + /* NOT APPLICABLE */ + + // XML/CSS/LaTeX/Markdown specific + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + environment: notApplicable, + notebookCell: notApplicable, + selector: notApplicable, + unit: notApplicable, + "interior.cell": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Resource + "statement.resource": notApplicable, + "name.resource": notApplicable, + "value.resource": notApplicable, + "type.resource": notApplicable, + "interior.resource": notApplicable, + + // Explicit namespace declarations + "statement.namespace": notApplicable, + "name.namespace": notApplicable, + "interior.namespace": notApplicable, + + // Misc + "statement.update": notApplicable, + "statement.package": notApplicable, + "statement.yield": notApplicable, + "value.yield": notApplicable, + "interior.static": notApplicable, + +}; \ No newline at end of file diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index b10b0d196c..168c5fb1da 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -45,6 +45,9 @@ ;; generic property delc. -- todo a lot on this ngl (property_declaration name: (_) @name + ;;(type_annotation: + ;; ":" + ;;) ) @statement ;; Generic interior @@ -64,7 +67,7 @@ "}" @interior.end.startOf . ) -) @statement +) @statement @class ;; Enum "class: decl. (class_declaration From 4d292c5b5717a3721b35dfffd0e4db17a32ec0b8 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 22 Aug 2026 19:27:51 -0400 Subject: [PATCH 05/13] got all but three required tests generating --- .../src/scopeSupportFacets/swift.ts | 9 ++++-- .../scopes/swift/branch.if.else.scope | 7 +++++ .../fixtures/scopes/swift/branch.if.scope | 5 ++++ resources/fixtures/scopes/swift/class.scope | 15 ++++++++++ .../fixtures/scopes/swift/comment.line.scope | 10 +++++++ .../fixtures/scopes/swift/condition.if.scope | 5 ++++ .../fixtures/scopes/swift/ifStatement.scope | 11 +++++++ .../fixtures/scopes/swift/interior.if.scope | 15 ++++++++++ .../fixtures/scopes/swift/name.class.scope | 23 +++++++++++++++ .../fixtures/scopes/swift/name.enum.scope | 23 +++++++++++++++ .../scopes/swift/name.interface.scope | 23 +++++++++++++++ .../swift/name.variable.initialized.scope | 17 +++++++++++ .../swift/name.variable.uninitialized.scope | 17 +++++++++++ .../scopes/swift/statement.class.scope | 11 +++++++ .../scopes/swift/statement.enum.scope | 11 +++++++ .../scopes/swift/statement.field.class.scope | 29 +++++++++++++++++++ .../swift/statement.field.interface.scope | 15 ++++++++++ .../scopes/swift/statement.interface.scope | 21 ++++++++++++++ .../statement.variable.initialized.scope | 10 +++++++ .../statement.variable.uninitialized.scope | 10 +++++++ .../swift/textFragment.comment.line.scope | 10 +++++++ .../swift/cursorless-test-project/test.swift | 2 +- resources/queries/swift.scm | 26 +++++++---------- 23 files changed, 306 insertions(+), 19 deletions(-) create mode 100644 resources/fixtures/scopes/swift/branch.if.else.scope create mode 100644 resources/fixtures/scopes/swift/branch.if.scope create mode 100644 resources/fixtures/scopes/swift/class.scope create mode 100644 resources/fixtures/scopes/swift/comment.line.scope create mode 100644 resources/fixtures/scopes/swift/condition.if.scope create mode 100644 resources/fixtures/scopes/swift/interior.if.scope create mode 100644 resources/fixtures/scopes/swift/name.class.scope create mode 100644 resources/fixtures/scopes/swift/name.enum.scope create mode 100644 resources/fixtures/scopes/swift/name.interface.scope create mode 100644 resources/fixtures/scopes/swift/name.variable.initialized.scope create mode 100644 resources/fixtures/scopes/swift/name.variable.uninitialized.scope create mode 100644 resources/fixtures/scopes/swift/statement.variable.initialized.scope create mode 100644 resources/fixtures/scopes/swift/statement.variable.uninitialized.scope create mode 100644 resources/fixtures/scopes/swift/textFragment.comment.line.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index d101c4a23b..c78f5d309c 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -55,7 +55,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "name.interface": supported, // named function - namedFunction: supported, + namedFunction: unsupported, // function calls functionCall: unsupported, @@ -145,10 +145,15 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // comments "comment.line": supported, - "string.singleLine": supported, "textFragment.comment.line": supported, "comment.block": unsupported, + // strings + "string.singleLine": unsupported, + "string.multiLine": unsupported, + "textFragment.string.multiLine": unsupported, + "textFragment.string.singleLine": unsupported, + // document-wide iteration "statement.iteration.document": unsupported, "class.iteration.document": unsupported, diff --git a/resources/fixtures/scopes/swift/branch.if.else.scope b/resources/fixtures/scopes/swift/branch.if.else.scope new file mode 100644 index 0000000000..fd686c2268 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -0,0 +1,7 @@ +if foo == 1 { + +} else { + +} +--- + diff --git a/resources/fixtures/scopes/swift/branch.if.scope b/resources/fixtures/scopes/swift/branch.if.scope new file mode 100644 index 0000000000..b0e06d4fb2 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.scope @@ -0,0 +1,5 @@ +if foo == 1 { + +} +--- + diff --git a/resources/fixtures/scopes/swift/class.scope b/resources/fixtures/scopes/swift/class.scope new file mode 100644 index 0000000000..63b2a8482f --- /dev/null +++ b/resources/fixtures/scopes/swift/class.scope @@ -0,0 +1,15 @@ +struct ExampleStruct { + +} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >---------------------- +0| struct ExampleStruct { +1| +2| } + -< + +[Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/swift/comment.line.scope b/resources/fixtures/scopes/swift/comment.line.scope new file mode 100644 index 0000000000..42c1af6d22 --- /dev/null +++ b/resources/fixtures/scopes/swift/comment.line.scope @@ -0,0 +1,10 @@ +// Hello yes this is comment +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:28 + >----------------------------< +0| // Hello yes this is comment + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope new file mode 100644 index 0000000000..b0e06d4fb2 --- /dev/null +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -0,0 +1,5 @@ +if foo == 1 { + +} +--- + diff --git a/resources/fixtures/scopes/swift/ifStatement.scope b/resources/fixtures/scopes/swift/ifStatement.scope index 80a2191be8..89248ad612 100644 --- a/resources/fixtures/scopes/swift/ifStatement.scope +++ b/resources/fixtures/scopes/swift/ifStatement.scope @@ -2,3 +2,14 @@ if foo { } --- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >-------- +0| if foo { +1| +2| } + -< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/interior.if.scope b/resources/fixtures/scopes/swift/interior.if.scope new file mode 100644 index 0000000000..4d0492288f --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.if.scope @@ -0,0 +1,15 @@ +if foo == 1 { + +} +--- + +[Content] = +[Removal] = +[Domain] = 0:13-2:0 + > +0| if foo == 1 { +1| +2| } + < + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.class.scope b/resources/fixtures/scopes/swift/name.class.scope new file mode 100644 index 0000000000..d2c264c138 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.class.scope @@ -0,0 +1,23 @@ +struct ExampleStruct { + +} +--- + +[Content] = +[Domain] = 0:7-0:20 + >-------------< +0| struct ExampleStruct { + +[Removal] = 0:7-0:21 + >--------------< +0| struct ExampleStruct { + +[Leading delimiter] = 0:6-0:7 + >-< +0| struct ExampleStruct { + +[Trailing delimiter] = 0:20-0:21 + >-< +0| struct ExampleStruct { + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.enum.scope b/resources/fixtures/scopes/swift/name.enum.scope new file mode 100644 index 0000000000..a037c87f38 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.enum.scope @@ -0,0 +1,23 @@ +enum TestEnumeration { + +} +--- + +[Content] = +[Domain] = 0:5-0:20 + >---------------< +0| enum TestEnumeration { + +[Removal] = 0:5-0:21 + >----------------< +0| enum TestEnumeration { + +[Leading delimiter] = 0:4-0:5 + >-< +0| enum TestEnumeration { + +[Trailing delimiter] = 0:20-0:21 + >-< +0| enum TestEnumeration { + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.interface.scope b/resources/fixtures/scopes/swift/name.interface.scope new file mode 100644 index 0000000000..8f5ee3a3c2 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.interface.scope @@ -0,0 +1,23 @@ +protocol ExampleProtocol { + +} +--- + +[Content] = +[Domain] = 0:9-0:24 + >---------------< +0| protocol ExampleProtocol { + +[Removal] = 0:9-0:26 + >-----------------< +0| protocol ExampleProtocol { + +[Leading delimiter] = 0:8-0:9 + >-< +0| protocol ExampleProtocol { + +[Trailing delimiter] = 0:24-0:26 + >--< +0| protocol ExampleProtocol { + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.variable.initialized.scope b/resources/fixtures/scopes/swift/name.variable.initialized.scope new file mode 100644 index 0000000000..0fcf9d66ee --- /dev/null +++ b/resources/fixtures/scopes/swift/name.variable.initialized.scope @@ -0,0 +1,17 @@ +var initializedMutableVariable: Double = 42.0 +--- + +[Content] = +[Domain] = 0:4-0:30 + >--------------------------< +0| var initializedMutableVariable: Double = 42.0 + +[Removal] = 0:3-0:30 + >---------------------------< +0| var initializedMutableVariable: Double = 42.0 + +[Leading delimiter] = 0:3-0:4 + >-< +0| var initializedMutableVariable: Double = 42.0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.variable.uninitialized.scope b/resources/fixtures/scopes/swift/name.variable.uninitialized.scope new file mode 100644 index 0000000000..749ebc7c0f --- /dev/null +++ b/resources/fixtures/scopes/swift/name.variable.uninitialized.scope @@ -0,0 +1,17 @@ +var uninitializedMutableVariable: Int +--- + +[Content] = +[Domain] = 0:4-0:32 + >----------------------------< +0| var uninitializedMutableVariable: Int + +[Removal] = 0:3-0:32 + >-----------------------------< +0| var uninitializedMutableVariable: Int + +[Leading delimiter] = 0:3-0:4 + >-< +0| var uninitializedMutableVariable: Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement.class.scope b/resources/fixtures/scopes/swift/statement.class.scope index 33b512a803..f876135c57 100644 --- a/resources/fixtures/scopes/swift/statement.class.scope +++ b/resources/fixtures/scopes/swift/statement.class.scope @@ -2,3 +2,14 @@ class ClassName { } --- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >----------------- +0| class ClassName { +1| +2| } + -< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.enum.scope b/resources/fixtures/scopes/swift/statement.enum.scope index fcf61444ed..76f0b54027 100644 --- a/resources/fixtures/scopes/swift/statement.enum.scope +++ b/resources/fixtures/scopes/swift/statement.enum.scope @@ -2,3 +2,14 @@ enum EnumerationName { } --- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >---------------------- +0| enum EnumerationName { +1| +2| } + -< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.field.class.scope b/resources/fixtures/scopes/swift/statement.field.class.scope index 1faeaa3d0b..0468e7a3b7 100644 --- a/resources/fixtures/scopes/swift/statement.field.class.scope +++ b/resources/fixtures/scopes/swift/statement.field.class.scope @@ -2,3 +2,32 @@ class AnotherClassName { let classConstantFieldOfCommonType = 42 } --- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------------------ +0| class AnotherClassName { +1| let classConstantFieldOfCommonType = 42 +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:43 + >---------------------------------------< +1| let classConstantFieldOfCommonType = 42 + +[#2 Removal] = 1:0-2:0 + >------------------------------------------- +1| let classConstantFieldOfCommonType = 42 +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| let classConstantFieldOfCommonType = 42 + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.field.interface.scope b/resources/fixtures/scopes/swift/statement.field.interface.scope index 99cdb66333..7b20b10451 100644 --- a/resources/fixtures/scopes/swift/statement.field.interface.scope +++ b/resources/fixtures/scopes/swift/statement.field.interface.scope @@ -1,2 +1,17 @@ var requiredSetGetMember: Type = { get set } --- + +[Content] = +[Domain] = 0:4-0:48 + >--------------------------------------------< +0| var requiredSetGetMember: Type = { get set } + +[Removal] = 0:0-0:48 + >------------------------------------------------< +0| var requiredSetGetMember: Type = { get set } + +[Leading delimiter] = 0:0-0:4 + >----< +0| var requiredSetGetMember: Type = { get set } + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.interface.scope b/resources/fixtures/scopes/swift/statement.interface.scope index 5ed7ae25bf..2d0de83138 100644 --- a/resources/fixtures/scopes/swift/statement.interface.scope +++ b/resources/fixtures/scopes/swift/statement.interface.scope @@ -2,3 +2,24 @@ protocol ProtocolName { } --- + +[Content] = +[Domain] = 0:0-2:1 + >----------------------- +0| protocol ProtocolName { +1| +2| } + -< + +[Removal] = 0:0-2:2 + >----------------------- +0| protocol ProtocolName { +1| +2| } + --< + +[Trailing delimiter] = 2:1-2:2 + >-< +2| } + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.variable.initialized.scope b/resources/fixtures/scopes/swift/statement.variable.initialized.scope new file mode 100644 index 0000000000..c6ab473759 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.variable.initialized.scope @@ -0,0 +1,10 @@ +var initializedMutableVariable: Double = 42.0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:45 + >---------------------------------------------< +0| var initializedMutableVariable: Double = 42.0 + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.variable.uninitialized.scope b/resources/fixtures/scopes/swift/statement.variable.uninitialized.scope new file mode 100644 index 0000000000..31fd4ac3b1 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.variable.uninitialized.scope @@ -0,0 +1,10 @@ +var uninitializedMutableVariable: Int +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:37 + >-------------------------------------< +0| var uninitializedMutableVariable: Int + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/textFragment.comment.line.scope b/resources/fixtures/scopes/swift/textFragment.comment.line.scope new file mode 100644 index 0000000000..328567996a --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +// Hello yes this is comment +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:28 + >----------------------------< +0| // Hello yes this is comment + +[Insertion delimiter] = " " diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index 9364627f62..a7a39a4556 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -18,7 +18,7 @@ struct ExamplesStruct { publicVariable += cast let fizz = publicVariable % 3 == 0 let buzz = publicVariable % 5 == 0 - if (fizz || buzz) { + if fizz || buzz { print((fizz ? "fizz" : "") + (buzz ? "buzz" : "")) } for _ in 0 ..< cast { diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 168c5fb1da..2b2a8f85a9 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -22,23 +22,20 @@ (if_statement "if" @branch.start.startOf @branch.removal.start condition: (_) @condition - (statements) @interior.start.startOf @interior.end.endOf + (statements) @interior.domain . "}" @branch.end.endOf @branch.removal.end (else)? @branch.removal.end.startOf ) @condition.domain - (#not-parent-type? @condition.domain if_statement) ) ( + (else) @branch.start @condition.domain.start (if_statement - (else) @branch.start @condition.domain.start - (if_statement - condition: (_) @condition - (statements) @interior.start.startOf @interior.end.endOf - . - "}" @branch.end.endOf @condition.domain.end - ) + condition: (_) @condition + (statements) @interior.domain + . + "}" @branch.end.endOf @condition.domain.end ) ) @@ -51,13 +48,10 @@ ) @statement ;; Generic interior -;;(_ - -;; "{" @interior.start.endOf -;; "}" @interior.end.startOf -;; . - -;;) +(_ + "{" @interior.start.endOf + "}" @interior.end.startOf +) ;; Non-enum class (struct/class) decl. (class_declaration From 8fd4fa6997d442db69d6a48eca1435a5d62f1c64 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 22 Aug 2026 19:51:38 -0400 Subject: [PATCH 06/13] i have no idea what's happening here ngl --- .../src/docs/user/languages/swift.mdx | 5 ++++ .../lib-common/src/extensionDependencies.ts | 1 - .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ .../takeEach.yml | 24 +++++++++++++++++++ 20 files changed, 437 insertions(+), 1 deletion(-) create mode 100644 packages/app-web-docs/src/docs/user/languages/swift.mdx create mode 100644 resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml create mode 100644 resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml create mode 100644 resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml create mode 100644 resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml create mode 100644 resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml create mode 100644 resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml create mode 100644 resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml create mode 100644 resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml create mode 100644 resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml create mode 100644 resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml create mode 100644 resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml create mode 100644 resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml create mode 100644 resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml create mode 100644 resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml create mode 100644 resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml create mode 100644 resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml create mode 100644 resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml create mode 100644 resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml diff --git a/packages/app-web-docs/src/docs/user/languages/swift.mdx b/packages/app-web-docs/src/docs/user/languages/swift.mdx new file mode 100644 index 0000000000..3735a04806 --- /dev/null +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -0,0 +1,5 @@ +import { Language } from "./components/Language"; + +# Swift + + diff --git a/packages/lib-common/src/extensionDependencies.ts b/packages/lib-common/src/extensionDependencies.ts index b6674c1df8..a62060bc0c 100644 --- a/packages/lib-common/src/extensionDependencies.ts +++ b/packages/lib-common/src/extensionDependencies.ts @@ -1,5 +1,4 @@ export const extensionDependencies = [ // Cursorless access to Tree sitter "pokey.parse-tree", - "swiftlang.swift-vscode" ]; diff --git a/resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml b/resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml b/resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml b/resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml b/resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml b/resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml b/resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml b/resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml b/resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml b/resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml b/resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml b/resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml b/resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml b/resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml b/resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml b/resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml b/resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml b/resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml b/resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml new file mode 100644 index 0000000000..1a03a88f86 --- /dev/null +++ b/resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml @@ -0,0 +1,24 @@ +languageId: plaintext +command: + version: 7 + spokenForm: take each + action: + name: setSelection + target: + type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + usePrePhraseSnapshot: false +initialState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} + marks: + default.e: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: hello world + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 5} From 3d3b00b507c28e0463ab99f05046fa652d9bc684 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 22 Aug 2026 20:00:22 -0400 Subject: [PATCH 07/13] pnpm fix again --- .../src/scopeSupportFacets/swift.ts | 460 +++++++++--------- 1 file changed, 229 insertions(+), 231 deletions(-) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index c78f5d309c..826c291b89 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -4,234 +4,232 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const swiftScopeSupport: LanguageScopeSupportFacetMap = { - /* SUPPORTED OR UNSUPPORTED (PLANNED) */ - - // if/else/elif - ifStatement: supported, - "branch.if": supported, - "branch.if.else": supported, - "branch.if.elif.else": unsupported, - "branch.if.iteration": unsupported, - "condition.if": supported, - "interior.if": supported, - - // for loop -- TODO: are swift for loops 'standard' for loops, for-each loops, or both? - "statement.for": unsupported, - "statement.foreach": unsupported, - "condition.for": unsupported, - "name.foreach": unsupported, - "value.foreach": unsupported, - "type.foreach": unsupported, - - // switch - "statement.switch": unsupported, - "branch.switchCase": unsupported, - "branch.switchCase.iteration": unsupported, - "condition.switchCase": unsupported, - "value.switch": unsupported, - "interior.switch": unsupported, - "interior.switchCase": unsupported, - - // control transfer - "statement.return": unsupported, - "value.return": unsupported, - "value.return.lambda": unsupported, - "statement.throw": unsupported, - "value.throw": unsupported, - "statement.break": unsupported, - "statement.continue": unsupported, - - // enum - "statement.enum": supported, - "name.enum": supported, - - // class - class: supported, - "statement.class": supported, - "name.class": supported, - - // protocol (equivalent to interfaces in other languages) - "statement.interface": supported, - "name.interface": supported, - - // named function - namedFunction: unsupported, - - // function calls - functionCall: unsupported, - "functionCall.constructor": unsupported, - "functionCall.method": unsupported, - "functionCall.chain": unsupported, - "functionCall.generic": unsupported, - "functionCall.enum": unsupported, - - // function callee - functionCallee: unsupported, - "functionCallee.constructor": unsupported, - "functionCallee.method": unsupported, - "functionCallee.chain": unsupported, - "functionCallee.generic": unsupported, - "functionCallee.enum": unsupported, - - // argument (actual) - "argument.actual.singleLine": unsupported, - "argument.actual.multiLine": unsupported, - "argument.actual.iteration": unsupported, - "argument.actual.method.singleLine": unsupported, - "argument.actual.method.multiLine": unsupported, - "argument.actual.method.iteration": unsupported, - "argument.actual.constructor.singleLine": unsupported, - "argument.actual.constructor.multiLine": unsupported, - "argument.actual.constructor.iteration": unsupported, - "argument.actual.enum.singleLine": unsupported, - "argument.actual.enum.multiLine": unsupported, - "argument.actual.enum.iteration": unsupported, - - // argument (formal) - "argument.formal.singleLine": unsupported, - "argument.formal.multiLine": unsupported, - "argument.formal.iteration": unsupported, - "argument.formal.method.singleLine": unsupported, - "argument.formal.method.multiLine": unsupported, - "argument.formal.method.iteration": unsupported, - "argument.formal.constructor.singleLine": unsupported, - "argument.formal.constructor.multiLine": unsupported, - "argument.formal.constructor.iteration": unsupported, - "argument.formal.lambda.singleLine": unsupported, - "argument.formal.lambda.multiLine": unsupported, - "argument.formal.lambda.iteration": unsupported, - "argument.formal.catch": unsupported, - - // argument list (actual) - "argumentList.actual.empty": unsupported, - "argumentList.actual.singleLine": unsupported, - "argumentList.actual.multiLine": unsupported, - "argumentList.actual.method.empty": unsupported, - "argumentList.actual.method.singleLine": unsupported, - "argumentList.actual.method.multiLine": unsupported, - "argumentList.actual.constructor.empty": unsupported, - "argumentList.actual.constructor.singleLine": unsupported, - "argumentList.actual.constructor.multiLine": unsupported, - "argumentList.actual.enum.empty": unsupported, - "argumentList.actual.enum.singleLine": unsupported, - "argumentList.actual.enum.multiLine": unsupported, - - // argument list (formal) - "argumentList.formal.empty": unsupported, - "argumentList.formal.singleLine": unsupported, - "argumentList.formal.multiLine": unsupported, - "argumentList.formal.lambda.empty": unsupported, - "argumentList.formal.lambda.singleLine": unsupported, - "argumentList.formal.lambda.multiLine": unsupported, - "argumentList.formal.method.empty": unsupported, - "argumentList.formal.method.singleLine": unsupported, - "argumentList.formal.method.multiLine": unsupported, - "argumentList.formal.constructor.empty": unsupported, - "argumentList.formal.constructor.singleLine": unsupported, - "argumentList.formal.constructor.multiLine": unsupported, - - // named variable/member/field - "statement.field.class": supported, - "statement.field.interface": supported, - "statement.variable.uninitialized": supported, - "statement.variable.initialized": supported, - "name.variable.initialized": supported, - "name.variable.uninitialized": supported, - - // variable/member/field value (RHS) - "value.field.class": unsupported, - "value.field.interface": unsupported, - "value.field.enum": unsupported, - - // comments - "comment.line": supported, - "textFragment.comment.line": supported, - "comment.block": unsupported, - - // strings - "string.singleLine": unsupported, - "string.multiLine": unsupported, - "textFragment.string.multiLine": unsupported, - "textFragment.string.singleLine": unsupported, - - // document-wide iteration - "statement.iteration.document": unsupported, - "class.iteration.document": unsupported, - "namedFunction.iteration.document": unsupported, - "name.iteration.document": unsupported, - "value.iteration.document": unsupported, - "type.iteration.document": unsupported, - - // per-class iteration - "statement.iteration.class": unsupported, - "class.iteration.class": unsupported, - "namedFunction.iteration.class": unsupported, - "name.iteration.class": unsupported, - "value.iteration.class": unsupported, - "type.iteration.class": unsupported, - - // per-protocol iteration - "statement.iteration.interface": unsupported, - "name.iteration.interface": unsupported, - "type.iteration.interface": unsupported, - - // per-block iteration - "statement.iteration.block": unsupported, - "name.iteration.block": unsupported, - "value.iteration.block": unsupported, - "type.iteration.block": unsupported, - - // misc - "statement.assignment.compound": unsupported, - "statement.typeAlias": unsupported, - "statement.misc": unsupported, - - - /* NOT APPLICABLE */ - - // XML/CSS/LaTeX/Markdown specific - section: notApplicable, - "section.iteration.document": notApplicable, - "section.iteration.parent": notApplicable, - element: notApplicable, - tags: notApplicable, - startTag: notApplicable, - endTag: notApplicable, - "interior.element": notApplicable, - "textFragment.element": notApplicable, - attribute: notApplicable, - "key.attribute": notApplicable, - "value.attribute": notApplicable, - environment: notApplicable, - notebookCell: notApplicable, - selector: notApplicable, - unit: notApplicable, - "interior.cell": notApplicable, - - // Command - command: notApplicable, - "statement.command": notApplicable, - "name.command": notApplicable, - "value.command": notApplicable, - "interior.command": notApplicable, - - // Resource - "statement.resource": notApplicable, - "name.resource": notApplicable, - "value.resource": notApplicable, - "type.resource": notApplicable, - "interior.resource": notApplicable, - - // Explicit namespace declarations - "statement.namespace": notApplicable, - "name.namespace": notApplicable, - "interior.namespace": notApplicable, - - // Misc - "statement.update": notApplicable, - "statement.package": notApplicable, - "statement.yield": notApplicable, - "value.yield": notApplicable, - "interior.static": notApplicable, - -}; \ No newline at end of file + /* SUPPORTED OR UNSUPPORTED (PLANNED) */ + + // if/else/elif + ifStatement: supported, + "branch.if": supported, + "branch.if.else": supported, + "branch.if.elif.else": unsupported, + "branch.if.iteration": unsupported, + "condition.if": supported, + "interior.if": supported, + + // for loop -- TODO: are swift for loops 'standard' for loops, for-each loops, or both? + "statement.for": unsupported, + "statement.foreach": unsupported, + "condition.for": unsupported, + "name.foreach": unsupported, + "value.foreach": unsupported, + "type.foreach": unsupported, + + // switch + "statement.switch": unsupported, + "branch.switchCase": unsupported, + "branch.switchCase.iteration": unsupported, + "condition.switchCase": unsupported, + "value.switch": unsupported, + "interior.switch": unsupported, + "interior.switchCase": unsupported, + + // control transfer + "statement.return": unsupported, + "value.return": unsupported, + "value.return.lambda": unsupported, + "statement.throw": unsupported, + "value.throw": unsupported, + "statement.break": unsupported, + "statement.continue": unsupported, + + // enum + "statement.enum": supported, + "name.enum": supported, + + // class + class: supported, + "statement.class": supported, + "name.class": supported, + + // protocol (equivalent to interfaces in other languages) + "statement.interface": supported, + "name.interface": supported, + + // named function + namedFunction: unsupported, + + // function calls + functionCall: unsupported, + "functionCall.constructor": unsupported, + "functionCall.method": unsupported, + "functionCall.chain": unsupported, + "functionCall.generic": unsupported, + "functionCall.enum": unsupported, + + // function callee + functionCallee: unsupported, + "functionCallee.constructor": unsupported, + "functionCallee.method": unsupported, + "functionCallee.chain": unsupported, + "functionCallee.generic": unsupported, + "functionCallee.enum": unsupported, + + // argument (actual) + "argument.actual.singleLine": unsupported, + "argument.actual.multiLine": unsupported, + "argument.actual.iteration": unsupported, + "argument.actual.method.singleLine": unsupported, + "argument.actual.method.multiLine": unsupported, + "argument.actual.method.iteration": unsupported, + "argument.actual.constructor.singleLine": unsupported, + "argument.actual.constructor.multiLine": unsupported, + "argument.actual.constructor.iteration": unsupported, + "argument.actual.enum.singleLine": unsupported, + "argument.actual.enum.multiLine": unsupported, + "argument.actual.enum.iteration": unsupported, + + // argument (formal) + "argument.formal.singleLine": unsupported, + "argument.formal.multiLine": unsupported, + "argument.formal.iteration": unsupported, + "argument.formal.method.singleLine": unsupported, + "argument.formal.method.multiLine": unsupported, + "argument.formal.method.iteration": unsupported, + "argument.formal.constructor.singleLine": unsupported, + "argument.formal.constructor.multiLine": unsupported, + "argument.formal.constructor.iteration": unsupported, + "argument.formal.lambda.singleLine": unsupported, + "argument.formal.lambda.multiLine": unsupported, + "argument.formal.lambda.iteration": unsupported, + "argument.formal.catch": unsupported, + + // argument list (actual) + "argumentList.actual.empty": unsupported, + "argumentList.actual.singleLine": unsupported, + "argumentList.actual.multiLine": unsupported, + "argumentList.actual.method.empty": unsupported, + "argumentList.actual.method.singleLine": unsupported, + "argumentList.actual.method.multiLine": unsupported, + "argumentList.actual.constructor.empty": unsupported, + "argumentList.actual.constructor.singleLine": unsupported, + "argumentList.actual.constructor.multiLine": unsupported, + "argumentList.actual.enum.empty": unsupported, + "argumentList.actual.enum.singleLine": unsupported, + "argumentList.actual.enum.multiLine": unsupported, + + // argument list (formal) + "argumentList.formal.empty": unsupported, + "argumentList.formal.singleLine": unsupported, + "argumentList.formal.multiLine": unsupported, + "argumentList.formal.lambda.empty": unsupported, + "argumentList.formal.lambda.singleLine": unsupported, + "argumentList.formal.lambda.multiLine": unsupported, + "argumentList.formal.method.empty": unsupported, + "argumentList.formal.method.singleLine": unsupported, + "argumentList.formal.method.multiLine": unsupported, + "argumentList.formal.constructor.empty": unsupported, + "argumentList.formal.constructor.singleLine": unsupported, + "argumentList.formal.constructor.multiLine": unsupported, + + // named variable/member/field + "statement.field.class": supported, + "statement.field.interface": supported, + "statement.variable.uninitialized": supported, + "statement.variable.initialized": supported, + "name.variable.initialized": supported, + "name.variable.uninitialized": supported, + + // variable/member/field value (RHS) + "value.field.class": unsupported, + "value.field.interface": unsupported, + "value.field.enum": unsupported, + + // comments + "comment.line": supported, + "textFragment.comment.line": supported, + "comment.block": unsupported, + + // strings + "string.singleLine": unsupported, + "string.multiLine": unsupported, + "textFragment.string.multiLine": unsupported, + "textFragment.string.singleLine": unsupported, + + // document-wide iteration + "statement.iteration.document": unsupported, + "class.iteration.document": unsupported, + "namedFunction.iteration.document": unsupported, + "name.iteration.document": unsupported, + "value.iteration.document": unsupported, + "type.iteration.document": unsupported, + + // per-class iteration + "statement.iteration.class": unsupported, + "class.iteration.class": unsupported, + "namedFunction.iteration.class": unsupported, + "name.iteration.class": unsupported, + "value.iteration.class": unsupported, + "type.iteration.class": unsupported, + + // per-protocol iteration + "statement.iteration.interface": unsupported, + "name.iteration.interface": unsupported, + "type.iteration.interface": unsupported, + + // per-block iteration + "statement.iteration.block": unsupported, + "name.iteration.block": unsupported, + "value.iteration.block": unsupported, + "type.iteration.block": unsupported, + + // misc + "statement.assignment.compound": unsupported, + "statement.typeAlias": unsupported, + "statement.misc": unsupported, + + /* NOT APPLICABLE */ + + // XML/CSS/LaTeX/Markdown specific + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, + element: notApplicable, + tags: notApplicable, + startTag: notApplicable, + endTag: notApplicable, + "interior.element": notApplicable, + "textFragment.element": notApplicable, + attribute: notApplicable, + "key.attribute": notApplicable, + "value.attribute": notApplicable, + environment: notApplicable, + notebookCell: notApplicable, + selector: notApplicable, + unit: notApplicable, + "interior.cell": notApplicable, + + // Command + command: notApplicable, + "statement.command": notApplicable, + "name.command": notApplicable, + "value.command": notApplicable, + "interior.command": notApplicable, + + // Resource + "statement.resource": notApplicable, + "name.resource": notApplicable, + "value.resource": notApplicable, + "type.resource": notApplicable, + "interior.resource": notApplicable, + + // Explicit namespace declarations + "statement.namespace": notApplicable, + "name.namespace": notApplicable, + "interior.namespace": notApplicable, + + // Misc + "statement.update": notApplicable, + "statement.package": notApplicable, + "statement.yield": notApplicable, + "value.yield": notApplicable, + "interior.static": notApplicable, +}; From 259b3df59acad0bbd02a838eacffbc7eac3fd357 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 22 Aug 2026 20:34:34 -0400 Subject: [PATCH 08/13] run precommit --- .gitignore | 2 +- .../scopes/swift/branch.if.else.scope | 1 - .../fixtures/scopes/swift/branch.if.scope | 1 - .../fixtures/scopes/swift/condition.if.scope | 1 - resources/queries/swift.scm | 82 +++++++++---------- 5 files changed, 42 insertions(+), 45 deletions(-) diff --git a/.gitignore b/.gitignore index b97bc3633a..ab3f0caee6 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,4 @@ node_modules/ .luacheckcache # Swift Test Project -/resources/playground/swift/cursorless-test-project/.build \ No newline at end of file +/resources/playground/swift/cursorless-test-project/.build diff --git a/resources/fixtures/scopes/swift/branch.if.else.scope b/resources/fixtures/scopes/swift/branch.if.else.scope index fd686c2268..1948d93016 100644 --- a/resources/fixtures/scopes/swift/branch.if.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -4,4 +4,3 @@ if foo == 1 { } --- - diff --git a/resources/fixtures/scopes/swift/branch.if.scope b/resources/fixtures/scopes/swift/branch.if.scope index b0e06d4fb2..2fbde755d3 100644 --- a/resources/fixtures/scopes/swift/branch.if.scope +++ b/resources/fixtures/scopes/swift/branch.if.scope @@ -2,4 +2,3 @@ if foo == 1 { } --- - diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope index b0e06d4fb2..2fbde755d3 100644 --- a/resources/fixtures/scopes/swift/condition.if.scope +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -2,4 +2,3 @@ if foo == 1 { } --- - diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 2b2a8f85a9..ff64c88911 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -4,71 +4,71 @@ (comment) @comment @textFragment ;; Protocol decl. (protocol_declaration - name: (_) @name - body: (protocol_body - "{" @interior.start.endOf - "}" @interior.end.startOf - . - ) + name: (_) @name + body: (protocol_body + "{" @interior.start.endOf + "}" @interior.end.startOf + . + ) ) @statement ;;if statement -- todo seperate main if branch from else and else if branches ( - (if_statement) @ifStatement @statement @branch.domain - (#not-parent-type? @ifStatement if_statement) + (if_statement) @ifStatement @statement @branch.domain + (#not-parent-type? @ifStatement if_statement) ) ( - (if_statement - "if" @branch.start.startOf @branch.removal.start - condition: (_) @condition - (statements) @interior.domain - . - "}" @branch.end.endOf @branch.removal.end - (else)? @branch.removal.end.startOf - ) @condition.domain + (if_statement + "if" @branch.start.startOf @branch.removal.start + condition: (_) @condition + (statements) @interior.domain + . + "}" @branch.end.endOf @branch.removal.end + (else)? @branch.removal.end.startOf + ) @condition.domain ) ( - (else) @branch.start @condition.domain.start - (if_statement - condition: (_) @condition - (statements) @interior.domain - . - "}" @branch.end.endOf @condition.domain.end - ) + (else) @branch.start @condition.domain.start + (if_statement + condition: (_) @condition + (statements) @interior.domain + . + "}" @branch.end.endOf @condition.domain.end + ) ) ;; generic property delc. -- todo a lot on this ngl (property_declaration - name: (_) @name - ;;(type_annotation: - ;; ":" - ;;) + name: (_) @name + ;;(type_annotation: + ;; ":" + ;;) ) @statement ;; Generic interior (_ - "{" @interior.start.endOf - "}" @interior.end.startOf + "{" @interior.start.endOf + "}" @interior.end.startOf ) ;; Non-enum class (struct/class) decl. (class_declaration - name: (_) @name - body: (class_body - "{" @interior.start.endOf - "}" @interior.end.startOf - . - ) + name: (_) @name + body: (class_body + "{" @interior.start.endOf + "}" @interior.end.startOf + . + ) ) @statement @class ;; Enum "class: decl. (class_declaration - name: (_) @name - body: (enum_class_body - "{" @interior.start.endOf - "}" @interior.end.startOf - . - ) + name: (_) @name + body: (enum_class_body + "{" @interior.start.endOf + "}" @interior.end.startOf + . + ) ) @statement From 56549bb3a0ea546a46865cd60d3993a69ffcee4c Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sun, 23 Aug 2026 22:06:48 -0400 Subject: [PATCH 09/13] Added for each loop; some if-else tests continue to fail to generate despite scopes working in editor --- .../src/scopeSupportFacets/swift.ts | 20 +++++---- .../scopes/swift/branch.if.elif.else.scope | 8 ++++ .../scopes/swift/branch.if.else.scope | 2 +- .../scopes/swift/branch.if.iteration.scope | 18 ++++++++ .../fixtures/scopes/swift/branch.if.scope | 2 +- .../fixtures/scopes/swift/condition.if.scope | 2 +- .../fixtures/scopes/swift/name.foreach.scope | 29 +++++++++++++ .../scopes/swift/statement.foreach.scope | 15 +++++++ .../fixtures/scopes/swift/type.foreach.scope | 25 +++++++++++ .../fixtures/scopes/swift/value.foreach.scope | 29 +++++++++++++ resources/playground/rust.rs | 1 + .../swift/cursorless-test-project/test.swift | 5 ++- resources/queries/swift.scm | 42 ++++++++++++++----- 13 files changed, 174 insertions(+), 24 deletions(-) create mode 100644 resources/fixtures/scopes/swift/branch.if.elif.else.scope create mode 100644 resources/fixtures/scopes/swift/branch.if.iteration.scope create mode 100644 resources/fixtures/scopes/swift/name.foreach.scope create mode 100644 resources/fixtures/scopes/swift/statement.foreach.scope create mode 100644 resources/fixtures/scopes/swift/type.foreach.scope create mode 100644 resources/fixtures/scopes/swift/value.foreach.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 826c291b89..5344acd08a 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -10,18 +10,16 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { ifStatement: supported, "branch.if": supported, "branch.if.else": supported, - "branch.if.elif.else": unsupported, - "branch.if.iteration": unsupported, + "branch.if.elif.else": supported, + "branch.if.iteration": supported, "condition.if": supported, "interior.if": supported, - // for loop -- TODO: are swift for loops 'standard' for loops, for-each loops, or both? - "statement.for": unsupported, - "statement.foreach": unsupported, - "condition.for": unsupported, - "name.foreach": unsupported, - "value.foreach": unsupported, - "type.foreach": unsupported, + // for loop + "statement.foreach": supported, + "name.foreach": supported, + "value.foreach": supported, + "type.foreach": supported, // switch "statement.switch": unsupported, @@ -188,6 +186,10 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { /* NOT APPLICABLE */ + // c-style for loop + "statement.for": notApplicable, + "condition.for": notApplicable, + // XML/CSS/LaTeX/Markdown specific section: notApplicable, "section.iteration.document": notApplicable, diff --git a/resources/fixtures/scopes/swift/branch.if.elif.else.scope b/resources/fixtures/scopes/swift/branch.if.elif.else.scope new file mode 100644 index 0000000000..cc79f52142 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.elif.else.scope @@ -0,0 +1,8 @@ +if firstCondition { + +} else secondCondition { + +} else { + +} +--- diff --git a/resources/fixtures/scopes/swift/branch.if.else.scope b/resources/fixtures/scopes/swift/branch.if.else.scope index 1948d93016..517641ab1e 100644 --- a/resources/fixtures/scopes/swift/branch.if.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -1,4 +1,4 @@ -if foo == 1 { +if condition { } else { diff --git a/resources/fixtures/scopes/swift/branch.if.iteration.scope b/resources/fixtures/scopes/swift/branch.if.iteration.scope new file mode 100644 index 0000000000..1bddf7937d --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -0,0 +1,18 @@ +if firstCondition { + +} else secondCondition { + +} else { + +} +--- + +[Content] = +[Domain] = 0:0-4:1 + >------------------- +0| if firstCondition { +1| +2| } else secondCondition { +3| +4| } else { + -< diff --git a/resources/fixtures/scopes/swift/branch.if.scope b/resources/fixtures/scopes/swift/branch.if.scope index 2fbde755d3..6a8d0054cf 100644 --- a/resources/fixtures/scopes/swift/branch.if.scope +++ b/resources/fixtures/scopes/swift/branch.if.scope @@ -1,4 +1,4 @@ -if foo == 1 { +if condition { } --- diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope index 2fbde755d3..6a8d0054cf 100644 --- a/resources/fixtures/scopes/swift/condition.if.scope +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -1,4 +1,4 @@ -if foo == 1 { +if condition { } --- diff --git a/resources/fixtures/scopes/swift/name.foreach.scope b/resources/fixtures/scopes/swift/name.foreach.scope new file mode 100644 index 0000000000..6cca538e5d --- /dev/null +++ b/resources/fixtures/scopes/swift/name.foreach.scope @@ -0,0 +1,29 @@ +for item in collection { + +} +--- + +[Content] = 0:4-0:8 + >----< +0| for item in collection { + +[Removal] = 0:4-0:9 + >-----< +0| for item in collection { + +[Leading delimiter] = 0:3-0:4 + >-< +0| for item in collection { + +[Trailing delimiter] = 0:8-0:9 + >-< +0| for item in collection { + +[Domain] = 0:0-2:1 + >------------------------ +0| for item in collection { +1| +2| } + -< + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement.foreach.scope b/resources/fixtures/scopes/swift/statement.foreach.scope new file mode 100644 index 0000000000..e2a3480ad5 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.foreach.scope @@ -0,0 +1,15 @@ +for item in collection { + +} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >------------------------ +0| for item in collection { +1| +2| } + -< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/type.foreach.scope b/resources/fixtures/scopes/swift/type.foreach.scope new file mode 100644 index 0000000000..76661ec025 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.foreach.scope @@ -0,0 +1,25 @@ +for typedItem: Type in collection { + +} +--- + +[Content] = 0:15-0:19 + >----< +0| for typedItem: Type in collection { + +[Removal] = 0:13-0:19 + >------< +0| for typedItem: Type in collection { + +[Leading delimiter] = 0:13-0:15 + >--< +0| for typedItem: Type in collection { + +[Domain] = 0:0-2:1 + >----------------------------------- +0| for typedItem: Type in collection { +1| +2| } + -< + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value.foreach.scope b/resources/fixtures/scopes/swift/value.foreach.scope new file mode 100644 index 0000000000..d5e8b83c65 --- /dev/null +++ b/resources/fixtures/scopes/swift/value.foreach.scope @@ -0,0 +1,29 @@ +for item in collection { + +} +--- + +[Content] = 0:12-0:22 + >----------< +0| for item in collection { + +[Removal] = 0:12-0:23 + >-----------< +0| for item in collection { + +[Leading delimiter] = 0:11-0:12 + >-< +0| for item in collection { + +[Trailing delimiter] = 0:22-0:23 + >-< +0| for item in collection { + +[Domain] = 0:0-2:1 + >------------------------ +0| for item in collection { +1| +2| } + -< + +[Insertion delimiter] = " " diff --git a/resources/playground/rust.rs b/resources/playground/rust.rs index 70bc5084d3..1cfa874e89 100644 --- a/resources/playground/rust.rs +++ b/resources/playground/rust.rs @@ -1,4 +1,5 @@ fn hello() { + let apple: Bool = false if true { //1 } else if false { diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index a7a39a4556..3f6659b5d7 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -17,13 +17,16 @@ struct ExamplesStruct { let cast: UInt128 = numericCast(times) publicVariable += cast let fizz = publicVariable % 3 == 0 - let buzz = publicVariable % 5 == 0 + let buzz: Bool = publicVariable % 5 == 0 if fizz || buzz { print((fizz ? "fizz" : "") + (buzz ? "buzz" : "")) } for _ in 0 ..< cast { print(ExamplesStruct.exampleFunction(exampleLabel: exampleLabel)) } + for c: Character in "test" { + + } } } diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index ff64c88911..41613d29eb 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -12,34 +12,39 @@ ) ) @statement -;;if statement -- todo seperate main if branch from else and else if branches +;;if statement ( - (if_statement) @ifStatement @statement @branch.domain + (if_statement) @ifStatement @statement @branch.iteration (#not-parent-type? @ifStatement if_statement) ) ( (if_statement - "if" @branch.start.startOf @branch.removal.start + "if" @branch.start @branch.removal.start condition: (_) @condition - (statements) @interior.domain - . - "}" @branch.end.endOf @branch.removal.end + (statements) + "}" @branch.end @branch.removal.end (else)? @branch.removal.end.startOf ) @condition.domain + (#not-parent-type? @condition.domain else) ) ( (else) @branch.start @condition.domain.start (if_statement condition: (_) @condition - (statements) @interior.domain - . - "}" @branch.end.endOf @condition.domain.end + (statements) + "}" @branch.end @condition.domain.end ) ) -;; generic property delc. -- todo a lot on this ngl +( + (else) @branch.start + (statements) + "}" @branch.end +) + +;; generic property delc (property_declaration name: (_) @name ;;(type_annotation: @@ -63,7 +68,7 @@ ) ) @statement @class -;; Enum "class: decl. +;; Enum "class" decl. (class_declaration name: (_) @name body: (enum_class_body @@ -72,3 +77,18 @@ . ) ) @statement + +;; For loop w/ type +( + (for_statement + "for" + item: (_) @name + (type_annotation + ":" @type.leading + . + _ @type @name.trailing + )? + "in" + collection: (_) @value + ) @statement @_.domain +) From 32307021f89bd3b585678c953fe91e8c88a7d87c Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Mon, 24 Aug 2026 02:54:13 -0400 Subject: [PATCH 10/13] Not really sure why this works, but it seemingly does now! --- .../scopes/swift/branch.if.elif.else.scope | 65 +++++++++++++++++++ .../scopes/swift/branch.if.else.scope | 57 ++++++++++++++++ .../fixtures/scopes/swift/branch.if.scope | 11 ++++ .../fixtures/scopes/swift/condition.if.scope | 25 +++++++ resources/queries/swift.scm | 8 +-- 5 files changed, 160 insertions(+), 6 deletions(-) diff --git a/resources/fixtures/scopes/swift/branch.if.elif.else.scope b/resources/fixtures/scopes/swift/branch.if.elif.else.scope index cc79f52142..71ef841c68 100644 --- a/resources/fixtures/scopes/swift/branch.if.elif.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.elif.else.scope @@ -6,3 +6,68 @@ if firstCondition { } --- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------------- +0| if firstCondition { +1| +2| } else secondCondition { + -< + +[#1 Removal] = 0:0-2:2 + >------------------- +0| if firstCondition { +1| +2| } else secondCondition { + --< + +[#1 Trailing delimiter] = 2:1-2:2 + >-< +2| } else secondCondition { + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:0-4:1 + >------------------- +0| if firstCondition { +1| +2| } else secondCondition { +3| +4| } else { + -< + +[#2 Trailing delimiter] = 4:1-4:2 + >-< +4| } else { + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:2-4:1 + >---------------------- +2| } else secondCondition { +3| +4| } else { + -< + +[#3 Removal] = 2:2-4:2 + >---------------------- +2| } else secondCondition { +3| +4| } else { + --< + +[#3 Leading delimiter] = 2:1-2:2 + >-< +2| } else secondCondition { + +[#3 Trailing delimiter] = 4:1-4:2 + >-< +4| } else { + +[#3 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch.if.else.scope b/resources/fixtures/scopes/swift/branch.if.else.scope index 517641ab1e..ab88c1db0a 100644 --- a/resources/fixtures/scopes/swift/branch.if.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -4,3 +4,60 @@ if condition { } --- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >-------------- +0| if condition { +1| +2| } else { + -< + +[#1 Removal] = 0:0-2:2 + >-------------- +0| if condition { +1| +2| } else { + --< + +[#1 Trailing delimiter] = 2:1-2:2 + >-< +2| } else { + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:0-4:1 + >-------------- +0| if condition { +1| +2| } else { +3| +4| } + -< + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:2-4:1 + >------ +2| } else { +3| +4| } + -< + +[#3 Removal] = 2:1-4:1 + >------- +2| } else { +3| +4| } + -< + +[#3 Leading delimiter] = 2:1-2:2 + >-< +2| } else { + +[#3 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch.if.scope b/resources/fixtures/scopes/swift/branch.if.scope index 6a8d0054cf..f0eae28d27 100644 --- a/resources/fixtures/scopes/swift/branch.if.scope +++ b/resources/fixtures/scopes/swift/branch.if.scope @@ -2,3 +2,14 @@ if condition { } --- + +[Content] = +[Removal] = +[Domain] = 0:0-2:1 + >-------------- +0| if condition { +1| +2| } + -< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope index 6a8d0054cf..752a0fa34f 100644 --- a/resources/fixtures/scopes/swift/condition.if.scope +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -2,3 +2,28 @@ if condition { } --- + +[Content] = 0:3-0:12 + >---------< +0| if condition { + +[Removal] = 0:3-0:13 + >----------< +0| if condition { + +[Leading delimiter] = 0:2-0:3 + >-< +0| if condition { + +[Trailing delimiter] = 0:12-0:13 + >-< +0| if condition { + +[Domain] = 0:0-2:1 + >-------------- +0| if condition { +1| +2| } + -< + +[Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 41613d29eb..595e18f782 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -8,7 +8,6 @@ body: (protocol_body "{" @interior.start.endOf "}" @interior.end.startOf - . ) ) @statement @@ -22,7 +21,6 @@ (if_statement "if" @branch.start @branch.removal.start condition: (_) @condition - (statements) "}" @branch.end @branch.removal.end (else)? @branch.removal.end.startOf ) @condition.domain @@ -32,15 +30,13 @@ ( (else) @branch.start @condition.domain.start (if_statement - condition: (_) @condition - (statements) - "}" @branch.end @condition.domain.end + condition: (_) @condition @condition.domain.end + "}" @branch.end ) ) ( (else) @branch.start - (statements) "}" @branch.end ) From 051b50d9c3e035ea43c76e7cfd12b47cdc7cac0a Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Mon, 24 Aug 2026 17:42:43 -0400 Subject: [PATCH 11/13] remove the buggy takeEach.yml copies --- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- .../takeEach.yml | 24 ------------------- 18 files changed, 432 deletions(-) delete mode 100644 resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml delete mode 100644 resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml delete mode 100644 resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml delete mode 100644 resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml delete mode 100644 resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml delete mode 100644 resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml delete mode 100644 resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml delete mode 100644 resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml delete mode 100644 resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml delete mode 100644 resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml delete mode 100644 resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml delete mode 100644 resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml delete mode 100644 resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml delete mode 100644 resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml delete mode 100644 resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml delete mode 100644 resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml delete mode 100644 resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml delete mode 100644 resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml diff --git a/resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml b/resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/115144f9a0c408636d0b1eca862d4380/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml b/resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/1410287bca916a58fec21626f2186c27/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml b/resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/37155f7829275e53c501e0bfccf01024/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml b/resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/3d316f7f337f81bcc06222b612e6dc0a/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml b/resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/53405ba23fc16a200add7f4515d30656/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml b/resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/83517f89966bc138393dcc3d312a5dcd/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml b/resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/874bb97d93d9d3758622030317923b15/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml b/resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/933c384feb656b3bf7d0a87b916918bb/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml b/resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/aaf4c4cf76d4ec3fa376a07029737bd6/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml b/resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/ba33400d37345f4641370de5635a6d0f/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml b/resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/c15159af806e192067eee8b06331addb/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml b/resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/c3f9adbdde0c6a02afa9ff7d699c721e/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml b/resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/d1c201d540ca96150baa1067c67bb78b/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml b/resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/d2b4f5a00c87c5a1e9a6282a9787f907/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml b/resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/da4c93499b3b80420c9c8ef71f1db218/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml b/resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/f2c4aef35a6cef99902a650a4f716ed1/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml b/resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/f397d66e96897a55290bc4b2c614ab1d/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} diff --git a/resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml b/resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml deleted file mode 100644 index 1a03a88f86..0000000000 --- a/resources/fixtures/recorded/fb9d5dadff0803ac8b1c5cb1ee6a0bf1/takeEach.yml +++ /dev/null @@ -1,24 +0,0 @@ -languageId: plaintext -command: - version: 7 - spokenForm: take each - action: - name: setSelection - target: - type: primitive - mark: {type: decoratedSymbol, symbolColor: default, character: e} - usePrePhraseSnapshot: false -initialState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 11} - active: {line: 0, character: 11} - marks: - default.e: - start: {line: 0, character: 0} - end: {line: 0, character: 5} -finalState: - documentContents: hello world - selections: - - anchor: {line: 0, character: 0} - active: {line: 0, character: 5} From bd2a1fde78f4ef470a7d9e55b34e2df9c80b5534 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Mon, 24 Aug 2026 23:10:24 -0400 Subject: [PATCH 12/13] improve scope support correctness, add multiline string and comment scope support, redo scope tests to better fit style guide --- .../src/scopeSupportFacets/swift.ts | 23 +-- .../scopes/swift/branch.if.elif.else.scope | 138 ++++++++++-------- .../scopes/swift/branch.if.else.scope | 72 ++++----- .../scopes/swift/branch.if.iteration.scope | 24 ++- .../fixtures/scopes/swift/branch.if.scope | 13 +- resources/fixtures/scopes/swift/class.scope | 13 +- .../fixtures/scopes/swift/comment.block.scope | 15 ++ .../fixtures/scopes/swift/comment.line.scope | 8 +- .../fixtures/scopes/swift/condition.if.scope | 33 ++--- .../fixtures/scopes/swift/ifStatement.scope | 13 +- .../fixtures/scopes/swift/interior.if.scope | 13 +- .../fixtures/scopes/swift/name.class.scope | 28 ++-- .../fixtures/scopes/swift/name.enum.scope | 24 ++- .../fixtures/scopes/swift/name.foreach.scope | 33 ++--- .../scopes/swift/name.interface.scope | 24 ++- .../swift/name.variable.initialized.scope | 17 --- .../swift/name.variable.uninitialized.scope | 17 --- .../scopes/swift/statement.class.scope | 13 +- .../scopes/swift/statement.enum.scope | 13 +- .../scopes/swift/statement.field.class.scope | 33 ----- .../swift/statement.field.interface.scope | 17 --- .../scopes/swift/statement.foreach.scope | 13 +- .../scopes/swift/statement.interface.scope | 25 +--- .../statement.variable.initialized.scope | 10 -- .../statement.variable.uninitialized.scope | 10 -- .../scopes/swift/string.multiLine.scope | 15 ++ .../scopes/swift/string.singleLine.scope | 10 ++ .../swift/textFragment.comment.block.scope | 15 ++ .../swift/textFragment.comment.line.scope | 8 +- .../swift/textFragment.string.multiLine.scope | 15 ++ .../textFragment.string.singleLine.scope | 10 ++ .../fixtures/scopes/swift/type.foreach.scope | 31 ++-- .../fixtures/scopes/swift/value.foreach.scope | 37 ++--- .../swift/cursorless-test-project/test.swift | 12 ++ resources/queries/swift.scm | 28 +++- 35 files changed, 376 insertions(+), 447 deletions(-) create mode 100644 resources/fixtures/scopes/swift/comment.block.scope delete mode 100644 resources/fixtures/scopes/swift/name.variable.initialized.scope delete mode 100644 resources/fixtures/scopes/swift/name.variable.uninitialized.scope delete mode 100644 resources/fixtures/scopes/swift/statement.field.class.scope delete mode 100644 resources/fixtures/scopes/swift/statement.field.interface.scope delete mode 100644 resources/fixtures/scopes/swift/statement.variable.initialized.scope delete mode 100644 resources/fixtures/scopes/swift/statement.variable.uninitialized.scope create mode 100644 resources/fixtures/scopes/swift/string.multiLine.scope create mode 100644 resources/fixtures/scopes/swift/string.singleLine.scope create mode 100644 resources/fixtures/scopes/swift/textFragment.comment.block.scope create mode 100644 resources/fixtures/scopes/swift/textFragment.string.multiLine.scope create mode 100644 resources/fixtures/scopes/swift/textFragment.string.singleLine.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 5344acd08a..04778605b9 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -129,12 +129,12 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "argumentList.formal.constructor.multiLine": unsupported, // named variable/member/field - "statement.field.class": supported, - "statement.field.interface": supported, - "statement.variable.uninitialized": supported, - "statement.variable.initialized": supported, - "name.variable.initialized": supported, - "name.variable.uninitialized": supported, + "statement.field.class": unsupported, + "statement.field.interface": unsupported, + "statement.variable.uninitialized": unsupported, + "statement.variable.initialized": unsupported, + "name.variable.initialized": unsupported, + "name.variable.uninitialized": unsupported, // variable/member/field value (RHS) "value.field.class": unsupported, @@ -144,13 +144,14 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // comments "comment.line": supported, "textFragment.comment.line": supported, - "comment.block": unsupported, + "textFragment.comment.block": supported, + "comment.block": supported, // strings - "string.singleLine": unsupported, - "string.multiLine": unsupported, - "textFragment.string.multiLine": unsupported, - "textFragment.string.singleLine": unsupported, + "string.singleLine": supported, + "string.multiLine": supported, + "textFragment.string.multiLine": supported, + "textFragment.string.singleLine": supported, // document-wide iteration "statement.iteration.document": unsupported, diff --git a/resources/fixtures/scopes/swift/branch.if.elif.else.scope b/resources/fixtures/scopes/swift/branch.if.elif.else.scope index 71ef841c68..c8aa5e8b4e 100644 --- a/resources/fixtures/scopes/swift/branch.if.elif.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.elif.else.scope @@ -1,73 +1,95 @@ -if firstCondition { - -} else secondCondition { - -} else { - -} +if foo {} +else if bar {} +else {} --- [#1 Content] = -[#1 Domain] = 0:0-2:1 - >------------------- -0| if firstCondition { -1| -2| } else secondCondition { - -< - -[#1 Removal] = 0:0-2:2 - >------------------- -0| if firstCondition { -1| -2| } else secondCondition { - --< - -[#1 Trailing delimiter] = 2:1-2:2 - >-< -2| } else secondCondition { +[#1 Domain] = 0:0-0:9 + >---------< +0| if foo {} + +[#1 Removal] = 0:0-1:0 + >--------- +0| if foo {} +1| else if bar {} + < [#1 Insertion delimiter] = "\n" [#2 Content] = -[#2 Removal] = -[#2 Domain] = 0:0-4:1 - >------------------- -0| if firstCondition { -1| -2| } else secondCondition { -3| -4| } else { - -< - -[#2 Trailing delimiter] = 4:1-4:2 - >-< -4| } else { +[#2 Domain] = 1:0-1:14 + >--------------< +1| else if bar {} + +[#2 Removal] = 1:0-2:0 + >-------------- +1| else if bar {} +2| else {} + < [#2 Insertion delimiter] = "\n" [#3 Content] = -[#3 Domain] = 2:2-4:1 - >---------------------- -2| } else secondCondition { -3| -4| } else { - -< - -[#3 Removal] = 2:2-4:2 - >---------------------- -2| } else secondCondition { -3| -4| } else { - --< - -[#3 Leading delimiter] = 2:1-2:2 - >-< -2| } else secondCondition { - -[#3 Trailing delimiter] = 4:1-4:2 - >-< -4| } else { +[#3 Domain] = 1:0-2:7 + >-------------- +1| else if bar {} +2| else {} + -------< + +[#3 Removal] = 0:9-2:7 + > +0| if foo {} +1| else if bar {} +2| else {} + -------< [#3 Insertion delimiter] = "\n" + + +[#4 Content] = +[#4 Domain] = 1:5-1:14 + >---------< +1| else if bar {} + +[#4 Removal] = 1:5-2:0 + >--------- +1| else if bar {} +2| else {} + < + +[#4 Leading delimiter] = 1:4-1:5 + >-< +1| else if bar {} + +[#4 Insertion delimiter] = "\n" + + +[#5 Content] = +[#5 Removal] = +[#5 Domain] = 1:5-2:7 + >--------- +1| else if bar {} +2| else {} + -------< + +[#5 Leading delimiter] = 1:4-1:5 + >-< +1| else if bar {} + +[#5 Insertion delimiter] = "\n" + + +[#6 Content] = +[#6 Domain] = 2:0-2:7 + >-------< +2| else {} + +[#6 Removal] = 1:14-2:7 + > +1| else if bar {} +2| else {} + -------< + +[#6 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch.if.else.scope b/resources/fixtures/scopes/swift/branch.if.else.scope index ab88c1db0a..fb73666f03 100644 --- a/resources/fixtures/scopes/swift/branch.if.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -1,63 +1,41 @@ -if condition { - -} else { - -} +if true {} +else {} --- [#1 Content] = -[#1 Domain] = 0:0-2:1 - >-------------- -0| if condition { -1| -2| } else { - -< - -[#1 Removal] = 0:0-2:2 - >-------------- -0| if condition { -1| -2| } else { - --< - -[#1 Trailing delimiter] = 2:1-2:2 - >-< -2| } else { +[#1 Domain] = 0:0-0:10 + >----------< +0| if true {} + +[#1 Removal] = 0:0-1:0 + >---------- +0| if true {} +1| else {} + < [#1 Insertion delimiter] = "\n" [#2 Content] = [#2 Removal] = -[#2 Domain] = 0:0-4:1 - >-------------- -0| if condition { -1| -2| } else { -3| -4| } - -< +[#2 Domain] = 0:0-1:7 + >---------- +0| if true {} +1| else {} + -------< [#2 Insertion delimiter] = "\n" [#3 Content] = -[#3 Domain] = 2:2-4:1 - >------ -2| } else { -3| -4| } - -< - -[#3 Removal] = 2:1-4:1 - >------- -2| } else { -3| -4| } - -< - -[#3 Leading delimiter] = 2:1-2:2 - >-< -2| } else { +[#3 Domain] = 1:0-1:7 + >-------< +1| else {} + +[#3 Removal] = 0:10-1:7 + > +0| if true {} +1| else {} + -------< [#3 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch.if.iteration.scope b/resources/fixtures/scopes/swift/branch.if.iteration.scope index 1bddf7937d..4284edc393 100644 --- a/resources/fixtures/scopes/swift/branch.if.iteration.scope +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -1,18 +1,12 @@ -if firstCondition { - -} else secondCondition { - -} else { - -} +if foo {} +else if bar {} +else {} --- [Content] = -[Domain] = 0:0-4:1 - >------------------- -0| if firstCondition { -1| -2| } else secondCondition { -3| -4| } else { - -< +[Domain] = 0:0-2:7 + >--------- +0| if foo {} +1| else if bar {} +2| else {} + -------< diff --git a/resources/fixtures/scopes/swift/branch.if.scope b/resources/fixtures/scopes/swift/branch.if.scope index f0eae28d27..95d75aa3fb 100644 --- a/resources/fixtures/scopes/swift/branch.if.scope +++ b/resources/fixtures/scopes/swift/branch.if.scope @@ -1,15 +1,10 @@ -if condition { - -} +if true {} --- [Content] = [Removal] = -[Domain] = 0:0-2:1 - >-------------- -0| if condition { -1| -2| } - -< +[Domain] = 0:0-0:10 + >----------< +0| if true {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/class.scope b/resources/fixtures/scopes/swift/class.scope index 63b2a8482f..80a9ab592c 100644 --- a/resources/fixtures/scopes/swift/class.scope +++ b/resources/fixtures/scopes/swift/class.scope @@ -1,15 +1,10 @@ -struct ExampleStruct { - -} +struct Foo {} --- [Content] = [Removal] = -[Domain] = 0:0-2:1 - >---------------------- -0| struct ExampleStruct { -1| -2| } - -< +[Domain] = 0:0-0:13 + >-------------< +0| struct Foo {} [Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/swift/comment.block.scope b/resources/fixtures/scopes/swift/comment.block.scope new file mode 100644 index 0000000000..477e57d0ee --- /dev/null +++ b/resources/fixtures/scopes/swift/comment.block.scope @@ -0,0 +1,15 @@ +/* +aaa +*/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:2 + >-- +0| /* +1| aaa +2| */ + --< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/comment.line.scope b/resources/fixtures/scopes/swift/comment.line.scope index 42c1af6d22..a469659c87 100644 --- a/resources/fixtures/scopes/swift/comment.line.scope +++ b/resources/fixtures/scopes/swift/comment.line.scope @@ -1,10 +1,10 @@ -// Hello yes this is comment +// aaa --- [Content] = [Removal] = -[Domain] = 0:0-0:28 - >----------------------------< -0| // Hello yes this is comment +[Domain] = 0:0-0:6 + >------< +0| // aaa [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope index 752a0fa34f..39fee6c27b 100644 --- a/resources/fixtures/scopes/swift/condition.if.scope +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -1,29 +1,24 @@ -if condition { - -} +if foo {} --- -[Content] = 0:3-0:12 - >---------< -0| if condition { +[Content] = 0:3-0:6 + >---< +0| if foo {} -[Removal] = 0:3-0:13 - >----------< -0| if condition { +[Removal] = 0:3-0:7 + >----< +0| if foo {} [Leading delimiter] = 0:2-0:3 >-< -0| if condition { +0| if foo {} -[Trailing delimiter] = 0:12-0:13 - >-< -0| if condition { +[Trailing delimiter] = 0:6-0:7 + >-< +0| if foo {} -[Domain] = 0:0-2:1 - >-------------- -0| if condition { -1| -2| } - -< +[Domain] = 0:0-0:9 + >---------< +0| if foo {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/ifStatement.scope b/resources/fixtures/scopes/swift/ifStatement.scope index 89248ad612..95d75aa3fb 100644 --- a/resources/fixtures/scopes/swift/ifStatement.scope +++ b/resources/fixtures/scopes/swift/ifStatement.scope @@ -1,15 +1,10 @@ -if foo { - -} +if true {} --- [Content] = [Removal] = -[Domain] = 0:0-2:1 - >-------- -0| if foo { -1| -2| } - -< +[Domain] = 0:0-0:10 + >----------< +0| if true {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/interior.if.scope b/resources/fixtures/scopes/swift/interior.if.scope index 4d0492288f..9a35dae364 100644 --- a/resources/fixtures/scopes/swift/interior.if.scope +++ b/resources/fixtures/scopes/swift/interior.if.scope @@ -1,15 +1,10 @@ -if foo == 1 { - -} +if foo { } --- [Content] = [Removal] = -[Domain] = 0:13-2:0 - > -0| if foo == 1 { -1| -2| } - < +[Domain] = 0:8-0:10 + >--< +0| if foo { } [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.class.scope b/resources/fixtures/scopes/swift/name.class.scope index d2c264c138..c4ecaeeb34 100644 --- a/resources/fixtures/scopes/swift/name.class.scope +++ b/resources/fixtures/scopes/swift/name.class.scope @@ -1,23 +1,21 @@ -struct ExampleStruct { - -} +class Foo {} --- [Content] = -[Domain] = 0:7-0:20 - >-------------< -0| struct ExampleStruct { +[Domain] = 0:6-0:9 + >---< +0| class Foo {} -[Removal] = 0:7-0:21 - >--------------< -0| struct ExampleStruct { +[Removal] = 0:6-0:10 + >----< +0| class Foo {} -[Leading delimiter] = 0:6-0:7 - >-< -0| struct ExampleStruct { +[Leading delimiter] = 0:5-0:6 + >-< +0| class Foo {} -[Trailing delimiter] = 0:20-0:21 - >-< -0| struct ExampleStruct { +[Trailing delimiter] = 0:9-0:10 + >-< +0| class Foo {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.enum.scope b/resources/fixtures/scopes/swift/name.enum.scope index a037c87f38..2162ad8604 100644 --- a/resources/fixtures/scopes/swift/name.enum.scope +++ b/resources/fixtures/scopes/swift/name.enum.scope @@ -1,23 +1,21 @@ -enum TestEnumeration { - -} +enum Foo {} --- [Content] = -[Domain] = 0:5-0:20 - >---------------< -0| enum TestEnumeration { +[Domain] = 0:5-0:8 + >---< +0| enum Foo {} -[Removal] = 0:5-0:21 - >----------------< -0| enum TestEnumeration { +[Removal] = 0:5-0:9 + >----< +0| enum Foo {} [Leading delimiter] = 0:4-0:5 >-< -0| enum TestEnumeration { +0| enum Foo {} -[Trailing delimiter] = 0:20-0:21 - >-< -0| enum TestEnumeration { +[Trailing delimiter] = 0:8-0:9 + >-< +0| enum Foo {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.foreach.scope b/resources/fixtures/scopes/swift/name.foreach.scope index 6cca538e5d..c8e077322e 100644 --- a/resources/fixtures/scopes/swift/name.foreach.scope +++ b/resources/fixtures/scopes/swift/name.foreach.scope @@ -1,29 +1,24 @@ -for item in collection { - -} +for foo in bar {} --- -[Content] = 0:4-0:8 - >----< -0| for item in collection { +[Content] = 0:4-0:7 + >---< +0| for foo in bar {} -[Removal] = 0:4-0:9 - >-----< -0| for item in collection { +[Removal] = 0:4-0:8 + >----< +0| for foo in bar {} [Leading delimiter] = 0:3-0:4 >-< -0| for item in collection { +0| for foo in bar {} -[Trailing delimiter] = 0:8-0:9 - >-< -0| for item in collection { +[Trailing delimiter] = 0:7-0:8 + >-< +0| for foo in bar {} -[Domain] = 0:0-2:1 - >------------------------ -0| for item in collection { -1| -2| } - -< +[Domain] = 0:0-0:17 + >-----------------< +0| for foo in bar {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.interface.scope b/resources/fixtures/scopes/swift/name.interface.scope index 8f5ee3a3c2..7268b1a3e0 100644 --- a/resources/fixtures/scopes/swift/name.interface.scope +++ b/resources/fixtures/scopes/swift/name.interface.scope @@ -1,23 +1,21 @@ -protocol ExampleProtocol { - -} +protocol Foo {} --- [Content] = -[Domain] = 0:9-0:24 - >---------------< -0| protocol ExampleProtocol { +[Domain] = 0:9-0:12 + >---< +0| protocol Foo {} -[Removal] = 0:9-0:26 - >-----------------< -0| protocol ExampleProtocol { +[Removal] = 0:9-0:13 + >----< +0| protocol Foo {} [Leading delimiter] = 0:8-0:9 >-< -0| protocol ExampleProtocol { +0| protocol Foo {} -[Trailing delimiter] = 0:24-0:26 - >--< -0| protocol ExampleProtocol { +[Trailing delimiter] = 0:12-0:13 + >-< +0| protocol Foo {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.variable.initialized.scope b/resources/fixtures/scopes/swift/name.variable.initialized.scope deleted file mode 100644 index 0fcf9d66ee..0000000000 --- a/resources/fixtures/scopes/swift/name.variable.initialized.scope +++ /dev/null @@ -1,17 +0,0 @@ -var initializedMutableVariable: Double = 42.0 ---- - -[Content] = -[Domain] = 0:4-0:30 - >--------------------------< -0| var initializedMutableVariable: Double = 42.0 - -[Removal] = 0:3-0:30 - >---------------------------< -0| var initializedMutableVariable: Double = 42.0 - -[Leading delimiter] = 0:3-0:4 - >-< -0| var initializedMutableVariable: Double = 42.0 - -[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.variable.uninitialized.scope b/resources/fixtures/scopes/swift/name.variable.uninitialized.scope deleted file mode 100644 index 749ebc7c0f..0000000000 --- a/resources/fixtures/scopes/swift/name.variable.uninitialized.scope +++ /dev/null @@ -1,17 +0,0 @@ -var uninitializedMutableVariable: Int ---- - -[Content] = -[Domain] = 0:4-0:32 - >----------------------------< -0| var uninitializedMutableVariable: Int - -[Removal] = 0:3-0:32 - >-----------------------------< -0| var uninitializedMutableVariable: Int - -[Leading delimiter] = 0:3-0:4 - >-< -0| var uninitializedMutableVariable: Int - -[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement.class.scope b/resources/fixtures/scopes/swift/statement.class.scope index f876135c57..a6008d311f 100644 --- a/resources/fixtures/scopes/swift/statement.class.scope +++ b/resources/fixtures/scopes/swift/statement.class.scope @@ -1,15 +1,10 @@ -class ClassName { - -} +class Foo {} --- [Content] = [Removal] = -[Domain] = 0:0-2:1 - >----------------- -0| class ClassName { -1| -2| } - -< +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.enum.scope b/resources/fixtures/scopes/swift/statement.enum.scope index 76f0b54027..88dd9cd028 100644 --- a/resources/fixtures/scopes/swift/statement.enum.scope +++ b/resources/fixtures/scopes/swift/statement.enum.scope @@ -1,15 +1,10 @@ -enum EnumerationName { - -} +enum Foo {} --- [Content] = [Removal] = -[Domain] = 0:0-2:1 - >---------------------- -0| enum EnumerationName { -1| -2| } - -< +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.field.class.scope b/resources/fixtures/scopes/swift/statement.field.class.scope deleted file mode 100644 index 0468e7a3b7..0000000000 --- a/resources/fixtures/scopes/swift/statement.field.class.scope +++ /dev/null @@ -1,33 +0,0 @@ -class AnotherClassName { - let classConstantFieldOfCommonType = 42 -} ---- - -[#1 Content] = -[#1 Removal] = -[#1 Domain] = 0:0-2:1 - >------------------------ -0| class AnotherClassName { -1| let classConstantFieldOfCommonType = 42 -2| } - -< - -[#1 Insertion delimiter] = "\n" - - -[#2 Content] = -[#2 Domain] = 1:4-1:43 - >---------------------------------------< -1| let classConstantFieldOfCommonType = 42 - -[#2 Removal] = 1:0-2:0 - >------------------------------------------- -1| let classConstantFieldOfCommonType = 42 -2| } - < - -[#2 Leading delimiter] = 1:0-1:4 - >----< -1| let classConstantFieldOfCommonType = 42 - -[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.field.interface.scope b/resources/fixtures/scopes/swift/statement.field.interface.scope deleted file mode 100644 index 7b20b10451..0000000000 --- a/resources/fixtures/scopes/swift/statement.field.interface.scope +++ /dev/null @@ -1,17 +0,0 @@ - var requiredSetGetMember: Type = { get set } ---- - -[Content] = -[Domain] = 0:4-0:48 - >--------------------------------------------< -0| var requiredSetGetMember: Type = { get set } - -[Removal] = 0:0-0:48 - >------------------------------------------------< -0| var requiredSetGetMember: Type = { get set } - -[Leading delimiter] = 0:0-0:4 - >----< -0| var requiredSetGetMember: Type = { get set } - -[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.foreach.scope b/resources/fixtures/scopes/swift/statement.foreach.scope index e2a3480ad5..005a6562ec 100644 --- a/resources/fixtures/scopes/swift/statement.foreach.scope +++ b/resources/fixtures/scopes/swift/statement.foreach.scope @@ -1,15 +1,10 @@ -for item in collection { - -} +for foo in bar {} --- [Content] = [Removal] = -[Domain] = 0:0-2:1 - >------------------------ -0| for item in collection { -1| -2| } - -< +[Domain] = 0:0-0:17 + >-----------------< +0| for foo in bar {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.interface.scope b/resources/fixtures/scopes/swift/statement.interface.scope index 2d0de83138..ea6dad63a6 100644 --- a/resources/fixtures/scopes/swift/statement.interface.scope +++ b/resources/fixtures/scopes/swift/statement.interface.scope @@ -1,25 +1,10 @@ -protocol ProtocolName { - -} +protocol Foo {} --- [Content] = -[Domain] = 0:0-2:1 - >----------------------- -0| protocol ProtocolName { -1| -2| } - -< - -[Removal] = 0:0-2:2 - >----------------------- -0| protocol ProtocolName { -1| -2| } - --< - -[Trailing delimiter] = 2:1-2:2 - >-< -2| } +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| protocol Foo {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.variable.initialized.scope b/resources/fixtures/scopes/swift/statement.variable.initialized.scope deleted file mode 100644 index c6ab473759..0000000000 --- a/resources/fixtures/scopes/swift/statement.variable.initialized.scope +++ /dev/null @@ -1,10 +0,0 @@ -var initializedMutableVariable: Double = 42.0 ---- - -[Content] = -[Removal] = -[Domain] = 0:0-0:45 - >---------------------------------------------< -0| var initializedMutableVariable: Double = 42.0 - -[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.variable.uninitialized.scope b/resources/fixtures/scopes/swift/statement.variable.uninitialized.scope deleted file mode 100644 index 31fd4ac3b1..0000000000 --- a/resources/fixtures/scopes/swift/statement.variable.uninitialized.scope +++ /dev/null @@ -1,10 +0,0 @@ -var uninitializedMutableVariable: Int ---- - -[Content] = -[Removal] = -[Domain] = 0:0-0:37 - >-------------------------------------< -0| var uninitializedMutableVariable: Int - -[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/string.multiLine.scope b/resources/fixtures/scopes/swift/string.multiLine.scope new file mode 100644 index 0000000000..e17fb9fb0f --- /dev/null +++ b/resources/fixtures/scopes/swift/string.multiLine.scope @@ -0,0 +1,15 @@ +""" +aaa +""" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:3 + >--- +0| """ +1| aaa +2| """ + ---< + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/string.singleLine.scope b/resources/fixtures/scopes/swift/string.singleLine.scope new file mode 100644 index 0000000000..f0d1750ce4 --- /dev/null +++ b/resources/fixtures/scopes/swift/string.singleLine.scope @@ -0,0 +1,10 @@ +"aaa" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| "aaa" + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.comment.block.scope b/resources/fixtures/scopes/swift/textFragment.comment.block.scope new file mode 100644 index 0000000000..2bc3b6e027 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.comment.block.scope @@ -0,0 +1,15 @@ +/* +aaa +*/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:2 + >-- +0| /* +1| aaa +2| */ + --< + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.comment.line.scope b/resources/fixtures/scopes/swift/textFragment.comment.line.scope index 328567996a..e47b42fed9 100644 --- a/resources/fixtures/scopes/swift/textFragment.comment.line.scope +++ b/resources/fixtures/scopes/swift/textFragment.comment.line.scope @@ -1,10 +1,10 @@ -// Hello yes this is comment +// aaa --- [Content] = [Removal] = -[Domain] = 0:0-0:28 - >----------------------------< -0| // Hello yes this is comment +[Domain] = 0:0-0:6 + >------< +0| // aaa [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope b/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..43868aa5c8 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope @@ -0,0 +1,15 @@ +""" +aaa +""" +--- + +[Content] = +[Removal] = +[Domain] = 0:3-2:0 + > +0| """ +1| aaa +2| """ + < + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope b/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..0ab585ba66 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"aaa" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:4 + >---< +0| "aaa" + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.foreach.scope b/resources/fixtures/scopes/swift/type.foreach.scope index 76661ec025..8e867374c0 100644 --- a/resources/fixtures/scopes/swift/type.foreach.scope +++ b/resources/fixtures/scopes/swift/type.foreach.scope @@ -1,25 +1,20 @@ -for typedItem: Type in collection { - -} +for foo: Type in bar {} --- -[Content] = 0:15-0:19 - >----< -0| for typedItem: Type in collection { +[Content] = 0:9-0:13 + >----< +0| for foo: Type in bar {} -[Removal] = 0:13-0:19 - >------< -0| for typedItem: Type in collection { +[Removal] = 0:7-0:13 + >------< +0| for foo: Type in bar {} -[Leading delimiter] = 0:13-0:15 - >--< -0| for typedItem: Type in collection { +[Leading delimiter] = 0:7-0:9 + >--< +0| for foo: Type in bar {} -[Domain] = 0:0-2:1 - >----------------------------------- -0| for typedItem: Type in collection { -1| -2| } - -< +[Domain] = 0:0-0:23 + >-----------------------< +0| for foo: Type in bar {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value.foreach.scope b/resources/fixtures/scopes/swift/value.foreach.scope index d5e8b83c65..d1ab264c5d 100644 --- a/resources/fixtures/scopes/swift/value.foreach.scope +++ b/resources/fixtures/scopes/swift/value.foreach.scope @@ -1,29 +1,24 @@ -for item in collection { - -} +for foo in bar {} --- -[Content] = 0:12-0:22 - >----------< -0| for item in collection { +[Content] = 0:11-0:14 + >---< +0| for foo in bar {} -[Removal] = 0:12-0:23 - >-----------< -0| for item in collection { +[Removal] = 0:11-0:15 + >----< +0| for foo in bar {} -[Leading delimiter] = 0:11-0:12 - >-< -0| for item in collection { +[Leading delimiter] = 0:10-0:11 + >-< +0| for foo in bar {} -[Trailing delimiter] = 0:22-0:23 - >-< -0| for item in collection { +[Trailing delimiter] = 0:14-0:15 + >-< +0| for foo in bar {} -[Domain] = 0:0-2:1 - >------------------------ -0| for item in collection { -1| -2| } - -< +[Domain] = 0:0-0:17 + >-----------------< +0| for foo in bar {} [Insertion delimiter] = " " diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index 3f6659b5d7..7ecc60974f 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -30,6 +30,18 @@ struct ExamplesStruct { } } +let basicMultilineString = """ +I am +a multiline string +!! +""" + +let extendedDelimiter = #"The radio said "No, John. You are the zombie." And then John was the zombie."# + +let multilineExtendedDelimiter = #""" +""""""""" waow +"""# + enum ExampleEnum { case exampleCaseOne case exampleCaseTwo diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 595e18f782..9bcc4734a0 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,7 +1,26 @@ ;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json -;; Comment +;; single line comment (comment) @comment @textFragment + +;; multiline comment +(multiline_comment) @comment @textFragment + +;; single line string +(line_string_literal + text: (_) @interior @textFragment +) @string + +;; multiline string +(multi_line_string_literal + text: (_) @interior @textFragment +) @string + +;; extended delimiter/"raw" strings (both multiline and single line) -- waiting on better tree-sitter support for these +;;(raw_string_literal +;; text: (_) @interior @textFragment +;;) @string + ;; Protocol decl. (protocol_declaration name: (_) @name @@ -11,12 +30,13 @@ ) ) @statement -;;if statement +;; if statement ( (if_statement) @ifStatement @statement @branch.iteration (#not-parent-type? @ifStatement if_statement) ) +;; if statement w/ condition & child branches ( (if_statement "if" @branch.start @branch.removal.start @@ -27,6 +47,7 @@ (#not-parent-type? @condition.domain else) ) +;; else if ( (else) @branch.start @condition.domain.start (if_statement @@ -35,6 +56,7 @@ ) ) +;; else ( (else) @branch.start "}" @branch.end @@ -74,7 +96,7 @@ ) ) @statement -;; For loop w/ type +;; For loop ( (for_statement "for" From df9c996721a10249c994523c8900a6b051b9b4ce Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Tue, 25 Aug 2026 23:16:12 -0400 Subject: [PATCH 13/13] add query predicate for checking ancestors, more swift support work two todos (lowercase ones) are questions, while the one that is upercase is a 'proper; todo --- .../src/scopeSupportFacets/swift.ts | 194 +++++++++++++++--- .../queryPredicateOperators.ts | 38 ++++ .../swift/cursorless-test-project/test.swift | 32 ++- resources/queries/swift.scm | 44 +++- 4 files changed, 279 insertions(+), 29 deletions(-) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 04778605b9..cdb3fb9623 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -15,22 +15,45 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "condition.if": supported, "interior.if": supported, + // ternary operator + "branch.ternary": unsupported, + "branch.ternary.iteration": unsupported, + "condition.ternary": unsupported, + // for loop "statement.foreach": supported, "name.foreach": supported, "value.foreach": supported, "type.foreach": supported, + // while loop + "statement.while": unsupported, + "condition.while": unsupported, + "interior.while": unsupported, + + // repeat-while loop (equivalent to do-while loops in other languages) + "statement.doWhile": unsupported, + "condition.doWhile": unsupported, + "interior.doWhile": unsupported, + + // do-catch (equivalent to try-catch in other languages) + // we're probably going to want a new scope facet for swift's try statements (`statement.tryErrorable`?) + "statement.try": unsupported, + "branch.try": unsupported, + "branch.try.iteration": unsupported, + "interior.try": unsupported, + // switch "statement.switch": unsupported, "branch.switchCase": unsupported, "branch.switchCase.iteration": unsupported, "condition.switchCase": unsupported, + "condition.switchCase.iteration": unsupported, "value.switch": unsupported, "interior.switch": unsupported, "interior.switchCase": unsupported, - // control transfer + // misc control transfer (returns, throw/break/continue statements, etc) "statement.return": unsupported, "value.return": unsupported, "value.return.lambda": unsupported, @@ -42,6 +65,10 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // enum "statement.enum": supported, "name.enum": supported, + "name.iteration.enum": supported, + "type.enum": supported, + "interior.enum": supported, + "value.iteration.enum": supported, // class class: supported, @@ -52,9 +79,27 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.interface": supported, "name.interface": supported, - // named function + // "standard" functions & methods namedFunction: unsupported, - + "namedFunction.method": unsupported, + "statement.function": unsupported, + "statement.method": unsupported, + "name.function": unsupported, + "name.method": unsupported, + + // constructors + "namedFunction.constructor": unsupported, + "statement.constructor": unsupported, + "name.constructor": unsupported, + + // protocol method declarations + "statement.method.interface": unsupported, + "name.method.interface": unsupported, + + // closures/lambda functions + anonymousFunction: unsupported, + "interior.lambda": unsupported, + // function calls functionCall: unsupported, "functionCall.constructor": unsupported, @@ -128,19 +173,37 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "argumentList.formal.constructor.singleLine": unsupported, "argumentList.formal.constructor.multiLine": unsupported, - // named variable/member/field + // variables and constants (var, let) + fieldAccess: unsupported, + "statement.field.class": unsupported, "statement.field.interface": unsupported, "statement.variable.uninitialized": unsupported, "statement.variable.initialized": unsupported, - "name.variable.initialized": unsupported, + "statement.variable.destructuring": unsupported, + "statement.constant": unsupported, + + "name.field.class": notApplicable, + "name.field.interface": notApplicable, + "name.field.enum": notApplicable, "name.variable.uninitialized": unsupported, + "name.variable.initialized": unsupported, + "name.variable.destructuring": unsupported, + "name.constant": unsupported, - // variable/member/field value (RHS) + "value.constant": unsupported, "value.field.class": unsupported, "value.field.interface": unsupported, "value.field.enum": unsupported, + // assignments + "statement.assignment": unsupported, + "statement.assignment.destructuring": unsupported, + "statement.assignment.compound": unsupported, + "name.assignment": unsupported, + "name.assignment.destructuring": unsupported, + "name.assignment.compound": unsupported, + // comments "comment.line": supported, "textFragment.comment.line": supported, @@ -154,42 +217,63 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "textFragment.string.singleLine": supported, // document-wide iteration - "statement.iteration.document": unsupported, - "class.iteration.document": unsupported, - "namedFunction.iteration.document": unsupported, - "name.iteration.document": unsupported, - "value.iteration.document": unsupported, - "type.iteration.document": unsupported, + "statement.iteration.document": supported, + "class.iteration.document": supported, + "namedFunction.iteration.document": supported, + "name.iteration.document": supported, + "value.iteration.document": supported, + "type.iteration.document": supported, // per-class iteration - "statement.iteration.class": unsupported, - "class.iteration.class": unsupported, - "namedFunction.iteration.class": unsupported, - "name.iteration.class": unsupported, - "value.iteration.class": unsupported, - "type.iteration.class": unsupported, + "statement.iteration.class": supported, + "class.iteration.class": supported, + "namedFunction.iteration.class": supported, + "name.iteration.class": supported, + "value.iteration.class": supported, + "type.iteration.class": supported, // per-protocol iteration - "statement.iteration.interface": unsupported, - "name.iteration.interface": unsupported, - "type.iteration.interface": unsupported, + "statement.iteration.interface": supported, + "name.iteration.interface": supported, + "type.iteration.interface": supported, - // per-block iteration + // per-block iteration -- todo: do classlikes, functions, protocols, branches, etc. count as blocks? "statement.iteration.block": unsupported, "name.iteration.block": unsupported, "value.iteration.block": unsupported, "type.iteration.block": unsupported, + // unenclosed collection item + "collectionItem.unenclosed.singleLine": unsupported, + "collectionItem.unenclosed.multiLine": unsupported, + "collectionItem.unenclosed.iteration": unsupported, + + // enclosed collections + map: unsupported, + list: unsupported, + "key.mapPair": unsupported, + "key.mapPair.iteration": unsupported, + // misc - "statement.assignment.compound": unsupported, + regularExpression: unsupported, + disqualifyDelimiter: unsupported, + pairDelimiter: unsupported, + "name.typeAlias": unsupported, "statement.typeAlias": unsupported, "statement.misc": unsupported, + // todo: do static variables/constants fulfill the scope facet "statement.static", or is that only for static blocks? + // "statement.static": unsupported, /* NOT APPLICABLE */ // c-style for loop "statement.for": notApplicable, "condition.for": notApplicable, + "interior.for": notApplicable, + + // loop branches + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, // XML/CSS/LaTeX/Markdown specific section: notApplicable, @@ -235,4 +319,68 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.yield": notApplicable, "value.yield": notApplicable, "interior.static": notApplicable, + + // TODO: reorganize these!!! + "name.argument.actual": notApplicable, + "name.argument.actual.iteration": notApplicable, + "name.argument.formal": notApplicable, + "name.argument.formal.iteration": notApplicable, + "name.argument.formal.method": notApplicable, + "name.argument.formal.method.iteration": notApplicable, + "name.argument.formal.lambda": notApplicable, + "name.argument.formal.lambda.iteration": notApplicable, + "name.argument.formal.constructor": notApplicable, + "name.argument.formal.constructor.iteration": notApplicable, + "name.argument.catch": notApplicable, + + "value.variable": notApplicable, + "value.variable.destructuring": notApplicable, + "value.assignment": notApplicable, + "value.assignment.destructuring": notApplicable, + "value.assignment.compound": notApplicable, + "value.mapPair": notApplicable, + "value.mapPair.iteration": notApplicable, + "value.typeAlias": notApplicable, + "value.argument.actual": notApplicable, + "value.argument.actual.iteration": notApplicable, + "value.argument.formal": notApplicable, + "value.argument.formal.iteration": notApplicable, + "value.argument.formal.method": notApplicable, + "value.argument.formal.method.iteration": notApplicable, + "value.argument.formal.constructor": notApplicable, + "value.argument.formal.constructor.iteration": notApplicable, + "value.argument.formal.lambda": notApplicable, + "value.argument.formal.lambda.iteration": notApplicable, + + "type.variable.uninitialized": notApplicable, + "type.variable.initialized": notApplicable, + "type.constant": notApplicable, + "type.return": notApplicable, + "type.return.method": notApplicable, + "type.return.lambda": notApplicable, + "type.field.class": notApplicable, + "type.field.interface": notApplicable, + "type.alias": notApplicable, + "type.cast": notApplicable, + "type.class": notApplicable, + "type.interface": notApplicable, + "type.typeArgument": notApplicable, + "type.typeArgument.iteration": notApplicable, + "type.argument.formal": notApplicable, + "type.argument.formal.iteration": notApplicable, + "type.argument.formal.method": notApplicable, + "type.argument.formal.method.iteration": notApplicable, + "type.argument.formal.lambda": notApplicable, + "type.argument.formal.lambda.iteration": notApplicable, + "type.argument.formal.constructor": notApplicable, + "type.argument.formal.constructor.iteration": notApplicable, + "type.argument.catch": notApplicable, + + "interior.class": notApplicable, + "interior.interface": notApplicable, + "interior.function": notApplicable, + "interior.constructor": notApplicable, + "interior.method": notApplicable, + "interior.foreach": notApplicable, + }; diff --git a/packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts b/packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts index 796fcfce00..d65ac56d2a 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts @@ -92,6 +92,43 @@ class NotParentType extends QueryPredicateOperator { } } +/** + * A predicate operator that returns true if no node from which this node + * descends is of the given type. For example, + * + * ```scm + * (#not-any-ancestor-type? @foo string) + * ``` + * + * will reject the match if the `@foo` capture has any ancestor which is a `string` node, + * taking into account the capture's parent, said parent's parent, and so + * on until a root node is reached. + * + * Like with `#not-parent-type?`, you may pass multiple types to this predicate, in which case + * the math will be rejected has any of said types as any of its ancestor nodes. + */ +class NotAnyAncestorType extends QueryPredicateOperator { + name = "not-any-ancestor-type?" as const; + schema = z.tuple([q.node, q.string]).rest(q.string); + run(capture: MutableQueryCapture, ...types: string[]) { + var target = getNode(capture).parent; + const ancestorTypes: string[] = [] + if (target != null) { + while (target != null) { + ancestorTypes.push(target.type); + target = target.parent; + } + for (const type of types) { + if (ancestorTypes.includes(type)) { + return false; + } + } + } + // Fall through if node has no parent or if ancestorTypes and types have no matches + return true; + } +} + /** * A predicate operator that returns true if the node is the nth child of its * parent. For example, `(#is-nth-child? @foo 0)` will reject the match if the @@ -462,6 +499,7 @@ export const queryPredicateOperators = [ new TrimEnd(), new DocumentRange(), new NotParentType(), + new NotAnyAncestorType(), new IsNthChild(), new ChildRange(), new CharacterRange(), diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index 7ecc60974f..d425f8e351 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -59,4 +59,34 @@ enum ExampleCompactEnum { protocol ExampleProtocol { var setGetMember: String? { set get } var getOnlyNumber: Double! {get} // using an explicit unwrap type like this is legal, but poor practice in real code -} \ No newline at end of file +} + +actor ExampleActor { + +} + +func nestedClassInFunc() { + let ternaryDecider = true + let ternaryOp = ternaryDecider ? "foo" : "bar" + let switchExample: UInt8 = 22 + var foobart = 0 + switch switchExample { + case 0: foobart = 5 + case 22: foobart = 42 + default: foobart = 69 + } + class Nested { + func veryNested() { + var i = 0 + while i < 10 { + i += 1 + } + repeat { + i -= 1 + } while i > 0 + struct HyperNested { + + } + } + } +} \ No newline at end of file diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 9bcc4734a0..d2e8e8b8c9 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,5 +1,9 @@ ;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json +;; document-wide +(source_file) @class.iteration @statement.iteration @name.iteration @value.iteration @type.iteration +(#document-range! @class.iteration @statement.iteration @name.iteration @value.iteration @type.iteration) + ;; single line comment (comment) @comment @textFragment @@ -70,13 +74,43 @@ ;;) ) @statement -;; Generic interior +;; Generic interior w/ top-level iterations +(_ + "{" @interior.start.endOf @statement.iteration.start.endOf @name.iteration.start.endOf + "}" @interior.end.startOf @statement.iteration.end.startOf @name.iteration.end.startOf +) + (_ - "{" @interior.start.endOf - "}" @interior.end.startOf + "{" @value.iteration.start.endOf @type.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @value.iteration.end.startOf @type.iteration.end.startOf @namedFunction.iteration.end.startOf ) -;; Non-enum class (struct/class) decl. +;; Generic interior -- class iteration +;; Classlikes (class/struct/actor) can be nested within other classlikes, and within both top-level functions and member functions. +;; They, however, cannot be nested within branches or loops of any kind. +( + ( + (_ + "{" @class.iteration.start.endOf + "}" @class.iteration.end.startOf + ) @_dummy + ) (#type? @_dummy class_declaration function_declaration) + (#not-any-ancestor-type? @_dummy if_statement switch_statement for_statement while_statement) + (#not-any-ancestor-type? @_dummy do_statement repeat_while_statement protocol_declaration) +) + +;; Generic interior -- branch and condition iteration +;; Branches and their conditions cannot be top-level but otherwise have no restrictions +( + ( + (_ + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @condition.iteration.end.startOf @branch.iteration.end.startOf + ) @_dummy + ) (#not-parent-type? @_dummy source_file) +) + +;; Non-enum class (struct/class/actor) decl. (class_declaration name: (_) @name body: (class_body @@ -88,7 +122,7 @@ ;; Enum "class" decl. (class_declaration - name: (_) @name + name: (_) @name @type body: (enum_class_body "{" @interior.start.endOf "}" @interior.end.startOf