From 5249da98ec9dcb48293089329bcf959a76ad452f Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 8 Aug 2026 21:23:45 -0400 Subject: [PATCH 01/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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/26] 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 From 792f019082ba000b37f081819d74e6b7f534e7c7 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Thu, 27 Aug 2026 21:56:49 -0400 Subject: [PATCH 14/26] partial revert of previous commit --- .../src/scopeSupportFacets/swift.ts | 11 +++--- .../queryPredicateOperators.ts | 38 ------------------- resources/queries/swift.scm | 10 +++-- 3 files changed, 11 insertions(+), 48 deletions(-) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index cdb3fb9623..956d190ae1 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -36,7 +36,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "condition.doWhile": unsupported, "interior.doWhile": unsupported, - // do-catch (equivalent to try-catch in other languages) + // 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, @@ -99,7 +99,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // closures/lambda functions anonymousFunction: unsupported, "interior.lambda": unsupported, - + // function calls functionCall: unsupported, "functionCall.constructor": unsupported, @@ -175,7 +175,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // variables and constants (var, let) fieldAccess: unsupported, - + "statement.field.class": unsupported, "statement.field.interface": unsupported, "statement.variable.uninitialized": unsupported, @@ -246,14 +246,14 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // unenclosed collection item "collectionItem.unenclosed.singleLine": unsupported, "collectionItem.unenclosed.multiLine": unsupported, - "collectionItem.unenclosed.iteration": unsupported, + "collectionItem.unenclosed.iteration": unsupported, // enclosed collections map: unsupported, list: unsupported, "key.mapPair": unsupported, "key.mapPair.iteration": unsupported, - + // misc regularExpression: unsupported, disqualifyDelimiter: unsupported, @@ -382,5 +382,4 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "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 d65ac56d2a..796fcfce00 100644 --- a/packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts +++ b/packages/lib-engine/src/languages/TreeSitterQuery/queryPredicateOperators.ts @@ -92,43 +92,6 @@ 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 @@ -499,7 +462,6 @@ export const queryPredicateOperators = [ new TrimEnd(), new DocumentRange(), new NotParentType(), - new NotAnyAncestorType(), new IsNthChild(), new ChildRange(), new CharacterRange(), diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index d2e8e8b8c9..1c8e72bb26 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -94,9 +94,10 @@ "{" @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) + ) + (#type? @_dummy class_declaration function_declaration) + (#not-parent-type? @_dummy if_statement switch_statement for_statement while_statement) + (#not-parent-type? @_dummy do_statement repeat_while_statement protocol_declaration) ) ;; Generic interior -- branch and condition iteration @@ -107,7 +108,8 @@ "{" @branch.iteration.start.endOf @condition.iteration.start.endOf "}" @condition.iteration.end.startOf @branch.iteration.end.startOf ) @_dummy - ) (#not-parent-type? @_dummy source_file) + ) + (#not-parent-type? @_dummy source_file) ) ;; Non-enum class (struct/class/actor) decl. From 9f946cd295ddaaaa35696f5af153f893d3b0adee Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 5 Sep 2026 22:22:40 -0400 Subject: [PATCH 15/26] Finished sorting scope support facets --- .../src/scopeSupportFacets/swift.ts | 135 +++++++++--------- 1 file changed, 71 insertions(+), 64 deletions(-) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 956d190ae1..d5078ecc31 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -25,6 +25,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "name.foreach": supported, "value.foreach": supported, "type.foreach": supported, + "interior.foreach": unsupported, // while loop "statement.while": unsupported, @@ -61,6 +62,9 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "value.throw": unsupported, "statement.break": unsupported, "statement.continue": unsupported, + "type.return": unsupported, + "type.return.method": unsupported, + "type.return.lambda": unsupported, // enum "statement.enum": supported, @@ -74,10 +78,14 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { class: supported, "statement.class": supported, "name.class": supported, + "interior.class": unsupported, + "type.class": unsupported, // protocol (equivalent to interfaces in other languages) "statement.interface": supported, "name.interface": supported, + "interior.interface": unsupported, + "type.interface": unsupported, // "standard" functions & methods namedFunction: unsupported, @@ -86,11 +94,14 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.method": unsupported, "name.function": unsupported, "name.method": unsupported, + "interior.function": unsupported, + "interior.method": unsupported, // constructors "namedFunction.constructor": unsupported, "statement.constructor": unsupported, "name.constructor": unsupported, + "interior.constructor": unsupported, // protocol method declarations "statement.method.interface": unsupported, @@ -195,6 +206,14 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "value.field.class": unsupported, "value.field.interface": unsupported, "value.field.enum": unsupported, + "value.variable": unsupported, + "value.variable.destructuring": unsupported, + + "type.constant": unsupported, + "type.variable.uninitialized": unsupported, + "type.variable.initialized": unsupported, + "type.field.class": unsupported, + "type.field.interface": unsupported, // assignments "statement.assignment": unsupported, @@ -204,6 +223,10 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "name.assignment.destructuring": unsupported, "name.assignment.compound": unsupported, + "value.assignment": unsupported, + "value.assignment.destructuring": unsupported, + "value.assignment.compound": unsupported, + // comments "comment.line": supported, "textFragment.comment.line": supported, @@ -237,7 +260,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "name.iteration.interface": supported, "type.iteration.interface": supported, - // per-block iteration -- todo: do classlikes, functions, protocols, branches, etc. count as blocks? + // per-block iteration -- todo: do classlikes, functions, protocols, etc. count as blocks? Or are only if states/branches/loops/etc. included here? "statement.iteration.block": unsupported, "name.iteration.block": unsupported, "value.iteration.block": unsupported, @@ -253,14 +276,61 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { list: unsupported, "key.mapPair": unsupported, "key.mapPair.iteration": unsupported, + "value.mapPair": unsupported, + "value.mapPair.iteration": unsupported, + + // argument names + "name.argument.actual": unsupported, + "name.argument.actual.iteration": unsupported, + "name.argument.formal": unsupported, + "name.argument.formal.iteration": unsupported, + "name.argument.formal.method": unsupported, + "name.argument.formal.method.iteration": unsupported, + "name.argument.formal.lambda": unsupported, + "name.argument.formal.lambda.iteration": unsupported, + "name.argument.formal.constructor": unsupported, + "name.argument.formal.constructor.iteration": unsupported, + "name.argument.catch": unsupported, + + // argument values + "value.argument.actual": unsupported, + "value.argument.actual.iteration": unsupported, + "value.argument.formal": unsupported, + "value.argument.formal.iteration": unsupported, + "value.argument.formal.method": unsupported, + "value.argument.formal.method.iteration": unsupported, + "value.argument.formal.constructor": unsupported, + "value.argument.formal.constructor.iteration": unsupported, + "value.argument.formal.lambda": unsupported, + "value.argument.formal.lambda.iteration": unsupported, + + // argument types + "type.argument.formal": unsupported, + "type.argument.formal.iteration": unsupported, + "type.argument.formal.method": unsupported, + "type.argument.formal.method.iteration": unsupported, + "type.argument.formal.lambda": unsupported, + "type.argument.formal.lambda.iteration": unsupported, + "type.argument.formal.constructor": unsupported, + "type.argument.formal.constructor.iteration": unsupported, + "type.argument.catch": unsupported, // misc regularExpression: unsupported, disqualifyDelimiter: unsupported, pairDelimiter: unsupported, + "name.typeAlias": unsupported, + "value.typeAlias": unsupported, + "statement.typeAlias": unsupported, "statement.misc": unsupported, + + "type.typeArgument": unsupported, + "type.typeArgument.iteration": unsupported, + "type.alias": unsupported, + "type.cast": unsupported, + // todo: do static variables/constants fulfill the scope facet "statement.static", or is that only for static blocks? // "statement.static": unsupported, @@ -319,67 +389,4 @@ 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, }; From f4a5d352bdbb29f890c0555f218defc2ecdcee49 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sun, 6 Sep 2026 21:08:28 -0400 Subject: [PATCH 16/26] more organization changes for facets, start on type annotation support seems like there might also be a regression in the engine somewhere but I'm not sure if that's the case or not; mostly making this commit to save my work before checking for that --- .../src/scopeSupportFacets/swift.ts | 138 +++++++++--------- .../swift/cursorless-test-project/test.swift | 6 +- resources/queries/swift.scm | 23 ++- 3 files changed, 93 insertions(+), 74 deletions(-) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index d5078ecc31..4e086834b9 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -11,21 +11,21 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "branch.if": supported, "branch.if.else": supported, "branch.if.elif.else": supported, - "branch.if.iteration": supported, "condition.if": supported, "interior.if": supported, + "branch.if.iteration": supported, // ternary operator "branch.ternary": unsupported, - "branch.ternary.iteration": unsupported, "condition.ternary": unsupported, + "branch.ternary.iteration": unsupported, // for loop "statement.foreach": supported, "name.foreach": supported, "value.foreach": supported, "type.foreach": supported, - "interior.foreach": unsupported, + "interior.foreach": supported, // while loop "statement.while": unsupported, @@ -41,19 +41,20 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // 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, + "branch.try.iteration": 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, + "branch.switchCase.iteration": unsupported, + "condition.switchCase.iteration": unsupported, + // misc control transfer (returns, throw/break/continue statements, etc) "statement.return": unsupported, "value.return": unsupported, @@ -69,24 +70,36 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // enum "statement.enum": supported, "name.enum": supported, - "name.iteration.enum": supported, "type.enum": supported, "interior.enum": supported, + + "name.iteration.enum": supported, "value.iteration.enum": supported, // class class: supported, "statement.class": supported, "name.class": supported, - "interior.class": unsupported, + "interior.class": supported, "type.class": unsupported, + "statement.iteration.class": supported, + "class.iteration.class": supported, + "namedFunction.iteration.class": supported, + "name.iteration.class": supported, + "value.iteration.class": unsupported, + "type.iteration.class": supported, + // protocol (equivalent to interfaces in other languages) "statement.interface": supported, "name.interface": supported, - "interior.interface": unsupported, + "interior.interface": supported, "type.interface": unsupported, + "statement.iteration.interface": supported, + "name.iteration.interface": supported, + "type.iteration.interface": supported, + // "standard" functions & methods namedFunction: unsupported, "namedFunction.method": unsupported, @@ -127,35 +140,37 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "functionCallee.generic": unsupported, "functionCallee.enum": unsupported, - // argument (actual) + // argument (actual; as in parameters as passed to a call) "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.iteration": unsupported, + "argument.actual.method.iteration": unsupported, + "argument.actual.constructor.iteration": unsupported, "argument.actual.enum.iteration": unsupported, - // argument (formal) + // argument (formal; as in the argument members within a callable block and its declaration) "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.formal.iteration": unsupported, + "argument.formal.method.iteration": unsupported, + "argument.formal.constructor.iteration": unsupported, + "argument.formal.lambda.iteration": unsupported, + // argument list (actual) "argumentList.actual.empty": unsupported, "argumentList.actual.singleLine": unsupported, @@ -194,9 +209,9 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.variable.destructuring": unsupported, "statement.constant": unsupported, - "name.field.class": notApplicable, - "name.field.interface": notApplicable, - "name.field.enum": notApplicable, + "name.field.class": unsupported, + "name.field.interface": unsupported, + "name.field.enum": unsupported, "name.variable.uninitialized": unsupported, "name.variable.initialized": unsupported, "name.variable.destructuring": unsupported, @@ -209,11 +224,11 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "value.variable": unsupported, "value.variable.destructuring": unsupported, - "type.constant": unsupported, - "type.variable.uninitialized": unsupported, - "type.variable.initialized": unsupported, - "type.field.class": unsupported, - "type.field.interface": unsupported, + "type.constant": supported, + "type.variable.uninitialized": supported, + "type.variable.initialized": supported, + "type.field.class": supported, + "type.field.interface": supported, // assignments "statement.assignment": unsupported, @@ -240,31 +255,18 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "textFragment.string.singleLine": supported, // document-wide iteration - "statement.iteration.document": supported, - "class.iteration.document": supported, - "namedFunction.iteration.document": supported, - "name.iteration.document": supported, - "value.iteration.document": supported, + "statement.iteration.document": unsupported, + "class.iteration.document": unsupported, + "namedFunction.iteration.document": unsupported, + "name.iteration.document": unsupported, + "value.iteration.document": unsupported, "type.iteration.document": supported, - // per-class iteration - "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": supported, - "name.iteration.interface": supported, - "type.iteration.interface": supported, - - // per-block iteration -- todo: do classlikes, functions, protocols, etc. count as blocks? Or are only if states/branches/loops/etc. included here? + // general per-block iteration (not branches) "statement.iteration.block": unsupported, "name.iteration.block": unsupported, "value.iteration.block": unsupported, - "type.iteration.block": unsupported, + "type.iteration.block": supported, // unenclosed collection item "collectionItem.unenclosed.singleLine": unsupported, @@ -281,58 +283,57 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { // argument names "name.argument.actual": unsupported, - "name.argument.actual.iteration": unsupported, "name.argument.formal": unsupported, - "name.argument.formal.iteration": unsupported, "name.argument.formal.method": unsupported, - "name.argument.formal.method.iteration": unsupported, "name.argument.formal.lambda": unsupported, - "name.argument.formal.lambda.iteration": unsupported, "name.argument.formal.constructor": unsupported, - "name.argument.formal.constructor.iteration": unsupported, "name.argument.catch": unsupported, + "name.argument.actual.iteration": unsupported, + "name.argument.formal.iteration": unsupported, + "name.argument.formal.method.iteration": unsupported, + "name.argument.formal.lambda.iteration": unsupported, + "name.argument.formal.constructor.iteration": unsupported, + // argument values "value.argument.actual": unsupported, - "value.argument.actual.iteration": unsupported, "value.argument.formal": unsupported, - "value.argument.formal.iteration": unsupported, "value.argument.formal.method": unsupported, - "value.argument.formal.method.iteration": unsupported, "value.argument.formal.constructor": unsupported, - "value.argument.formal.constructor.iteration": unsupported, "value.argument.formal.lambda": unsupported, + + "value.argument.actual.iteration": unsupported, + "value.argument.formal.iteration": unsupported, + "value.argument.formal.method.iteration": unsupported, + "value.argument.formal.constructor.iteration": unsupported, "value.argument.formal.lambda.iteration": unsupported, // argument types "type.argument.formal": unsupported, - "type.argument.formal.iteration": unsupported, "type.argument.formal.method": unsupported, - "type.argument.formal.method.iteration": unsupported, "type.argument.formal.lambda": unsupported, - "type.argument.formal.lambda.iteration": unsupported, "type.argument.formal.constructor": unsupported, - "type.argument.formal.constructor.iteration": unsupported, "type.argument.catch": unsupported, - // misc - regularExpression: unsupported, - disqualifyDelimiter: unsupported, - pairDelimiter: unsupported, + "type.argument.formal.iteration": unsupported, + "type.argument.formal.method.iteration": unsupported, + "type.argument.formal.lambda.iteration": unsupported, + "type.argument.formal.constructor.iteration": unsupported, + // type aliases "name.typeAlias": unsupported, "value.typeAlias": unsupported, - "statement.typeAlias": unsupported, "statement.misc": unsupported, - "type.typeArgument": unsupported, - "type.typeArgument.iteration": unsupported, "type.alias": unsupported, "type.cast": unsupported, + "type.typeArgument.iteration": unsupported, - // todo: do static variables/constants fulfill the scope facet "statement.static", or is that only for static blocks? - // "statement.static": unsupported, + // misc + regularExpression: unsupported, + disqualifyDelimiter: unsupported, + pairDelimiter: unsupported, /* NOT APPLICABLE */ @@ -389,4 +390,5 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.yield": notApplicable, "value.yield": notApplicable, "interior.static": notApplicable, + "statement.static": notApplicable, }; diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index d425f8e351..beda45118b 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -1,3 +1,5 @@ +let pipis: Bool = true + struct ExamplesStruct { static let constant = "hello world" public var publicVariable: UInt128 = 0 @@ -38,10 +40,6 @@ 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 1c8e72bb26..da888440b0 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,8 +1,10 @@ ;; 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) +( + (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 @@ -76,13 +78,17 @@ ;; 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 + . ) (_ + . "{" @value.iteration.start.endOf @type.iteration.start.endOf @namedFunction.iteration.start.endOf "}" @value.iteration.end.startOf @type.iteration.end.startOf @namedFunction.iteration.end.startOf + . ) ;; Generic interior -- class iteration @@ -91,8 +97,10 @@ ( ( (_ + . "{" @class.iteration.start.endOf "}" @class.iteration.end.startOf + . ) @_dummy ) (#type? @_dummy class_declaration function_declaration) @@ -105,8 +113,10 @@ ( ( (_ + . "{" @branch.iteration.start.endOf @condition.iteration.start.endOf "}" @condition.iteration.end.startOf @branch.iteration.end.startOf + . ) @_dummy ) (#not-parent-type? @_dummy source_file) @@ -146,3 +156,12 @@ collection: (_) @value ) @statement @_.domain ) + +;; const/var type +( + (type_annotation + ":" @type.leading + . + _ @type + ) +) From 83f558e17671f33136ede2daf80397142caa2099 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sun, 6 Sep 2026 21:19:09 -0400 Subject: [PATCH 17/26] disabled document wide iteration scopes, as for some reason they're broken (potentially an issue with tree-sitter-swift?) this is the source of what I thought might be an engine issue in the previous commit --- resources/queries/swift.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index da888440b0..e85256e6e9 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,10 +1,10 @@ ;; 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) -) +;; document-wide -- seems like there might be a problem with tree-sitter-swift that causes this to not work correctly? +;;( +;; (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 From 335d924e171f1b663bd88f910f2fd34778d23f6c Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Wed, 9 Sep 2026 21:35:56 -0400 Subject: [PATCH 18/26] small changes to classlikes in swift.scm --- .../swift/cursorless-test-project/test.swift | 16 +++++++++++++++- resources/queries/swift.scm | 6 +++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index beda45118b..24cba1c6d8 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -27,9 +27,23 @@ struct ExamplesStruct { print(ExamplesStruct.exampleFunction(exampleLabel: exampleLabel)) } for c: Character in "test" { + print("wiwi") + } + } +} +struct Structy { + let foo = 11 + func pipis() -> Bool { + if foo == 11 { + return true + } else { + return false } } + class Nested { + let foo = 11 + } } let basicMultilineString = """ @@ -83,7 +97,7 @@ func nestedClassInFunc() { i -= 1 } while i > 0 struct HyperNested { - + let foo = 222222 } } } diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index e85256e6e9..0bf129e0be 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -122,9 +122,9 @@ (#not-parent-type? @_dummy source_file) ) -;; Non-enum class (struct/class/actor) decl. +;; non-enum classlike decl. (class_declaration - name: (_) @name + name: (_) @name @type body: (class_body "{" @interior.start.endOf "}" @interior.end.startOf @@ -140,7 +140,7 @@ "}" @interior.end.startOf . ) -) @statement +) @statement @class ;; For loop ( From 2c3f84b31438d472edce9972f0b99826d92a89b3 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Wed, 9 Sep 2026 21:46:36 -0400 Subject: [PATCH 19/26] fix compile time error caused by architectural change --- packages/lib-common/src/references/languageReferences.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/lib-common/src/references/languageReferences.ts b/packages/lib-common/src/references/languageReferences.ts index c8b6ad64be..d66677d83e 100644 --- a/packages/lib-common/src/references/languageReferences.ts +++ b/packages/lib-common/src/references/languageReferences.ts @@ -33,6 +33,7 @@ export type LanguageId = | "scm" | "scss" | "shellscript" + | "swift" | "talon" | "talon-list" | "typescript" @@ -131,6 +132,9 @@ export const languageReferences: Record = { shellscript: { name: "Shell Script", }, + swift: { + name: "Swift", + }, talon: { name: "Talon", }, From 35f280f936feed77c7107220a04bbbefd911f82e Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Wed, 9 Sep 2026 22:30:34 -0400 Subject: [PATCH 20/26] fixed docs not building --- .../cursorless.nvim/node/cursorless-neovim | 1 + .../cursorless.nvim/node/test-runner | 1 + .../private-scopes/fixtures/string.json | 34 ++ .../private-scopes/fixtures/textFragment.json | 68 +++ .../contributing/private-scopes/string.mdx | 8 + .../private-scopes/textFragment.mdx | 16 + .../src/docs/user/languages/README.md | 1 + .../docs/user/languages/fixtures/swift.json | 506 ++++++++++++++++++ .../src/docs/user/languages/swift.mdx | 197 ++++++- .../src/docs/user/scopes/branch.mdx | 16 + .../src/docs/user/scopes/class.mdx | 4 + .../src/docs/user/scopes/comment.mdx | 8 + .../src/docs/user/scopes/condition.mdx | 4 + .../src/docs/user/scopes/fixtures/branch.json | 130 +++++ .../src/docs/user/scopes/fixtures/class.json | 17 + .../docs/user/scopes/fixtures/comment.json | 34 ++ .../docs/user/scopes/fixtures/condition.json | 17 + .../user/scopes/fixtures/ifStatement.json | 17 + .../docs/user/scopes/fixtures/interior.json | 17 + .../src/docs/user/scopes/fixtures/name.json | 68 +++ .../docs/user/scopes/fixtures/statement.json | 68 +++ .../src/docs/user/scopes/fixtures/type.json | 17 + .../src/docs/user/scopes/fixtures/value.json | 17 + .../src/docs/user/scopes/ifStatement.mdx | 4 + .../src/docs/user/scopes/interior.mdx | 4 + .../src/docs/user/scopes/name.mdx | 16 + .../src/docs/user/scopes/statement.mdx | 16 + .../src/docs/user/scopes/type.mdx | 4 + .../src/docs/user/scopes/value.mdx | 4 + 29 files changed, 1312 insertions(+), 2 deletions(-) create mode 120000 packages/app-neovim/cursorless.nvim/node/cursorless-neovim create mode 120000 packages/app-neovim/cursorless.nvim/node/test-runner create mode 100644 packages/app-web-docs/src/docs/user/languages/fixtures/swift.json diff --git a/packages/app-neovim/cursorless.nvim/node/cursorless-neovim b/packages/app-neovim/cursorless.nvim/node/cursorless-neovim new file mode 120000 index 0000000000..cba160f37e --- /dev/null +++ b/packages/app-neovim/cursorless.nvim/node/cursorless-neovim @@ -0,0 +1 @@ +/Users/rinofthestars/cursorless/packages/app-neovim \ No newline at end of file diff --git a/packages/app-neovim/cursorless.nvim/node/test-runner b/packages/app-neovim/cursorless.nvim/node/test-runner new file mode 120000 index 0000000000..93c6944eec --- /dev/null +++ b/packages/app-neovim/cursorless.nvim/node/test-runner @@ -0,0 +1 @@ +/Users/rinofthestars/cursorless/packages/test-runner \ No newline at end of file diff --git a/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json b/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json index a075ba5b65..18e1bfd859 100644 --- a/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json +++ b/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json @@ -628,6 +628,40 @@ } ] }, + { + "name": "scopes/swift/string.multiLine", + "languageId": "swift", + "facet": "string.multiLine", + "code": "\"\"\"\naaa\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:3", + "removal": "0:0-2:3" + } + ], + "domain": "0:0-2:3" + } + ] + }, + { + "name": "scopes/swift/string.singleLine", + "languageId": "swift", + "facet": "string.singleLine", + "code": "\"aaa\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:5", + "removal": "0:0-0:5" + } + ], + "domain": "0:0-0:5" + } + ] + }, { "name": "scopes/talon/string.singleLine", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json b/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json index 03938caf4f..c47840ff8c 100644 --- a/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json +++ b/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json @@ -1411,6 +1411,74 @@ } ] }, + { + "name": "scopes/swift/textFragment.comment.block", + "languageId": "swift", + "facet": "textFragment.comment.block", + "code": "/*\naaa\n*/", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:2", + "removal": "0:0-2:2" + } + ], + "domain": "0:0-2:2" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.line", + "languageId": "swift", + "facet": "textFragment.comment.line", + "code": "// aaa", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:6", + "removal": "0:0-0:6" + } + ], + "domain": "0:0-0:6" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.multiLine", + "languageId": "swift", + "facet": "textFragment.string.multiLine", + "code": "\"\"\"\naaa\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:3-2:0", + "removal": "0:3-2:0" + } + ], + "domain": "0:3-2:0" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.singleLine", + "languageId": "swift", + "facet": "textFragment.string.singleLine", + "code": "\"aaa\"", + "scopes": [ + { + "targets": [ + { + "content": "0:1-0:4", + "removal": "0:1-0:4" + } + ], + "domain": "0:1-0:4" + } + ] + }, { "name": "scopes/talon/textFragment.comment.line", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/contributing/private-scopes/string.mdx b/packages/app-web-docs/src/docs/contributing/private-scopes/string.mdx index 1f541ccf32..db8d2d4a84 100644 --- a/packages/app-web-docs/src/docs/contributing/private-scopes/string.mdx +++ b/packages/app-web-docs/src/docs/contributing/private-scopes/string.mdx @@ -93,6 +93,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### YAML @@ -185,6 +189,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### Talon list diff --git a/packages/app-web-docs/src/docs/contributing/private-scopes/textFragment.mdx b/packages/app-web-docs/src/docs/contributing/private-scopes/textFragment.mdx index 936aab6cd7..56d30f8e9d 100644 --- a/packages/app-web-docs/src/docs/contributing/private-scopes/textFragment.mdx +++ b/packages/app-web-docs/src/docs/contributing/private-scopes/textFragment.mdx @@ -107,6 +107,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### XML @@ -199,6 +203,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### Talon list @@ -297,6 +305,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### YAML @@ -389,6 +401,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### Talon list diff --git a/packages/app-web-docs/src/docs/user/languages/README.md b/packages/app-web-docs/src/docs/user/languages/README.md index 6a3a17ae2a..1f8f404151 100644 --- a/packages/app-web-docs/src/docs/user/languages/README.md +++ b/packages/app-web-docs/src/docs/user/languages/README.md @@ -33,6 +33,7 @@ sidebar_position: 4 - [Tree-sitter query (SCM)](./scm.mdx) - [SCSS](./scss.mdx) - [Shell Script](./shellscript.mdx) +- [Swift](./swift.mdx) - [Talon](./talon.mdx) - [Talon list](./talon-list.mdx) - [TypeScript](./typescript.mdx) diff --git a/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json new file mode 100644 index 0000000000..d759ff75b7 --- /dev/null +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json @@ -0,0 +1,506 @@ +[ + { + "name": "scopes/swift/branch.if.elif.else", + "languageId": "swift", + "facet": "branch.if.elif.else", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:9", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:9" + }, + { + "targets": [ + { + "content": "1:0-1:14", + "removal": "1:0-2:0" + } + ], + "domain": "1:0-1:14" + }, + { + "targets": [ + { + "content": "1:0-2:7", + "removal": "0:9-2:7" + } + ], + "domain": "1:0-2:7" + }, + { + "targets": [ + { + "content": "1:5-1:14", + "removal": "1:5-2:0" + } + ], + "domain": "1:5-1:14" + }, + { + "targets": [ + { + "content": "1:5-2:7", + "removal": "1:5-2:7" + } + ], + "domain": "1:5-2:7" + }, + { + "targets": [ + { + "content": "2:0-2:7", + "removal": "1:14-2:7" + } + ], + "domain": "2:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.else", + "languageId": "swift", + "facet": "branch.if.else", + "code": "if true {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:10" + }, + { + "targets": [ + { + "content": "0:0-1:7", + "removal": "0:0-1:7" + } + ], + "domain": "0:0-1:7" + }, + { + "targets": [ + { + "content": "1:0-1:7", + "removal": "0:10-1:7" + } + ], + "domain": "1:0-1:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.iteration", + "languageId": "swift", + "facet": "branch.if.iteration", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if", + "languageId": "swift", + "facet": "branch.if", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/swift/class", + "languageId": "swift", + "facet": "class", + "code": "struct Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13", + "removal": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + } + ] + }, + { + "name": "scopes/swift/comment.block", + "languageId": "swift", + "facet": "comment.block", + "code": "/*\naaa\n*/", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:2", + "removal": "0:0-2:2" + } + ], + "domain": "0:0-2:2" + } + ] + }, + { + "name": "scopes/swift/comment.line", + "languageId": "swift", + "facet": "comment.line", + "code": "// aaa", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:6", + "removal": "0:0-0:6" + } + ], + "domain": "0:0-0:6" + } + ] + }, + { + "name": "scopes/swift/condition.if", + "languageId": "swift", + "facet": "condition.if", + "code": "if foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:3-0:6", + "removal": "0:3-0:7" + } + ], + "domain": "0:0-0:9" + } + ] + }, + { + "name": "scopes/swift/ifStatement", + "languageId": "swift", + "facet": "ifStatement", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/swift/interior.if", + "languageId": "swift", + "facet": "interior.if", + "code": "if foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:8-0:10", + "removal": "0:8-0:10" + } + ], + "domain": "0:8-0:10" + } + ] + }, + { + "name": "scopes/swift/name.class", + "languageId": "swift", + "facet": "name.class", + "code": "class Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:6-0:9", + "removal": "0:6-0:10" + } + ], + "domain": "0:6-0:9" + } + ] + }, + { + "name": "scopes/swift/name.enum", + "languageId": "swift", + "facet": "name.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:5-0:8", + "removal": "0:5-0:9" + } + ], + "domain": "0:5-0:8" + } + ] + }, + { + "name": "scopes/swift/name.foreach", + "languageId": "swift", + "facet": "name.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:7", + "removal": "0:4-0:8" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/name.interface", + "languageId": "swift", + "facet": "name.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.class", + "languageId": "swift", + "facet": "statement.class", + "code": "class Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12", + "removal": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.enum", + "languageId": "swift", + "facet": "statement.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, + { + "name": "scopes/swift/statement.foreach", + "languageId": "swift", + "facet": "statement.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/statement.interface", + "languageId": "swift", + "facet": "statement.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, + { + "name": "scopes/swift/string.multiLine", + "languageId": "swift", + "facet": "string.multiLine", + "code": "\"\"\"\naaa\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:3", + "removal": "0:0-2:3" + } + ], + "domain": "0:0-2:3" + } + ] + }, + { + "name": "scopes/swift/string.singleLine", + "languageId": "swift", + "facet": "string.singleLine", + "code": "\"aaa\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:5", + "removal": "0:0-0:5" + } + ], + "domain": "0:0-0:5" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.block", + "languageId": "swift", + "facet": "textFragment.comment.block", + "code": "/*\naaa\n*/", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:2", + "removal": "0:0-2:2" + } + ], + "domain": "0:0-2:2" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.line", + "languageId": "swift", + "facet": "textFragment.comment.line", + "code": "// aaa", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:6", + "removal": "0:0-0:6" + } + ], + "domain": "0:0-0:6" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.multiLine", + "languageId": "swift", + "facet": "textFragment.string.multiLine", + "code": "\"\"\"\naaa\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:3-2:0", + "removal": "0:3-2:0" + } + ], + "domain": "0:3-2:0" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.singleLine", + "languageId": "swift", + "facet": "textFragment.string.singleLine", + "code": "\"aaa\"", + "scopes": [ + { + "targets": [ + { + "content": "0:1-0:4", + "removal": "0:1-0:4" + } + ], + "domain": "0:1-0:4" + } + ] + }, + { + "name": "scopes/swift/type.foreach", + "languageId": "swift", + "facet": "type.foreach", + "code": "for foo: Type in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:13", + "removal": "0:7-0:13" + } + ], + "domain": "0:0-0:23" + } + ] + }, + { + "name": "scopes/swift/value.foreach", + "languageId": "swift", + "facet": "value.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:14", + "removal": "0:11-0:15" + } + ], + "domain": "0:0-0:17" + } + ] + } +] diff --git a/packages/app-web-docs/src/docs/user/languages/swift.mdx b/packages/app-web-docs/src/docs/user/languages/swift.mdx index 3735a04806..68984dce2f 100644 --- a/packages/app-web-docs/src/docs/user/languages/swift.mdx +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -1,5 +1,198 @@ -import { Language } from "./components/Language"; +import { ScopeVisualizer, ScopeVisualizerOptions, ScopeVisualizerProvider } from "@site/src/docs/components/ScopeVisualizer"; +import scopeTests from "./fixtures/swift.json"; # Swift - + + +Below are visualizations of all our scope tests for this language. These were created primarily for testing purposes rather than as documentation. There are quite a few, and they may feel a bit overwhelming from a documentation standpoint. + +## Scopes + + + +### Branch + +#### 1. Branch: If + +An if branch + + + +#### 2. Branch: If elif else + +An if-elif-else branch. The removal range for the if branch should include the trailing `else` keyword. + + + +#### 3. Branch: If else + +An if-else branch + + + +#### 4. Branch: If (iteration) + +Iteration scope for if/elif/else branches: the if/elif/else statement. + + + +### Class + +#### 1. Class + +A class/struct declaration + + + +### Comment + +#### 1. Comment: Block + +A block comment + + + +#### 2. Comment: Line + +A line comment + + + +### Condition + +#### 1. Condition: If + +A condition in an if statement + + + +### If statement + +#### 1. If statement + +An if statement + + + +### Interior + +#### 1. Interior: If + +The body of an if/elif/else branch + + + +### Name + +#### 1. Name: Class + +Name of a class/struct declaration + + + +#### 2. Name: Enum + +Name of an enum declaration + + + +#### 3. Name: Foreach + +Iteration variable name in a for-each loop + + + +#### 4. Name: Interface + +Name of an interface declaration + + + +### Statement + +#### 1. Statement: Class + +A class/struct declaration + + + +#### 2. Statement: Enum + +An enum declaration + + + +#### 3. Statement: Foreach + +A for-each loop + + + +#### 4. Statement: Interface + +An interface declaration + + + +### Type + +#### 1. Type: Foreach + +Type of a variable in a for-each loop + + + +### Value + +#### 1. Value: Foreach + +Iterable in a for-each loop + + + +## Internal scopes + +The following are internal scopes. They are not intended for user interaction or spoken use. These scopes exist solely for internal Cursorless functionality. + +### String + +#### 1. String: Multi line + +A multi-line string + + + +#### 2. String: Single line + +A single-line string + + + +### Text fragment + +#### 1. Text fragment: Comment block + +Internally used text fragment consisting of a block comment + + + +#### 2. Text fragment: Comment line + +Internally used text fragment consisting of a line comment + + + +#### 3. Text fragment: String multi line + +Internally used text fragment consisting of a multi-line string + + + +#### 4. Text fragment: String single line + +Internally used text fragment consisting of a single-line string + + + + diff --git a/packages/app-web-docs/src/docs/user/scopes/branch.mdx b/packages/app-web-docs/src/docs/user/scopes/branch.mdx index baa502a056..1670ab851b 100644 --- a/packages/app-web-docs/src/docs/user/scopes/branch.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/branch.mdx @@ -95,6 +95,10 @@ Default: `branch` +##### Swift + + + ### Branch: If elif else An if-elif-else branch. The removal range for the if branch should include the trailing `else` keyword. @@ -163,6 +167,10 @@ Default: `branch` +##### Swift + + + ### Branch: If else An if-else branch @@ -231,6 +239,10 @@ Default: `branch` +##### Swift + + + ### Branch: Loop A for / while loop branch. For most languages this is not supported, but eg in Python you can have an else branch for a loop. @@ -495,6 +507,10 @@ Default: `branch` +##### Swift + + + ### Branch: Loop (iteration) Iteration scope for loop branches: the loop statement. diff --git a/packages/app-web-docs/src/docs/user/scopes/class.mdx b/packages/app-web-docs/src/docs/user/scopes/class.mdx index 2f889edb29..5dbe89f84a 100644 --- a/packages/app-web-docs/src/docs/user/scopes/class.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/class.mdx @@ -107,6 +107,10 @@ Default: `class` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/comment.mdx b/packages/app-web-docs/src/docs/user/scopes/comment.mdx index 61fb07c692..8ba8d6888f 100644 --- a/packages/app-web-docs/src/docs/user/scopes/comment.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/comment.mdx @@ -105,6 +105,10 @@ Default: `comment` +##### Swift + + + ##### XML @@ -199,6 +203,10 @@ Default: `comment` +##### Swift + + + ##### Talon list diff --git a/packages/app-web-docs/src/docs/user/scopes/condition.mdx b/packages/app-web-docs/src/docs/user/scopes/condition.mdx index d6d5a1bcaf..14f9618046 100644 --- a/packages/app-web-docs/src/docs/user/scopes/condition.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/condition.mdx @@ -179,6 +179,10 @@ Default: `condition` +##### Swift + + + ##### Talon diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json index 7e7ad75716..53da11bfa4 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json @@ -3359,5 +3359,135 @@ "domain": "0:13-0:14" } ] + }, + { + "name": "scopes/swift/branch.if.elif.else", + "languageId": "swift", + "facet": "branch.if.elif.else", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:9", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:9" + }, + { + "targets": [ + { + "content": "1:0-1:14", + "removal": "1:0-2:0" + } + ], + "domain": "1:0-1:14" + }, + { + "targets": [ + { + "content": "1:0-2:7", + "removal": "0:9-2:7" + } + ], + "domain": "1:0-2:7" + }, + { + "targets": [ + { + "content": "1:5-1:14", + "removal": "1:5-2:0" + } + ], + "domain": "1:5-1:14" + }, + { + "targets": [ + { + "content": "1:5-2:7", + "removal": "1:5-2:7" + } + ], + "domain": "1:5-2:7" + }, + { + "targets": [ + { + "content": "2:0-2:7", + "removal": "1:14-2:7" + } + ], + "domain": "2:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.else", + "languageId": "swift", + "facet": "branch.if.else", + "code": "if true {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:10" + }, + { + "targets": [ + { + "content": "0:0-1:7", + "removal": "0:0-1:7" + } + ], + "domain": "0:0-1:7" + }, + { + "targets": [ + { + "content": "1:0-1:7", + "removal": "0:10-1:7" + } + ], + "domain": "1:0-1:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.iteration", + "languageId": "swift", + "facet": "branch.if.iteration", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if", + "languageId": "swift", + "facet": "branch.if", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] } ] diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json index 914335f92c..ff94ed8c7c 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json @@ -785,6 +785,23 @@ } ] }, + { + "name": "scopes/swift/class", + "languageId": "swift", + "facet": "class", + "code": "struct Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13", + "removal": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + } + ] + }, { "name": "scopes/typescript.core/class", "languageId": "typescript.core", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/comment.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/comment.json index 59bfe0a6fe..e4604f35c3 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/comment.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/comment.json @@ -713,6 +713,40 @@ } ] }, + { + "name": "scopes/swift/comment.block", + "languageId": "swift", + "facet": "comment.block", + "code": "/*\naaa\n*/", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:2", + "removal": "0:0-2:2" + } + ], + "domain": "0:0-2:2" + } + ] + }, + { + "name": "scopes/swift/comment.line", + "languageId": "swift", + "facet": "comment.line", + "code": "// aaa", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:6", + "removal": "0:0-0:6" + } + ], + "domain": "0:0-0:6" + } + ] + }, { "name": "scopes/talon/comment.line", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json index d47bb1f43c..0cf58ef45b 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json @@ -1844,6 +1844,23 @@ } ] }, + { + "name": "scopes/swift/condition.if", + "languageId": "swift", + "facet": "condition.if", + "code": "if foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:3-0:6", + "removal": "0:3-0:7" + } + ], + "domain": "0:0-0:9" + } + ] + }, { "name": "scopes/talon/condition.if", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/ifStatement.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/ifStatement.json index 9789c6912b..850f54172c 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/ifStatement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/ifStatement.json @@ -288,6 +288,23 @@ } ] }, + { + "name": "scopes/swift/ifStatement", + "languageId": "swift", + "facet": "ifStatement", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, { "name": "scopes/talon/ifStatement", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json index 094669a52e..847f8a42b5 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json @@ -5048,6 +5048,23 @@ } ] }, + { + "name": "scopes/swift/interior.if", + "languageId": "swift", + "facet": "interior.if", + "code": "if foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:8-0:10", + "removal": "0:8-0:10" + } + ], + "domain": "0:8-0:10" + } + ] + }, { "name": "scopes/talon/interior.command", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json index e2d0b04bd6..2a8a8aa96f 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json @@ -12191,6 +12191,74 @@ } ] }, + { + "name": "scopes/swift/name.class", + "languageId": "swift", + "facet": "name.class", + "code": "class Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:6-0:9", + "removal": "0:6-0:10" + } + ], + "domain": "0:6-0:9" + } + ] + }, + { + "name": "scopes/swift/name.enum", + "languageId": "swift", + "facet": "name.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:5-0:8", + "removal": "0:5-0:9" + } + ], + "domain": "0:5-0:8" + } + ] + }, + { + "name": "scopes/swift/name.foreach", + "languageId": "swift", + "facet": "name.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:7", + "removal": "0:4-0:8" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/name.interface", + "languageId": "swift", + "facet": "name.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + } + ] + }, { "name": "scopes/talon/name/name.assignment", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json index fc80eec426..f40ce42e68 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json @@ -11155,6 +11155,74 @@ } ] }, + { + "name": "scopes/swift/statement.class", + "languageId": "swift", + "facet": "statement.class", + "code": "class Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12", + "removal": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.enum", + "languageId": "swift", + "facet": "statement.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, + { + "name": "scopes/swift/statement.foreach", + "languageId": "swift", + "facet": "statement.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/statement.interface", + "languageId": "swift", + "facet": "statement.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, { "name": "scopes/talon/statement.assignment", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json index d6fc0be164..0a461d80ce 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json @@ -7399,6 +7399,23 @@ } ] }, + { + "name": "scopes/swift/type.foreach", + "languageId": "swift", + "facet": "type.foreach", + "code": "for foo: Type in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:13", + "removal": "0:7-0:13" + } + ], + "domain": "0:0-0:23" + } + ] + }, { "name": "scopes/typescript/type.cast", "languageId": "typescript", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json index c868b52dbc..1586cc113e 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json @@ -8820,6 +8820,23 @@ } ] }, + { + "name": "scopes/swift/value.foreach", + "languageId": "swift", + "facet": "value.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:14", + "removal": "0:11-0:15" + } + ], + "domain": "0:0-0:17" + } + ] + }, { "name": "scopes/talon/value/value.assignment", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/ifStatement.mdx b/packages/app-web-docs/src/docs/user/scopes/ifStatement.mdx index 85578983c4..f849b6448c 100644 --- a/packages/app-web-docs/src/docs/user/scopes/ifStatement.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/ifStatement.mdx @@ -99,6 +99,10 @@ Default: `if state` +##### Swift + + + ##### Talon diff --git a/packages/app-web-docs/src/docs/user/scopes/interior.mdx b/packages/app-web-docs/src/docs/user/scopes/interior.mdx index f4119efe72..67446d68b8 100644 --- a/packages/app-web-docs/src/docs/user/scopes/interior.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/interior.mdx @@ -501,6 +501,10 @@ Cursorless ID: `interior` +##### Swift + + + ##### Talon diff --git a/packages/app-web-docs/src/docs/user/scopes/name.mdx b/packages/app-web-docs/src/docs/user/scopes/name.mdx index 1763ce0176..e4ade266f7 100644 --- a/packages/app-web-docs/src/docs/user/scopes/name.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/name.mdx @@ -579,6 +579,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -733,6 +737,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -935,6 +943,10 @@ Default: `name` +##### Swift + + + ##### Talon @@ -1079,6 +1091,10 @@ Default: `name` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/statement.mdx b/packages/app-web-docs/src/docs/user/scopes/statement.mdx index 5ebbd68846..acf6f2c3bd 100644 --- a/packages/app-web-docs/src/docs/user/scopes/statement.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/statement.mdx @@ -307,6 +307,10 @@ Default: `state` +##### Swift + + + ### Statement: Command A command statement, eg Talon spoken command or bash @@ -537,6 +541,10 @@ Default: `state` +##### Swift + + + ##### TypeScript @@ -727,6 +735,10 @@ Default: `state` +##### Swift + + + ##### Talon @@ -1061,6 +1073,10 @@ Default: `state` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/type.mdx b/packages/app-web-docs/src/docs/user/scopes/type.mdx index b726a017ea..0b7dc94ced 100644 --- a/packages/app-web-docs/src/docs/user/scopes/type.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/type.mdx @@ -609,6 +609,10 @@ Default: `type` +##### Swift + + + ### Type: Interface An interface declaration diff --git a/packages/app-web-docs/src/docs/user/scopes/value.mdx b/packages/app-web-docs/src/docs/user/scopes/value.mdx index e5d2ff3778..c584d7e847 100644 --- a/packages/app-web-docs/src/docs/user/scopes/value.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/value.mdx @@ -611,6 +611,10 @@ Default: `value` +##### Swift + + + ##### Talon From f672c4e97ca12cbbd14d3c5377f7a5787dcc53be Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Wed, 9 Sep 2026 22:37:24 -0400 Subject: [PATCH 21/26] prevent symlinks from being committed by accident --- .gitignore | 4 ++++ packages/app-neovim/cursorless.nvim/node/cursorless-neovim | 1 - packages/app-neovim/cursorless.nvim/node/test-runner | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 120000 packages/app-neovim/cursorless.nvim/node/cursorless-neovim delete mode 120000 packages/app-neovim/cursorless.nvim/node/test-runner diff --git a/.gitignore b/.gitignore index ab3f0caee6..f15bf11b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,3 +19,7 @@ node_modules/ # Swift Test Project /resources/playground/swift/cursorless-test-project/.build + +# Neovim symlinks +/packages/app-neovim/cursorless.nvim/node/cursorless-neovim +/packages/app-neovim/cursorless.nvim/node/test-runner diff --git a/packages/app-neovim/cursorless.nvim/node/cursorless-neovim b/packages/app-neovim/cursorless.nvim/node/cursorless-neovim deleted file mode 120000 index cba160f37e..0000000000 --- a/packages/app-neovim/cursorless.nvim/node/cursorless-neovim +++ /dev/null @@ -1 +0,0 @@ -/Users/rinofthestars/cursorless/packages/app-neovim \ No newline at end of file diff --git a/packages/app-neovim/cursorless.nvim/node/test-runner b/packages/app-neovim/cursorless.nvim/node/test-runner deleted file mode 120000 index 93c6944eec..0000000000 --- a/packages/app-neovim/cursorless.nvim/node/test-runner +++ /dev/null @@ -1 +0,0 @@ -/Users/rinofthestars/cursorless/packages/test-runner \ No newline at end of file From cc728105a21a631f9b3be3c6dfd4db21047388df Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Wed, 9 Sep 2026 22:41:01 -0400 Subject: [PATCH 22/26] run pre-commit on a file it missed bc git hooks dont work in vscode on my end for some reason --- .../docs/user/languages/fixtures/swift.json | 1008 ++++++++--------- 1 file changed, 504 insertions(+), 504 deletions(-) diff --git a/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json index d759ff75b7..2ba9606106 100644 --- a/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json @@ -1,506 +1,506 @@ [ - { - "name": "scopes/swift/branch.if.elif.else", - "languageId": "swift", - "facet": "branch.if.elif.else", - "code": "if foo {}\nelse if bar {}\nelse {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:9", - "removal": "0:0-1:0" - } - ], - "domain": "0:0-0:9" - }, - { - "targets": [ - { - "content": "1:0-1:14", - "removal": "1:0-2:0" - } - ], - "domain": "1:0-1:14" - }, - { - "targets": [ - { - "content": "1:0-2:7", - "removal": "0:9-2:7" - } - ], - "domain": "1:0-2:7" - }, - { - "targets": [ - { - "content": "1:5-1:14", - "removal": "1:5-2:0" - } - ], - "domain": "1:5-1:14" - }, - { - "targets": [ - { - "content": "1:5-2:7", - "removal": "1:5-2:7" - } - ], - "domain": "1:5-2:7" - }, - { - "targets": [ - { - "content": "2:0-2:7", - "removal": "1:14-2:7" - } - ], - "domain": "2:0-2:7" - } - ] - }, - { - "name": "scopes/swift/branch.if.else", - "languageId": "swift", - "facet": "branch.if.else", - "code": "if true {}\nelse {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:10", - "removal": "0:0-1:0" - } - ], - "domain": "0:0-0:10" - }, - { - "targets": [ - { - "content": "0:0-1:7", - "removal": "0:0-1:7" - } - ], - "domain": "0:0-1:7" - }, - { - "targets": [ - { - "content": "1:0-1:7", - "removal": "0:10-1:7" - } - ], - "domain": "1:0-1:7" - } - ] - }, - { - "name": "scopes/swift/branch.if.iteration", - "languageId": "swift", - "facet": "branch.if.iteration", - "code": "if foo {}\nelse if bar {}\nelse {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-2:7" - } - ], - "domain": "0:0-2:7" - } - ] - }, - { - "name": "scopes/swift/branch.if", - "languageId": "swift", - "facet": "branch.if", - "code": "if true {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:10", - "removal": "0:0-0:10" - } - ], - "domain": "0:0-0:10" - } - ] - }, - { - "name": "scopes/swift/class", - "languageId": "swift", - "facet": "class", - "code": "struct Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:13", - "removal": "0:0-0:13" - } - ], - "domain": "0:0-0:13" - } - ] - }, - { - "name": "scopes/swift/comment.block", - "languageId": "swift", - "facet": "comment.block", - "code": "/*\naaa\n*/", - "scopes": [ - { - "targets": [ - { - "content": "0:0-2:2", - "removal": "0:0-2:2" - } - ], - "domain": "0:0-2:2" - } - ] - }, - { - "name": "scopes/swift/comment.line", - "languageId": "swift", - "facet": "comment.line", - "code": "// aaa", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:6", - "removal": "0:0-0:6" - } - ], - "domain": "0:0-0:6" - } - ] - }, - { - "name": "scopes/swift/condition.if", - "languageId": "swift", - "facet": "condition.if", - "code": "if foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:3-0:6", - "removal": "0:3-0:7" - } - ], - "domain": "0:0-0:9" - } - ] - }, - { - "name": "scopes/swift/ifStatement", - "languageId": "swift", - "facet": "ifStatement", - "code": "if true {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:10", - "removal": "0:0-0:10" - } - ], - "domain": "0:0-0:10" - } - ] - }, - { - "name": "scopes/swift/interior.if", - "languageId": "swift", - "facet": "interior.if", - "code": "if foo { }", - "scopes": [ - { - "targets": [ - { - "content": "0:8-0:10", - "removal": "0:8-0:10" - } - ], - "domain": "0:8-0:10" - } - ] - }, - { - "name": "scopes/swift/name.class", - "languageId": "swift", - "facet": "name.class", - "code": "class Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:6-0:9", - "removal": "0:6-0:10" - } - ], - "domain": "0:6-0:9" - } - ] - }, - { - "name": "scopes/swift/name.enum", - "languageId": "swift", - "facet": "name.enum", - "code": "enum Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:5-0:8", - "removal": "0:5-0:9" - } - ], - "domain": "0:5-0:8" - } - ] - }, - { - "name": "scopes/swift/name.foreach", - "languageId": "swift", - "facet": "name.foreach", - "code": "for foo in bar {}", - "scopes": [ - { - "targets": [ - { - "content": "0:4-0:7", - "removal": "0:4-0:8" - } - ], - "domain": "0:0-0:17" - } - ] - }, - { - "name": "scopes/swift/name.interface", - "languageId": "swift", - "facet": "name.interface", - "code": "protocol Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:9-0:12", - "removal": "0:9-0:13" - } - ], - "domain": "0:9-0:12" - } - ] - }, - { - "name": "scopes/swift/statement.class", - "languageId": "swift", - "facet": "statement.class", - "code": "class Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:12", - "removal": "0:0-0:12" - } - ], - "domain": "0:0-0:12" - } - ] - }, - { - "name": "scopes/swift/statement.enum", - "languageId": "swift", - "facet": "statement.enum", - "code": "enum Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:11", - "removal": "0:0-0:11" - } - ], - "domain": "0:0-0:11" - } - ] - }, - { - "name": "scopes/swift/statement.foreach", - "languageId": "swift", - "facet": "statement.foreach", - "code": "for foo in bar {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:17", - "removal": "0:0-0:17" - } - ], - "domain": "0:0-0:17" - } - ] - }, - { - "name": "scopes/swift/statement.interface", - "languageId": "swift", - "facet": "statement.interface", - "code": "protocol Foo {}", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:15", - "removal": "0:0-0:15" - } - ], - "domain": "0:0-0:15" - } - ] - }, - { - "name": "scopes/swift/string.multiLine", - "languageId": "swift", - "facet": "string.multiLine", - "code": "\"\"\"\naaa\n\"\"\"", - "scopes": [ - { - "targets": [ - { - "content": "0:0-2:3", - "removal": "0:0-2:3" - } - ], - "domain": "0:0-2:3" - } - ] - }, - { - "name": "scopes/swift/string.singleLine", - "languageId": "swift", - "facet": "string.singleLine", - "code": "\"aaa\"", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:5", - "removal": "0:0-0:5" - } - ], - "domain": "0:0-0:5" - } - ] - }, - { - "name": "scopes/swift/textFragment.comment.block", - "languageId": "swift", - "facet": "textFragment.comment.block", - "code": "/*\naaa\n*/", - "scopes": [ - { - "targets": [ - { - "content": "0:0-2:2", - "removal": "0:0-2:2" - } - ], - "domain": "0:0-2:2" - } - ] - }, - { - "name": "scopes/swift/textFragment.comment.line", - "languageId": "swift", - "facet": "textFragment.comment.line", - "code": "// aaa", - "scopes": [ - { - "targets": [ - { - "content": "0:0-0:6", - "removal": "0:0-0:6" - } - ], - "domain": "0:0-0:6" - } - ] - }, - { - "name": "scopes/swift/textFragment.string.multiLine", - "languageId": "swift", - "facet": "textFragment.string.multiLine", - "code": "\"\"\"\naaa\n\"\"\"", - "scopes": [ - { - "targets": [ - { - "content": "0:3-2:0", - "removal": "0:3-2:0" - } - ], - "domain": "0:3-2:0" - } - ] - }, - { - "name": "scopes/swift/textFragment.string.singleLine", - "languageId": "swift", - "facet": "textFragment.string.singleLine", - "code": "\"aaa\"", - "scopes": [ - { - "targets": [ - { - "content": "0:1-0:4", - "removal": "0:1-0:4" - } - ], - "domain": "0:1-0:4" - } - ] - }, - { - "name": "scopes/swift/type.foreach", - "languageId": "swift", - "facet": "type.foreach", - "code": "for foo: Type in bar {}", - "scopes": [ - { - "targets": [ - { - "content": "0:9-0:13", - "removal": "0:7-0:13" - } - ], - "domain": "0:0-0:23" - } - ] - }, - { - "name": "scopes/swift/value.foreach", - "languageId": "swift", - "facet": "value.foreach", - "code": "for foo in bar {}", - "scopes": [ - { - "targets": [ - { - "content": "0:11-0:14", - "removal": "0:11-0:15" - } - ], - "domain": "0:0-0:17" - } - ] - } + { + "name": "scopes/swift/branch.if.elif.else", + "languageId": "swift", + "facet": "branch.if.elif.else", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:9", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:9" + }, + { + "targets": [ + { + "content": "1:0-1:14", + "removal": "1:0-2:0" + } + ], + "domain": "1:0-1:14" + }, + { + "targets": [ + { + "content": "1:0-2:7", + "removal": "0:9-2:7" + } + ], + "domain": "1:0-2:7" + }, + { + "targets": [ + { + "content": "1:5-1:14", + "removal": "1:5-2:0" + } + ], + "domain": "1:5-1:14" + }, + { + "targets": [ + { + "content": "1:5-2:7", + "removal": "1:5-2:7" + } + ], + "domain": "1:5-2:7" + }, + { + "targets": [ + { + "content": "2:0-2:7", + "removal": "1:14-2:7" + } + ], + "domain": "2:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.else", + "languageId": "swift", + "facet": "branch.if.else", + "code": "if true {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:10" + }, + { + "targets": [ + { + "content": "0:0-1:7", + "removal": "0:0-1:7" + } + ], + "domain": "0:0-1:7" + }, + { + "targets": [ + { + "content": "1:0-1:7", + "removal": "0:10-1:7" + } + ], + "domain": "1:0-1:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.iteration", + "languageId": "swift", + "facet": "branch.if.iteration", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if", + "languageId": "swift", + "facet": "branch.if", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/swift/class", + "languageId": "swift", + "facet": "class", + "code": "struct Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13", + "removal": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + } + ] + }, + { + "name": "scopes/swift/comment.block", + "languageId": "swift", + "facet": "comment.block", + "code": "/*\naaa\n*/", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:2", + "removal": "0:0-2:2" + } + ], + "domain": "0:0-2:2" + } + ] + }, + { + "name": "scopes/swift/comment.line", + "languageId": "swift", + "facet": "comment.line", + "code": "// aaa", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:6", + "removal": "0:0-0:6" + } + ], + "domain": "0:0-0:6" + } + ] + }, + { + "name": "scopes/swift/condition.if", + "languageId": "swift", + "facet": "condition.if", + "code": "if foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:3-0:6", + "removal": "0:3-0:7" + } + ], + "domain": "0:0-0:9" + } + ] + }, + { + "name": "scopes/swift/ifStatement", + "languageId": "swift", + "facet": "ifStatement", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/swift/interior.if", + "languageId": "swift", + "facet": "interior.if", + "code": "if foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:8-0:10", + "removal": "0:8-0:10" + } + ], + "domain": "0:8-0:10" + } + ] + }, + { + "name": "scopes/swift/name.class", + "languageId": "swift", + "facet": "name.class", + "code": "class Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:6-0:9", + "removal": "0:6-0:10" + } + ], + "domain": "0:6-0:9" + } + ] + }, + { + "name": "scopes/swift/name.enum", + "languageId": "swift", + "facet": "name.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:5-0:8", + "removal": "0:5-0:9" + } + ], + "domain": "0:5-0:8" + } + ] + }, + { + "name": "scopes/swift/name.foreach", + "languageId": "swift", + "facet": "name.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:7", + "removal": "0:4-0:8" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/name.interface", + "languageId": "swift", + "facet": "name.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.class", + "languageId": "swift", + "facet": "statement.class", + "code": "class Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12", + "removal": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.enum", + "languageId": "swift", + "facet": "statement.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, + { + "name": "scopes/swift/statement.foreach", + "languageId": "swift", + "facet": "statement.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/statement.interface", + "languageId": "swift", + "facet": "statement.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, + { + "name": "scopes/swift/string.multiLine", + "languageId": "swift", + "facet": "string.multiLine", + "code": "\"\"\"\naaa\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:3", + "removal": "0:0-2:3" + } + ], + "domain": "0:0-2:3" + } + ] + }, + { + "name": "scopes/swift/string.singleLine", + "languageId": "swift", + "facet": "string.singleLine", + "code": "\"aaa\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:5", + "removal": "0:0-0:5" + } + ], + "domain": "0:0-0:5" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.block", + "languageId": "swift", + "facet": "textFragment.comment.block", + "code": "/*\naaa\n*/", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:2", + "removal": "0:0-2:2" + } + ], + "domain": "0:0-2:2" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.line", + "languageId": "swift", + "facet": "textFragment.comment.line", + "code": "// aaa", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:6", + "removal": "0:0-0:6" + } + ], + "domain": "0:0-0:6" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.multiLine", + "languageId": "swift", + "facet": "textFragment.string.multiLine", + "code": "\"\"\"\naaa\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:3-2:0", + "removal": "0:3-2:0" + } + ], + "domain": "0:3-2:0" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.singleLine", + "languageId": "swift", + "facet": "textFragment.string.singleLine", + "code": "\"aaa\"", + "scopes": [ + { + "targets": [ + { + "content": "0:1-0:4", + "removal": "0:1-0:4" + } + ], + "domain": "0:1-0:4" + } + ] + }, + { + "name": "scopes/swift/type.foreach", + "languageId": "swift", + "facet": "type.foreach", + "code": "for foo: Type in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:13", + "removal": "0:7-0:13" + } + ], + "domain": "0:0-0:23" + } + ] + }, + { + "name": "scopes/swift/value.foreach", + "languageId": "swift", + "facet": "value.foreach", + "code": "for foo in bar {}", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:14", + "removal": "0:11-0:15" + } + ], + "domain": "0:0-0:17" + } + ] + } ] From f6ecfb20cec7a473a38c0906712f33a9a24b5822 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Wed, 9 Sep 2026 22:49:43 -0400 Subject: [PATCH 23/26] fix issues caused by scm only targeting at most three captures at once --- resources/queries/swift.scm | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 0bf129e0be..54e79f6f90 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,10 +1,15 @@ ;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json ;; document-wide -- seems like there might be a problem with tree-sitter-swift that causes this to not work correctly? -;;( -;; (source_file) @class.iteration @statement.iteration @name.iteration @value.iteration @type.iteration -;; (#document-range! @class.iteration @statement.iteration @name.iteration @value.iteration @type.iteration) -;;) +( + (source_file) @value.iteration @type.iteration + (#document-range! @value.iteration @type.iteration) +) + +( + (source_file) @class.iteration @statement.iteration @name.iteration + (#document-range! @class.iteration @statement.iteration @name.iteration) +) ;; single line comment (comment) @comment @textFragment @@ -104,8 +109,9 @@ ) @_dummy ) (#type? @_dummy class_declaration function_declaration) - (#not-parent-type? @_dummy if_statement switch_statement for_statement while_statement) + (#not-parent-type? @_dummy switch_statement for_statement while_statement) (#not-parent-type? @_dummy do_statement repeat_while_statement protocol_declaration) + (#not-parent-type? @_dummy if_statement) ) ;; Generic interior -- branch and condition iteration From 71cbe7554ad8d779fc07675cf0997bcbdd7c69d6 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sun, 13 Sep 2026 19:53:11 -0400 Subject: [PATCH 24/26] new scope tests --- resources/fixtures/scopes/swift/class.iteration.class.scope | 2 ++ resources/fixtures/scopes/swift/interior.class.scope | 2 ++ resources/fixtures/scopes/swift/interior.enum.scope | 2 ++ resources/fixtures/scopes/swift/interior.foreach.scope | 2 ++ resources/fixtures/scopes/swift/interior.interface.scope | 2 ++ resources/fixtures/scopes/swift/name.iteration.class.scope | 2 ++ resources/fixtures/scopes/swift/name.iteration.enum.scope | 2 ++ .../fixtures/scopes/swift/name.iteration.interface.scope | 2 ++ .../fixtures/scopes/swift/namedFunction.iteration.class.scope | 2 ++ .../fixtures/scopes/swift/statement.iteration.class.scope | 2 ++ .../fixtures/scopes/swift/statement.iteration.interface.scope | 2 ++ resources/fixtures/scopes/swift/type.constant.scope | 2 ++ resources/fixtures/scopes/swift/type.enum.scope | 2 ++ resources/fixtures/scopes/swift/type.field.class.scope | 4 ++++ resources/fixtures/scopes/swift/type.field.interface.scope | 4 ++++ resources/fixtures/scopes/swift/type.iteration.block.scope | 2 ++ resources/fixtures/scopes/swift/type.iteration.class.scope | 2 ++ .../fixtures/scopes/swift/type.iteration.interface.scope | 2 ++ .../fixtures/scopes/swift/type.variable.initialized.scope | 2 ++ .../fixtures/scopes/swift/type.variable.uninitialized.scope | 2 ++ resources/fixtures/scopes/swift/value.iteration.enum.scope | 2 ++ resources/queries/swift.scm | 3 ++- 22 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 resources/fixtures/scopes/swift/class.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/interior.class.scope create mode 100644 resources/fixtures/scopes/swift/interior.enum.scope create mode 100644 resources/fixtures/scopes/swift/interior.foreach.scope create mode 100644 resources/fixtures/scopes/swift/interior.interface.scope create mode 100644 resources/fixtures/scopes/swift/name.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/name.iteration.enum.scope create mode 100644 resources/fixtures/scopes/swift/name.iteration.interface.scope create mode 100644 resources/fixtures/scopes/swift/namedFunction.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/statement.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/statement.iteration.interface.scope create mode 100644 resources/fixtures/scopes/swift/type.constant.scope create mode 100644 resources/fixtures/scopes/swift/type.enum.scope create mode 100644 resources/fixtures/scopes/swift/type.field.class.scope create mode 100644 resources/fixtures/scopes/swift/type.field.interface.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.block.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.interface.scope create mode 100644 resources/fixtures/scopes/swift/type.variable.initialized.scope create mode 100644 resources/fixtures/scopes/swift/type.variable.uninitialized.scope create mode 100644 resources/fixtures/scopes/swift/value.iteration.enum.scope diff --git a/resources/fixtures/scopes/swift/class.iteration.class.scope b/resources/fixtures/scopes/swift/class.iteration.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/resources/fixtures/scopes/swift/class.iteration.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/resources/fixtures/scopes/swift/interior.class.scope b/resources/fixtures/scopes/swift/interior.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/resources/fixtures/scopes/swift/interior.enum.scope b/resources/fixtures/scopes/swift/interior.enum.scope new file mode 100644 index 0000000000..f14a727bf6 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.enum.scope @@ -0,0 +1,2 @@ +enum Foo { } +--- diff --git a/resources/fixtures/scopes/swift/interior.foreach.scope b/resources/fixtures/scopes/swift/interior.foreach.scope new file mode 100644 index 0000000000..20fe47c9bd --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.foreach.scope @@ -0,0 +1,2 @@ +for foo in bat { } +--- diff --git a/resources/fixtures/scopes/swift/interior.interface.scope b/resources/fixtures/scopes/swift/interior.interface.scope new file mode 100644 index 0000000000..c0958082d9 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.interface.scope @@ -0,0 +1,2 @@ +protocol Foo { } +--- diff --git a/resources/fixtures/scopes/swift/name.iteration.class.scope b/resources/fixtures/scopes/swift/name.iteration.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/resources/fixtures/scopes/swift/name.iteration.enum.scope b/resources/fixtures/scopes/swift/name.iteration.enum.scope new file mode 100644 index 0000000000..f14a727bf6 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.enum.scope @@ -0,0 +1,2 @@ +enum Foo { } +--- diff --git a/resources/fixtures/scopes/swift/name.iteration.interface.scope b/resources/fixtures/scopes/swift/name.iteration.interface.scope new file mode 100644 index 0000000000..c0958082d9 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.interface.scope @@ -0,0 +1,2 @@ +protocol Foo { } +--- diff --git a/resources/fixtures/scopes/swift/namedFunction.iteration.class.scope b/resources/fixtures/scopes/swift/namedFunction.iteration.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/resources/fixtures/scopes/swift/namedFunction.iteration.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/resources/fixtures/scopes/swift/statement.iteration.class.scope b/resources/fixtures/scopes/swift/statement.iteration.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/resources/fixtures/scopes/swift/statement.iteration.interface.scope b/resources/fixtures/scopes/swift/statement.iteration.interface.scope new file mode 100644 index 0000000000..c0958082d9 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.interface.scope @@ -0,0 +1,2 @@ +protocol Foo { } +--- diff --git a/resources/fixtures/scopes/swift/type.constant.scope b/resources/fixtures/scopes/swift/type.constant.scope new file mode 100644 index 0000000000..86a2d72c96 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.constant.scope @@ -0,0 +1,2 @@ +let foo: Int = 0 +--- diff --git a/resources/fixtures/scopes/swift/type.enum.scope b/resources/fixtures/scopes/swift/type.enum.scope new file mode 100644 index 0000000000..aac4cd6aba --- /dev/null +++ b/resources/fixtures/scopes/swift/type.enum.scope @@ -0,0 +1,2 @@ +enum Foo {} +--- diff --git a/resources/fixtures/scopes/swift/type.field.class.scope b/resources/fixtures/scopes/swift/type.field.class.scope new file mode 100644 index 0000000000..4d95689a8f --- /dev/null +++ b/resources/fixtures/scopes/swift/type.field.class.scope @@ -0,0 +1,4 @@ +struct Foo { + var foo: Int = 0 +} +--- diff --git a/resources/fixtures/scopes/swift/type.field.interface.scope b/resources/fixtures/scopes/swift/type.field.interface.scope new file mode 100644 index 0000000000..9c963ec112 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -0,0 +1,4 @@ +protocol Foo { + var foo: Int { set get } +} +--- diff --git a/resources/fixtures/scopes/swift/type.iteration.block.scope b/resources/fixtures/scopes/swift/type.iteration.block.scope new file mode 100644 index 0000000000..47e568339a --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.block.scope @@ -0,0 +1,2 @@ +func foo { } +--- diff --git a/resources/fixtures/scopes/swift/type.iteration.class.scope b/resources/fixtures/scopes/swift/type.iteration.class.scope new file mode 100644 index 0000000000..287f9b0c16 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.class.scope @@ -0,0 +1,2 @@ +class Foo { } +--- diff --git a/resources/fixtures/scopes/swift/type.iteration.interface.scope b/resources/fixtures/scopes/swift/type.iteration.interface.scope new file mode 100644 index 0000000000..c0958082d9 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.interface.scope @@ -0,0 +1,2 @@ +protocol Foo { } +--- diff --git a/resources/fixtures/scopes/swift/type.variable.initialized.scope b/resources/fixtures/scopes/swift/type.variable.initialized.scope new file mode 100644 index 0000000000..8e41ba65a0 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.variable.initialized.scope @@ -0,0 +1,2 @@ +var foo: Int = 0 +--- diff --git a/resources/fixtures/scopes/swift/type.variable.uninitialized.scope b/resources/fixtures/scopes/swift/type.variable.uninitialized.scope new file mode 100644 index 0000000000..d37d32a41a --- /dev/null +++ b/resources/fixtures/scopes/swift/type.variable.uninitialized.scope @@ -0,0 +1,2 @@ +var foo: Int +--- diff --git a/resources/fixtures/scopes/swift/value.iteration.enum.scope b/resources/fixtures/scopes/swift/value.iteration.enum.scope new file mode 100644 index 0000000000..f14a727bf6 --- /dev/null +++ b/resources/fixtures/scopes/swift/value.iteration.enum.scope @@ -0,0 +1,2 @@ +enum Foo { } +--- diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 54e79f6f90..558a39fc4d 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -163,7 +163,7 @@ ) @statement @_.domain ) -;; const/var type +;; generic type annotation ( (type_annotation ":" @type.leading @@ -171,3 +171,4 @@ _ @type ) ) + From e320dab215236f2ca01bd3380667b045921770b9 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sun, 13 Sep 2026 21:01:43 -0400 Subject: [PATCH 25/26] ...and get them functioning --- .../src/scopeSupportFacets/swift.ts | 2 +- .../scopes/swift/branch.if.iteration.scope | 12 ++- .../scopes/swift/class.iteration.class.scope | 11 +++ .../scopes/swift/interior.class.scope | 8 ++ .../fixtures/scopes/swift/interior.enum.scope | 8 ++ .../scopes/swift/interior.foreach.scope | 8 ++ .../scopes/swift/interior.interface.scope | 8 ++ .../scopes/swift/name.iteration.class.scope | 11 +++ .../scopes/swift/name.iteration.enum.scope | 11 +++ .../swift/name.iteration.interface.scope | 11 +++ .../swift/namedFunction.iteration.class.scope | 2 - .../swift/statement.iteration.class.scope | 11 +++ .../swift/statement.iteration.interface.scope | 11 +++ .../fixtures/scopes/swift/type.constant.scope | 15 ++++ .../fixtures/scopes/swift/type.enum.scope | 19 ++++ .../scopes/swift/type.field.class.scope | 35 ++++++++ .../scopes/swift/type.field.interface.scope | 15 ++++ .../fixtures/scopes/swift/type.foreach.scope | 26 ++++-- .../scopes/swift/type.iteration.block.scope | 11 +++ .../scopes/swift/type.iteration.class.scope | 11 +++ .../swift/type.iteration.document.scope | 7 ++ .../swift/type.iteration.interface.scope | 11 +++ .../swift/type.variable.initialized.scope | 15 ++++ .../swift/type.variable.uninitialized.scope | 15 ++++ .../scopes/swift/value.iteration.enum.scope | 11 +++ resources/queries/swift.scm | 88 ++++++++++--------- 26 files changed, 342 insertions(+), 51 deletions(-) delete mode 100644 resources/fixtures/scopes/swift/namedFunction.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.document.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 4e086834b9..3f655fb2c0 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -85,7 +85,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.iteration.class": supported, "class.iteration.class": supported, - "namedFunction.iteration.class": supported, + "namedFunction.iteration.class": unsupported, "name.iteration.class": supported, "value.iteration.class": unsupported, "type.iteration.class": supported, diff --git a/resources/fixtures/scopes/swift/branch.if.iteration.scope b/resources/fixtures/scopes/swift/branch.if.iteration.scope index 4284edc393..59553c1851 100644 --- a/resources/fixtures/scopes/swift/branch.if.iteration.scope +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -3,10 +3,18 @@ else if bar {} else {} --- -[Content] = -[Domain] = 0:0-2:7 +[#1 Content] = +[#1 Domain] = 0:0-2:7 >--------- 0| if foo {} 1| else if bar {} 2| else {} -------< + + +[#2 Content] = +[#2 Domain] = 1:13-2:6 + >- +1| else if bar {} +2| else {} + ------< diff --git a/resources/fixtures/scopes/swift/class.iteration.class.scope b/resources/fixtures/scopes/swift/class.iteration.class.scope index 287f9b0c16..a3ec5f3456 100644 --- a/resources/fixtures/scopes/swift/class.iteration.class.scope +++ b/resources/fixtures/scopes/swift/class.iteration.class.scope @@ -1,2 +1,13 @@ class Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/resources/fixtures/scopes/swift/interior.class.scope b/resources/fixtures/scopes/swift/interior.class.scope index 287f9b0c16..13ef2f4d94 100644 --- a/resources/fixtures/scopes/swift/interior.class.scope +++ b/resources/fixtures/scopes/swift/interior.class.scope @@ -1,2 +1,10 @@ class Foo { } --- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| class Foo { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.enum.scope b/resources/fixtures/scopes/swift/interior.enum.scope index f14a727bf6..d96875b078 100644 --- a/resources/fixtures/scopes/swift/interior.enum.scope +++ b/resources/fixtures/scopes/swift/interior.enum.scope @@ -1,2 +1,10 @@ enum Foo { } --- + +[Content] = +[Removal] = +[Domain] = 0:10-0:11 + >-< +0| enum Foo { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.foreach.scope b/resources/fixtures/scopes/swift/interior.foreach.scope index 20fe47c9bd..ac81619891 100644 --- a/resources/fixtures/scopes/swift/interior.foreach.scope +++ b/resources/fixtures/scopes/swift/interior.foreach.scope @@ -1,2 +1,10 @@ for foo in bat { } --- + +[Content] = +[Removal] = +[Domain] = 0:16-0:17 + >-< +0| for foo in bat { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.interface.scope b/resources/fixtures/scopes/swift/interior.interface.scope index c0958082d9..675578b704 100644 --- a/resources/fixtures/scopes/swift/interior.interface.scope +++ b/resources/fixtures/scopes/swift/interior.interface.scope @@ -1,2 +1,10 @@ protocol Foo { } --- + +[Content] = +[Removal] = +[Domain] = 0:14-0:15 + >-< +0| protocol Foo { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.iteration.class.scope b/resources/fixtures/scopes/swift/name.iteration.class.scope index 287f9b0c16..a3ec5f3456 100644 --- a/resources/fixtures/scopes/swift/name.iteration.class.scope +++ b/resources/fixtures/scopes/swift/name.iteration.class.scope @@ -1,2 +1,13 @@ class Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/resources/fixtures/scopes/swift/name.iteration.enum.scope b/resources/fixtures/scopes/swift/name.iteration.enum.scope index f14a727bf6..9034c4ee11 100644 --- a/resources/fixtures/scopes/swift/name.iteration.enum.scope +++ b/resources/fixtures/scopes/swift/name.iteration.enum.scope @@ -1,2 +1,13 @@ enum Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| enum Foo { } + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| enum Foo { } diff --git a/resources/fixtures/scopes/swift/name.iteration.interface.scope b/resources/fixtures/scopes/swift/name.iteration.interface.scope index c0958082d9..7db5025f1b 100644 --- a/resources/fixtures/scopes/swift/name.iteration.interface.scope +++ b/resources/fixtures/scopes/swift/name.iteration.interface.scope @@ -1,2 +1,13 @@ protocol Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| protocol Foo { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| protocol Foo { } diff --git a/resources/fixtures/scopes/swift/namedFunction.iteration.class.scope b/resources/fixtures/scopes/swift/namedFunction.iteration.class.scope deleted file mode 100644 index 287f9b0c16..0000000000 --- a/resources/fixtures/scopes/swift/namedFunction.iteration.class.scope +++ /dev/null @@ -1,2 +0,0 @@ -class Foo { } ---- diff --git a/resources/fixtures/scopes/swift/statement.iteration.class.scope b/resources/fixtures/scopes/swift/statement.iteration.class.scope index 287f9b0c16..a3ec5f3456 100644 --- a/resources/fixtures/scopes/swift/statement.iteration.class.scope +++ b/resources/fixtures/scopes/swift/statement.iteration.class.scope @@ -1,2 +1,13 @@ class Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/resources/fixtures/scopes/swift/statement.iteration.interface.scope b/resources/fixtures/scopes/swift/statement.iteration.interface.scope index c0958082d9..7db5025f1b 100644 --- a/resources/fixtures/scopes/swift/statement.iteration.interface.scope +++ b/resources/fixtures/scopes/swift/statement.iteration.interface.scope @@ -1,2 +1,13 @@ protocol Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| protocol Foo { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| protocol Foo { } diff --git a/resources/fixtures/scopes/swift/type.constant.scope b/resources/fixtures/scopes/swift/type.constant.scope index 86a2d72c96..386c29221d 100644 --- a/resources/fixtures/scopes/swift/type.constant.scope +++ b/resources/fixtures/scopes/swift/type.constant.scope @@ -1,2 +1,17 @@ let foo: Int = 0 --- + +[Content] = +[Domain] = 0:9-0:12 + >---< +0| let foo: Int = 0 + +[Removal] = 0:7-0:12 + >-----< +0| let foo: Int = 0 + +[Leading delimiter] = 0:7-0:9 + >--< +0| let foo: Int = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.enum.scope b/resources/fixtures/scopes/swift/type.enum.scope index aac4cd6aba..2162ad8604 100644 --- a/resources/fixtures/scopes/swift/type.enum.scope +++ b/resources/fixtures/scopes/swift/type.enum.scope @@ -1,2 +1,21 @@ enum Foo {} --- + +[Content] = +[Domain] = 0:5-0:8 + >---< +0| enum Foo {} + +[Removal] = 0:5-0:9 + >----< +0| enum Foo {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| enum Foo {} + +[Trailing delimiter] = 0:8-0:9 + >-< +0| enum Foo {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.field.class.scope b/resources/fixtures/scopes/swift/type.field.class.scope index 4d95689a8f..8e772e72e1 100644 --- a/resources/fixtures/scopes/swift/type.field.class.scope +++ b/resources/fixtures/scopes/swift/type.field.class.scope @@ -2,3 +2,38 @@ struct Foo { var foo: Int = 0 } --- + +[#1 Content] = +[#1 Domain] = 0:7-0:10 + >---< +0| struct Foo { + +[#1 Removal] = 0:7-0:11 + >----< +0| struct Foo { + +[#1 Leading delimiter] = 0:6-0:7 + >-< +0| struct Foo { + +[#1 Trailing delimiter] = 0:10-0:11 + >-< +0| struct Foo { + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 1:13-1:16 + >---< +1| var foo: Int = 0 + +[#2 Removal] = 1:11-1:16 + >-----< +1| var foo: Int = 0 + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| var foo: Int = 0 + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.field.interface.scope b/resources/fixtures/scopes/swift/type.field.interface.scope index 9c963ec112..13d746a265 100644 --- a/resources/fixtures/scopes/swift/type.field.interface.scope +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -2,3 +2,18 @@ protocol Foo { var foo: Int { set get } } --- + +[Content] = +[Domain] = 1:13-1:16 + >---< +1| var foo: Int { set get } + +[Removal] = 1:11-1:16 + >-----< +1| var foo: Int { set get } + +[Leading delimiter] = 1:11-1:13 + >--< +1| var foo: Int { set get } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.foreach.scope b/resources/fixtures/scopes/swift/type.foreach.scope index 8e867374c0..b33e662415 100644 --- a/resources/fixtures/scopes/swift/type.foreach.scope +++ b/resources/fixtures/scopes/swift/type.foreach.scope @@ -1,20 +1,36 @@ for foo: Type in bar {} --- -[Content] = 0:9-0:13 +[#1 Content] = 0:9-0:13 >----< 0| for foo: Type in bar {} -[Removal] = 0:7-0:13 +[#1 Removal] = 0:7-0:13 >------< 0| for foo: Type in bar {} -[Leading delimiter] = 0:7-0:9 +[#1 Leading delimiter] = 0:7-0:9 >--< 0| for foo: Type in bar {} -[Domain] = 0:0-0:23 +[#1 Domain] = 0:0-0:23 >-----------------------< 0| for foo: Type in bar {} -[Insertion delimiter] = " " +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:9-0:13 + >----< +0| for foo: Type in bar {} + +[#2 Removal] = 0:7-0:13 + >------< +0| for foo: Type in bar {} + +[#2 Leading delimiter] = 0:7-0:9 + >--< +0| for foo: Type in bar {} + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.iteration.block.scope b/resources/fixtures/scopes/swift/type.iteration.block.scope index 47e568339a..c5bbfd9099 100644 --- a/resources/fixtures/scopes/swift/type.iteration.block.scope +++ b/resources/fixtures/scopes/swift/type.iteration.block.scope @@ -1,2 +1,13 @@ func foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| func foo { } + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| func foo { } diff --git a/resources/fixtures/scopes/swift/type.iteration.class.scope b/resources/fixtures/scopes/swift/type.iteration.class.scope index 287f9b0c16..a3ec5f3456 100644 --- a/resources/fixtures/scopes/swift/type.iteration.class.scope +++ b/resources/fixtures/scopes/swift/type.iteration.class.scope @@ -1,2 +1,13 @@ class Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:13 + >-------------< +0| class Foo { } + + +[#2 Content] = +[#2 Domain] = 0:11-0:12 + >-< +0| class Foo { } diff --git a/resources/fixtures/scopes/swift/type.iteration.document.scope b/resources/fixtures/scopes/swift/type.iteration.document.scope new file mode 100644 index 0000000000..66c4ce7aef --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.document.scope @@ -0,0 +1,7 @@ +let foo: Int = 0 +--- + +[Content] = +[Domain] = 0:0-0:16 + >----------------< +0| let foo: Int = 0 diff --git a/resources/fixtures/scopes/swift/type.iteration.interface.scope b/resources/fixtures/scopes/swift/type.iteration.interface.scope index c0958082d9..7db5025f1b 100644 --- a/resources/fixtures/scopes/swift/type.iteration.interface.scope +++ b/resources/fixtures/scopes/swift/type.iteration.interface.scope @@ -1,2 +1,13 @@ protocol Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| protocol Foo { } + + +[#2 Content] = +[#2 Domain] = 0:14-0:15 + >-< +0| protocol Foo { } diff --git a/resources/fixtures/scopes/swift/type.variable.initialized.scope b/resources/fixtures/scopes/swift/type.variable.initialized.scope index 8e41ba65a0..d8d205f9e1 100644 --- a/resources/fixtures/scopes/swift/type.variable.initialized.scope +++ b/resources/fixtures/scopes/swift/type.variable.initialized.scope @@ -1,2 +1,17 @@ var foo: Int = 0 --- + +[Content] = +[Domain] = 0:9-0:12 + >---< +0| var foo: Int = 0 + +[Removal] = 0:7-0:12 + >-----< +0| var foo: Int = 0 + +[Leading delimiter] = 0:7-0:9 + >--< +0| var foo: Int = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.variable.uninitialized.scope b/resources/fixtures/scopes/swift/type.variable.uninitialized.scope index d37d32a41a..98b51069c8 100644 --- a/resources/fixtures/scopes/swift/type.variable.uninitialized.scope +++ b/resources/fixtures/scopes/swift/type.variable.uninitialized.scope @@ -1,2 +1,17 @@ var foo: Int --- + +[Content] = +[Domain] = 0:9-0:12 + >---< +0| var foo: Int + +[Removal] = 0:7-0:12 + >-----< +0| var foo: Int + +[Leading delimiter] = 0:7-0:9 + >--< +0| var foo: Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value.iteration.enum.scope b/resources/fixtures/scopes/swift/value.iteration.enum.scope index f14a727bf6..9034c4ee11 100644 --- a/resources/fixtures/scopes/swift/value.iteration.enum.scope +++ b/resources/fixtures/scopes/swift/value.iteration.enum.scope @@ -1,2 +1,13 @@ enum Foo { } --- + +[#1 Content] = +[#1 Domain] = 0:0-0:12 + >------------< +0| enum Foo { } + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| enum Foo { } diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 558a39fc4d..d1b8dc8192 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,9 +1,9 @@ ;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json -;; document-wide -- seems like there might be a problem with tree-sitter-swift that causes this to not work correctly? +;; document-wide ( - (source_file) @value.iteration @type.iteration - (#document-range! @value.iteration @type.iteration) + (source_file) @value.iteration @type.iteration @interior.iteration + (#document-range! @value.iteration @type.iteration @interior.iteration) ) ( @@ -82,51 +82,60 @@ ) @statement ;; 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 @statement.iteration.start.endOf @name.iteration.start.endOf + "}" @interior.end.startOf @statement.iteration.end.startOf @name.iteration.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 - . +( + (_ + "{" @value.iteration.start.endOf @type.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @value.iteration.end.startOf @type.iteration.end.startOf @namedFunction.iteration.end.startOf + ) ) -;; 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 + (_ + "{" @class.iteration.start.endOf @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @class.iteration.end.startOf @condition.iteration.end.startOf @branch.iteration.end.startOf ) - (#type? @_dummy class_declaration function_declaration) - (#not-parent-type? @_dummy switch_statement for_statement while_statement) - (#not-parent-type? @_dummy do_statement repeat_while_statement protocol_declaration) - (#not-parent-type? @_dummy if_statement) ) + + +;; 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-parent-type? @_dummy switch_statement for_statement while_statement) +;; (#not-parent-type? @_dummy do_statement repeat_while_statement protocol_declaration) +;; (#not-parent-type? @_dummy if_statement) +;; ) + ;; 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) -) +;; ( +;; ( +;; (_ +;; . +;; "{" @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 classlike decl. (class_declaration @@ -134,7 +143,6 @@ body: (class_body "{" @interior.start.endOf "}" @interior.end.startOf - . ) ) @statement @class @@ -144,7 +152,6 @@ body: (enum_class_body "{" @interior.start.endOf "}" @interior.end.startOf - . ) ) @statement @class @@ -171,4 +178,3 @@ _ @type ) ) - From 4b0022cf9756e65c4b4be443c2e5ff8f82bef92f Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sun, 13 Sep 2026 21:40:15 -0400 Subject: [PATCH 26/26] docs gaming --- .../docs/user/languages/fixtures/swift.json | 452 ++++++++++++++++++ .../src/docs/user/languages/swift.mdx | 130 ++++- .../src/docs/user/scopes/class.mdx | 4 + .../src/docs/user/scopes/fixtures/branch.json | 8 + .../src/docs/user/scopes/fixtures/class.json | 24 + .../docs/user/scopes/fixtures/interior.json | 68 +++ .../src/docs/user/scopes/fixtures/name.json | 72 +++ .../docs/user/scopes/fixtures/statement.json | 48 ++ .../src/docs/user/scopes/fixtures/type.json | 208 ++++++++ .../src/docs/user/scopes/fixtures/value.json | 24 + .../src/docs/user/scopes/interior.mdx | 16 + .../src/docs/user/scopes/name.mdx | 12 + .../src/docs/user/scopes/statement.mdx | 8 + .../src/docs/user/scopes/type.mdx | 40 ++ .../src/docs/user/scopes/value.mdx | 8 + resources/queries/swift.scm | 4 +- 16 files changed, 1121 insertions(+), 5 deletions(-) diff --git a/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json index 2ba9606106..bcd8c61da1 100644 --- a/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json @@ -109,6 +109,14 @@ } ], "domain": "0:0-2:7" + }, + { + "targets": [ + { + "content": "1:13-2:6" + } + ], + "domain": "1:13-2:6" } ] }, @@ -129,6 +137,30 @@ } ] }, + { + "name": "scopes/swift/class.iteration.class", + "languageId": "swift", + "facet": "class.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, { "name": "scopes/swift/class", "languageId": "swift", @@ -214,6 +246,57 @@ } ] }, + { + "name": "scopes/swift/interior.class", + "languageId": "swift", + "facet": "interior.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/interior.enum", + "languageId": "swift", + "facet": "interior.enum", + "code": "enum Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:10-0:11", + "removal": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, + { + "name": "scopes/swift/interior.foreach", + "languageId": "swift", + "facet": "interior.foreach", + "code": "for foo in bat { }", + "scopes": [ + { + "targets": [ + { + "content": "0:16-0:17", + "removal": "0:16-0:17" + } + ], + "domain": "0:16-0:17" + } + ] + }, { "name": "scopes/swift/interior.if", "languageId": "swift", @@ -231,6 +314,23 @@ } ] }, + { + "name": "scopes/swift/interior.interface", + "languageId": "swift", + "facet": "interior.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:14-0:15", + "removal": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, { "name": "scopes/swift/name.class", "languageId": "swift", @@ -299,6 +399,78 @@ } ] }, + { + "name": "scopes/swift/name.iteration.class", + "languageId": "swift", + "facet": "name.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/name.iteration.enum", + "languageId": "swift", + "facet": "name.iteration.enum", + "code": "enum Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + }, + { + "targets": [ + { + "content": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, + { + "name": "scopes/swift/name.iteration.interface", + "languageId": "swift", + "facet": "name.iteration.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + }, + { + "targets": [ + { + "content": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, { "name": "scopes/swift/statement.class", "languageId": "swift", @@ -367,6 +539,54 @@ } ] }, + { + "name": "scopes/swift/statement.iteration.class", + "languageId": "swift", + "facet": "statement.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.iteration.interface", + "languageId": "swift", + "facet": "statement.iteration.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + }, + { + "targets": [ + { + "content": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, { "name": "scopes/swift/string.multiLine", "languageId": "swift", @@ -469,6 +689,83 @@ } ] }, + { + "name": "scopes/swift/type.constant", + "languageId": "swift", + "facet": "type.constant", + "code": "let foo: Int = 0", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:7-0:12" + } + ], + "domain": "0:9-0:12" + } + ] + }, + { + "name": "scopes/swift/type.enum", + "languageId": "swift", + "facet": "type.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:5-0:8", + "removal": "0:5-0:9" + } + ], + "domain": "0:5-0:8" + } + ] + }, + { + "name": "scopes/swift/type.field.class", + "languageId": "swift", + "facet": "type.field.class", + "code": "struct Foo {\n var foo: Int = 0\n}", + "scopes": [ + { + "targets": [ + { + "content": "0:7-0:10", + "removal": "0:7-0:11" + } + ], + "domain": "0:7-0:10" + }, + { + "targets": [ + { + "content": "1:13-1:16", + "removal": "1:11-1:16" + } + ], + "domain": "1:13-1:16" + } + ] + }, + { + "name": "scopes/swift/type.field.interface", + "languageId": "swift", + "facet": "type.field.interface", + "code": "protocol Foo {\n var foo: Int { set get }\n}", + "scopes": [ + { + "targets": [ + { + "content": "1:13-1:16", + "removal": "1:11-1:16" + } + ], + "domain": "1:13-1:16" + } + ] + }, { "name": "scopes/swift/type.foreach", "languageId": "swift", @@ -483,6 +780,137 @@ } ], "domain": "0:0-0:23" + }, + { + "targets": [ + { + "content": "0:9-0:13", + "removal": "0:7-0:13" + } + ], + "domain": "0:9-0:13" + } + ] + }, + { + "name": "scopes/swift/type.iteration.block", + "languageId": "swift", + "facet": "type.iteration.block", + "code": "func foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + }, + { + "targets": [ + { + "content": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, + { + "name": "scopes/swift/type.iteration.class", + "languageId": "swift", + "facet": "type.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/type.iteration.document", + "languageId": "swift", + "facet": "type.iteration.document", + "code": "let foo: Int = 0", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + } + ] + }, + { + "name": "scopes/swift/type.iteration.interface", + "languageId": "swift", + "facet": "type.iteration.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + }, + { + "targets": [ + { + "content": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, + { + "name": "scopes/swift/type.variable.initialized", + "languageId": "swift", + "facet": "type.variable.initialized", + "code": "var foo: Int = 0", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:7-0:12" + } + ], + "domain": "0:9-0:12" + } + ] + }, + { + "name": "scopes/swift/type.variable.uninitialized", + "languageId": "swift", + "facet": "type.variable.uninitialized", + "code": "var foo: Int", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:7-0:12" + } + ], + "domain": "0:9-0:12" } ] }, @@ -502,5 +930,29 @@ "domain": "0:0-0:17" } ] + }, + { + "name": "scopes/swift/value.iteration.enum", + "languageId": "swift", + "facet": "value.iteration.enum", + "code": "enum Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + }, + { + "targets": [ + { + "content": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] } ] diff --git a/packages/app-web-docs/src/docs/user/languages/swift.mdx b/packages/app-web-docs/src/docs/user/languages/swift.mdx index 68984dce2f..705a5d4a36 100644 --- a/packages/app-web-docs/src/docs/user/languages/swift.mdx +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -45,6 +45,12 @@ Below are visualizations of all our scope tests for this language. These were cr +#### 2. Class (iteration class) + +Iteration scope for classes: class bodies. + + + ### Comment #### 1. Comment: Block @@ -77,12 +83,36 @@ Below are visualizations of all our scope tests for this language. These were cr ### Interior -#### 1. Interior: If +#### 1. Interior: Class + +The body of a class/struct declaration + + + +#### 2. Interior: Enum + +The body of an enum declaration + + + +#### 3. Interior: Foreach + +The body of a for-each loop + + + +#### 4. Interior: If The body of an if/elif/else branch +#### 5. Interior: Interface + +The body of an interface declaration + + + ### Name #### 1. Name: Class @@ -109,6 +139,24 @@ Below are visualizations of all our scope tests for this language. These were cr +#### 5. Name (iteration class) + +Iteration scope for names: class bodies. + + + +#### 6. Name (iteration enum) + +Iteration scope for names: enum bodies. + + + +#### 7. Name (iteration interface) + +Iteration scope for names: interface bodies. + + + ### Statement #### 1. Statement: Class @@ -135,14 +183,86 @@ Below are visualizations of all our scope tests for this language. These were cr +#### 5. Statement (iteration class) + +Iteration scope for statements: class bodies. + + + +#### 6. Statement (iteration interface) + +Iteration scope for statements: interface bodies. + + + ### Type -#### 1. Type: Foreach +#### 1. Type: Constant + +Type of a constant declaration + + + +#### 2. Type: Enum + +An enum declaration + + + +#### 3. Type: Field class + +Type of a field declaration in a class/struct + + + +#### 4. Type: Field interface + +Type of a field declaration in an interface + + + +#### 5. Type: Foreach Type of a variable in a for-each loop +#### 6. Type: Variable initialized + +Type of an initialized variable declaration + + + +#### 7. Type: Variable uninitialized + +Type of an uninitialized variable declaration + + + +#### 8. Type (iteration block) + +Iteration scope for types: statement blocks (body of functions/if-statements/for-loops/etc). + + + +#### 9. Type (iteration class) + +Iteration scope for types: class bodies. + + + +#### 10. Type (iteration document) + +Iteration scope for types: the entire document including leading and trailing empty lines. + + + +#### 11. Type (iteration interface) + +Iteration scope for types: interface bodies. + + + ### Value #### 1. Value: Foreach @@ -151,6 +271,12 @@ Below are visualizations of all our scope tests for this language. These were cr +#### 2. Value (iteration enum) + +Iteration scope for values: enum bodies. + + + ## Internal scopes The following are internal scopes. They are not intended for user interaction or spoken use. These scopes exist solely for internal Cursorless functionality. diff --git a/packages/app-web-docs/src/docs/user/scopes/class.mdx b/packages/app-web-docs/src/docs/user/scopes/class.mdx index 5dbe89f84a..13bdef4489 100644 --- a/packages/app-web-docs/src/docs/user/scopes/class.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/class.mdx @@ -147,6 +147,10 @@ Default: `class` +##### Swift + + + ### Class (iteration document) Iteration scope for classes: the entire document including leading and trailing empty lines. diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json index 357fe7323b..3501ebc4f3 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json @@ -3505,6 +3505,14 @@ } ], "domain": "0:0-2:7" + }, + { + "targets": [ + { + "content": "1:13-2:6" + } + ], + "domain": "1:13-2:6" } ] }, diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json index ff94ed8c7c..e795e40a69 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json @@ -785,6 +785,30 @@ } ] }, + { + "name": "scopes/swift/class.iteration.class", + "languageId": "swift", + "facet": "class.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, { "name": "scopes/swift/class", "languageId": "swift", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json index eeb820ac30..b779bc26b3 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json @@ -5109,6 +5109,57 @@ } ] }, + { + "name": "scopes/swift/interior.class", + "languageId": "swift", + "facet": "interior.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/interior.enum", + "languageId": "swift", + "facet": "interior.enum", + "code": "enum Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:10-0:11", + "removal": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, + { + "name": "scopes/swift/interior.foreach", + "languageId": "swift", + "facet": "interior.foreach", + "code": "for foo in bat { }", + "scopes": [ + { + "targets": [ + { + "content": "0:16-0:17", + "removal": "0:16-0:17" + } + ], + "domain": "0:16-0:17" + } + ] + }, { "name": "scopes/swift/interior.if", "languageId": "swift", @@ -5126,6 +5177,23 @@ } ] }, + { + "name": "scopes/swift/interior.interface", + "languageId": "swift", + "facet": "interior.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:14-0:15", + "removal": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, { "name": "scopes/talon/interior.command", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json index 497777e2b6..80713da582 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json @@ -12363,6 +12363,78 @@ } ] }, + { + "name": "scopes/swift/name.iteration.class", + "languageId": "swift", + "facet": "name.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/name.iteration.enum", + "languageId": "swift", + "facet": "name.iteration.enum", + "code": "enum Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + }, + { + "targets": [ + { + "content": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, + { + "name": "scopes/swift/name.iteration.interface", + "languageId": "swift", + "facet": "name.iteration.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + }, + { + "targets": [ + { + "content": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, { "name": "scopes/talon/name/name.assignment", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json index 4f284e5b6a..0c685d5209 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json @@ -11430,6 +11430,54 @@ } ] }, + { + "name": "scopes/swift/statement.iteration.class", + "languageId": "swift", + "facet": "statement.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/statement.iteration.interface", + "languageId": "swift", + "facet": "statement.iteration.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + }, + { + "targets": [ + { + "content": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, { "name": "scopes/talon/statement.assignment", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json index 0a461d80ce..f4aa4fe635 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json @@ -7399,6 +7399,83 @@ } ] }, + { + "name": "scopes/swift/type.constant", + "languageId": "swift", + "facet": "type.constant", + "code": "let foo: Int = 0", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:7-0:12" + } + ], + "domain": "0:9-0:12" + } + ] + }, + { + "name": "scopes/swift/type.enum", + "languageId": "swift", + "facet": "type.enum", + "code": "enum Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:5-0:8", + "removal": "0:5-0:9" + } + ], + "domain": "0:5-0:8" + } + ] + }, + { + "name": "scopes/swift/type.field.class", + "languageId": "swift", + "facet": "type.field.class", + "code": "struct Foo {\n var foo: Int = 0\n}", + "scopes": [ + { + "targets": [ + { + "content": "0:7-0:10", + "removal": "0:7-0:11" + } + ], + "domain": "0:7-0:10" + }, + { + "targets": [ + { + "content": "1:13-1:16", + "removal": "1:11-1:16" + } + ], + "domain": "1:13-1:16" + } + ] + }, + { + "name": "scopes/swift/type.field.interface", + "languageId": "swift", + "facet": "type.field.interface", + "code": "protocol Foo {\n var foo: Int { set get }\n}", + "scopes": [ + { + "targets": [ + { + "content": "1:13-1:16", + "removal": "1:11-1:16" + } + ], + "domain": "1:13-1:16" + } + ] + }, { "name": "scopes/swift/type.foreach", "languageId": "swift", @@ -7413,6 +7490,137 @@ } ], "domain": "0:0-0:23" + }, + { + "targets": [ + { + "content": "0:9-0:13", + "removal": "0:7-0:13" + } + ], + "domain": "0:9-0:13" + } + ] + }, + { + "name": "scopes/swift/type.iteration.block", + "languageId": "swift", + "facet": "type.iteration.block", + "code": "func foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + }, + { + "targets": [ + { + "content": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, + { + "name": "scopes/swift/type.iteration.class", + "languageId": "swift", + "facet": "type.iteration.class", + "code": "class Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + }, + { + "targets": [ + { + "content": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/type.iteration.document", + "languageId": "swift", + "facet": "type.iteration.document", + "code": "let foo: Int = 0", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + } + ] + }, + { + "name": "scopes/swift/type.iteration.interface", + "languageId": "swift", + "facet": "type.iteration.interface", + "code": "protocol Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:16" + } + ], + "domain": "0:0-0:16" + }, + { + "targets": [ + { + "content": "0:14-0:15" + } + ], + "domain": "0:14-0:15" + } + ] + }, + { + "name": "scopes/swift/type.variable.initialized", + "languageId": "swift", + "facet": "type.variable.initialized", + "code": "var foo: Int = 0", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:7-0:12" + } + ], + "domain": "0:9-0:12" + } + ] + }, + { + "name": "scopes/swift/type.variable.uninitialized", + "languageId": "swift", + "facet": "type.variable.uninitialized", + "code": "var foo: Int", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:7-0:12" + } + ], + "domain": "0:9-0:12" } ] }, diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json index 966568fa65..72f3aa5286 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json @@ -9061,6 +9061,30 @@ } ] }, + { + "name": "scopes/swift/value.iteration.enum", + "languageId": "swift", + "facet": "value.iteration.enum", + "code": "enum Foo { }", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:12" + } + ], + "domain": "0:0-0:12" + }, + { + "targets": [ + { + "content": "0:10-0:11" + } + ], + "domain": "0:10-0:11" + } + ] + }, { "name": "scopes/talon/value/value.assignment", "languageId": "talon", diff --git a/packages/app-web-docs/src/docs/user/scopes/interior.mdx b/packages/app-web-docs/src/docs/user/scopes/interior.mdx index a6e396cf9b..2df6d257c6 100644 --- a/packages/app-web-docs/src/docs/user/scopes/interior.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/interior.mdx @@ -91,6 +91,10 @@ Cursorless ID: `interior` +##### Swift + + + ### Interior: Command The body of a command, eg Talon spoken command @@ -237,6 +241,10 @@ Cursorless ID: `interior` +##### Swift + + + ##### TypeScript @@ -351,6 +359,10 @@ Cursorless ID: `interior` +##### Swift + + + ##### Talon @@ -539,6 +551,10 @@ Cursorless ID: `interior` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/name.mdx b/packages/app-web-docs/src/docs/user/scopes/name.mdx index 9a0327e165..aea06ed9ee 100644 --- a/packages/app-web-docs/src/docs/user/scopes/name.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/name.mdx @@ -1691,6 +1691,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -1819,6 +1823,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -1851,6 +1859,10 @@ Default: `name` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/statement.mdx b/packages/app-web-docs/src/docs/user/scopes/statement.mdx index cb3cbc4938..410b9d86c9 100644 --- a/packages/app-web-docs/src/docs/user/scopes/statement.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/statement.mdx @@ -2103,6 +2103,10 @@ Default: `state` +##### Swift + + + ### Statement (iteration document) Iteration scope for statements: the entire document including leading and trailing empty lines. @@ -2211,6 +2215,10 @@ Default: `state` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/type.mdx b/packages/app-web-docs/src/docs/user/scopes/type.mdx index 0b7dc94ced..f065c17d88 100644 --- a/packages/app-web-docs/src/docs/user/scopes/type.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/type.mdx @@ -447,6 +447,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -493,6 +497,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -549,6 +557,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -577,6 +589,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -875,6 +891,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -923,6 +943,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1015,6 +1039,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1085,6 +1113,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1133,6 +1165,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1161,6 +1197,10 @@ Default: `type` +##### Swift + + + ##### TypeScript diff --git a/packages/app-web-docs/src/docs/user/scopes/value.mdx b/packages/app-web-docs/src/docs/user/scopes/value.mdx index 55bf69acac..01a162e017 100644 --- a/packages/app-web-docs/src/docs/user/scopes/value.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/value.mdx @@ -613,6 +613,10 @@ Default: `value` +##### Swift + + + ##### Talon @@ -1457,6 +1461,10 @@ Default: `value` +##### Swift + + + ##### TypeScript diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index d1b8dc8192..63a2980998 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -99,12 +99,10 @@ ( (_ "{" @class.iteration.start.endOf @branch.iteration.start.endOf @condition.iteration.start.endOf - "}" @class.iteration.end.startOf @condition.iteration.end.startOf @branch.iteration.end.startOf + "}" @class.iteration.end.startOf @condition.iteration.end.startOf @branch.iteration.end.startOf ) ) - - ;; 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.