From 5249da98ec9dcb48293089329bcf959a76ad452f Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Sat, 8 Aug 2026 21:23:45 -0400 Subject: [PATCH 01/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] 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/46] ...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/46] 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. From fb5e2e9af21ccb66f14e75fe5a0caccac2ac735d Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Fri, 18 Sep 2026 21:22:24 -0400 Subject: [PATCH 27/46] better if scope facets; misc. housekeeping --- .../scopes/swift/branch.if.iteration.scope | 16 +-- .../fixtures/scopes/swift/ifStatement.scope | 9 +- .../fixtures/scopes/swift/interior.if.scope | 50 ++++++++-- .../fixtures/scopes/swift/statement.if.scope | 15 +++ .../swift/cursorless-test-project/test.swift | 99 +------------------ resources/queries/swift.scm | 53 ++-------- 6 files changed, 87 insertions(+), 155 deletions(-) create mode 100644 resources/fixtures/scopes/swift/statement.if.scope diff --git a/resources/fixtures/scopes/swift/branch.if.iteration.scope b/resources/fixtures/scopes/swift/branch.if.iteration.scope index 59553c1851..efb38f535e 100644 --- a/resources/fixtures/scopes/swift/branch.if.iteration.scope +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -1,20 +1,20 @@ -if foo {} -else if bar {} +if true {} +else if false {} else {} --- [#1 Content] = [#1 Domain] = 0:0-2:7 - >--------- -0| if foo {} -1| else if bar {} + >---------- +0| if true {} +1| else if false {} 2| else {} -------< [#2 Content] = -[#2 Domain] = 1:13-2:6 - >- -1| else if bar {} +[#2 Domain] = 1:15-2:6 + >- +1| else if false {} 2| else {} ------< diff --git a/resources/fixtures/scopes/swift/ifStatement.scope b/resources/fixtures/scopes/swift/ifStatement.scope index 95d75aa3fb..e0d492e889 100644 --- a/resources/fixtures/scopes/swift/ifStatement.scope +++ b/resources/fixtures/scopes/swift/ifStatement.scope @@ -1,10 +1,15 @@ if true {} +else if false {} +else {} --- [Content] = [Removal] = -[Domain] = 0:0-0:10 - >----------< +[Domain] = 0:0-2:7 + >---------- 0| if true {} +1| else if false {} +2| else {} + -------< [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/interior.if.scope b/resources/fixtures/scopes/swift/interior.if.scope index 9a35dae364..bfa0250542 100644 --- a/resources/fixtures/scopes/swift/interior.if.scope +++ b/resources/fixtures/scopes/swift/interior.if.scope @@ -1,10 +1,46 @@ -if foo { } +if (true) { } +else if (false) { } +else { } --- -[Content] = -[Removal] = -[Domain] = 0:8-0:10 - >--< -0| if foo { } +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:11-0:12 + >-< +0| if (true) { } -[Insertion delimiter] = " " +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:18-2:6 + >- +1| else if (false) { } +2| else { } + ------< + +[#3 Removal] = +[#3 Domain] = 1:17-2:7 + >-- +1| else if (false) { } +2| else { } + -------< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } + +[#4 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement.if.scope b/resources/fixtures/scopes/swift/statement.if.scope new file mode 100644 index 0000000000..e0d492e889 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.if.scope @@ -0,0 +1,15 @@ +if true {} +else if false {} +else {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:7 + >---------- +0| if true {} +1| else if false {} +2| else {} + -------< + +[Insertion delimiter] = "\n" diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index 24cba1c6d8..eebeab6fd8 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -1,104 +1,15 @@ -let pipis: Bool = true +protocol ExampleProtocol: ParentProtocol { -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 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) { - let cast: UInt128 = numericCast(times) - publicVariable += cast - let fizz = publicVariable % 3 == 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" { - 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 = """ -I am -a multiline string -!! -""" - -let extendedDelimiter = #"The radio said "No, John. You are the zombie." And then John was the zombie."# +struct ExampleStruct: ParentStruct { -enum ExampleEnum { - case exampleCaseOne - case exampleCaseTwo } -/* - These Examples are Pissing me off... - I'm the original - Multiline walker -*/ -enum ExampleCompactEnum { - case compactCaseOne, compactCaseTwo -} +enum ExampleEnumeration: ParentEnumeration { -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 } -actor ExampleActor { - -} +struct MultiInheritanceStruct: ParentStruct, ParentProtocol, OtherParentProtocol { -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 { - let foo = 222222 - } - } - } -} \ No newline at end of file +} \ No newline at end of file diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 63a2980998..2bb78c0a23 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -32,15 +32,6 @@ ;; text: (_) @interior @textFragment ;;) @string -;; Protocol decl. -(protocol_declaration - name: (_) @name - body: (protocol_body - "{" @interior.start.endOf - "}" @interior.end.startOf - ) -) @statement - ;; if statement ( (if_statement) @ifStatement @statement @branch.iteration @@ -76,9 +67,6 @@ ;; generic property delc (property_declaration name: (_) @name - ;;(type_annotation: - ;; ":" - ;;) ) @statement ;; Generic interior w/ top-level iterations @@ -103,38 +91,6 @@ ) ) -;; 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) -;; ) - ;; non-enum classlike decl. (class_declaration name: (_) @name @type @@ -144,6 +100,15 @@ ) ) @statement @class +;; Protocol decl. +(protocol_declaration + name: (_) @name @type + body: (protocol_body + "{" @interior.start.endOf + "}" @interior.end.startOf + ) +) @statement + ;; Enum "class" decl. (class_declaration name: (_) @name @type From f16ebb78a3dd282ca3e84189b03aa1a6fecd2218 Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Fri, 18 Sep 2026 21:37:20 -0400 Subject: [PATCH 28/46] run pnpm fix --- .../docs/user/languages/fixtures/swift.json | 66 +++++++++++++++---- .../src/docs/user/languages/swift.mdx | 12 +++- .../src/docs/user/scopes/fixtures/branch.json | 6 +- .../user/scopes/fixtures/ifStatement.json | 8 +-- .../docs/user/scopes/fixtures/interior.json | 35 ++++++++-- .../docs/user/scopes/fixtures/statement.json | 17 +++++ .../src/docs/user/scopes/statement.mdx | 4 ++ 7 files changed, 123 insertions(+), 25 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 bcd8c61da1..3c4d82caa4 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 @@ -100,7 +100,7 @@ "name": "scopes/swift/branch.if.iteration", "languageId": "swift", "facet": "branch.if.iteration", - "code": "if foo {}\nelse if bar {}\nelse {}", + "code": "if true {}\nelse if false {}\nelse {}", "scopes": [ { "targets": [ @@ -113,10 +113,10 @@ { "targets": [ { - "content": "1:13-2:6" + "content": "1:15-2:6" } ], - "domain": "1:13-2:6" + "domain": "1:15-2:6" } ] }, @@ -233,16 +233,16 @@ "name": "scopes/swift/ifStatement", "languageId": "swift", "facet": "ifStatement", - "code": "if true {}", + "code": "if true {}\nelse if false {}\nelse {}", "scopes": [ { "targets": [ { - "content": "0:0-0:10", - "removal": "0:0-0:10" + "content": "0:0-2:7", + "removal": "0:0-2:7" } ], - "domain": "0:0-0:10" + "domain": "0:0-2:7" } ] }, @@ -301,16 +301,43 @@ "name": "scopes/swift/interior.if", "languageId": "swift", "facet": "interior.if", - "code": "if foo { }", + "code": "if (true) { }\nelse if (false) { }\nelse { }", "scopes": [ { "targets": [ { - "content": "0:8-0:10", - "removal": "0:8-0:10" + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + }, + { + "targets": [ + { + "content": "1:17-1:18", + "removal": "1:17-1:18" } ], - "domain": "0:8-0:10" + "domain": "1:17-1:18" + }, + { + "targets": [ + { + "content": "1:18-2:6", + "removal": "1:17-2:7" + } + ], + "domain": "1:17-2:7" + }, + { + "targets": [ + { + "content": "2:6-2:7", + "removal": "2:6-2:7" + } + ], + "domain": "2:6-2:7" } ] }, @@ -522,6 +549,23 @@ } ] }, + { + "name": "scopes/swift/statement.if", + "languageId": "swift", + "facet": "statement.if", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7", + "removal": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, { "name": "scopes/swift/statement.interface", "languageId": "swift", 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 705a5d4a36..7065ff4f34 100644 --- a/packages/app-web-docs/src/docs/user/languages/swift.mdx +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -177,19 +177,25 @@ Below are visualizations of all our scope tests for this language. These were cr -#### 4. Statement: Interface +#### 4. Statement: If + +An if/elif/else statement + + + +#### 5. Statement: Interface An interface declaration -#### 5. Statement (iteration class) +#### 6. Statement (iteration class) Iteration scope for statements: class bodies. -#### 6. Statement (iteration interface) +#### 7. Statement (iteration interface) Iteration scope for statements: interface bodies. 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 3501ebc4f3..ae18b5678f 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 @@ -3496,7 +3496,7 @@ "name": "scopes/swift/branch.if.iteration", "languageId": "swift", "facet": "branch.if.iteration", - "code": "if foo {}\nelse if bar {}\nelse {}", + "code": "if true {}\nelse if false {}\nelse {}", "scopes": [ { "targets": [ @@ -3509,10 +3509,10 @@ { "targets": [ { - "content": "1:13-2:6" + "content": "1:15-2:6" } ], - "domain": "1:13-2:6" + "domain": "1:15-2:6" } ] }, 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 850f54172c..a80d6377d3 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 @@ -292,16 +292,16 @@ "name": "scopes/swift/ifStatement", "languageId": "swift", "facet": "ifStatement", - "code": "if true {}", + "code": "if true {}\nelse if false {}\nelse {}", "scopes": [ { "targets": [ { - "content": "0:0-0:10", - "removal": "0:0-0:10" + "content": "0:0-2:7", + "removal": "0:0-2:7" } ], - "domain": "0:0-0:10" + "domain": "0:0-2:7" } ] }, 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 b779bc26b3..517a2746f6 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 @@ -5164,16 +5164,43 @@ "name": "scopes/swift/interior.if", "languageId": "swift", "facet": "interior.if", - "code": "if foo { }", + "code": "if (true) { }\nelse if (false) { }\nelse { }", "scopes": [ { "targets": [ { - "content": "0:8-0:10", - "removal": "0:8-0:10" + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + }, + { + "targets": [ + { + "content": "1:17-1:18", + "removal": "1:17-1:18" + } + ], + "domain": "1:17-1:18" + }, + { + "targets": [ + { + "content": "1:18-2:6", + "removal": "1:17-2:7" + } + ], + "domain": "1:17-2:7" + }, + { + "targets": [ + { + "content": "2:6-2:7", + "removal": "2:6-2:7" } ], - "domain": "0:8-0:10" + "domain": "2:6-2:7" } ] }, 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 0df1bdf3d5..3730ecae0c 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 @@ -11515,6 +11515,23 @@ } ] }, + { + "name": "scopes/swift/statement.if", + "languageId": "swift", + "facet": "statement.if", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7", + "removal": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, { "name": "scopes/swift/statement.interface", "languageId": "swift", 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 485511592c..db36ec0b68 100644 --- a/packages/app-web-docs/src/docs/user/scopes/statement.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/statement.mdx @@ -1001,6 +1001,10 @@ Default: `state` +##### Swift + + + ##### Talon From ca4b9c1d211f2087b0cab3204bcdb3d3554e72ff Mon Sep 17 00:00:00 2001 From: rinOfTheStars Date: Fri, 18 Sep 2026 21:55:27 -0400 Subject: [PATCH 29/46] fix type.interface scope facet --- .../docs/user/languages/fixtures/swift.json | 26 ++++++++++++++++ .../src/docs/user/languages/swift.mdx | 18 +++++++---- .../src/docs/user/scopes/fixtures/type.json | 26 ++++++++++++++++ .../src/docs/user/scopes/type.mdx | 4 +++ .../src/scopeSupportFacets/swift.ts | 2 +- .../scopes/swift/type.field.interface.scope | 30 +++++++++++++++---- .../scopes/swift/type.interface.scope | 21 +++++++++++++ .../swift/cursorless-test-project/test.swift | 4 +-- resources/queries/swift.scm | 2 +- 9 files changed, 118 insertions(+), 15 deletions(-) create mode 100644 resources/fixtures/scopes/swift/type.interface.scope 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 3c4d82caa4..84a24c6ca3 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 @@ -799,6 +799,15 @@ "facet": "type.field.interface", "code": "protocol Foo {\n var foo: Int { set get }\n}", "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + }, { "targets": [ { @@ -836,6 +845,23 @@ } ] }, + { + "name": "scopes/swift/type.interface", + "languageId": "swift", + "facet": "type.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + } + ] + }, { "name": "scopes/swift/type.iteration.block", "languageId": "swift", 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 7065ff4f34..f75a7a68a2 100644 --- a/packages/app-web-docs/src/docs/user/languages/swift.mdx +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -233,37 +233,43 @@ Below are visualizations of all our scope tests for this language. These were cr -#### 6. Type: Variable initialized +#### 6. Type: Interface + +An interface declaration + + + +#### 7. Type: Variable initialized Type of an initialized variable declaration -#### 7. Type: Variable uninitialized +#### 8. Type: Variable uninitialized Type of an uninitialized variable declaration -#### 8. Type (iteration block) +#### 9. Type (iteration block) Iteration scope for types: statement blocks (body of functions/if-statements/for-loops/etc). -#### 9. Type (iteration class) +#### 10. Type (iteration class) Iteration scope for types: class bodies. -#### 10. Type (iteration document) +#### 11. Type (iteration document) Iteration scope for types: the entire document including leading and trailing empty lines. -#### 11. Type (iteration interface) +#### 12. Type (iteration interface) Iteration scope for types: interface bodies. 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 86ae9b145f..1ab637567f 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 @@ -7542,6 +7542,15 @@ "facet": "type.field.interface", "code": "protocol Foo {\n var foo: Int { set get }\n}", "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + }, { "targets": [ { @@ -7579,6 +7588,23 @@ } ] }, + { + "name": "scopes/swift/type.interface", + "languageId": "swift", + "facet": "type.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:12", + "removal": "0:9-0:13" + } + ], + "domain": "0:9-0:12" + } + ] + }, { "name": "scopes/swift/type.iteration.block", "languageId": "swift", 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 b919b1da7c..abed32aee4 100644 --- a/packages/app-web-docs/src/docs/user/scopes/type.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/type.mdx @@ -665,6 +665,10 @@ Default: `type` +##### Swift + + + ##### TypeScript diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 21b28667bd..62d7f40da7 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -95,7 +95,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.interface": supported, "name.interface": supported, "interior.interface": supported, - "type.interface": unsupported, + "type.interface": supported, "statement.iteration.interface": supported, "name.iteration.interface": supported, diff --git a/resources/fixtures/scopes/swift/type.field.interface.scope b/resources/fixtures/scopes/swift/type.field.interface.scope index 13d746a265..f8b5ed701f 100644 --- a/resources/fixtures/scopes/swift/type.field.interface.scope +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -3,17 +3,37 @@ protocol Foo { } --- -[Content] = -[Domain] = 1:13-1:16 +[#1 Content] = +[#1 Domain] = 0:9-0:12 + >---< +0| protocol Foo { + +[#1 Removal] = 0:9-0:13 + >----< +0| protocol Foo { + +[#1 Leading delimiter] = 0:8-0:9 + >-< +0| protocol Foo { + +[#1 Trailing delimiter] = 0:12-0:13 + >-< +0| protocol Foo { + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 1:13-1:16 >---< 1| var foo: Int { set get } -[Removal] = 1:11-1:16 +[#2 Removal] = 1:11-1:16 >-----< 1| var foo: Int { set get } -[Leading delimiter] = 1:11-1:13 +[#2 Leading delimiter] = 1:11-1:13 >--< 1| var foo: Int { set get } -[Insertion delimiter] = " " +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.interface.scope b/resources/fixtures/scopes/swift/type.interface.scope new file mode 100644 index 0000000000..7268b1a3e0 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.interface.scope @@ -0,0 +1,21 @@ +protocol Foo {} +--- + +[Content] = +[Domain] = 0:9-0:12 + >---< +0| protocol Foo {} + +[Removal] = 0:9-0:13 + >----< +0| protocol Foo {} + +[Leading delimiter] = 0:8-0:9 + >-< +0| protocol Foo {} + +[Trailing delimiter] = 0:12-0:13 + >-< +0| protocol Foo {} + +[Insertion delimiter] = " " diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift index eebeab6fd8..9b862d1d7c 100644 --- a/resources/playground/swift/cursorless-test-project/test.swift +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -1,9 +1,9 @@ protocol ExampleProtocol: ParentProtocol { - + var foo: Type {set get} } struct ExampleStruct: ParentStruct { - + var foo: Type } enum ExampleEnumeration: ParentEnumeration { diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 2bb78c0a23..dc075d226d 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -107,7 +107,7 @@ "{" @interior.start.endOf "}" @interior.end.startOf ) -) @statement +) @statement @class ;; Enum "class" decl. (class_declaration From dff09a26edd63ffc742d4af224ac8aca48fb4fe4 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:03:12 +0200 Subject: [PATCH 30/46] Update --- .gitignore | 3 --- resources/fixtures/scopes/swift/comment.block.scope | 13 ++++--------- resources/fixtures/scopes/swift/comment.line.scope | 8 ++++---- .../fixtures/scopes/swift/string.multiLine.scope | 10 ++++++---- .../fixtures/scopes/swift/string.singleLine.scope | 8 ++++---- .../scopes/swift/textFragment.comment.block.scope | 13 ++++--------- .../scopes/swift/textFragment.comment.line.scope | 8 ++++---- .../swift/textFragment.string.multiLine.scope | 10 ++++++---- .../swift/textFragment.string.singleLine.scope | 8 ++++---- .../test.swift => swift.swift} | 0 .../swift/cursorless-test-project/Package.swift | 8 -------- 11 files changed, 36 insertions(+), 53 deletions(-) rename resources/playground/{swift/cursorless-test-project/test.swift => swift.swift} (100%) delete mode 100644 resources/playground/swift/cursorless-test-project/Package.swift diff --git a/.gitignore b/.gitignore index f15bf11b4b..50b4aceec7 100644 --- a/.gitignore +++ b/.gitignore @@ -17,9 +17,6 @@ node_modules/ .DS_Store .luacheckcache -# 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/resources/fixtures/scopes/swift/comment.block.scope b/resources/fixtures/scopes/swift/comment.block.scope index 477e57d0ee..5e8b51111c 100644 --- a/resources/fixtures/scopes/swift/comment.block.scope +++ b/resources/fixtures/scopes/swift/comment.block.scope @@ -1,15 +1,10 @@ -/* -aaa -*/ +/* Hello world */ --- [Content] = [Removal] = -[Domain] = 0:0-2:2 - >-- -0| /* -1| aaa -2| */ - --< +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/comment.line.scope b/resources/fixtures/scopes/swift/comment.line.scope index a469659c87..7d1477b8a1 100644 --- a/resources/fixtures/scopes/swift/comment.line.scope +++ b/resources/fixtures/scopes/swift/comment.line.scope @@ -1,10 +1,10 @@ -// aaa +// Hello world --- [Content] = [Removal] = -[Domain] = 0:0-0:6 - >------< -0| // aaa +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/string.multiLine.scope b/resources/fixtures/scopes/swift/string.multiLine.scope index e17fb9fb0f..322d7a6860 100644 --- a/resources/fixtures/scopes/swift/string.multiLine.scope +++ b/resources/fixtures/scopes/swift/string.multiLine.scope @@ -1,15 +1,17 @@ """ -aaa +Hello +world """ --- [Content] = [Removal] = -[Domain] = 0:0-2:3 +[Domain] = 0:0-3:3 >--- 0| """ -1| aaa -2| """ +1| Hello +2| world +3| """ ---< [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/string.singleLine.scope b/resources/fixtures/scopes/swift/string.singleLine.scope index f0d1750ce4..4b26cf31b3 100644 --- a/resources/fixtures/scopes/swift/string.singleLine.scope +++ b/resources/fixtures/scopes/swift/string.singleLine.scope @@ -1,10 +1,10 @@ -"aaa" +"Hello world" --- [Content] = [Removal] = -[Domain] = 0:0-0:5 - >-----< -0| "aaa" +[Domain] = 0:0-0:13 + >-------------< +0| "Hello world" [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.comment.block.scope b/resources/fixtures/scopes/swift/textFragment.comment.block.scope index 2bc3b6e027..af33f95d00 100644 --- a/resources/fixtures/scopes/swift/textFragment.comment.block.scope +++ b/resources/fixtures/scopes/swift/textFragment.comment.block.scope @@ -1,15 +1,10 @@ -/* -aaa -*/ +/* Hello world */ --- [Content] = [Removal] = -[Domain] = 0:0-2:2 - >-- -0| /* -1| aaa -2| */ - --< +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.comment.line.scope b/resources/fixtures/scopes/swift/textFragment.comment.line.scope index e47b42fed9..6758f81490 100644 --- a/resources/fixtures/scopes/swift/textFragment.comment.line.scope +++ b/resources/fixtures/scopes/swift/textFragment.comment.line.scope @@ -1,10 +1,10 @@ -// aaa +// Hello world --- [Content] = [Removal] = -[Domain] = 0:0-0:6 - >------< -0| // aaa +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope b/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope index 43868aa5c8..a5531210d9 100644 --- a/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope +++ b/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope @@ -1,15 +1,17 @@ """ -aaa +Hello +world """ --- [Content] = [Removal] = -[Domain] = 0:3-2:0 +[Domain] = 0:3-3:0 > 0| """ -1| aaa -2| """ +1| Hello +2| world +3| """ < [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope b/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope index 0ab585ba66..85dcf5fa7f 100644 --- a/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope +++ b/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope @@ -1,10 +1,10 @@ -"aaa" +"Hello world" --- [Content] = [Removal] = -[Domain] = 0:1-0:4 - >---< -0| "aaa" +[Domain] = 0:1-0:12 + >-----------< +0| "Hello world" [Insertion delimiter] = " " diff --git a/resources/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift.swift similarity index 100% rename from resources/playground/swift/cursorless-test-project/test.swift rename to resources/playground/swift.swift diff --git a/resources/playground/swift/cursorless-test-project/Package.swift b/resources/playground/swift/cursorless-test-project/Package.swift deleted file mode 100644 index 09374339a2..0000000000 --- a/resources/playground/swift/cursorless-test-project/Package.swift +++ /dev/null @@ -1,8 +0,0 @@ -// 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" -) From 12dc997cd83d40c312a50bdc17a45f011bd04e60 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:05:09 +0200 Subject: [PATCH 31/46] Update playground file --- resources/playground/swift.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/playground/swift.swift b/resources/playground/swift.swift index 9b862d1d7c..9db2eea02f 100644 --- a/resources/playground/swift.swift +++ b/resources/playground/swift.swift @@ -12,4 +12,4 @@ enum ExampleEnumeration: ParentEnumeration { struct MultiInheritanceStruct: ParentStruct, ParentProtocol, OtherParentProtocol { -} \ No newline at end of file +} From 97c14a56d1c64ae44b852111e8e6cdf08800f626 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:05:58 +0200 Subject: [PATCH 32/46] Update playground file --- resources/playground/rust.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/playground/rust.rs b/resources/playground/rust.rs index 1cfa874e89..766a2ce1a7 100644 --- a/resources/playground/rust.rs +++ b/resources/playground/rust.rs @@ -5,4 +5,4 @@ fn hello() { } else if false { //2 } -} \ No newline at end of file +} From f9fcda1e1a724d44bdbc26f29018102b3035a135 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:12:00 +0200 Subject: [PATCH 33/46] For each --- .../fixtures/scopes/swift/condition.if.scope | 85 +++++++++++++++---- .../scopes/swift/interior.foreach.scope | 8 +- .../fixtures/scopes/swift/name.foreach.scope | 28 +++--- .../scopes/swift/statement.foreach.scope | 8 +- .../fixtures/scopes/swift/value.foreach.scope | 32 +++---- 5 files changed, 107 insertions(+), 54 deletions(-) diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope index 39fee6c27b..547fac7183 100644 --- a/resources/fixtures/scopes/swift/condition.if.scope +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -1,24 +1,77 @@ -if foo {} +if (true) {} +else if (false) {} +else {} --- -[Content] = 0:3-0:6 - >---< -0| if foo {} +[#1 Content] = 0:3-0:9 + >------< +0| if (true) {} -[Removal] = 0:3-0:7 - >----< -0| if foo {} +[#1 Removal] = 0:3-0:10 + >-------< +0| if (true) {} -[Leading delimiter] = 0:2-0:3 +[#1 Leading delimiter] = 0:2-0:3 >-< -0| if foo {} +0| if (true) {} -[Trailing delimiter] = 0:6-0:7 - >-< -0| if foo {} +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| if (true) {} -[Domain] = 0:0-0:9 - >---------< -0| if foo {} +[#1 Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< -[Insertion delimiter] = " " +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:15 + >-------< +1| else if (false) {} + +[#2 Removal] = 1:8-1:16 + >--------< +1| else if (false) {} + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| else if (false) {} + +[#2 Trailing delimiter] = 1:15-1:16 + >-< +1| else if (false) {} + +[#2 Domain] = 1:0-1:15 + >---------------< +1| else if (false) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:8-1:15 + >-------< +1| else if (false) {} + +[#3 Removal] = 1:8-1:16 + >--------< +1| else if (false) {} + +[#3 Leading delimiter] = 1:7-1:8 + >-< +1| else if (false) {} + +[#3 Trailing delimiter] = 1:15-1:16 + >-< +1| else if (false) {} + +[#3 Domain] = 1:5-2:7 + >------------- +1| else if (false) {} +2| else {} + -------< + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.foreach.scope b/resources/fixtures/scopes/swift/interior.foreach.scope index ac81619891..b1842875b3 100644 --- a/resources/fixtures/scopes/swift/interior.foreach.scope +++ b/resources/fixtures/scopes/swift/interior.foreach.scope @@ -1,10 +1,10 @@ -for foo in bat { } +for v in values { } --- [Content] = [Removal] = -[Domain] = 0:16-0:17 - >-< -0| for foo in bat { } +[Domain] = 0:17-0:18 + >-< +0| for v in values { } [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.foreach.scope b/resources/fixtures/scopes/swift/name.foreach.scope index c8e077322e..76a1dd8dda 100644 --- a/resources/fixtures/scopes/swift/name.foreach.scope +++ b/resources/fixtures/scopes/swift/name.foreach.scope @@ -1,24 +1,24 @@ -for foo in bar {} +for v in values {} --- -[Content] = 0:4-0:7 - >---< -0| for foo in bar {} +[Content] = 0:4-0:5 + >-< +0| for v in values {} -[Removal] = 0:4-0:8 - >----< -0| for foo in bar {} +[Removal] = 0:4-0:6 + >--< +0| for v in values {} [Leading delimiter] = 0:3-0:4 >-< -0| for foo in bar {} +0| for v in values {} -[Trailing delimiter] = 0:7-0:8 - >-< -0| for foo in bar {} +[Trailing delimiter] = 0:5-0:6 + >-< +0| for v in values {} -[Domain] = 0:0-0:17 - >-----------------< -0| for foo in bar {} +[Domain] = 0:0-0:18 + >------------------< +0| for v in values {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement.foreach.scope b/resources/fixtures/scopes/swift/statement.foreach.scope index 005a6562ec..823a899261 100644 --- a/resources/fixtures/scopes/swift/statement.foreach.scope +++ b/resources/fixtures/scopes/swift/statement.foreach.scope @@ -1,10 +1,10 @@ -for foo in bar {} +for v in values {} --- [Content] = [Removal] = -[Domain] = 0:0-0:17 - >-----------------< -0| for foo in bar {} +[Domain] = 0:0-0:18 + >------------------< +0| for v in values {} [Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/value.foreach.scope b/resources/fixtures/scopes/swift/value.foreach.scope index d1ab264c5d..d89b2cb282 100644 --- a/resources/fixtures/scopes/swift/value.foreach.scope +++ b/resources/fixtures/scopes/swift/value.foreach.scope @@ -1,24 +1,24 @@ -for foo in bar {} +for v in values {} --- -[Content] = 0:11-0:14 - >---< -0| for foo in bar {} +[Content] = 0:9-0:15 + >------< +0| for v in values {} -[Removal] = 0:11-0:15 - >----< -0| for foo in bar {} +[Removal] = 0:9-0:16 + >-------< +0| for v in values {} -[Leading delimiter] = 0:10-0:11 - >-< -0| for foo in bar {} +[Leading delimiter] = 0:8-0:9 + >-< +0| for v in values {} -[Trailing delimiter] = 0:14-0:15 - >-< -0| for foo in bar {} +[Trailing delimiter] = 0:15-0:16 + >-< +0| for v in values {} -[Domain] = 0:0-0:17 - >-----------------< -0| for foo in bar {} +[Domain] = 0:0-0:18 + >------------------< +0| for v in values {} [Insertion delimiter] = " " From 32e0d03787f3258fea1ba44e8f1f29667c9b654b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:21:14 +0200 Subject: [PATCH 34/46] Update test --- resources/fixtures/scopes/swift/type.iteration.document.scope | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/fixtures/scopes/swift/type.iteration.document.scope b/resources/fixtures/scopes/swift/type.iteration.document.scope index 66c4ce7aef..f2a3fa399d 100644 --- a/resources/fixtures/scopes/swift/type.iteration.document.scope +++ b/resources/fixtures/scopes/swift/type.iteration.document.scope @@ -1,4 +1,4 @@ -let foo: Int = 0 +let foo: Int --- [Content] = From 07b6db2d51d9f052f805306b8770172b0d67f220 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:23:52 +0200 Subject: [PATCH 35/46] Meta Updater --- .../private-scopes/fixtures/string.json | 16 +-- .../private-scopes/fixtures/textFragment.json | 32 ++--- .../docs/user/languages/fixtures/swift.json | 128 ++++++++++-------- .../docs/user/scopes/fixtures/comment.json | 16 +-- .../docs/user/scopes/fixtures/condition.json | 26 +++- .../docs/user/scopes/fixtures/interior.json | 8 +- .../src/docs/user/scopes/fixtures/name.json | 8 +- .../docs/user/scopes/fixtures/statement.json | 8 +- .../src/docs/user/scopes/fixtures/type.json | 6 +- .../src/docs/user/scopes/fixtures/value.json | 8 +- .../swift/type.iteration.document.scope | 11 +- 11 files changed, 154 insertions(+), 113 deletions(-) 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 18e1bfd859..9b81761f9f 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 @@ -632,16 +632,16 @@ "name": "scopes/swift/string.multiLine", "languageId": "swift", "facet": "string.multiLine", - "code": "\"\"\"\naaa\n\"\"\"", + "code": "\"\"\"\nHello\nworld\n\"\"\"", "scopes": [ { "targets": [ { - "content": "0:0-2:3", - "removal": "0:0-2:3" + "content": "0:0-3:3", + "removal": "0:0-3:3" } ], - "domain": "0:0-2:3" + "domain": "0:0-3:3" } ] }, @@ -649,16 +649,16 @@ "name": "scopes/swift/string.singleLine", "languageId": "swift", "facet": "string.singleLine", - "code": "\"aaa\"", + "code": "\"Hello world\"", "scopes": [ { "targets": [ { - "content": "0:0-0:5", - "removal": "0:0-0:5" + "content": "0:0-0:13", + "removal": "0:0-0:13" } ], - "domain": "0:0-0:5" + "domain": "0:0-0:13" } ] }, 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 f9f5fa85c2..a853ccc740 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 @@ -1483,16 +1483,16 @@ "name": "scopes/swift/textFragment.comment.block", "languageId": "swift", "facet": "textFragment.comment.block", - "code": "/*\naaa\n*/", + "code": "/* Hello world */", "scopes": [ { "targets": [ { - "content": "0:0-2:2", - "removal": "0:0-2:2" + "content": "0:0-0:17", + "removal": "0:0-0:17" } ], - "domain": "0:0-2:2" + "domain": "0:0-0:17" } ] }, @@ -1500,16 +1500,16 @@ "name": "scopes/swift/textFragment.comment.line", "languageId": "swift", "facet": "textFragment.comment.line", - "code": "// aaa", + "code": "// Hello world", "scopes": [ { "targets": [ { - "content": "0:0-0:6", - "removal": "0:0-0:6" + "content": "0:0-0:14", + "removal": "0:0-0:14" } ], - "domain": "0:0-0:6" + "domain": "0:0-0:14" } ] }, @@ -1517,16 +1517,16 @@ "name": "scopes/swift/textFragment.string.multiLine", "languageId": "swift", "facet": "textFragment.string.multiLine", - "code": "\"\"\"\naaa\n\"\"\"", + "code": "\"\"\"\nHello\nworld\n\"\"\"", "scopes": [ { "targets": [ { - "content": "0:3-2:0", - "removal": "0:3-2:0" + "content": "0:3-3:0", + "removal": "0:3-3:0" } ], - "domain": "0:3-2:0" + "domain": "0:3-3:0" } ] }, @@ -1534,16 +1534,16 @@ "name": "scopes/swift/textFragment.string.singleLine", "languageId": "swift", "facet": "textFragment.string.singleLine", - "code": "\"aaa\"", + "code": "\"Hello world\"", "scopes": [ { "targets": [ { - "content": "0:1-0:4", - "removal": "0:1-0:4" + "content": "0:1-0:12", + "removal": "0:1-0:12" } ], - "domain": "0:1-0:4" + "domain": "0:1-0:12" } ] }, 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 84a24c6ca3..10ea418961 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 @@ -182,16 +182,16 @@ "name": "scopes/swift/comment.block", "languageId": "swift", "facet": "comment.block", - "code": "/*\naaa\n*/", + "code": "/* Hello world */", "scopes": [ { "targets": [ { - "content": "0:0-2:2", - "removal": "0:0-2:2" + "content": "0:0-0:17", + "removal": "0:0-0:17" } ], - "domain": "0:0-2:2" + "domain": "0:0-0:17" } ] }, @@ -199,16 +199,16 @@ "name": "scopes/swift/comment.line", "languageId": "swift", "facet": "comment.line", - "code": "// aaa", + "code": "// Hello world", "scopes": [ { "targets": [ { - "content": "0:0-0:6", - "removal": "0:0-0:6" + "content": "0:0-0:14", + "removal": "0:0-0:14" } ], - "domain": "0:0-0:6" + "domain": "0:0-0:14" } ] }, @@ -216,16 +216,34 @@ "name": "scopes/swift/condition.if", "languageId": "swift", "facet": "condition.if", - "code": "if foo {}", + "code": "if (true) {}\nelse if (false) {}\nelse {}", "scopes": [ { "targets": [ { - "content": "0:3-0:6", - "removal": "0:3-0:7" + "content": "0:3-0:9", + "removal": "0:3-0:10" } ], - "domain": "0:0-0:9" + "domain": "0:0-2:7" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:0-1:15" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:5-2:7" } ] }, @@ -284,16 +302,16 @@ "name": "scopes/swift/interior.foreach", "languageId": "swift", "facet": "interior.foreach", - "code": "for foo in bat { }", + "code": "for v in values { }", "scopes": [ { "targets": [ { - "content": "0:16-0:17", - "removal": "0:16-0:17" + "content": "0:17-0:18", + "removal": "0:17-0:18" } ], - "domain": "0:16-0:17" + "domain": "0:17-0:18" } ] }, @@ -396,16 +414,16 @@ "name": "scopes/swift/name.foreach", "languageId": "swift", "facet": "name.foreach", - "code": "for foo in bar {}", + "code": "for v in values {}", "scopes": [ { "targets": [ { - "content": "0:4-0:7", - "removal": "0:4-0:8" + "content": "0:4-0:5", + "removal": "0:4-0:6" } ], - "domain": "0:0-0:17" + "domain": "0:0-0:18" } ] }, @@ -536,16 +554,16 @@ "name": "scopes/swift/statement.foreach", "languageId": "swift", "facet": "statement.foreach", - "code": "for foo in bar {}", + "code": "for v in values {}", "scopes": [ { "targets": [ { - "content": "0:0-0:17", - "removal": "0:0-0:17" + "content": "0:0-0:18", + "removal": "0:0-0:18" } ], - "domain": "0:0-0:17" + "domain": "0:0-0:18" } ] }, @@ -635,16 +653,16 @@ "name": "scopes/swift/string.multiLine", "languageId": "swift", "facet": "string.multiLine", - "code": "\"\"\"\naaa\n\"\"\"", + "code": "\"\"\"\nHello\nworld\n\"\"\"", "scopes": [ { "targets": [ { - "content": "0:0-2:3", - "removal": "0:0-2:3" + "content": "0:0-3:3", + "removal": "0:0-3:3" } ], - "domain": "0:0-2:3" + "domain": "0:0-3:3" } ] }, @@ -652,16 +670,16 @@ "name": "scopes/swift/string.singleLine", "languageId": "swift", "facet": "string.singleLine", - "code": "\"aaa\"", + "code": "\"Hello world\"", "scopes": [ { "targets": [ { - "content": "0:0-0:5", - "removal": "0:0-0:5" + "content": "0:0-0:13", + "removal": "0:0-0:13" } ], - "domain": "0:0-0:5" + "domain": "0:0-0:13" } ] }, @@ -669,16 +687,16 @@ "name": "scopes/swift/textFragment.comment.block", "languageId": "swift", "facet": "textFragment.comment.block", - "code": "/*\naaa\n*/", + "code": "/* Hello world */", "scopes": [ { "targets": [ { - "content": "0:0-2:2", - "removal": "0:0-2:2" + "content": "0:0-0:17", + "removal": "0:0-0:17" } ], - "domain": "0:0-2:2" + "domain": "0:0-0:17" } ] }, @@ -686,16 +704,16 @@ "name": "scopes/swift/textFragment.comment.line", "languageId": "swift", "facet": "textFragment.comment.line", - "code": "// aaa", + "code": "// Hello world", "scopes": [ { "targets": [ { - "content": "0:0-0:6", - "removal": "0:0-0:6" + "content": "0:0-0:14", + "removal": "0:0-0:14" } ], - "domain": "0:0-0:6" + "domain": "0:0-0:14" } ] }, @@ -703,16 +721,16 @@ "name": "scopes/swift/textFragment.string.multiLine", "languageId": "swift", "facet": "textFragment.string.multiLine", - "code": "\"\"\"\naaa\n\"\"\"", + "code": "\"\"\"\nHello\nworld\n\"\"\"", "scopes": [ { "targets": [ { - "content": "0:3-2:0", - "removal": "0:3-2:0" + "content": "0:3-3:0", + "removal": "0:3-3:0" } ], - "domain": "0:3-2:0" + "domain": "0:3-3:0" } ] }, @@ -720,16 +738,16 @@ "name": "scopes/swift/textFragment.string.singleLine", "languageId": "swift", "facet": "textFragment.string.singleLine", - "code": "\"aaa\"", + "code": "\"Hello world\"", "scopes": [ { "targets": [ { - "content": "0:1-0:4", - "removal": "0:1-0:4" + "content": "0:1-0:12", + "removal": "0:1-0:12" } ], - "domain": "0:1-0:4" + "domain": "0:1-0:12" } ] }, @@ -914,15 +932,15 @@ "name": "scopes/swift/type.iteration.document", "languageId": "swift", "facet": "type.iteration.document", - "code": "let foo: Int = 0", + "code": "\nlet foo: Int\n", "scopes": [ { "targets": [ { - "content": "0:0-0:16" + "content": "0:0-2:0" } ], - "domain": "0:0-0:16" + "domain": "0:0-2:0" } ] }, @@ -988,16 +1006,16 @@ "name": "scopes/swift/value.foreach", "languageId": "swift", "facet": "value.foreach", - "code": "for foo in bar {}", + "code": "for v in values {}", "scopes": [ { "targets": [ { - "content": "0:11-0:14", - "removal": "0:11-0:15" + "content": "0:9-0:15", + "removal": "0:9-0:16" } ], - "domain": "0:0-0:17" + "domain": "0:0-0:18" } ] }, 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 e4604f35c3..41be4947fa 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 @@ -717,16 +717,16 @@ "name": "scopes/swift/comment.block", "languageId": "swift", "facet": "comment.block", - "code": "/*\naaa\n*/", + "code": "/* Hello world */", "scopes": [ { "targets": [ { - "content": "0:0-2:2", - "removal": "0:0-2:2" + "content": "0:0-0:17", + "removal": "0:0-0:17" } ], - "domain": "0:0-2:2" + "domain": "0:0-0:17" } ] }, @@ -734,16 +734,16 @@ "name": "scopes/swift/comment.line", "languageId": "swift", "facet": "comment.line", - "code": "// aaa", + "code": "// Hello world", "scopes": [ { "targets": [ { - "content": "0:0-0:6", - "removal": "0:0-0:6" + "content": "0:0-0:14", + "removal": "0:0-0:14" } ], - "domain": "0:0-0:6" + "domain": "0:0-0:14" } ] }, 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 ada5586e01..e057e810bb 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 @@ -1900,16 +1900,34 @@ "name": "scopes/swift/condition.if", "languageId": "swift", "facet": "condition.if", - "code": "if foo {}", + "code": "if (true) {}\nelse if (false) {}\nelse {}", "scopes": [ { "targets": [ { - "content": "0:3-0:6", - "removal": "0:3-0:7" + "content": "0:3-0:9", + "removal": "0:3-0:10" + } + ], + "domain": "0:0-2:7" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:0-1:15" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" } ], - "domain": "0:0-0:9" + "domain": "1:5-2:7" } ] }, 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 517a2746f6..c2edf6b055 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 @@ -5147,16 +5147,16 @@ "name": "scopes/swift/interior.foreach", "languageId": "swift", "facet": "interior.foreach", - "code": "for foo in bat { }", + "code": "for v in values { }", "scopes": [ { "targets": [ { - "content": "0:16-0:17", - "removal": "0:16-0:17" + "content": "0:17-0:18", + "removal": "0:17-0:18" } ], - "domain": "0:16-0:17" + "domain": "0:17-0:18" } ] }, 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 84644cffd4..0418341b18 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 @@ -12419,16 +12419,16 @@ "name": "scopes/swift/name.foreach", "languageId": "swift", "facet": "name.foreach", - "code": "for foo in bar {}", + "code": "for v in values {}", "scopes": [ { "targets": [ { - "content": "0:4-0:7", - "removal": "0:4-0:8" + "content": "0:4-0:5", + "removal": "0:4-0:6" } ], - "domain": "0:0-0:17" + "domain": "0:0-0:18" } ] }, 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 3730ecae0c..8f0fa3ead6 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 @@ -11502,16 +11502,16 @@ "name": "scopes/swift/statement.foreach", "languageId": "swift", "facet": "statement.foreach", - "code": "for foo in bar {}", + "code": "for v in values {}", "scopes": [ { "targets": [ { - "content": "0:0-0:17", - "removal": "0:0-0:17" + "content": "0:0-0:18", + "removal": "0:0-0:18" } ], - "domain": "0:0-0:17" + "domain": "0:0-0:18" } ] }, 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 1ab637567f..90e7175f97 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 @@ -7657,15 +7657,15 @@ "name": "scopes/swift/type.iteration.document", "languageId": "swift", "facet": "type.iteration.document", - "code": "let foo: Int = 0", + "code": "\nlet foo: Int\n", "scopes": [ { "targets": [ { - "content": "0:0-0:16" + "content": "0:0-2:0" } ], - "domain": "0:0-0:16" + "domain": "0:0-2:0" } ] }, 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 3a7de39b7b..bce55cb619 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 @@ -9065,16 +9065,16 @@ "name": "scopes/swift/value.foreach", "languageId": "swift", "facet": "value.foreach", - "code": "for foo in bar {}", + "code": "for v in values {}", "scopes": [ { "targets": [ { - "content": "0:11-0:14", - "removal": "0:11-0:15" + "content": "0:9-0:15", + "removal": "0:9-0:16" } ], - "domain": "0:0-0:17" + "domain": "0:0-0:18" } ] }, diff --git a/resources/fixtures/scopes/swift/type.iteration.document.scope b/resources/fixtures/scopes/swift/type.iteration.document.scope index f2a3fa399d..41725916d2 100644 --- a/resources/fixtures/scopes/swift/type.iteration.document.scope +++ b/resources/fixtures/scopes/swift/type.iteration.document.scope @@ -1,7 +1,12 @@ + let foo: Int + --- [Content] = -[Domain] = 0:0-0:16 - >----------------< -0| let foo: Int = 0 +[Domain] = 0:0-2:0 + > +0| +1| let foo: Int +2| + < From 8b1128986b6e58f5d2c9a4a53eeb8dbc7b5b715d Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:48:37 +0200 Subject: [PATCH 36/46] Updates --- .../docs/user/languages/fixtures/swift.json | 35 ++--- .../src/docs/user/scopes/fixtures/branch.json | 8 -- .../src/docs/user/scopes/fixtures/type.json | 27 ++-- .../scopes/swift/branch.if.iteration.scope | 12 +- .../fixtures/scopes/swift/type.enum.scope | 17 +-- .../scopes/swift/type.interface.scope | 17 +-- resources/queries/swift.scm | 127 ++++++++---------- 7 files changed, 85 insertions(+), 158 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 10ea418961..51ac9ca079 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,14 +109,6 @@ } ], "domain": "0:0-2:7" - }, - { - "targets": [ - { - "content": "1:15-2:6" - } - ], - "domain": "1:15-2:6" } ] }, @@ -777,11 +769,11 @@ { "targets": [ { - "content": "0:5-0:8", - "removal": "0:5-0:9" + "content": "0:0-0:11", + "removal": "0:0-0:11" } ], - "domain": "0:5-0:8" + "domain": "0:0-0:11" } ] }, @@ -791,15 +783,6 @@ "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": [ { @@ -820,11 +803,11 @@ { "targets": [ { - "content": "0:9-0:12", - "removal": "0:9-0:13" + "content": "0:0-2:1", + "removal": "0:0-2:1" } ], - "domain": "0:9-0:12" + "domain": "0:0-2:1" }, { "targets": [ @@ -872,11 +855,11 @@ { "targets": [ { - "content": "0:9-0:12", - "removal": "0:9-0:13" + "content": "0:0-0:15", + "removal": "0:0-0:15" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:15" } ] }, 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 ae18b5678f..65c9bced30 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,14 +3505,6 @@ } ], "domain": "0:0-2:7" - }, - { - "targets": [ - { - "content": "1:15-2:6" - } - ], - "domain": "1:15-2:6" } ] }, 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 90e7175f97..e5acd38976 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 @@ -7502,11 +7502,11 @@ { "targets": [ { - "content": "0:5-0:8", - "removal": "0:5-0:9" + "content": "0:0-0:11", + "removal": "0:0-0:11" } ], - "domain": "0:5-0:8" + "domain": "0:0-0:11" } ] }, @@ -7516,15 +7516,6 @@ "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": [ { @@ -7545,11 +7536,11 @@ { "targets": [ { - "content": "0:9-0:12", - "removal": "0:9-0:13" + "content": "0:0-2:1", + "removal": "0:0-2:1" } ], - "domain": "0:9-0:12" + "domain": "0:0-2:1" }, { "targets": [ @@ -7597,11 +7588,11 @@ { "targets": [ { - "content": "0:9-0:12", - "removal": "0:9-0:13" + "content": "0:0-0:15", + "removal": "0:0-0:15" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:15" } ] }, diff --git a/resources/fixtures/scopes/swift/branch.if.iteration.scope b/resources/fixtures/scopes/swift/branch.if.iteration.scope index efb38f535e..5a5ed880ea 100644 --- a/resources/fixtures/scopes/swift/branch.if.iteration.scope +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -3,18 +3,10 @@ else if false {} else {} --- -[#1 Content] = -[#1 Domain] = 0:0-2:7 +[Content] = +[Domain] = 0:0-2:7 >---------- 0| if true {} 1| else if false {} 2| else {} -------< - - -[#2 Content] = -[#2 Domain] = 1:15-2:6 - >- -1| else if false {} -2| else {} - ------< diff --git a/resources/fixtures/scopes/swift/type.enum.scope b/resources/fixtures/scopes/swift/type.enum.scope index 2162ad8604..70c26e7b58 100644 --- a/resources/fixtures/scopes/swift/type.enum.scope +++ b/resources/fixtures/scopes/swift/type.enum.scope @@ -2,20 +2,9 @@ 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 - >-< +[Removal] = +[Domain] = 0:0-0:11 + >-----------< 0| enum Foo {} [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.interface.scope b/resources/fixtures/scopes/swift/type.interface.scope index 7268b1a3e0..eb75796f70 100644 --- a/resources/fixtures/scopes/swift/type.interface.scope +++ b/resources/fixtures/scopes/swift/type.interface.scope @@ -2,20 +2,9 @@ protocol Foo {} --- [Content] = -[Domain] = 0:9-0:12 - >---< -0| protocol Foo {} - -[Removal] = 0:9-0:13 - >----< -0| protocol Foo {} - -[Leading delimiter] = 0:8-0:9 - >-< -0| protocol Foo {} - -[Trailing delimiter] = 0:12-0:13 - >-< +[Removal] = +[Domain] = 0:0-0:15 + >---------------< 0| protocol Foo {} [Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index dc075d226d..6b22e1a38f 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -1,30 +1,52 @@ ;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json +[ + (class_declaration) + (protocol_declaration) + (for_statement) + + ;; Disabled on purpose. We have a better definition of these below. + ;; (if_statement) +] @statement + ;; document-wide ( - (source_file) @value.iteration @type.iteration @interior.iteration - (#document-range! @value.iteration @type.iteration @interior.iteration) + (source_file) @statementNameValueType.iteration @class.iteration @namedFunction.iteration + (#document-range! @statementNameValueType.iteration @class.iteration @namedFunction.iteration) ) -( - (source_file) @class.iteration @statement.iteration @name.iteration - (#document-range! @class.iteration @statement.iteration @name.iteration) +;;!! { } +;;! ^ +(_ + "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf +) + +(_ + "{" @interior.start.endOf + "}" @interior.end.startOf ) -;; single line comment +;;!! // Hello world +;;! ^^^^^^^^^^^^^^ (comment) @comment @textFragment -;; multiline comment +;;!! /* Hello world */ +;;! ^^^^^^^^^^^^^^^^^ (multiline_comment) @comment @textFragment -;; single line string +;;!! "Hello world" +;;! ^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ (line_string_literal - text: (_) @interior @textFragment + text: (_) @textFragment ) @string -;; multiline string +;;!! """Hello world""" +;;! ^^^^^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ (multi_line_string_literal - text: (_) @interior @textFragment + text: (_) @textFragment ) @string ;; extended delimiter/"raw" strings (both multiline and single line) -- waiting on better tree-sitter support for these @@ -69,69 +91,38 @@ name: (_) @name ) @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 - ) -) - -( - (_ - "{" @value.iteration.start.endOf @type.iteration.start.endOf @namedFunction.iteration.start.endOf - "}" @value.iteration.end.startOf @type.iteration.end.startOf @namedFunction.iteration.end.startOf - ) -) - -( - (_ - "{" @class.iteration.start.endOf @branch.iteration.start.endOf @condition.iteration.start.endOf - "}" @class.iteration.end.startOf @condition.iteration.end.startOf @branch.iteration.end.startOf - ) -) +;;!! struct Foo {} +;;! ^^^ +(class_declaration + name: (_) @name + (class_body) +) @class -;; non-enum classlike decl. +;;!! enum Foo {} +;;! ^^^ (class_declaration - name: (_) @name @type - body: (class_body - "{" @interior.start.endOf - "}" @interior.end.startOf - ) -) @statement @class + name: (_) @name + (enum_class_body) +) @type -;; Protocol decl. +;;!! protocol Foo {} +;;! ^^^ (protocol_declaration - name: (_) @name @type - body: (protocol_body - "{" @interior.start.endOf - "}" @interior.end.startOf - ) -) @statement @class - -;; Enum "class" decl. -(class_declaration - name: (_) @name @type - body: (enum_class_body - "{" @interior.start.endOf - "}" @interior.end.startOf - ) -) @statement @class + name: (_) @name +) @type ;; For loop -( - (for_statement - "for" - item: (_) @name - (type_annotation - ":" @type.leading - . - _ @type @name.trailing - )? - "in" - collection: (_) @value - ) @statement @_.domain -) +(for_statement + "for" + item: (_) @name + (type_annotation + ":" @type.leading + . + _ @type @name.trailing + )? + "in" + collection: (_) @value +) @_.domain ;; generic type annotation ( From 5cfefa25a620c044c6eafa58e6b3b0adcf99600a Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 09:52:20 +0200 Subject: [PATCH 37/46] name domain --- .../docs/user/languages/fixtures/swift.json | 6 ++-- .../src/docs/user/scopes/fixtures/name.json | 6 ++-- .../fixtures/scopes/swift/name.class.scope | 7 +++-- .../fixtures/scopes/swift/name.enum.scope | 7 +++-- .../scopes/swift/name.interface.scope | 7 +++-- .../scopes/swift/type.field.class.scope | 30 ++++--------------- .../scopes/swift/type.field.interface.scope | 20 ++++--------- resources/queries/swift.scm | 8 ++--- 8 files changed, 36 insertions(+), 55 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 51ac9ca079..672e98ccf6 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 @@ -381,7 +381,7 @@ "removal": "0:6-0:10" } ], - "domain": "0:6-0:9" + "domain": "0:0-0:12" } ] }, @@ -398,7 +398,7 @@ "removal": "0:5-0:9" } ], - "domain": "0:5-0:8" + "domain": "0:0-0:11" } ] }, @@ -432,7 +432,7 @@ "removal": "0:9-0:13" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:15" } ] }, 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 0418341b18..f1650b6579 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 @@ -12394,7 +12394,7 @@ "removal": "0:6-0:10" } ], - "domain": "0:6-0:9" + "domain": "0:0-0:12" } ] }, @@ -12411,7 +12411,7 @@ "removal": "0:5-0:9" } ], - "domain": "0:5-0:8" + "domain": "0:0-0:11" } ] }, @@ -12445,7 +12445,7 @@ "removal": "0:9-0:13" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:15" } ] }, diff --git a/resources/fixtures/scopes/swift/name.class.scope b/resources/fixtures/scopes/swift/name.class.scope index c4ecaeeb34..211086562c 100644 --- a/resources/fixtures/scopes/swift/name.class.scope +++ b/resources/fixtures/scopes/swift/name.class.scope @@ -1,8 +1,7 @@ class Foo {} --- -[Content] = -[Domain] = 0:6-0:9 +[Content] = 0:6-0:9 >---< 0| class Foo {} @@ -18,4 +17,8 @@ class Foo {} >-< 0| class Foo {} +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} + [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.enum.scope b/resources/fixtures/scopes/swift/name.enum.scope index 2162ad8604..09d2849071 100644 --- a/resources/fixtures/scopes/swift/name.enum.scope +++ b/resources/fixtures/scopes/swift/name.enum.scope @@ -1,8 +1,7 @@ enum Foo {} --- -[Content] = -[Domain] = 0:5-0:8 +[Content] = 0:5-0:8 >---< 0| enum Foo {} @@ -18,4 +17,8 @@ enum Foo {} >-< 0| enum Foo {} +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.interface.scope b/resources/fixtures/scopes/swift/name.interface.scope index 7268b1a3e0..6327dc4e46 100644 --- a/resources/fixtures/scopes/swift/name.interface.scope +++ b/resources/fixtures/scopes/swift/name.interface.scope @@ -1,8 +1,7 @@ protocol Foo {} --- -[Content] = -[Domain] = 0:9-0:12 +[Content] = 0:9-0:12 >---< 0| protocol Foo {} @@ -18,4 +17,8 @@ protocol Foo {} >-< 0| protocol Foo {} +[Domain] = 0:0-0:15 + >---------------< +0| protocol Foo {} + [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.field.class.scope b/resources/fixtures/scopes/swift/type.field.class.scope index 8e772e72e1..4a358c8142 100644 --- a/resources/fixtures/scopes/swift/type.field.class.scope +++ b/resources/fixtures/scopes/swift/type.field.class.scope @@ -3,37 +3,17 @@ struct Foo { } --- -[#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 +[Content] = +[Domain] = 1:13-1:16 >---< 1| var foo: Int = 0 -[#2 Removal] = 1:11-1:16 +[Removal] = 1:11-1:16 >-----< 1| var foo: Int = 0 -[#2 Leading delimiter] = 1:11-1:13 +[Leading delimiter] = 1:11-1:13 >--< 1| var foo: Int = 0 -[#2 Insertion delimiter] = " " +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.field.interface.scope b/resources/fixtures/scopes/swift/type.field.interface.scope index f8b5ed701f..b99cc0dab1 100644 --- a/resources/fixtures/scopes/swift/type.field.interface.scope +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -4,21 +4,13 @@ protocol Foo { --- [#1 Content] = -[#1 Domain] = 0:9-0:12 - >---< -0| protocol Foo { - -[#1 Removal] = 0:9-0:13 - >----< -0| protocol Foo { - -[#1 Leading delimiter] = 0:8-0:9 - >-< -0| protocol Foo { - -[#1 Trailing delimiter] = 0:12-0:13 - >-< +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >-------------- 0| protocol Foo { +1| var foo: Int { set get } +2| } + -< [#1 Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 6b22e1a38f..c8b9ffbd62 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -89,27 +89,27 @@ ;; generic property delc (property_declaration name: (_) @name -) @statement +) @statement @name.domain ;;!! struct Foo {} ;;! ^^^ (class_declaration name: (_) @name (class_body) -) @class +) @class @name.domain ;;!! enum Foo {} ;;! ^^^ (class_declaration name: (_) @name (enum_class_body) -) @type +) @type @name.domain ;;!! protocol Foo {} ;;! ^^^ (protocol_declaration name: (_) @name -) @type +) @type @name.domain ;; For loop (for_statement From 0e07bfaca8c739596a449eeeb6a9db793a99ff4e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 14:37:06 +0200 Subject: [PATCH 38/46] if_statement --- .../docs/user/languages/fixtures/swift.json | 71 +++--------- .../src/docs/user/scopes/fixtures/branch.json | 38 +----- .../docs/user/scopes/fixtures/condition.json | 21 +--- .../src/docs/user/scopes/fixtures/type.json | 12 +- .../scopes/swift/branch.if.elif.else.scope | 60 +--------- .../scopes/swift/branch.if.else.scope | 17 +-- .../fixtures/scopes/swift/condition.if.scope | 81 +++++-------- .../fixtures/scopes/swift/type.foreach.scope | 40 +++---- resources/queries/swift.scm | 109 +++++++++++------- 9 files changed, 152 insertions(+), 297 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 672e98ccf6..e2ef6c827f 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 @@ -9,7 +9,7 @@ "targets": [ { "content": "0:0-0:9", - "removal": "0:0-1:0" + "removal": "0:0-1:5" } ], "domain": "0:0-0:9" @@ -23,33 +23,6 @@ ], "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": [ { @@ -76,15 +49,6 @@ ], "domain": "0:0-0:10" }, - { - "targets": [ - { - "content": "0:0-1:7", - "removal": "0:0-1:7" - } - ], - "domain": "0:0-1:7" - }, { "targets": [ { @@ -208,13 +172,13 @@ "name": "scopes/swift/condition.if", "languageId": "swift", "facet": "condition.if", - "code": "if (true) {}\nelse if (false) {}\nelse {}", + "code": "if true {}\nelse if false {}\nelse {}", "scopes": [ { "targets": [ { - "content": "0:3-0:9", - "removal": "0:3-0:10" + "content": "0:3-0:7", + "removal": "0:3-0:8" } ], "domain": "0:0-2:7" @@ -222,20 +186,11 @@ { "targets": [ { - "content": "1:8-1:15", - "removal": "1:8-1:16" - } - ], - "domain": "1:0-1:15" - }, - { - "targets": [ - { - "content": "1:8-1:15", - "removal": "1:8-1:16" + "content": "1:8-1:13", + "removal": "1:8-1:14" } ], - "domain": "1:5-2:7" + "domain": "1:0-1:16" } ] }, @@ -824,13 +779,13 @@ "name": "scopes/swift/type.foreach", "languageId": "swift", "facet": "type.foreach", - "code": "for foo: Type in bar {}", + "code": "for v: Int in values {}", "scopes": [ { "targets": [ { - "content": "0:9-0:13", - "removal": "0:7-0:13" + "content": "0:7-0:10", + "removal": "0:5-0:10" } ], "domain": "0:0-0:23" @@ -838,11 +793,11 @@ { "targets": [ { - "content": "0:9-0:13", - "removal": "0:7-0:13" + "content": "0:7-0:10", + "removal": "0:5-0:10" } ], - "domain": "0:9-0:13" + "domain": "0:7-0:10" } ] }, 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 65c9bced30..d29d0a9a0d 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 @@ -3405,7 +3405,7 @@ "targets": [ { "content": "0:0-0:9", - "removal": "0:0-1:0" + "removal": "0:0-1:5" } ], "domain": "0:0-0:9" @@ -3419,33 +3419,6 @@ ], "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": [ { @@ -3472,15 +3445,6 @@ ], "domain": "0:0-0:10" }, - { - "targets": [ - { - "content": "0:0-1:7", - "removal": "0:0-1:7" - } - ], - "domain": "0:0-1:7" - }, { "targets": [ { 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 e057e810bb..2d22836f1e 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 @@ -1900,13 +1900,13 @@ "name": "scopes/swift/condition.if", "languageId": "swift", "facet": "condition.if", - "code": "if (true) {}\nelse if (false) {}\nelse {}", + "code": "if true {}\nelse if false {}\nelse {}", "scopes": [ { "targets": [ { - "content": "0:3-0:9", - "removal": "0:3-0:10" + "content": "0:3-0:7", + "removal": "0:3-0:8" } ], "domain": "0:0-2:7" @@ -1914,20 +1914,11 @@ { "targets": [ { - "content": "1:8-1:15", - "removal": "1:8-1:16" - } - ], - "domain": "1:0-1:15" - }, - { - "targets": [ - { - "content": "1:8-1:15", - "removal": "1:8-1:16" + "content": "1:8-1:13", + "removal": "1:8-1:14" } ], - "domain": "1:5-2:7" + "domain": "1:0-1:16" } ] }, 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 e5acd38976..49eb8d4fdd 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 @@ -7557,13 +7557,13 @@ "name": "scopes/swift/type.foreach", "languageId": "swift", "facet": "type.foreach", - "code": "for foo: Type in bar {}", + "code": "for v: Int in values {}", "scopes": [ { "targets": [ { - "content": "0:9-0:13", - "removal": "0:7-0:13" + "content": "0:7-0:10", + "removal": "0:5-0:10" } ], "domain": "0:0-0:23" @@ -7571,11 +7571,11 @@ { "targets": [ { - "content": "0:9-0:13", - "removal": "0:7-0:13" + "content": "0:7-0:10", + "removal": "0:5-0:10" } ], - "domain": "0:9-0:13" + "domain": "0:7-0:10" } ] }, diff --git a/resources/fixtures/scopes/swift/branch.if.elif.else.scope b/resources/fixtures/scopes/swift/branch.if.elif.else.scope index c8aa5e8b4e..f3854ad3d7 100644 --- a/resources/fixtures/scopes/swift/branch.if.elif.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.elif.else.scope @@ -8,11 +8,11 @@ else {} >---------< 0| if foo {} -[#1 Removal] = 0:0-1:0 +[#1 Removal] = 0:0-1:5 >--------- 0| if foo {} 1| else if bar {} - < + -----< [#1 Insertion delimiter] = "\n" @@ -32,64 +32,14 @@ else {} [#3 Content] = -[#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 +[#3 Domain] = 2:0-2:7 >-------< 2| else {} -[#6 Removal] = 1:14-2:7 +[#3 Removal] = 1:14-2:7 > 1| else if bar {} 2| else {} -------< -[#6 Insertion delimiter] = "\n" +[#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 fb73666f03..9720b629a7 100644 --- a/resources/fixtures/scopes/swift/branch.if.else.scope +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -17,25 +17,14 @@ else {} [#2 Content] = -[#2 Removal] = -[#2 Domain] = 0:0-1:7 - >---------- -0| if true {} -1| else {} - -------< - -[#2 Insertion delimiter] = "\n" - - -[#3 Content] = -[#3 Domain] = 1:0-1:7 +[#2 Domain] = 1:0-1:7 >-------< 1| else {} -[#3 Removal] = 0:10-1:7 +[#2 Removal] = 0:10-1:7 > 0| if true {} 1| else {} -------< -[#3 Insertion delimiter] = "\n" +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition.if.scope index 547fac7183..c4bc11ae65 100644 --- a/resources/fixtures/scopes/swift/condition.if.scope +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -1,77 +1,52 @@ -if (true) {} -else if (false) {} +if true {} +else if false {} else {} --- -[#1 Content] = 0:3-0:9 - >------< -0| if (true) {} +[#1 Content] = 0:3-0:7 + >----< +0| if true {} -[#1 Removal] = 0:3-0:10 - >-------< -0| if (true) {} +[#1 Removal] = 0:3-0:8 + >-----< +0| if true {} [#1 Leading delimiter] = 0:2-0:3 >-< -0| if (true) {} +0| if true {} -[#1 Trailing delimiter] = 0:9-0:10 - >-< -0| if (true) {} +[#1 Trailing delimiter] = 0:7-0:8 + >-< +0| if true {} [#1 Domain] = 0:0-2:7 - >------------ -0| if (true) {} -1| else if (false) {} + >---------- +0| if true {} +1| else if false {} 2| else {} -------< [#1 Insertion delimiter] = " " -[#2 Content] = 1:8-1:15 - >-------< -1| else if (false) {} +[#2 Content] = 1:8-1:13 + >-----< +1| else if false {} -[#2 Removal] = 1:8-1:16 - >--------< -1| else if (false) {} +[#2 Removal] = 1:8-1:14 + >------< +1| else if false {} [#2 Leading delimiter] = 1:7-1:8 >-< -1| else if (false) {} +1| else if false {} -[#2 Trailing delimiter] = 1:15-1:16 - >-< -1| else if (false) {} +[#2 Trailing delimiter] = 1:13-1:14 + >-< +1| else if false {} -[#2 Domain] = 1:0-1:15 - >---------------< -1| else if (false) {} +[#2 Domain] = 1:0-1:16 + >----------------< +1| else if false {} [#2 Insertion delimiter] = " " - - -[#3 Content] = 1:8-1:15 - >-------< -1| else if (false) {} - -[#3 Removal] = 1:8-1:16 - >--------< -1| else if (false) {} - -[#3 Leading delimiter] = 1:7-1:8 - >-< -1| else if (false) {} - -[#3 Trailing delimiter] = 1:15-1:16 - >-< -1| else if (false) {} - -[#3 Domain] = 1:5-2:7 - >------------- -1| else if (false) {} -2| else {} - -------< - -[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.foreach.scope b/resources/fixtures/scopes/swift/type.foreach.scope index b33e662415..c6902de8ca 100644 --- a/resources/fixtures/scopes/swift/type.foreach.scope +++ b/resources/fixtures/scopes/swift/type.foreach.scope @@ -1,36 +1,36 @@ -for foo: Type in bar {} +for v: Int in values {} --- -[#1 Content] = 0:9-0:13 - >----< -0| for foo: Type in bar {} +[#1 Content] = 0:7-0:10 + >---< +0| for v: Int in values {} -[#1 Removal] = 0:7-0:13 - >------< -0| for foo: Type in bar {} +[#1 Removal] = 0:5-0:10 + >-----< +0| for v: Int in values {} -[#1 Leading delimiter] = 0:7-0:9 - >--< -0| for foo: Type in bar {} +[#1 Leading delimiter] = 0:5-0:7 + >--< +0| for v: Int in values {} [#1 Domain] = 0:0-0:23 >-----------------------< -0| for foo: Type in bar {} +0| for v: Int in values {} [#1 Insertion delimiter] = " " [#2 Content] = -[#2 Domain] = 0:9-0:13 - >----< -0| for foo: Type in bar {} +[#2 Domain] = 0:7-0:10 + >---< +0| for v: Int in values {} -[#2 Removal] = 0:7-0:13 - >------< -0| for foo: Type in bar {} +[#2 Removal] = 0:5-0:10 + >-----< +0| for v: Int in values {} -[#2 Leading delimiter] = 0:7-0:9 - >--< -0| for foo: Type in bar {} +[#2 Leading delimiter] = 0:5-0:7 + >--< +0| for v: Int in values {} [#2 Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index c8b9ffbd62..2f545d6b22 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -4,6 +4,7 @@ (class_declaration) (protocol_declaration) (for_statement) + (property_declaration) ;; Disabled on purpose. We have a better definition of these below. ;; (if_statement) @@ -54,42 +55,10 @@ ;; text: (_) @interior @textFragment ;;) @string -;; 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 - condition: (_) @condition - "}" @branch.end @branch.removal.end - (else)? @branch.removal.end.startOf - ) @condition.domain - (#not-parent-type? @condition.domain else) -) - -;; else if -( - (else) @branch.start @condition.domain.start - (if_statement - condition: (_) @condition @condition.domain.end - "}" @branch.end - ) -) - -;; else -( - (else) @branch.start - "}" @branch.end -) - ;; generic property delc -(property_declaration - name: (_) @name -) @statement @name.domain +;; (property_declaration +;; name: (_) @name +;; ) @name.domain ;;!! struct Foo {} ;;! ^^^ @@ -111,19 +80,81 @@ name: (_) @name ) @type @name.domain -;; For loop +;;!! for v: Int in values {} +;;! ^ +;;! ^^^ +;;! ^^^^^^ (for_statement - "for" item: (_) @name (type_annotation ":" @type.leading . - _ @type @name.trailing + _ @type )? - "in" collection: (_) @value ) @_.domain +;;!! if true {} else if false {} else {} +( + (if_statement) @ifStatement @statement @branch.iteration + (#not-parent-type? @ifStatement if_statement) +) + +( + (if_statement + condition: (_) @condition + ) @condition.domain + (#not-parent-type? @condition.domain if_statement) +) + +;;!! if true {} +( + (if_statement + "}" @branch.end.endOf + ) @branch.start.startOf + (#not-parent-type? @branch.start.startOf if_statement) + (#not-child-type? @branch.start.startOf else) +) + +;;!! if true {} else {} +( + (if_statement + "}" @branch.end.endOf + (else) @branch.removal.end.startOf + (if_statement)? @branch.removal.end.startOf + ) @branch.start.startOf @branch.removal.start.startOf + (#not-parent-type? @branch.start.startOf if_statement) +) + +;;!! else if true {} else {} +(if_statement + (else) @branch.start @condition.domain.start + (if_statement + condition: (_) @condition + "}" @branch.end @condition.domain.end + . + (else) + ) +) + +;;!! else if true {} +( + (if_statement + (else) @branch.start @condition.domain.start + (if_statement + condition: (_) @condition + "}" @branch.end @condition.domain.end + ) @_dummy + ) + (#not-child-type? @_dummy else) +) + +;;!! else {} +( + (else) @branch.start + "}" @branch.end +) + ;; generic type annotation ( (type_annotation From 9c2d8d40ce8a584ec3724f8b9bb9d4b86af94abc Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 14:51:28 +0200 Subject: [PATCH 39/46] if interior --- .../docs/user/languages/fixtures/swift.json | 72 +++++++++++++++++-- .../src/docs/user/languages/swift.mdx | 6 ++ .../docs/user/scopes/fixtures/interior.json | 72 +++++++++++++++++-- .../src/docs/user/scopes/interior.mdx | 6 ++ .../fixtures/scopes/swift/interior.if.scope | 22 +----- .../fixtures/scopes/swift/interior.if2.scope | 10 +++ .../fixtures/scopes/swift/interior.if3.scope | 20 ++++++ .../fixtures/scopes/swift/interior.if4.scope | 20 ++++++ resources/queries/swift.scm | 33 ++++++--- 9 files changed, 219 insertions(+), 42 deletions(-) create mode 100644 resources/fixtures/scopes/swift/interior.if2.scope create mode 100644 resources/fixtures/scopes/swift/interior.if3.scope create mode 100644 resources/fixtures/scopes/swift/interior.if4.scope 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 e2ef6c827f..0fedef1bc7 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 @@ -289,20 +289,80 @@ { "targets": [ { - "content": "1:18-2:6", - "removal": "1:17-2:7" + "content": "2:6-2:7", + "removal": "2:6-2:7" + } + ], + "domain": "2:6-2:7" + } + ] + }, + { + "name": "scopes/swift/interior.if2", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/interior.if3", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }\nelse { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" } ], - "domain": "1:17-2:7" + "domain": "0:11-0:12" }, { "targets": [ { - "content": "2:6-2:7", - "removal": "2:6-2:7" + "content": "1:6-1:7", + "removal": "1:6-1:7" } ], - "domain": "2:6-2:7" + "domain": "1:6-1:7" + } + ] + }, + { + "name": "scopes/swift/interior.if4", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }\nelse if (false) { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + }, + { + "targets": [ + { + "content": "1:17-1:18", + "removal": "1:17-1:18" + } + ], + "domain": "1:17-1:18" } ] }, 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 f75a7a68a2..39a6b42a68 100644 --- a/packages/app-web-docs/src/docs/user/languages/swift.mdx +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -107,6 +107,12 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + + + #### 5. Interior: Interface The body of an interface declaration 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 c2edf6b055..3f9f7c36f3 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 @@ -5187,20 +5187,80 @@ { "targets": [ { - "content": "1:18-2:6", - "removal": "1:17-2:7" + "content": "2:6-2:7", + "removal": "2:6-2:7" + } + ], + "domain": "2:6-2:7" + } + ] + }, + { + "name": "scopes/swift/interior.if2", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + } + ] + }, + { + "name": "scopes/swift/interior.if3", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }\nelse { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" } ], - "domain": "1:17-2:7" + "domain": "0:11-0:12" }, { "targets": [ { - "content": "2:6-2:7", - "removal": "2:6-2:7" + "content": "1:6-1:7", + "removal": "1:6-1:7" } ], - "domain": "2:6-2:7" + "domain": "1:6-1:7" + } + ] + }, + { + "name": "scopes/swift/interior.if4", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }\nelse if (false) { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + }, + { + "targets": [ + { + "content": "1:17-1:18", + "removal": "1:17-1:18" + } + ], + "domain": "1:17-1:18" } ] }, 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 2df6d257c6..915faf0ced 100644 --- a/packages/app-web-docs/src/docs/user/scopes/interior.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/interior.mdx @@ -519,6 +519,12 @@ Cursorless ID: `interior` + + + + + + ##### Talon diff --git a/resources/fixtures/scopes/swift/interior.if.scope b/resources/fixtures/scopes/swift/interior.if.scope index bfa0250542..407453929f 100644 --- a/resources/fixtures/scopes/swift/interior.if.scope +++ b/resources/fixtures/scopes/swift/interior.if.scope @@ -21,26 +21,10 @@ else { } [#2 Insertion delimiter] = " " -[#3 Content] = 1:18-2:6 - >- -1| else if (false) { } -2| else { } - ------< - +[#3 Content] = [#3 Removal] = -[#3 Domain] = 1:17-2:7 - >-- -1| else if (false) { } -2| else { } - -------< - -[#3 Insertion delimiter] = " " - - -[#4 Content] = -[#4 Removal] = -[#4 Domain] = 2:6-2:7 +[#3 Domain] = 2:6-2:7 >-< 2| else { } -[#4 Insertion delimiter] = " " +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.if2.scope b/resources/fixtures/scopes/swift/interior.if2.scope new file mode 100644 index 0000000000..a47d3ff21a --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.if2.scope @@ -0,0 +1,10 @@ +if (true) { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| if (true) { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.if3.scope b/resources/fixtures/scopes/swift/interior.if3.scope new file mode 100644 index 0000000000..68458d6dd2 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.if3.scope @@ -0,0 +1,20 @@ +if (true) { } +else { } +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:6-1:7 + >-< +1| else { } + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.if4.scope b/resources/fixtures/scopes/swift/interior.if4.scope new file mode 100644 index 0000000000..00317b0cca --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.if4.scope @@ -0,0 +1,20 @@ +if (true) { } +else if (false) { } +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + +[#2 Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 2f545d6b22..f949c874b2 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -18,14 +18,20 @@ ;;!! { } ;;! ^ -(_ - "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf - "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf +( + (_ + "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf + ) @_dummy + (#not-type? @_dummy if_statement) ) -(_ - "{" @interior.start.endOf - "}" @interior.end.startOf +( + (_ + "{" @interior.start.endOf + "}" @interior.end.startOf + ) @_dummy + (#not-type? @_dummy if_statement) ) ;;!! // Hello world @@ -110,7 +116,8 @@ ;;!! if true {} ( (if_statement - "}" @branch.end.endOf + "{" @interior.start.endOf + "}" @branch.end.endOf @interior.end.startOf ) @branch.start.startOf (#not-parent-type? @branch.start.startOf if_statement) (#not-child-type? @branch.start.startOf else) @@ -119,7 +126,8 @@ ;;!! if true {} else {} ( (if_statement - "}" @branch.end.endOf + "{" @interior.start.endOf + "}" @branch.end.endOf @interior.end.startOf (else) @branch.removal.end.startOf (if_statement)? @branch.removal.end.startOf ) @branch.start.startOf @branch.removal.start.startOf @@ -131,7 +139,8 @@ (else) @branch.start @condition.domain.start (if_statement condition: (_) @condition - "}" @branch.end @condition.domain.end + "{" @interior.start.endOf + "}" @branch.end @interior.end.startOf @condition.domain.end . (else) ) @@ -143,7 +152,8 @@ (else) @branch.start @condition.domain.start (if_statement condition: (_) @condition - "}" @branch.end @condition.domain.end + "{" @interior.start.endOf + "}" @branch.end @interior.end.startOf @condition.domain.end ) @_dummy ) (#not-child-type? @_dummy else) @@ -152,7 +162,8 @@ ;;!! else {} ( (else) @branch.start - "}" @branch.end + "{" @interior.start.endOf + "}" @branch.end @interior.end.startOf ) ;; generic type annotation From ab9067ed6d9a48c3209a9b98aa9c8b7d814dd9e4 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 15:06:27 +0200 Subject: [PATCH 40/46] variables --- .../docs/user/languages/fixtures/swift.json | 41 ++++++++------ .../src/docs/user/scopes/fixtures/type.json | 41 ++++++++------ .../fixtures/scopes/swift/type.constant.scope | 7 ++- .../scopes/swift/type.field.class.scope | 54 +++++++++++++++---- .../scopes/swift/type.field.interface.scope | 17 +++--- .../fixtures/scopes/swift/type.foreach.scope | 26 ++------- .../swift/type.variable.initialized.scope | 7 ++- .../swift/type.variable.uninitialized.scope | 7 ++- resources/queries/swift.scm | 31 ++++++++--- 9 files changed, 150 insertions(+), 81 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 0fedef1bc7..653a9a209d 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 @@ -771,7 +771,7 @@ "removal": "0:7-0:12" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:16" } ] }, @@ -796,8 +796,17 @@ "name": "scopes/swift/type.field.class", "languageId": "swift", "facet": "type.field.class", - "code": "struct Foo {\n var foo: Int = 0\n}", + "code": "struct Foo {\n var bar: Int\n var baz: Int = 0\n}", "scopes": [ + { + "targets": [ + { + "content": "0:0-3:1", + "removal": "0:0-3:1" + } + ], + "domain": "0:0-3:1" + }, { "targets": [ { @@ -805,7 +814,16 @@ "removal": "1:11-1:16" } ], - "domain": "1:13-1:16" + "domain": "1:4-1:16" + }, + { + "targets": [ + { + "content": "2:13-2:16", + "removal": "2:11-2:16" + } + ], + "domain": "2:4-2:20" } ] }, @@ -813,7 +831,7 @@ "name": "scopes/swift/type.field.interface", "languageId": "swift", "facet": "type.field.interface", - "code": "protocol Foo {\n var foo: Int { set get }\n}", + "code": "protocol Foo {\n var foo: Int { get set }\n}", "scopes": [ { "targets": [ @@ -831,7 +849,7 @@ "removal": "1:11-1:16" } ], - "domain": "1:13-1:16" + "domain": "1:4-1:28" } ] }, @@ -849,15 +867,6 @@ } ], "domain": "0:0-0:23" - }, - { - "targets": [ - { - "content": "0:7-0:10", - "removal": "0:5-0:10" - } - ], - "domain": "0:7-0:10" } ] }, @@ -979,7 +988,7 @@ "removal": "0:7-0:12" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:16" } ] }, @@ -996,7 +1005,7 @@ "removal": "0:7-0:12" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:12" } ] }, 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 49eb8d4fdd..a35a05714d 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 @@ -7489,7 +7489,7 @@ "removal": "0:7-0:12" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:16" } ] }, @@ -7514,8 +7514,17 @@ "name": "scopes/swift/type.field.class", "languageId": "swift", "facet": "type.field.class", - "code": "struct Foo {\n var foo: Int = 0\n}", + "code": "struct Foo {\n var bar: Int\n var baz: Int = 0\n}", "scopes": [ + { + "targets": [ + { + "content": "0:0-3:1", + "removal": "0:0-3:1" + } + ], + "domain": "0:0-3:1" + }, { "targets": [ { @@ -7523,7 +7532,16 @@ "removal": "1:11-1:16" } ], - "domain": "1:13-1:16" + "domain": "1:4-1:16" + }, + { + "targets": [ + { + "content": "2:13-2:16", + "removal": "2:11-2:16" + } + ], + "domain": "2:4-2:20" } ] }, @@ -7531,7 +7549,7 @@ "name": "scopes/swift/type.field.interface", "languageId": "swift", "facet": "type.field.interface", - "code": "protocol Foo {\n var foo: Int { set get }\n}", + "code": "protocol Foo {\n var foo: Int { get set }\n}", "scopes": [ { "targets": [ @@ -7549,7 +7567,7 @@ "removal": "1:11-1:16" } ], - "domain": "1:13-1:16" + "domain": "1:4-1:28" } ] }, @@ -7567,15 +7585,6 @@ } ], "domain": "0:0-0:23" - }, - { - "targets": [ - { - "content": "0:7-0:10", - "removal": "0:5-0:10" - } - ], - "domain": "0:7-0:10" } ] }, @@ -7697,7 +7706,7 @@ "removal": "0:7-0:12" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:16" } ] }, @@ -7714,7 +7723,7 @@ "removal": "0:7-0:12" } ], - "domain": "0:9-0:12" + "domain": "0:0-0:12" } ] }, diff --git a/resources/fixtures/scopes/swift/type.constant.scope b/resources/fixtures/scopes/swift/type.constant.scope index 386c29221d..2e5df8e802 100644 --- a/resources/fixtures/scopes/swift/type.constant.scope +++ b/resources/fixtures/scopes/swift/type.constant.scope @@ -1,8 +1,7 @@ let foo: Int = 0 --- -[Content] = -[Domain] = 0:9-0:12 +[Content] = 0:9-0:12 >---< 0| let foo: Int = 0 @@ -14,4 +13,8 @@ let foo: Int = 0 >--< 0| let foo: Int = 0 +[Domain] = 0:0-0:16 + >----------------< +0| let foo: Int = 0 + [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.field.class.scope b/resources/fixtures/scopes/swift/type.field.class.scope index 4a358c8142..815f507020 100644 --- a/resources/fixtures/scopes/swift/type.field.class.scope +++ b/resources/fixtures/scopes/swift/type.field.class.scope @@ -1,19 +1,55 @@ struct Foo { - var foo: Int = 0 + var bar: Int + var baz: Int = 0 } --- -[Content] = -[Domain] = 1:13-1:16 +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-3:1 + >------------ +0| struct Foo { +1| var bar: Int +2| var baz: Int = 0 +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:13-1:16 >---< -1| var foo: Int = 0 +1| var bar: Int -[Removal] = 1:11-1:16 +[#2 Removal] = 1:11-1:16 >-----< -1| var foo: Int = 0 +1| var bar: Int -[Leading delimiter] = 1:11-1:13 +[#2 Leading delimiter] = 1:11-1:13 >--< -1| var foo: Int = 0 +1| var bar: Int + +[#2 Domain] = 1:4-1:16 + >------------< +1| var bar: Int + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:13-2:16 + >---< +2| var baz: Int = 0 + +[#3 Removal] = 2:11-2:16 + >-----< +2| var baz: Int = 0 + +[#3 Leading delimiter] = 2:11-2:13 + >--< +2| var baz: Int = 0 + +[#3 Domain] = 2:4-2:20 + >----------------< +2| var baz: Int = 0 -[Insertion delimiter] = " " +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.field.interface.scope b/resources/fixtures/scopes/swift/type.field.interface.scope index b99cc0dab1..48767adca8 100644 --- a/resources/fixtures/scopes/swift/type.field.interface.scope +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -1,5 +1,5 @@ protocol Foo { - var foo: Int { set get } + var foo: Int { get set } } --- @@ -8,24 +8,27 @@ protocol Foo { [#1 Domain] = 0:0-2:1 >-------------- 0| protocol Foo { -1| var foo: Int { set get } +1| var foo: Int { get set } 2| } -< [#1 Insertion delimiter] = " " -[#2 Content] = -[#2 Domain] = 1:13-1:16 +[#2 Content] = 1:13-1:16 >---< -1| var foo: Int { set get } +1| var foo: Int { get set } [#2 Removal] = 1:11-1:16 >-----< -1| var foo: Int { set get } +1| var foo: Int { get set } [#2 Leading delimiter] = 1:11-1:13 >--< -1| var foo: Int { set get } +1| var foo: Int { get set } + +[#2 Domain] = 1:4-1:28 + >------------------------< +1| var foo: Int { get set } [#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.foreach.scope b/resources/fixtures/scopes/swift/type.foreach.scope index c6902de8ca..dc72384111 100644 --- a/resources/fixtures/scopes/swift/type.foreach.scope +++ b/resources/fixtures/scopes/swift/type.foreach.scope @@ -1,36 +1,20 @@ for v: Int in values {} --- -[#1 Content] = 0:7-0:10 +[Content] = 0:7-0:10 >---< 0| for v: Int in values {} -[#1 Removal] = 0:5-0:10 +[Removal] = 0:5-0:10 >-----< 0| for v: Int in values {} -[#1 Leading delimiter] = 0:5-0:7 +[Leading delimiter] = 0:5-0:7 >--< 0| for v: Int in values {} -[#1 Domain] = 0:0-0:23 +[Domain] = 0:0-0:23 >-----------------------< 0| for v: Int in values {} -[#1 Insertion delimiter] = " " - - -[#2 Content] = -[#2 Domain] = 0:7-0:10 - >---< -0| for v: Int in values {} - -[#2 Removal] = 0:5-0:10 - >-----< -0| for v: Int in values {} - -[#2 Leading delimiter] = 0:5-0:7 - >--< -0| for v: Int in values {} - -[#2 Insertion delimiter] = " " +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.variable.initialized.scope b/resources/fixtures/scopes/swift/type.variable.initialized.scope index d8d205f9e1..28043523ca 100644 --- a/resources/fixtures/scopes/swift/type.variable.initialized.scope +++ b/resources/fixtures/scopes/swift/type.variable.initialized.scope @@ -1,8 +1,7 @@ var foo: Int = 0 --- -[Content] = -[Domain] = 0:9-0:12 +[Content] = 0:9-0:12 >---< 0| var foo: Int = 0 @@ -14,4 +13,8 @@ var foo: Int = 0 >--< 0| var foo: Int = 0 +[Domain] = 0:0-0:16 + >----------------< +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 98b51069c8..99f31b1b07 100644 --- a/resources/fixtures/scopes/swift/type.variable.uninitialized.scope +++ b/resources/fixtures/scopes/swift/type.variable.uninitialized.scope @@ -1,8 +1,7 @@ var foo: Int --- -[Content] = -[Domain] = 0:9-0:12 +[Content] = 0:9-0:12 >---< 0| var foo: Int @@ -14,4 +13,8 @@ var foo: Int >--< 0| var foo: Int +[Domain] = 0:0-0:12 + >------------< +0| var foo: Int + [Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index f949c874b2..a0857615cc 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -71,7 +71,7 @@ (class_declaration name: (_) @name (class_body) -) @class @name.domain +) @class @type @name.domain ;;!! enum Foo {} ;;! ^^^ @@ -166,11 +166,30 @@ "}" @branch.end @interior.end.startOf ) -;; generic type annotation -( +;;!! let foo: Int = 0 +;;!! var foo: Int 0 +;;! ^^^ +;;! ^^^ +;;! ^ +(property_declaration + name: (_) @name (type_annotation ":" @type.leading - . - _ @type + (_) @type + )? + ( + "=" @value.leading + value: (_) @value + )? +) @_.domain + +;;!! let foo: Int { get set} +;;! ^^^ +;;! ^^^ +(protocol_property_declaration + name: (_) @name + (type_annotation + ":" @type.leading + (_) @type ) -) +) @_.domain From 4a7f98b74687fc938622ef457a3017bec8cf536f Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 15:34:41 +0200 Subject: [PATCH 41/46] iteration scopes --- .../docs/user/languages/fixtures/swift.json | 72 +++ .../src/docs/user/languages/swift.mdx | 6 + .../src/docs/user/scopes/fixtures/type.json | 72 +++ .../src/docs/user/scopes/type.mdx | 6 + .../src/scopeSupportFacets/swift.ts | 423 +++++++++--------- .../scopes/swift/name.iteration.block.scope | 27 ++ .../scopes/swift/name.iteration.block2.scope | 13 + .../scopes/swift/name.iteration.block3.scope | 30 ++ .../scopes/swift/name.iteration.block4.scope | 13 + .../swift/statement.iteration.block.scope | 27 ++ .../swift/statement.iteration.block2.scope | 13 + .../swift/statement.iteration.block3.scope | 30 ++ .../swift/statement.iteration.block4.scope | 13 + .../scopes/swift/type.iteration.block.scope | 28 +- .../scopes/swift/type.iteration.block2.scope | 13 + .../scopes/swift/type.iteration.block3.scope | 30 ++ .../scopes/swift/type.iteration.block4.scope | 13 + .../scopes/swift/value.iteration.block.scope | 27 ++ .../scopes/swift/value.iteration.block2.scope | 13 + .../scopes/swift/value.iteration.block3.scope | 30 ++ .../scopes/swift/value.iteration.block4.scope | 13 + resources/queries/swift.scm | 33 +- 22 files changed, 721 insertions(+), 224 deletions(-) create mode 100644 resources/fixtures/scopes/swift/name.iteration.block.scope create mode 100644 resources/fixtures/scopes/swift/name.iteration.block2.scope create mode 100644 resources/fixtures/scopes/swift/name.iteration.block3.scope create mode 100644 resources/fixtures/scopes/swift/name.iteration.block4.scope create mode 100644 resources/fixtures/scopes/swift/statement.iteration.block.scope create mode 100644 resources/fixtures/scopes/swift/statement.iteration.block2.scope create mode 100644 resources/fixtures/scopes/swift/statement.iteration.block3.scope create mode 100644 resources/fixtures/scopes/swift/statement.iteration.block4.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.block2.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.block3.scope create mode 100644 resources/fixtures/scopes/swift/type.iteration.block4.scope create mode 100644 resources/fixtures/scopes/swift/value.iteration.block.scope create mode 100644 resources/fixtures/scopes/swift/value.iteration.block2.scope create mode 100644 resources/fixtures/scopes/swift/value.iteration.block3.scope create mode 100644 resources/fixtures/scopes/swift/value.iteration.block4.scope 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 653a9a209d..250b0c71fe 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 @@ -891,6 +891,30 @@ "name": "scopes/swift/type.iteration.block", "languageId": "swift", "facet": "type.iteration.block", + "code": "struct Foo {\n func bar { }\n}", + "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.block2", + "languageId": "swift", + "facet": "type.iteration.block", "code": "func foo { }", "scopes": [ { @@ -911,6 +935,54 @@ } ] }, + { + "name": "scopes/swift/type.iteration.block3", + "languageId": "swift", + "facet": "type.iteration.block", + "code": "if true { }\nelse if false { }\nelse { }", + "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.block4", + "languageId": "swift", + "facet": "type.iteration.block", + "code": "while true { }", + "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", 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 39a6b42a68..51801a943b 100644 --- a/packages/app-web-docs/src/docs/user/languages/swift.mdx +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -263,6 +263,12 @@ Below are visualizations of all our scope tests for this language. These were cr + + + + + + #### 10. Type (iteration class) Iteration scope for types: class bodies. 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 a35a05714d..dc702ba201 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 @@ -7609,6 +7609,30 @@ "name": "scopes/swift/type.iteration.block", "languageId": "swift", "facet": "type.iteration.block", + "code": "struct Foo {\n func bar { }\n}", + "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.block2", + "languageId": "swift", + "facet": "type.iteration.block", "code": "func foo { }", "scopes": [ { @@ -7629,6 +7653,54 @@ } ] }, + { + "name": "scopes/swift/type.iteration.block3", + "languageId": "swift", + "facet": "type.iteration.block", + "code": "if true { }\nelse if false { }\nelse { }", + "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.block4", + "languageId": "swift", + "facet": "type.iteration.block", + "code": "while true { }", + "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", 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 abed32aee4..cffccd3a52 100644 --- a/packages/app-web-docs/src/docs/user/scopes/type.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/type.mdx @@ -1055,6 +1055,12 @@ Default: `type` + + + + + + ##### TypeScript diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 62d7f40da7..a1e40afe23 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -4,8 +4,6 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const swiftScopeSupport: LanguageScopeSupportFacetMap = { - /* SUPPORTED OR UNSUPPORTED (PLANNED) */ - // if/else/elif ifStatement: supported, "statement.if": supported, @@ -17,9 +15,9 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "branch.if.iteration": supported, // ternary operator - "branch.ternary": unsupported, - "condition.ternary": unsupported, - "branch.ternary.iteration": unsupported, + "branch.ternary": supported, + "condition.ternary": supported, + "branch.ternary.iteration": supported, // for loop "statement.foreach": supported, @@ -29,44 +27,44 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "interior.foreach": supported, // while loop - "statement.while": unsupported, - "condition.while": unsupported, - "interior.while": unsupported, + "statement.while": supported, + "condition.while": supported, + "interior.while": supported, // repeat-while loop (equivalent to do-while loops in other languages) - "statement.doWhile": unsupported, - "condition.doWhile": unsupported, - "interior.doWhile": unsupported, + "statement.doWhile": supported, + "condition.doWhile": supported, + "interior.doWhile": supported, // 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, - "interior.try": unsupported, - "branch.try.iteration": unsupported, + "statement.try": supported, + "branch.try": supported, + "interior.try": supported, + "branch.try.iteration": supported, // switch - "statement.switch": unsupported, - "branch.switchCase": unsupported, - "condition.switchCase": unsupported, - "value.switch": unsupported, - "interior.switch": unsupported, - "interior.switchCase": unsupported, + "statement.switch": supported, + "branch.switchCase": supported, + "condition.switchCase": supported, + "value.switch": supported, + "interior.switch": supported, + "interior.switchCase": supported, - "branch.switchCase.iteration": unsupported, - "condition.switchCase.iteration": unsupported, + "branch.switchCase.iteration": supported, + "condition.switchCase.iteration": supported, // misc control transfer (returns, throw/break/continue statements, etc) - "statement.return": unsupported, - "value.return": unsupported, - "value.return.lambda": unsupported, - "statement.throw": unsupported, - "value.throw": unsupported, - "statement.break": unsupported, - "statement.continue": unsupported, - "type.return": unsupported, - "type.return.method": unsupported, - "type.return.lambda": unsupported, + "statement.return": supported, + "value.return": supported, + "value.return.lambda": supported, + "statement.throw": supported, + "value.throw": supported, + "statement.break": supported, + "statement.continue": supported, + "type.return": supported, + "type.return.method": supported, + "type.return.lambda": supported, // enum "statement.enum": supported, @@ -82,13 +80,13 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.class": supported, "name.class": supported, "interior.class": supported, - "type.class": unsupported, + "type.class": supported, "statement.iteration.class": supported, "class.iteration.class": supported, - "namedFunction.iteration.class": unsupported, + "namedFunction.iteration.class": supported, "name.iteration.class": supported, - "value.iteration.class": unsupported, + "value.iteration.class": supported, "type.iteration.class": supported, // protocol (equivalent to interfaces in other languages) @@ -102,129 +100,126 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "type.iteration.interface": supported, // "standard" functions & methods - namedFunction: unsupported, - "namedFunction.method": unsupported, - "statement.function": unsupported, - "statement.method": unsupported, - "name.function": unsupported, - "name.method": unsupported, - "interior.function": unsupported, - "interior.method": unsupported, + namedFunction: supported, + "namedFunction.method": supported, + "statement.function": supported, + "statement.method": supported, + "name.function": supported, + "name.method": supported, + "interior.function": supported, + "interior.method": supported, // constructors - "namedFunction.constructor": unsupported, - "statement.constructor": unsupported, - "name.constructor": unsupported, - "interior.constructor": unsupported, + "namedFunction.constructor": supported, + "statement.constructor": supported, + "name.constructor": supported, + "interior.constructor": supported, // protocol method declarations - "statement.method.interface": unsupported, - "name.method.interface": unsupported, + "statement.method.interface": supported, + "name.method.interface": supported, // closures/lambda functions - anonymousFunction: unsupported, - "interior.lambda": unsupported, + anonymousFunction: supported, + "interior.lambda": supported, // function calls - functionCall: unsupported, - "statement.functionCall": unsupported, - "functionCall.constructor": unsupported, - "functionCall.method": unsupported, - "functionCall.chain": unsupported, - "functionCall.generic": unsupported, - "functionCall.enum": unsupported, + functionCall: supported, + "statement.functionCall": supported, + "functionCall.constructor": supported, + "functionCall.method": supported, + "functionCall.chain": supported, + "functionCall.generic": supported, + "functionCall.enum": supported, // function callee - functionCallee: unsupported, - "functionCallee.constructor": unsupported, - "functionCallee.method": unsupported, - "functionCallee.chain": unsupported, - "functionCallee.generic": unsupported, - "functionCallee.enum": unsupported, + functionCallee: supported, + "functionCallee.constructor": supported, + "functionCallee.method": supported, + "functionCallee.chain": supported, + "functionCallee.generic": supported, + "functionCallee.enum": supported, // argument (actual; as in parameters as passed to a call) - "argument.actual.singleLine": unsupported, - "argument.actual.multiLine": unsupported, - "argument.actual.method.singleLine": unsupported, - "argument.actual.method.multiLine": unsupported, - "argument.actual.constructor.singleLine": unsupported, - "argument.actual.constructor.multiLine": 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.actual.singleLine": supported, + "argument.actual.multiLine": supported, + "argument.actual.method.singleLine": supported, + "argument.actual.method.multiLine": supported, + "argument.actual.constructor.singleLine": supported, + "argument.actual.constructor.multiLine": supported, + "argument.actual.enum.singleLine": supported, + "argument.actual.enum.multiLine": supported, + + "argument.actual.iteration": supported, + "argument.actual.method.iteration": supported, + "argument.actual.constructor.iteration": supported, + "argument.actual.enum.iteration": supported, // argument (formal; as in the argument members within a callable block and its declaration) - "argument.formal.singleLine": unsupported, - "argument.formal.multiLine": unsupported, - "argument.formal.method.singleLine": unsupported, - "argument.formal.method.multiLine": unsupported, - "argument.formal.constructor.singleLine": unsupported, - "argument.formal.constructor.multiLine": unsupported, - "argument.formal.lambda.singleLine": unsupported, - "argument.formal.lambda.multiLine": 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.formal.singleLine": supported, + "argument.formal.multiLine": supported, + "argument.formal.method.singleLine": supported, + "argument.formal.method.multiLine": supported, + "argument.formal.constructor.singleLine": supported, + "argument.formal.constructor.multiLine": supported, + "argument.formal.lambda.singleLine": supported, + "argument.formal.lambda.multiLine": supported, + "argument.formal.catch": supported, + + "argument.formal.iteration": supported, + "argument.formal.method.iteration": supported, + "argument.formal.constructor.iteration": supported, + "argument.formal.lambda.iteration": supported, // 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, + "argumentList.actual.empty": supported, + "argumentList.actual.singleLine": supported, + "argumentList.actual.multiLine": supported, + "argumentList.actual.method.empty": supported, + "argumentList.actual.method.singleLine": supported, + "argumentList.actual.method.multiLine": supported, + "argumentList.actual.constructor.empty": supported, + "argumentList.actual.constructor.singleLine": supported, + "argumentList.actual.constructor.multiLine": supported, + "argumentList.actual.enum.empty": supported, + "argumentList.actual.enum.singleLine": supported, + "argumentList.actual.enum.multiLine": supported, // 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, - - // variables and constants (var, let) - fieldAccess: unsupported, - - "statement.field.class": unsupported, - "statement.field.interface": unsupported, - "statement.variable.uninitialized": unsupported, - "statement.variable.initialized": unsupported, - "statement.variable.destructuring": unsupported, - "statement.constant": unsupported, - - "name.field.class": unsupported, - "name.field.interface": unsupported, - "name.field.enum": unsupported, - "name.variable.uninitialized": unsupported, - "name.variable.initialized": unsupported, - "name.variable.destructuring": unsupported, - "name.constant": unsupported, - - "value.constant": unsupported, - "value.field.class": unsupported, - "value.field.interface": unsupported, - "value.field.enum": unsupported, - "value.variable": unsupported, - "value.variable.destructuring": unsupported, + "argumentList.formal.empty": supported, + "argumentList.formal.singleLine": supported, + "argumentList.formal.multiLine": supported, + "argumentList.formal.lambda.empty": supported, + "argumentList.formal.lambda.singleLine": supported, + "argumentList.formal.lambda.multiLine": supported, + "argumentList.formal.method.empty": supported, + "argumentList.formal.method.singleLine": supported, + "argumentList.formal.method.multiLine": supported, + "argumentList.formal.constructor.empty": supported, + "argumentList.formal.constructor.singleLine": supported, + "argumentList.formal.constructor.multiLine": supported, + + "statement.field.class": supported, + "statement.field.interface": supported, + "statement.variable.uninitialized": supported, + "statement.variable.initialized": supported, + "statement.variable.destructuring": supported, + "statement.constant": supported, + + "name.field.class": supported, + "name.field.interface": supported, + "name.field.enum": supported, + "name.variable.uninitialized": supported, + "name.variable.initialized": supported, + "name.variable.destructuring": supported, + "name.constant": supported, + + "value.constant": supported, + "value.field.class": supported, + "value.field.interface": supported, + "value.field.enum": supported, + "value.variable": supported, + "value.variable.destructuring": supported, "type.constant": supported, "type.variable.uninitialized": supported, @@ -233,16 +228,16 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "type.field.interface": supported, // assignments - "statement.assignment": unsupported, - "statement.assignment.destructuring": unsupported, - "statement.assignment.compound": unsupported, - "name.assignment": unsupported, - "name.assignment.destructuring": unsupported, - "name.assignment.compound": unsupported, + "statement.assignment": supported, + "statement.assignment.destructuring": supported, + "statement.assignment.compound": supported, + "name.assignment": supported, + "name.assignment.destructuring": supported, + "name.assignment.compound": supported, - "value.assignment": unsupported, - "value.assignment.destructuring": unsupported, - "value.assignment.compound": unsupported, + "value.assignment": supported, + "value.assignment.destructuring": supported, + "value.assignment.compound": supported, // comments "comment.line": supported, @@ -257,87 +252,91 @@ 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, + "statement.iteration.document": supported, + "class.iteration.document": supported, + "namedFunction.iteration.document": supported, + "name.iteration.document": supported, + "value.iteration.document": supported, "type.iteration.document": supported, // general per-block iteration (not branches) - "statement.iteration.block": unsupported, - "name.iteration.block": unsupported, - "value.iteration.block": unsupported, + "statement.iteration.block": supported, + "name.iteration.block": supported, + "value.iteration.block": supported, "type.iteration.block": supported, // unenclosed collection item - "collectionItem.unenclosed.singleLine": unsupported, - "collectionItem.unenclosed.multiLine": unsupported, - "collectionItem.unenclosed.iteration": unsupported, + "collectionItem.unenclosed.singleLine": supported, + "collectionItem.unenclosed.multiLine": supported, + "collectionItem.unenclosed.iteration": supported, // enclosed collections - map: unsupported, - list: unsupported, - "key.mapPair": unsupported, - "key.mapPair.iteration": unsupported, - "value.mapPair": unsupported, - "value.mapPair.iteration": unsupported, + map: supported, + list: supported, + "key.mapPair": supported, + "key.mapPair.iteration": supported, + "value.mapPair": supported, + "value.mapPair.iteration": supported, // argument names - "name.argument.actual": unsupported, - "name.argument.formal": unsupported, - "name.argument.formal.method": unsupported, - "name.argument.formal.lambda": unsupported, - "name.argument.formal.constructor": 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, + "name.argument.actual": supported, + "name.argument.formal": supported, + "name.argument.formal.method": supported, + "name.argument.formal.lambda": supported, + "name.argument.formal.constructor": supported, + "name.argument.catch": supported, + + "name.argument.actual.iteration": supported, + "name.argument.formal.iteration": supported, + "name.argument.formal.method.iteration": supported, + "name.argument.formal.lambda.iteration": supported, + "name.argument.formal.constructor.iteration": supported, // argument values - "value.argument.actual": unsupported, - "value.argument.formal": unsupported, - "value.argument.formal.method": unsupported, - "value.argument.formal.constructor": 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, + "value.argument.actual": supported, + "value.argument.formal": supported, + "value.argument.formal.method": supported, + "value.argument.formal.constructor": supported, + "value.argument.formal.lambda": supported, + + "value.argument.actual.iteration": supported, + "value.argument.formal.iteration": supported, + "value.argument.formal.method.iteration": supported, + "value.argument.formal.constructor.iteration": supported, + "value.argument.formal.lambda.iteration": supported, // argument types - "type.argument.formal": unsupported, - "type.argument.formal.method": unsupported, - "type.argument.formal.lambda": unsupported, - "type.argument.formal.constructor": unsupported, - "type.argument.catch": unsupported, + "type.argument.formal": supported, + "type.argument.formal.method": supported, + "type.argument.formal.lambda": supported, + "type.argument.formal.constructor": supported, + "type.argument.catch": supported, - "type.argument.formal.iteration": unsupported, - "type.argument.formal.method.iteration": unsupported, - "type.argument.formal.lambda.iteration": unsupported, - "type.argument.formal.constructor.iteration": unsupported, + "type.argument.formal.iteration": supported, + "type.argument.formal.method.iteration": supported, + "type.argument.formal.lambda.iteration": supported, + "type.argument.formal.constructor.iteration": supported, // type aliases - "name.typeAlias": unsupported, - "value.typeAlias": unsupported, - "statement.typeAlias": unsupported, - "statement.misc": unsupported, - "type.typeArgument": unsupported, - "type.alias": unsupported, - "type.cast": unsupported, - "type.typeArgument.iteration": unsupported, + "name.typeAlias": supported, + "value.typeAlias": supported, + "statement.typeAlias": supported, + "statement.misc": supported, + "type.typeArgument": supported, + "type.alias": supported, + "type.cast": supported, + "type.typeArgument.iteration": supported, // misc - regularExpression: unsupported, - disqualifyDelimiter: unsupported, - pairDelimiter: unsupported, - "textFragment.regularExpression": unsupported, - "statement.import": unsupported, + regularExpression: supported, + disqualifyDelimiter: supported, + pairDelimiter: supported, + "textFragment.regularExpression": supported, + "statement.import": supported, + + /* UNSUPPORTED */ + + fieldAccess: unsupported, /* NOT APPLICABLE */ diff --git a/resources/fixtures/scopes/swift/name.iteration.block.scope b/resources/fixtures/scopes/swift/name.iteration.block.scope new file mode 100644 index 0000000000..fd2ecf6f7a --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.block.scope @@ -0,0 +1,27 @@ +struct Foo { + func bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:12-2:0 + > +0| struct Foo { +1| func bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| func bar() { } diff --git a/resources/fixtures/scopes/swift/name.iteration.block2.scope b/resources/fixtures/scopes/swift/name.iteration.block2.scope new file mode 100644 index 0000000000..eb1487158f --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.block2.scope @@ -0,0 +1,13 @@ +func foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| func foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| func foo() { } diff --git a/resources/fixtures/scopes/swift/name.iteration.block3.scope b/resources/fixtures/scopes/swift/name.iteration.block3.scope new file mode 100644 index 0000000000..0ffb1c499a --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.block3.scope @@ -0,0 +1,30 @@ +if true { } +else if false { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >----------- +0| if true { } +1| else if false { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:9-0:10 + >-< +0| if true { } + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| else if false { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/resources/fixtures/scopes/swift/name.iteration.block4.scope b/resources/fixtures/scopes/swift/name.iteration.block4.scope new file mode 100644 index 0000000000..e7b3236d45 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.block4.scope @@ -0,0 +1,13 @@ +while true { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| while true { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| while true { } diff --git a/resources/fixtures/scopes/swift/statement.iteration.block.scope b/resources/fixtures/scopes/swift/statement.iteration.block.scope new file mode 100644 index 0000000000..fd2ecf6f7a --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.block.scope @@ -0,0 +1,27 @@ +struct Foo { + func bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:12-2:0 + > +0| struct Foo { +1| func bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| func bar() { } diff --git a/resources/fixtures/scopes/swift/statement.iteration.block2.scope b/resources/fixtures/scopes/swift/statement.iteration.block2.scope new file mode 100644 index 0000000000..eb1487158f --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.block2.scope @@ -0,0 +1,13 @@ +func foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| func foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| func foo() { } diff --git a/resources/fixtures/scopes/swift/statement.iteration.block3.scope b/resources/fixtures/scopes/swift/statement.iteration.block3.scope new file mode 100644 index 0000000000..0ffb1c499a --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.block3.scope @@ -0,0 +1,30 @@ +if true { } +else if false { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >----------- +0| if true { } +1| else if false { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:9-0:10 + >-< +0| if true { } + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| else if false { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/resources/fixtures/scopes/swift/statement.iteration.block4.scope b/resources/fixtures/scopes/swift/statement.iteration.block4.scope new file mode 100644 index 0000000000..e7b3236d45 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.block4.scope @@ -0,0 +1,13 @@ +while true { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| while true { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| while true { } diff --git a/resources/fixtures/scopes/swift/type.iteration.block.scope b/resources/fixtures/scopes/swift/type.iteration.block.scope index c5bbfd9099..fd2ecf6f7a 100644 --- a/resources/fixtures/scopes/swift/type.iteration.block.scope +++ b/resources/fixtures/scopes/swift/type.iteration.block.scope @@ -1,13 +1,27 @@ -func foo { } +struct Foo { + func bar() { } +} --- [#1 Content] = -[#1 Domain] = 0:0-0:12 - >------------< -0| func foo { } +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() { } +2| } + -< [#2 Content] = -[#2 Domain] = 0:10-0:11 - >-< -0| func foo { } +[#2 Domain] = 0:12-2:0 + > +0| struct Foo { +1| func bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| func bar() { } diff --git a/resources/fixtures/scopes/swift/type.iteration.block2.scope b/resources/fixtures/scopes/swift/type.iteration.block2.scope new file mode 100644 index 0000000000..eb1487158f --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.block2.scope @@ -0,0 +1,13 @@ +func foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| func foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| func foo() { } diff --git a/resources/fixtures/scopes/swift/type.iteration.block3.scope b/resources/fixtures/scopes/swift/type.iteration.block3.scope new file mode 100644 index 0000000000..0ffb1c499a --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.block3.scope @@ -0,0 +1,30 @@ +if true { } +else if false { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >----------- +0| if true { } +1| else if false { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:9-0:10 + >-< +0| if true { } + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| else if false { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/resources/fixtures/scopes/swift/type.iteration.block4.scope b/resources/fixtures/scopes/swift/type.iteration.block4.scope new file mode 100644 index 0000000000..e7b3236d45 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.block4.scope @@ -0,0 +1,13 @@ +while true { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| while true { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| while true { } diff --git a/resources/fixtures/scopes/swift/value.iteration.block.scope b/resources/fixtures/scopes/swift/value.iteration.block.scope new file mode 100644 index 0000000000..fd2ecf6f7a --- /dev/null +++ b/resources/fixtures/scopes/swift/value.iteration.block.scope @@ -0,0 +1,27 @@ +struct Foo { + func bar() { } +} +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() { } +2| } + -< + + +[#2 Content] = +[#2 Domain] = 0:12-2:0 + > +0| struct Foo { +1| func bar() { } +2| } + < + + +[#3 Content] = +[#3 Domain] = 1:16-1:17 + >-< +1| func bar() { } diff --git a/resources/fixtures/scopes/swift/value.iteration.block2.scope b/resources/fixtures/scopes/swift/value.iteration.block2.scope new file mode 100644 index 0000000000..eb1487158f --- /dev/null +++ b/resources/fixtures/scopes/swift/value.iteration.block2.scope @@ -0,0 +1,13 @@ +func foo() { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| func foo() { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| func foo() { } diff --git a/resources/fixtures/scopes/swift/value.iteration.block3.scope b/resources/fixtures/scopes/swift/value.iteration.block3.scope new file mode 100644 index 0000000000..0ffb1c499a --- /dev/null +++ b/resources/fixtures/scopes/swift/value.iteration.block3.scope @@ -0,0 +1,30 @@ +if true { } +else if false { } +else { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-2:8 + >----------- +0| if true { } +1| else if false { } +2| else { } + --------< + + +[#2 Content] = +[#2 Domain] = 0:9-0:10 + >-< +0| if true { } + + +[#3 Content] = +[#3 Domain] = 1:15-1:16 + >-< +1| else if false { } + + +[#4 Content] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } diff --git a/resources/fixtures/scopes/swift/value.iteration.block4.scope b/resources/fixtures/scopes/swift/value.iteration.block4.scope new file mode 100644 index 0000000000..e7b3236d45 --- /dev/null +++ b/resources/fixtures/scopes/swift/value.iteration.block4.scope @@ -0,0 +1,13 @@ +while true { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| while true { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| while true { } diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index a0857615cc..7279f9e03f 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -61,11 +61,6 @@ ;; text: (_) @interior @textFragment ;;) @string -;; generic property delc -;; (property_declaration -;; name: (_) @name -;; ) @name.domain - ;;!! struct Foo {} ;;! ^^^ (class_declaration @@ -123,6 +118,16 @@ (#not-child-type? @branch.start.startOf else) ) +;;!! if true { } +;;! ^ +( + (if_statement + "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf + ) @_dummy + (#not-child-type? @_dummy else) +) + ;;!! if true {} else {} ( (if_statement @@ -134,6 +139,16 @@ (#not-parent-type? @branch.start.startOf if_statement) ) +;;!! if true { } else {} +;;! ^ +( + (if_statement + "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf + (else) + ) +) + ;;!! else if true {} else {} (if_statement (else) @branch.start @condition.domain.start @@ -166,6 +181,14 @@ "}" @branch.end @interior.end.startOf ) +;;!! else { } +;;! ^ +( + (else) + "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf +) + ;;!! let foo: Int = 0 ;;!! var foo: Int 0 ;;! ^^^ From 9bf512cecbf62634c592560f43ccceea7a8e774e Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 16:14:04 +0200 Subject: [PATCH 42/46] fixtures in folders --- .../src/scopeSupportFacets/swift.ts | 529 ++++++++---------- .../scopes/swift/anonymousFunction.scope | 10 + .../{ => branch}/branch.if.elif.else.scope | 0 .../swift/{ => branch}/branch.if.else.scope | 0 .../{ => branch}/branch.if.iteration.scope | 0 .../scopes/swift/{ => branch}/branch.if.scope | 0 .../branch/branch.ternary.iteration.scope | 7 + .../scopes/swift/branch/branch.ternary.scope | 37 ++ .../swift/branch/branch.try.iteration.scope | 10 + .../scopes/swift/branch/branch.try.scope | 30 + .../swift/class.iteration.document.scope | 12 + .../collectionItem.unenclosed.iteration.scope | 7 + .../swift/{ => condition}/condition.if.scope | 0 .../swift/condition/condition.ternary.scope | 20 + .../swift/condition/condition.while.scope | 24 + .../swift/{ => interior}/interior.class.scope | 0 .../swift/interior/interior.constructor.scope | 27 + .../swift/interior/interior.doWhile.scope | 10 + .../swift/{ => interior}/interior.enum.scope | 0 .../{ => interior}/interior.foreach.scope | 0 .../swift/interior/interior.function.scope | 10 + .../swift/{ => interior}/interior.if.scope | 0 .../swift/{ => interior}/interior.if2.scope | 0 .../swift/{ => interior}/interior.if3.scope | 0 .../swift/{ => interior}/interior.if4.scope | 0 .../{ => interior}/interior.interface.scope | 0 .../swift/interior/interior.method.scope | 27 + .../swift/interior/interior.switch.scope | 10 + .../scopes/swift/interior/interior.try.scope | 20 + .../swift/interior/interior.while.scope | 10 + .../scopes/swift/{ => name}/name.class.scope | 0 .../scopes/swift/name/name.constant.scope | 24 + .../scopes/swift/{ => name}/name.enum.scope | 0 .../scopes/swift/name/name.field.class.scope | 69 +++ .../swift/{ => name}/name.foreach.scope | 0 .../swift/{ => name}/name.interface.scope | 0 .../{ => name}/name.iteration.block.scope | 0 .../{ => name}/name.iteration.block2.scope | 0 .../{ => name}/name.iteration.block3.scope | 0 .../{ => name}/name.iteration.block4.scope | 0 .../{ => name}/name.iteration.class.scope | 0 .../swift/name/name.iteration.document.scope | 14 + .../{ => name}/name.iteration.enum.scope | 0 .../{ => name}/name.iteration.interface.scope | 0 .../name/name.variable.initialized.scope | 24 + .../name/name.variable.uninitialized.scope | 20 + .../{ => statement}/statement.class.scope | 0 .../swift/statement/statement.constant.scope | 10 + .../swift/statement/statement.doWhile.scope | 10 + .../{ => statement}/statement.enum.scope | 0 .../statement/statement.field.class.scope | 33 ++ .../{ => statement}/statement.foreach.scope | 0 .../swift/{ => statement}/statement.if.scope | 0 .../{ => statement}/statement.interface.scope | 0 .../statement.iteration.block.scope | 0 .../statement.iteration.block2.scope | 0 .../statement.iteration.block3.scope | 0 .../statement.iteration.block4.scope | 0 .../statement.iteration.class.scope | 0 .../statement.iteration.document.scope | 12 + .../statement.iteration.interface.scope | 0 .../swift/statement/statement.try.scope | 13 + .../statement.variable.initialized.scope | 10 + .../statement.variable.uninitialized.scope | 10 + .../swift/statement/statement.while.scope | 10 + .../textFragment.comment.block.scope | 0 .../textFragment.comment.line.scope | 0 .../textFragment.string.multiLine.scope | 0 .../textFragment.string.singleLine.scope | 0 .../scopes/swift/type/type.class.scope | 10 + .../swift/{ => type}/type.constant.scope | 0 .../scopes/swift/{ => type}/type.enum.scope | 0 .../swift/{ => type}/type.field.class.scope | 0 .../{ => type}/type.field.interface.scope | 0 .../swift/{ => type}/type.foreach.scope | 0 .../swift/{ => type}/type.interface.scope | 0 .../{ => type}/type.iteration.block.scope | 0 .../{ => type}/type.iteration.block2.scope | 0 .../{ => type}/type.iteration.block3.scope | 0 .../{ => type}/type.iteration.block4.scope | 0 .../{ => type}/type.iteration.class.scope | 0 .../{ => type}/type.iteration.document.scope | 0 .../{ => type}/type.iteration.interface.scope | 0 .../type.variable.initialized.scope | 0 .../type.variable.uninitialized.scope | 0 .../scopes/swift/value/value.constant.scope | 20 + .../swift/{ => value}/value.foreach.scope | 0 .../{ => value}/value.iteration.block.scope | 0 .../{ => value}/value.iteration.block2.scope | 0 .../{ => value}/value.iteration.block3.scope | 0 .../{ => value}/value.iteration.block4.scope | 0 .../swift/value/value.iteration.class.scope | 13 + .../value/value.iteration.document.scope | 12 + .../{ => value}/value.iteration.enum.scope | 0 resources/queries/swift.scm | 51 +- 95 files changed, 876 insertions(+), 289 deletions(-) create mode 100644 resources/fixtures/scopes/swift/anonymousFunction.scope rename resources/fixtures/scopes/swift/{ => branch}/branch.if.elif.else.scope (100%) rename resources/fixtures/scopes/swift/{ => branch}/branch.if.else.scope (100%) rename resources/fixtures/scopes/swift/{ => branch}/branch.if.iteration.scope (100%) rename resources/fixtures/scopes/swift/{ => branch}/branch.if.scope (100%) create mode 100644 resources/fixtures/scopes/swift/branch/branch.ternary.iteration.scope create mode 100644 resources/fixtures/scopes/swift/branch/branch.ternary.scope create mode 100644 resources/fixtures/scopes/swift/branch/branch.try.iteration.scope create mode 100644 resources/fixtures/scopes/swift/branch/branch.try.scope create mode 100644 resources/fixtures/scopes/swift/class.iteration.document.scope create mode 100644 resources/fixtures/scopes/swift/collectionItem.unenclosed.iteration.scope rename resources/fixtures/scopes/swift/{ => condition}/condition.if.scope (100%) create mode 100644 resources/fixtures/scopes/swift/condition/condition.ternary.scope create mode 100644 resources/fixtures/scopes/swift/condition/condition.while.scope rename resources/fixtures/scopes/swift/{ => interior}/interior.class.scope (100%) create mode 100644 resources/fixtures/scopes/swift/interior/interior.constructor.scope create mode 100644 resources/fixtures/scopes/swift/interior/interior.doWhile.scope rename resources/fixtures/scopes/swift/{ => interior}/interior.enum.scope (100%) rename resources/fixtures/scopes/swift/{ => interior}/interior.foreach.scope (100%) create mode 100644 resources/fixtures/scopes/swift/interior/interior.function.scope rename resources/fixtures/scopes/swift/{ => interior}/interior.if.scope (100%) rename resources/fixtures/scopes/swift/{ => interior}/interior.if2.scope (100%) rename resources/fixtures/scopes/swift/{ => interior}/interior.if3.scope (100%) rename resources/fixtures/scopes/swift/{ => interior}/interior.if4.scope (100%) rename resources/fixtures/scopes/swift/{ => interior}/interior.interface.scope (100%) create mode 100644 resources/fixtures/scopes/swift/interior/interior.method.scope create mode 100644 resources/fixtures/scopes/swift/interior/interior.switch.scope create mode 100644 resources/fixtures/scopes/swift/interior/interior.try.scope create mode 100644 resources/fixtures/scopes/swift/interior/interior.while.scope rename resources/fixtures/scopes/swift/{ => name}/name.class.scope (100%) create mode 100644 resources/fixtures/scopes/swift/name/name.constant.scope rename resources/fixtures/scopes/swift/{ => name}/name.enum.scope (100%) create mode 100644 resources/fixtures/scopes/swift/name/name.field.class.scope rename resources/fixtures/scopes/swift/{ => name}/name.foreach.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.interface.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.iteration.block.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.iteration.block2.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.iteration.block3.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.iteration.block4.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.iteration.class.scope (100%) create mode 100644 resources/fixtures/scopes/swift/name/name.iteration.document.scope rename resources/fixtures/scopes/swift/{ => name}/name.iteration.enum.scope (100%) rename resources/fixtures/scopes/swift/{ => name}/name.iteration.interface.scope (100%) create mode 100644 resources/fixtures/scopes/swift/name/name.variable.initialized.scope create mode 100644 resources/fixtures/scopes/swift/name/name.variable.uninitialized.scope rename resources/fixtures/scopes/swift/{ => statement}/statement.class.scope (100%) create mode 100644 resources/fixtures/scopes/swift/statement/statement.constant.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.doWhile.scope rename resources/fixtures/scopes/swift/{ => statement}/statement.enum.scope (100%) create mode 100644 resources/fixtures/scopes/swift/statement/statement.field.class.scope rename resources/fixtures/scopes/swift/{ => statement}/statement.foreach.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.if.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.interface.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.iteration.block.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.iteration.block2.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.iteration.block3.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.iteration.block4.scope (100%) rename resources/fixtures/scopes/swift/{ => statement}/statement.iteration.class.scope (100%) create mode 100644 resources/fixtures/scopes/swift/statement/statement.iteration.document.scope rename resources/fixtures/scopes/swift/{ => statement}/statement.iteration.interface.scope (100%) create mode 100644 resources/fixtures/scopes/swift/statement/statement.try.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.variable.initialized.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.variable.uninitialized.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.while.scope rename resources/fixtures/scopes/swift/{ => textFragment}/textFragment.comment.block.scope (100%) rename resources/fixtures/scopes/swift/{ => textFragment}/textFragment.comment.line.scope (100%) rename resources/fixtures/scopes/swift/{ => textFragment}/textFragment.string.multiLine.scope (100%) rename resources/fixtures/scopes/swift/{ => textFragment}/textFragment.string.singleLine.scope (100%) create mode 100644 resources/fixtures/scopes/swift/type/type.class.scope rename resources/fixtures/scopes/swift/{ => type}/type.constant.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.enum.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.field.class.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.field.interface.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.foreach.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.interface.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.block.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.block2.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.block3.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.block4.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.class.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.document.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.iteration.interface.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.variable.initialized.scope (100%) rename resources/fixtures/scopes/swift/{ => type}/type.variable.uninitialized.scope (100%) create mode 100644 resources/fixtures/scopes/swift/value/value.constant.scope rename resources/fixtures/scopes/swift/{ => value}/value.foreach.scope (100%) rename resources/fixtures/scopes/swift/{ => value}/value.iteration.block.scope (100%) rename resources/fixtures/scopes/swift/{ => value}/value.iteration.block2.scope (100%) rename resources/fixtures/scopes/swift/{ => value}/value.iteration.block3.scope (100%) rename resources/fixtures/scopes/swift/{ => value}/value.iteration.block4.scope (100%) create mode 100644 resources/fixtures/scopes/swift/value/value.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/value/value.iteration.document.scope rename resources/fixtures/scopes/swift/{ => value}/value.iteration.enum.scope (100%) diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index a1e40afe23..65fc23f406 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -4,174 +4,39 @@ import { ScopeSupportFacetLevel } from "./scopeSupportFacets.types"; const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const swiftScopeSupport: LanguageScopeSupportFacetMap = { - // if/else/elif - ifStatement: supported, - "statement.if": supported, - "branch.if": supported, - "branch.if.else": supported, - "branch.if.elif.else": supported, - "condition.if": supported, - "interior.if": supported, - "branch.if.iteration": supported, - - // ternary operator - "branch.ternary": supported, - "condition.ternary": supported, - "branch.ternary.iteration": supported, - - // for loop - "statement.foreach": supported, - "name.foreach": supported, - "value.foreach": supported, - "type.foreach": supported, - "interior.foreach": supported, - - // while loop - "statement.while": supported, - "condition.while": supported, - "interior.while": supported, - - // repeat-while loop (equivalent to do-while loops in other languages) - "statement.doWhile": supported, - "condition.doWhile": supported, - "interior.doWhile": supported, - - // 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": supported, - "branch.try": supported, - "interior.try": supported, - "branch.try.iteration": supported, - - // switch - "statement.switch": supported, - "branch.switchCase": supported, - "condition.switchCase": supported, - "value.switch": supported, - "interior.switch": supported, - "interior.switchCase": supported, - - "branch.switchCase.iteration": supported, - "condition.switchCase.iteration": supported, - - // misc control transfer (returns, throw/break/continue statements, etc) - "statement.return": supported, - "value.return": supported, - "value.return.lambda": supported, - "statement.throw": supported, - "value.throw": supported, - "statement.break": supported, - "statement.continue": supported, - "type.return": supported, - "type.return.method": supported, - "type.return.lambda": supported, - - // enum - "statement.enum": supported, - "name.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": supported, - "type.class": supported, - - "statement.iteration.class": supported, - "class.iteration.class": supported, - "namedFunction.iteration.class": supported, - "name.iteration.class": supported, - "value.iteration.class": supported, - "type.iteration.class": supported, - - // protocol (equivalent to interfaces in other languages) - "statement.interface": supported, - "name.interface": supported, - "interior.interface": supported, - "type.interface": supported, - - "statement.iteration.interface": supported, - "name.iteration.interface": supported, - "type.iteration.interface": supported, - - // "standard" functions & methods - namedFunction: supported, - "namedFunction.method": supported, - "statement.function": supported, - "statement.method": supported, - "name.function": supported, - "name.method": supported, - "interior.function": supported, - "interior.method": supported, - - // constructors - "namedFunction.constructor": supported, - "statement.constructor": supported, - "name.constructor": supported, - "interior.constructor": supported, - - // protocol method declarations - "statement.method.interface": supported, - "name.method.interface": supported, - - // closures/lambda functions + disqualifyDelimiter: supported, + pairDelimiter: supported, anonymousFunction: supported, - "interior.lambda": supported, - - // function calls - functionCall: supported, - "statement.functionCall": supported, - "functionCall.constructor": supported, - "functionCall.method": supported, - "functionCall.chain": supported, - "functionCall.generic": supported, - "functionCall.enum": supported, - - // function callee - functionCallee: supported, - "functionCallee.constructor": supported, - "functionCallee.method": supported, - "functionCallee.chain": supported, - "functionCallee.generic": supported, - "functionCallee.enum": supported, + list: supported, + map: supported, + regularExpression: supported, - // argument (actual; as in parameters as passed to a call) "argument.actual.singleLine": supported, "argument.actual.multiLine": supported, + "argument.actual.iteration": supported, "argument.actual.method.singleLine": supported, "argument.actual.method.multiLine": supported, + "argument.actual.method.iteration": supported, "argument.actual.constructor.singleLine": supported, "argument.actual.constructor.multiLine": supported, + "argument.actual.constructor.iteration": supported, "argument.actual.enum.singleLine": supported, "argument.actual.enum.multiLine": supported, - - "argument.actual.iteration": supported, - "argument.actual.method.iteration": supported, - "argument.actual.constructor.iteration": supported, "argument.actual.enum.iteration": supported, - - // argument (formal; as in the argument members within a callable block and its declaration) "argument.formal.singleLine": supported, "argument.formal.multiLine": supported, + "argument.formal.iteration": supported, "argument.formal.method.singleLine": supported, "argument.formal.method.multiLine": supported, + "argument.formal.method.iteration": supported, "argument.formal.constructor.singleLine": supported, "argument.formal.constructor.multiLine": supported, + "argument.formal.constructor.iteration": supported, "argument.formal.lambda.singleLine": supported, "argument.formal.lambda.multiLine": supported, - "argument.formal.catch": supported, - - "argument.formal.iteration": supported, - "argument.formal.method.iteration": supported, - "argument.formal.constructor.iteration": supported, "argument.formal.lambda.iteration": supported, + "argument.formal.catch": supported, - // argument list (actual) "argumentList.actual.empty": supported, "argumentList.actual.singleLine": supported, "argumentList.actual.multiLine": supported, @@ -184,155 +49,226 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "argumentList.actual.enum.empty": supported, "argumentList.actual.enum.singleLine": supported, "argumentList.actual.enum.multiLine": supported, - - // argument list (formal) "argumentList.formal.empty": supported, "argumentList.formal.singleLine": supported, "argumentList.formal.multiLine": supported, - "argumentList.formal.lambda.empty": supported, - "argumentList.formal.lambda.singleLine": supported, - "argumentList.formal.lambda.multiLine": supported, "argumentList.formal.method.empty": supported, "argumentList.formal.method.singleLine": supported, "argumentList.formal.method.multiLine": supported, "argumentList.formal.constructor.empty": supported, "argumentList.formal.constructor.singleLine": supported, "argumentList.formal.constructor.multiLine": supported, + "argumentList.formal.lambda.empty": supported, + "argumentList.formal.lambda.singleLine": supported, + "argumentList.formal.lambda.multiLine": supported, + "collectionItem.unenclosed.singleLine": supported, + "collectionItem.unenclosed.multiLine": supported, + "collectionItem.unenclosed.iteration": supported, + + "branch.if": supported, + "branch.if.elif.else": supported, + "branch.if.else": supported, + "branch.if.iteration": supported, + "branch.try": supported, + "branch.try.iteration": supported, + "branch.switchCase": supported, + "branch.switchCase.iteration": supported, + "branch.ternary": supported, + "branch.ternary.iteration": supported, + + class: supported, + "class.iteration.document": supported, + "class.iteration.class": supported, + + "comment.line": supported, + "comment.block": supported, + + "condition.if": supported, + "condition.while": supported, + "condition.doWhile": supported, + "condition.ternary": supported, + "condition.switchCase": supported, + "condition.switchCase.iteration": supported, + + functionCall: supported, + "functionCall.constructor": supported, + "functionCall.method": supported, + "functionCall.chain": supported, + "functionCall.generic": supported, + "functionCall.enum": supported, + + functionCallee: supported, + "functionCallee.constructor": supported, + "functionCallee.method": supported, + "functionCallee.chain": supported, + "functionCallee.generic": supported, + "functionCallee.enum": supported, + + namedFunction: supported, + "namedFunction.constructor": supported, + "namedFunction.method": supported, + "namedFunction.iteration.document": supported, + "namedFunction.iteration.class": supported, + + ifStatement: supported, + + "statement.class": supported, + "statement.interface": supported, + "statement.enum": supported, "statement.field.class": supported, "statement.field.interface": supported, + "statement.function": supported, + "statement.constructor": supported, + "statement.method": supported, + "statement.method.interface": supported, + "statement.functionCall": supported, + "statement.if": supported, + "statement.try": supported, + "statement.switch": supported, + "statement.foreach": supported, + "statement.while": supported, + "statement.doWhile": supported, "statement.variable.uninitialized": supported, "statement.variable.initialized": supported, "statement.variable.destructuring": supported, "statement.constant": supported, - - "name.field.class": supported, - "name.field.interface": supported, - "name.field.enum": supported, - "name.variable.uninitialized": supported, - "name.variable.initialized": supported, - "name.variable.destructuring": supported, - "name.constant": supported, - - "value.constant": supported, - "value.field.class": supported, - "value.field.interface": supported, - "value.field.enum": supported, - "value.variable": supported, - "value.variable.destructuring": supported, - - "type.constant": supported, - "type.variable.uninitialized": supported, - "type.variable.initialized": supported, - "type.field.class": supported, - "type.field.interface": supported, - - // assignments "statement.assignment": supported, "statement.assignment.destructuring": supported, "statement.assignment.compound": supported, - "name.assignment": supported, - "name.assignment.destructuring": supported, - "name.assignment.compound": supported, + "statement.typeAlias": supported, + "statement.return": supported, + "statement.throw": supported, + "statement.break": supported, + "statement.continue": supported, + "statement.import": supported, + "statement.misc": supported, + "statement.iteration.document": supported, + "statement.iteration.class": supported, + "statement.iteration.interface": supported, + "statement.iteration.block": supported, - "value.assignment": supported, - "value.assignment.destructuring": supported, - "value.assignment.compound": supported, + "string.singleLine": supported, + "string.multiLine": supported, - // comments - "comment.line": supported, "textFragment.comment.line": supported, "textFragment.comment.block": supported, - "comment.block": supported, - - // strings - "string.singleLine": supported, - "string.multiLine": supported, - "textFragment.string.multiLine": supported, "textFragment.string.singleLine": supported, + "textFragment.string.multiLine": supported, + "textFragment.regularExpression": supported, - // document-wide iteration - "statement.iteration.document": supported, - "class.iteration.document": supported, - "namedFunction.iteration.document": supported, - "name.iteration.document": supported, - "value.iteration.document": supported, - "type.iteration.document": supported, - - // general per-block iteration (not branches) - "statement.iteration.block": supported, - "name.iteration.block": supported, - "value.iteration.block": supported, - "type.iteration.block": supported, - - // unenclosed collection item - "collectionItem.unenclosed.singleLine": supported, - "collectionItem.unenclosed.multiLine": supported, - "collectionItem.unenclosed.iteration": supported, - - // enclosed collections - map: supported, - list: supported, - "key.mapPair": supported, - "key.mapPair.iteration": supported, - "value.mapPair": supported, - "value.mapPair.iteration": supported, - - // argument names + "name.variable.uninitialized": supported, + "name.variable.initialized": supported, + "name.variable.destructuring": supported, + "name.constant": supported, + "name.assignment": supported, + "name.assignment.destructuring": supported, + "name.assignment.compound": supported, + "name.typeAlias": supported, + "name.foreach": supported, + "name.function": supported, + "name.method": supported, + "name.method.interface": supported, + "name.constructor": supported, + "name.class": supported, + "name.interface": supported, + "name.enum": supported, + "name.field.class": supported, + "name.field.interface": supported, + "name.field.enum": supported, "name.argument.actual": supported, + "name.argument.actual.iteration": supported, "name.argument.formal": supported, + "name.argument.formal.iteration": supported, "name.argument.formal.method": supported, + "name.argument.formal.method.iteration": supported, "name.argument.formal.lambda": supported, + "name.argument.formal.lambda.iteration": supported, "name.argument.formal.constructor": supported, + "name.argument.formal.constructor.iteration": supported, "name.argument.catch": supported, + "name.iteration.document": supported, + "name.iteration.class": supported, + "name.iteration.block": supported, + "name.iteration.interface": supported, + "name.iteration.enum": supported, - "name.argument.actual.iteration": supported, - "name.argument.formal.iteration": supported, - "name.argument.formal.method.iteration": supported, - "name.argument.formal.lambda.iteration": supported, - "name.argument.formal.constructor.iteration": supported, + "key.mapPair": supported, + "key.mapPair.iteration": supported, - // argument values + "value.variable": supported, + "value.variable.destructuring": supported, + "value.constant": supported, + "value.assignment": supported, + "value.assignment.destructuring": supported, + "value.assignment.compound": supported, + "value.mapPair": supported, + "value.mapPair.iteration": supported, + "value.foreach": supported, + "value.return": supported, + "value.return.lambda": supported, + "value.field.class": supported, + "value.field.enum": supported, + "value.throw": supported, + "value.switch": supported, + "value.typeAlias": supported, "value.argument.actual": supported, - "value.argument.formal": supported, - "value.argument.formal.method": supported, - "value.argument.formal.constructor": supported, - "value.argument.formal.lambda": supported, - "value.argument.actual.iteration": supported, + "value.argument.formal": supported, "value.argument.formal.iteration": supported, + "value.argument.formal.method": supported, "value.argument.formal.method.iteration": supported, + "value.argument.formal.constructor": supported, "value.argument.formal.constructor.iteration": supported, - "value.argument.formal.lambda.iteration": supported, + "value.iteration.block": supported, + "value.iteration.class": supported, + "value.iteration.enum": supported, + "value.iteration.document": supported, - // argument types + "type.variable.uninitialized": supported, + "type.variable.initialized": supported, + "type.constant": supported, + "type.return": supported, + "type.return.method": supported, + "type.return.lambda": supported, + "type.field.class": supported, + "type.field.interface": supported, + "type.foreach": supported, + "type.alias": supported, + "type.cast": supported, + "type.class": supported, + "type.interface": supported, + "type.enum": supported, + "type.typeArgument": supported, + "type.typeArgument.iteration": supported, "type.argument.formal": supported, - "type.argument.formal.method": supported, - "type.argument.formal.lambda": supported, - "type.argument.formal.constructor": supported, - "type.argument.catch": supported, - "type.argument.formal.iteration": supported, + "type.argument.formal.method": supported, "type.argument.formal.method.iteration": supported, + "type.argument.formal.lambda": supported, "type.argument.formal.lambda.iteration": supported, + "type.argument.formal.constructor": supported, "type.argument.formal.constructor.iteration": supported, + "type.argument.catch": supported, + "type.iteration.block": supported, + "type.iteration.class": supported, + "type.iteration.interface": supported, + "type.iteration.document": supported, - // type aliases - "name.typeAlias": supported, - "value.typeAlias": supported, - "statement.typeAlias": supported, - "statement.misc": supported, - "type.typeArgument": supported, - "type.alias": supported, - "type.cast": supported, - "type.typeArgument.iteration": supported, - - // misc - regularExpression: supported, - disqualifyDelimiter: supported, - pairDelimiter: supported, - "textFragment.regularExpression": supported, - "statement.import": supported, + "interior.class": supported, + "interior.interface": supported, + "interior.enum": supported, + "interior.function": supported, + "interior.constructor": supported, + "interior.method": supported, + "interior.lambda": supported, + "interior.if": supported, + "interior.try": supported, + "interior.switch": supported, + "interior.switchCase": supported, + "interior.foreach": supported, + "interior.while": supported, + "interior.doWhile": supported, /* UNSUPPORTED */ @@ -340,31 +276,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { /* 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, - subSection: notApplicable, - subSubSection: notApplicable, - sectionLevelOne: notApplicable, - sectionLevelTwo: notApplicable, - sectionLevelThree: notApplicable, - sectionLevelFour: notApplicable, - sectionLevelFive: notApplicable, - sectionLevelSix: notApplicable, - subParagraph: notApplicable, - namedParagraph: notApplicable, - chapter: notApplicable, - part: notApplicable, - "section.iteration.document": notApplicable, - "section.iteration.parent": notApplicable, + // Element and tags element: notApplicable, tags: notApplicable, startTag: notApplicable, @@ -374,11 +286,11 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { attribute: notApplicable, "key.attribute": notApplicable, "value.attribute": notApplicable, - environment: notApplicable, - notebookCell: notApplicable, - selector: notApplicable, - unit: notApplicable, - "interior.cell": notApplicable, + + // Section + section: notApplicable, + "section.iteration.document": notApplicable, + "section.iteration.parent": notApplicable, // Command command: notApplicable, @@ -387,23 +299,64 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "value.command": notApplicable, "interior.command": notApplicable, - // Resource + // Notebook cell + notebookCell: notApplicable, + "interior.cell": notApplicable, + + // Resource syntax "statement.resource": notApplicable, "name.resource": notApplicable, "value.resource": notApplicable, "type.resource": notApplicable, "interior.resource": notApplicable, - // Explicit namespace declarations + // Namespace "statement.namespace": notApplicable, "name.namespace": notApplicable, "interior.namespace": notApplicable, - // Misc + // Loop else branch + "branch.loop": notApplicable, + "branch.loop.iteration": notApplicable, + + // C-style for loop + "statement.for": notApplicable, + "condition.for": notApplicable, + "interior.for": notApplicable, + + // Update statement "statement.update": notApplicable, - "statement.package": notApplicable, - "statement.yield": notApplicable, - "value.yield": notApplicable, - "interior.static": notApplicable, + + // Static initialization block "statement.static": notApplicable, + "interior.static": notApplicable, + + // Package declaration + "statement.package": notApplicable, + + // Default argument value in closures + "value.argument.formal.lambda": notApplicable, + "value.argument.formal.lambda.iteration": notApplicable, + + // Protocol property value + "value.field.interface": notApplicable, + + // Document + chapter: notApplicable, + subSection: notApplicable, + subSubSection: notApplicable, + sectionLevelOne: notApplicable, + sectionLevelTwo: notApplicable, + sectionLevelThree: notApplicable, + sectionLevelFour: notApplicable, + sectionLevelFive: notApplicable, + sectionLevelSix: notApplicable, + namedParagraph: notApplicable, + subParagraph: notApplicable, + part: notApplicable, + + // Miscellaneous + environment: notApplicable, + selector: notApplicable, + unit: notApplicable, }; diff --git a/resources/fixtures/scopes/swift/anonymousFunction.scope b/resources/fixtures/scopes/swift/anonymousFunction.scope new file mode 100644 index 0000000000..1430b8a0cd --- /dev/null +++ b/resources/fixtures/scopes/swift/anonymousFunction.scope @@ -0,0 +1,10 @@ +{ () -> Int in 0 } +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| { () -> Int in 0 } + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch.if.elif.else.scope b/resources/fixtures/scopes/swift/branch/branch.if.elif.else.scope similarity index 100% rename from resources/fixtures/scopes/swift/branch.if.elif.else.scope rename to resources/fixtures/scopes/swift/branch/branch.if.elif.else.scope diff --git a/resources/fixtures/scopes/swift/branch.if.else.scope b/resources/fixtures/scopes/swift/branch/branch.if.else.scope similarity index 100% rename from resources/fixtures/scopes/swift/branch.if.else.scope rename to resources/fixtures/scopes/swift/branch/branch.if.else.scope diff --git a/resources/fixtures/scopes/swift/branch.if.iteration.scope b/resources/fixtures/scopes/swift/branch/branch.if.iteration.scope similarity index 100% rename from resources/fixtures/scopes/swift/branch.if.iteration.scope rename to resources/fixtures/scopes/swift/branch/branch.if.iteration.scope diff --git a/resources/fixtures/scopes/swift/branch.if.scope b/resources/fixtures/scopes/swift/branch/branch.if.scope similarity index 100% rename from resources/fixtures/scopes/swift/branch.if.scope rename to resources/fixtures/scopes/swift/branch/branch.if.scope diff --git a/resources/fixtures/scopes/swift/branch/branch.ternary.iteration.scope b/resources/fixtures/scopes/swift/branch/branch.ternary.iteration.scope new file mode 100644 index 0000000000..b1deb5daa4 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.ternary.iteration.scope @@ -0,0 +1,7 @@ +foo ? 0 : 1 +--- + +[Content] = +[Domain] = 0:0-0:11 + >-----------< +0| foo ? 0 : 1 diff --git a/resources/fixtures/scopes/swift/branch/branch.ternary.scope b/resources/fixtures/scopes/swift/branch/branch.ternary.scope new file mode 100644 index 0000000000..2a30971d42 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.ternary.scope @@ -0,0 +1,37 @@ +foo ? 0 : 1 +--- + +[#1 Content] = +[#1 Domain] = 0:6-0:7 + >-< +0| foo ? 0 : 1 + +[#1 Removal] = 0:6-0:8 + >--< +0| foo ? 0 : 1 + +[#1 Leading delimiter] = 0:5-0:6 + >-< +0| foo ? 0 : 1 + +[#1 Trailing delimiter] = 0:7-0:8 + >-< +0| foo ? 0 : 1 + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 0:10-0:11 + >-< +0| foo ? 0 : 1 + +[#2 Removal] = 0:9-0:11 + >--< +0| foo ? 0 : 1 + +[#2 Leading delimiter] = 0:9-0:10 + >-< +0| foo ? 0 : 1 + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch/branch.try.iteration.scope b/resources/fixtures/scopes/swift/branch/branch.try.iteration.scope new file mode 100644 index 0000000000..a2d557db66 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.try.iteration.scope @@ -0,0 +1,10 @@ +do {} +catch {} +--- + +[Content] = +[Domain] = 0:0-1:8 + >----- +0| do {} +1| catch {} + --------< diff --git a/resources/fixtures/scopes/swift/branch/branch.try.scope b/resources/fixtures/scopes/swift/branch/branch.try.scope new file mode 100644 index 0000000000..b92d53331e --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.try.scope @@ -0,0 +1,30 @@ +do {} +catch {} +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:5 + >-----< +0| do {} + +[#1 Removal] = 0:0-1:0 + >----- +0| do {} +1| catch {} + < + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:0-1:8 + >--------< +1| catch {} + +[#2 Removal] = 0:5-1:8 + > +0| do {} +1| catch {} + --------< + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/class.iteration.document.scope b/resources/fixtures/scopes/swift/class.iteration.document.scope new file mode 100644 index 0000000000..c3d14f02e1 --- /dev/null +++ b/resources/fixtures/scopes/swift/class.iteration.document.scope @@ -0,0 +1,12 @@ + +struct Foo {} + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| struct Foo {} +2| + < diff --git a/resources/fixtures/scopes/swift/collectionItem.unenclosed.iteration.scope b/resources/fixtures/scopes/swift/collectionItem.unenclosed.iteration.scope new file mode 100644 index 0000000000..1bb6585874 --- /dev/null +++ b/resources/fixtures/scopes/swift/collectionItem.unenclosed.iteration.scope @@ -0,0 +1,7 @@ +let foo = 0, bar = 1 +--- + +[Content] = +[Domain] = 0:0-0:20 + >--------------------< +0| let foo = 0, bar = 1 diff --git a/resources/fixtures/scopes/swift/condition.if.scope b/resources/fixtures/scopes/swift/condition/condition.if.scope similarity index 100% rename from resources/fixtures/scopes/swift/condition.if.scope rename to resources/fixtures/scopes/swift/condition/condition.if.scope diff --git a/resources/fixtures/scopes/swift/condition/condition.ternary.scope b/resources/fixtures/scopes/swift/condition/condition.ternary.scope new file mode 100644 index 0000000000..de80654a5f --- /dev/null +++ b/resources/fixtures/scopes/swift/condition/condition.ternary.scope @@ -0,0 +1,20 @@ +foo ? 0 : 1 +--- + +[Content] = 0:0-0:3 + >---< +0| foo ? 0 : 1 + +[Removal] = 0:0-0:4 + >----< +0| foo ? 0 : 1 + +[Trailing delimiter] = 0:3-0:4 + >-< +0| foo ? 0 : 1 + +[Domain] = 0:0-0:11 + >-----------< +0| foo ? 0 : 1 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/condition/condition.while.scope b/resources/fixtures/scopes/swift/condition/condition.while.scope new file mode 100644 index 0000000000..ef535c29be --- /dev/null +++ b/resources/fixtures/scopes/swift/condition/condition.while.scope @@ -0,0 +1,24 @@ +while foo {} +--- + +[Content] = 0:6-0:9 + >---< +0| while foo {} + +[Removal] = 0:6-0:10 + >----< +0| while foo {} + +[Leading delimiter] = 0:5-0:6 + >-< +0| while foo {} + +[Trailing delimiter] = 0:9-0:10 + >-< +0| while foo {} + +[Domain] = 0:0-0:12 + >------------< +0| while foo {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.class.scope b/resources/fixtures/scopes/swift/interior/interior.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.class.scope rename to resources/fixtures/scopes/swift/interior/interior.class.scope diff --git a/resources/fixtures/scopes/swift/interior/interior.constructor.scope b/resources/fixtures/scopes/swift/interior/interior.constructor.scope new file mode 100644 index 0000000000..8503cb88bb --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.constructor.scope @@ -0,0 +1,27 @@ +struct Foo { + init() { } +} +--- + +[#1 Content] = 1:2-1:12 + >----------< +1| init() { } + +[#1 Removal] = +[#1 Domain] = 0:12-2:0 + > +0| struct Foo { +1| init() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:10-1:11 + >-< +1| init() { } + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior/interior.doWhile.scope b/resources/fixtures/scopes/swift/interior/interior.doWhile.scope new file mode 100644 index 0000000000..16e7fb5fb8 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.doWhile.scope @@ -0,0 +1,10 @@ +repeat { } while foo +--- + +[Content] = +[Removal] = +[Domain] = 0:8-0:9 + >-< +0| repeat { } while foo + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.enum.scope b/resources/fixtures/scopes/swift/interior/interior.enum.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.enum.scope rename to resources/fixtures/scopes/swift/interior/interior.enum.scope diff --git a/resources/fixtures/scopes/swift/interior.foreach.scope b/resources/fixtures/scopes/swift/interior/interior.foreach.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.foreach.scope rename to resources/fixtures/scopes/swift/interior/interior.foreach.scope diff --git a/resources/fixtures/scopes/swift/interior/interior.function.scope b/resources/fixtures/scopes/swift/interior/interior.function.scope new file mode 100644 index 0000000000..7c395916ef --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.function.scope @@ -0,0 +1,10 @@ +func foo() { } +--- + +[Content] = +[Removal] = +[Domain] = 0:12-0:13 + >-< +0| func foo() { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.if.scope b/resources/fixtures/scopes/swift/interior/interior.if.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.if.scope rename to resources/fixtures/scopes/swift/interior/interior.if.scope diff --git a/resources/fixtures/scopes/swift/interior.if2.scope b/resources/fixtures/scopes/swift/interior/interior.if2.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.if2.scope rename to resources/fixtures/scopes/swift/interior/interior.if2.scope diff --git a/resources/fixtures/scopes/swift/interior.if3.scope b/resources/fixtures/scopes/swift/interior/interior.if3.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.if3.scope rename to resources/fixtures/scopes/swift/interior/interior.if3.scope diff --git a/resources/fixtures/scopes/swift/interior.if4.scope b/resources/fixtures/scopes/swift/interior/interior.if4.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.if4.scope rename to resources/fixtures/scopes/swift/interior/interior.if4.scope diff --git a/resources/fixtures/scopes/swift/interior.interface.scope b/resources/fixtures/scopes/swift/interior/interior.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/interior.interface.scope rename to resources/fixtures/scopes/swift/interior/interior.interface.scope diff --git a/resources/fixtures/scopes/swift/interior/interior.method.scope b/resources/fixtures/scopes/swift/interior/interior.method.scope new file mode 100644 index 0000000000..e5063171eb --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.method.scope @@ -0,0 +1,27 @@ +struct Foo { + func bar() { } +} +--- + +[#1 Content] = 1:2-1:16 + >--------------< +1| func bar() { } + +[#1 Removal] = +[#1 Domain] = 0:12-2:0 + > +0| struct Foo { +1| func bar() { } +2| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:14-1:15 + >-< +1| func bar() { } + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior/interior.switch.scope b/resources/fixtures/scopes/swift/interior/interior.switch.scope new file mode 100644 index 0000000000..5cabb1a765 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.switch.scope @@ -0,0 +1,10 @@ +switch value { } +--- + +[Content] = +[Removal] = +[Domain] = 0:14-0:15 + >-< +0| switch value { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior/interior.try.scope b/resources/fixtures/scopes/swift/interior/interior.try.scope new file mode 100644 index 0000000000..16d560261c --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.try.scope @@ -0,0 +1,20 @@ +do { } +catch { } +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:4-0:5 + >-< +0| do { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:7-1:8 + >-< +1| catch { } + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior/interior.while.scope b/resources/fixtures/scopes/swift/interior/interior.while.scope new file mode 100644 index 0000000000..cf2a2a635d --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.while.scope @@ -0,0 +1,10 @@ +while foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:11-0:12 + >-< +0| while foo { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.class.scope b/resources/fixtures/scopes/swift/name/name.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.class.scope rename to resources/fixtures/scopes/swift/name/name.class.scope diff --git a/resources/fixtures/scopes/swift/name/name.constant.scope b/resources/fixtures/scopes/swift/name/name.constant.scope new file mode 100644 index 0000000000..07ca5d9f60 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.constant.scope @@ -0,0 +1,24 @@ +let foo = 0 +--- + +[Content] = 0:4-0:7 + >---< +0| let foo = 0 + +[Removal] = 0:4-0:8 + >----< +0| let foo = 0 + +[Leading delimiter] = 0:3-0:4 + >-< +0| let foo = 0 + +[Trailing delimiter] = 0:7-0:8 + >-< +0| let foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| let foo = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.enum.scope b/resources/fixtures/scopes/swift/name/name.enum.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.enum.scope rename to resources/fixtures/scopes/swift/name/name.enum.scope diff --git a/resources/fixtures/scopes/swift/name/name.field.class.scope b/resources/fixtures/scopes/swift/name/name.field.class.scope new file mode 100644 index 0000000000..acc2e9ccca --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.field.class.scope @@ -0,0 +1,69 @@ +struct Foo { + var bar: Int + var baz: Int = 0 +} +--- + +[#1 Content] = 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 Domain] = 0:0-3:1 + >------------ +0| struct Foo { +1| var bar: Int +2| var baz: Int = 0 +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:11 + >---< +1| var bar: Int + +[#2 Removal] = 1:7-1:11 + >----< +1| var bar: Int + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| var bar: Int + +[#2 Domain] = 1:4-1:16 + >------------< +1| var bar: Int + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:8-2:11 + >---< +2| var baz: Int = 0 + +[#3 Removal] = 2:7-2:11 + >----< +2| var baz: Int = 0 + +[#3 Leading delimiter] = 2:7-2:8 + >-< +2| var baz: Int = 0 + +[#3 Domain] = 2:4-2:20 + >----------------< +2| var baz: Int = 0 + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.foreach.scope b/resources/fixtures/scopes/swift/name/name.foreach.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.foreach.scope rename to resources/fixtures/scopes/swift/name/name.foreach.scope diff --git a/resources/fixtures/scopes/swift/name.interface.scope b/resources/fixtures/scopes/swift/name/name.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.interface.scope rename to resources/fixtures/scopes/swift/name/name.interface.scope diff --git a/resources/fixtures/scopes/swift/name.iteration.block.scope b/resources/fixtures/scopes/swift/name/name.iteration.block.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.block.scope rename to resources/fixtures/scopes/swift/name/name.iteration.block.scope diff --git a/resources/fixtures/scopes/swift/name.iteration.block2.scope b/resources/fixtures/scopes/swift/name/name.iteration.block2.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.block2.scope rename to resources/fixtures/scopes/swift/name/name.iteration.block2.scope diff --git a/resources/fixtures/scopes/swift/name.iteration.block3.scope b/resources/fixtures/scopes/swift/name/name.iteration.block3.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.block3.scope rename to resources/fixtures/scopes/swift/name/name.iteration.block3.scope diff --git a/resources/fixtures/scopes/swift/name.iteration.block4.scope b/resources/fixtures/scopes/swift/name/name.iteration.block4.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.block4.scope rename to resources/fixtures/scopes/swift/name/name.iteration.block4.scope diff --git a/resources/fixtures/scopes/swift/name.iteration.class.scope b/resources/fixtures/scopes/swift/name/name.iteration.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.class.scope rename to resources/fixtures/scopes/swift/name/name.iteration.class.scope diff --git a/resources/fixtures/scopes/swift/name/name.iteration.document.scope b/resources/fixtures/scopes/swift/name/name.iteration.document.scope new file mode 100644 index 0000000000..ab3e11e7af --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.iteration.document.scope @@ -0,0 +1,14 @@ + +let foo = 0 +let bar = 1 + +--- + +[Content] = +[Domain] = 0:0-3:0 + > +0| +1| let foo = 0 +2| let bar = 1 +3| + < diff --git a/resources/fixtures/scopes/swift/name.iteration.enum.scope b/resources/fixtures/scopes/swift/name/name.iteration.enum.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.enum.scope rename to resources/fixtures/scopes/swift/name/name.iteration.enum.scope diff --git a/resources/fixtures/scopes/swift/name.iteration.interface.scope b/resources/fixtures/scopes/swift/name/name.iteration.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/name.iteration.interface.scope rename to resources/fixtures/scopes/swift/name/name.iteration.interface.scope diff --git a/resources/fixtures/scopes/swift/name/name.variable.initialized.scope b/resources/fixtures/scopes/swift/name/name.variable.initialized.scope new file mode 100644 index 0000000000..1cd9475d1d --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.variable.initialized.scope @@ -0,0 +1,24 @@ +var foo = 0 +--- + +[Content] = 0:4-0:7 + >---< +0| var foo = 0 + +[Removal] = 0:4-0:8 + >----< +0| var foo = 0 + +[Leading delimiter] = 0:3-0:4 + >-< +0| var foo = 0 + +[Trailing delimiter] = 0:7-0:8 + >-< +0| var foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| var foo = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.variable.uninitialized.scope b/resources/fixtures/scopes/swift/name/name.variable.uninitialized.scope new file mode 100644 index 0000000000..aadb078077 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.variable.uninitialized.scope @@ -0,0 +1,20 @@ +var foo: Int +--- + +[Content] = 0:4-0:7 + >---< +0| var foo: Int + +[Removal] = 0:3-0:7 + >----< +0| var foo: Int + +[Leading delimiter] = 0:3-0:4 + >-< +0| var foo: Int + +[Domain] = 0:0-0:12 + >------------< +0| var foo: Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement.class.scope b/resources/fixtures/scopes/swift/statement/statement.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.class.scope rename to resources/fixtures/scopes/swift/statement/statement.class.scope diff --git a/resources/fixtures/scopes/swift/statement/statement.constant.scope b/resources/fixtures/scopes/swift/statement/statement.constant.scope new file mode 100644 index 0000000000..837abc1652 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.constant.scope @@ -0,0 +1,10 @@ +let foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| let foo = 0 + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.doWhile.scope b/resources/fixtures/scopes/swift/statement/statement.doWhile.scope new file mode 100644 index 0000000000..94a69ac137 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.doWhile.scope @@ -0,0 +1,10 @@ +repeat {} while foo +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| repeat {} while foo + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.enum.scope b/resources/fixtures/scopes/swift/statement/statement.enum.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.enum.scope rename to resources/fixtures/scopes/swift/statement/statement.enum.scope diff --git a/resources/fixtures/scopes/swift/statement/statement.field.class.scope b/resources/fixtures/scopes/swift/statement/statement.field.class.scope new file mode 100644 index 0000000000..a84287473b --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.field.class.scope @@ -0,0 +1,33 @@ +struct Foo { + var bar = 0 +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| var bar = 0 +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:2-1:13 + >-----------< +1| var bar = 0 + +[#2 Removal] = 1:0-2:0 + >------------- +1| var bar = 0 +2| } + < + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| var bar = 0 + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.foreach.scope b/resources/fixtures/scopes/swift/statement/statement.foreach.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.foreach.scope rename to resources/fixtures/scopes/swift/statement/statement.foreach.scope diff --git a/resources/fixtures/scopes/swift/statement.if.scope b/resources/fixtures/scopes/swift/statement/statement.if.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.if.scope rename to resources/fixtures/scopes/swift/statement/statement.if.scope diff --git a/resources/fixtures/scopes/swift/statement.interface.scope b/resources/fixtures/scopes/swift/statement/statement.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.interface.scope rename to resources/fixtures/scopes/swift/statement/statement.interface.scope diff --git a/resources/fixtures/scopes/swift/statement.iteration.block.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.block.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.iteration.block.scope rename to resources/fixtures/scopes/swift/statement/statement.iteration.block.scope diff --git a/resources/fixtures/scopes/swift/statement.iteration.block2.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.block2.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.iteration.block2.scope rename to resources/fixtures/scopes/swift/statement/statement.iteration.block2.scope diff --git a/resources/fixtures/scopes/swift/statement.iteration.block3.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.block3.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.iteration.block3.scope rename to resources/fixtures/scopes/swift/statement/statement.iteration.block3.scope diff --git a/resources/fixtures/scopes/swift/statement.iteration.block4.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.block4.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.iteration.block4.scope rename to resources/fixtures/scopes/swift/statement/statement.iteration.block4.scope diff --git a/resources/fixtures/scopes/swift/statement.iteration.class.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.iteration.class.scope rename to resources/fixtures/scopes/swift/statement/statement.iteration.class.scope diff --git a/resources/fixtures/scopes/swift/statement/statement.iteration.document.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.document.scope new file mode 100644 index 0000000000..54abd7726c --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo: Int + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo: Int +2| + < diff --git a/resources/fixtures/scopes/swift/statement.iteration.interface.scope b/resources/fixtures/scopes/swift/statement/statement.iteration.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/statement.iteration.interface.scope rename to resources/fixtures/scopes/swift/statement/statement.iteration.interface.scope diff --git a/resources/fixtures/scopes/swift/statement/statement.try.scope b/resources/fixtures/scopes/swift/statement/statement.try.scope new file mode 100644 index 0000000000..1105e8f94f --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.try.scope @@ -0,0 +1,13 @@ +do {} +catch {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-1:8 + >----- +0| do {} +1| catch {} + --------< + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.variable.initialized.scope b/resources/fixtures/scopes/swift/statement/statement.variable.initialized.scope new file mode 100644 index 0000000000..4934548475 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.variable.initialized.scope @@ -0,0 +1,10 @@ +var foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| var foo = 0 + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.variable.uninitialized.scope b/resources/fixtures/scopes/swift/statement/statement.variable.uninitialized.scope new file mode 100644 index 0000000000..0c4f8800bd --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.variable.uninitialized.scope @@ -0,0 +1,10 @@ +var foo: Int +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:12 + >------------< +0| var foo: Int + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.while.scope b/resources/fixtures/scopes/swift/statement/statement.while.scope new file mode 100644 index 0000000000..fbccae0780 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.while.scope @@ -0,0 +1,10 @@ +while true {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| while true {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/textFragment.comment.block.scope b/resources/fixtures/scopes/swift/textFragment/textFragment.comment.block.scope similarity index 100% rename from resources/fixtures/scopes/swift/textFragment.comment.block.scope rename to resources/fixtures/scopes/swift/textFragment/textFragment.comment.block.scope diff --git a/resources/fixtures/scopes/swift/textFragment.comment.line.scope b/resources/fixtures/scopes/swift/textFragment/textFragment.comment.line.scope similarity index 100% rename from resources/fixtures/scopes/swift/textFragment.comment.line.scope rename to resources/fixtures/scopes/swift/textFragment/textFragment.comment.line.scope diff --git a/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope b/resources/fixtures/scopes/swift/textFragment/textFragment.string.multiLine.scope similarity index 100% rename from resources/fixtures/scopes/swift/textFragment.string.multiLine.scope rename to resources/fixtures/scopes/swift/textFragment/textFragment.string.multiLine.scope diff --git a/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope b/resources/fixtures/scopes/swift/textFragment/textFragment.string.singleLine.scope similarity index 100% rename from resources/fixtures/scopes/swift/textFragment.string.singleLine.scope rename to resources/fixtures/scopes/swift/textFragment/textFragment.string.singleLine.scope diff --git a/resources/fixtures/scopes/swift/type/type.class.scope b/resources/fixtures/scopes/swift/type/type.class.scope new file mode 100644 index 0000000000..b23e5da403 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.class.scope @@ -0,0 +1,10 @@ +class Foo: Bar {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| class Foo: Bar {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type.constant.scope b/resources/fixtures/scopes/swift/type/type.constant.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.constant.scope rename to resources/fixtures/scopes/swift/type/type.constant.scope diff --git a/resources/fixtures/scopes/swift/type.enum.scope b/resources/fixtures/scopes/swift/type/type.enum.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.enum.scope rename to resources/fixtures/scopes/swift/type/type.enum.scope diff --git a/resources/fixtures/scopes/swift/type.field.class.scope b/resources/fixtures/scopes/swift/type/type.field.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.field.class.scope rename to resources/fixtures/scopes/swift/type/type.field.class.scope diff --git a/resources/fixtures/scopes/swift/type.field.interface.scope b/resources/fixtures/scopes/swift/type/type.field.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.field.interface.scope rename to resources/fixtures/scopes/swift/type/type.field.interface.scope diff --git a/resources/fixtures/scopes/swift/type.foreach.scope b/resources/fixtures/scopes/swift/type/type.foreach.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.foreach.scope rename to resources/fixtures/scopes/swift/type/type.foreach.scope diff --git a/resources/fixtures/scopes/swift/type.interface.scope b/resources/fixtures/scopes/swift/type/type.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.interface.scope rename to resources/fixtures/scopes/swift/type/type.interface.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.block.scope b/resources/fixtures/scopes/swift/type/type.iteration.block.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.block.scope rename to resources/fixtures/scopes/swift/type/type.iteration.block.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.block2.scope b/resources/fixtures/scopes/swift/type/type.iteration.block2.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.block2.scope rename to resources/fixtures/scopes/swift/type/type.iteration.block2.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.block3.scope b/resources/fixtures/scopes/swift/type/type.iteration.block3.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.block3.scope rename to resources/fixtures/scopes/swift/type/type.iteration.block3.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.block4.scope b/resources/fixtures/scopes/swift/type/type.iteration.block4.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.block4.scope rename to resources/fixtures/scopes/swift/type/type.iteration.block4.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.class.scope b/resources/fixtures/scopes/swift/type/type.iteration.class.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.class.scope rename to resources/fixtures/scopes/swift/type/type.iteration.class.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.document.scope b/resources/fixtures/scopes/swift/type/type.iteration.document.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.document.scope rename to resources/fixtures/scopes/swift/type/type.iteration.document.scope diff --git a/resources/fixtures/scopes/swift/type.iteration.interface.scope b/resources/fixtures/scopes/swift/type/type.iteration.interface.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.iteration.interface.scope rename to resources/fixtures/scopes/swift/type/type.iteration.interface.scope diff --git a/resources/fixtures/scopes/swift/type.variable.initialized.scope b/resources/fixtures/scopes/swift/type/type.variable.initialized.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.variable.initialized.scope rename to resources/fixtures/scopes/swift/type/type.variable.initialized.scope diff --git a/resources/fixtures/scopes/swift/type.variable.uninitialized.scope b/resources/fixtures/scopes/swift/type/type.variable.uninitialized.scope similarity index 100% rename from resources/fixtures/scopes/swift/type.variable.uninitialized.scope rename to resources/fixtures/scopes/swift/type/type.variable.uninitialized.scope diff --git a/resources/fixtures/scopes/swift/value/value.constant.scope b/resources/fixtures/scopes/swift/value/value.constant.scope new file mode 100644 index 0000000000..6e9832c52a --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.constant.scope @@ -0,0 +1,20 @@ +let foo = 0 +--- + +[Content] = 0:10-0:11 + >-< +0| let foo = 0 + +[Removal] = 0:8-0:11 + >---< +0| let foo = 0 + +[Leading delimiter] = 0:8-0:10 + >--< +0| let foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| let foo = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value.foreach.scope b/resources/fixtures/scopes/swift/value/value.foreach.scope similarity index 100% rename from resources/fixtures/scopes/swift/value.foreach.scope rename to resources/fixtures/scopes/swift/value/value.foreach.scope diff --git a/resources/fixtures/scopes/swift/value.iteration.block.scope b/resources/fixtures/scopes/swift/value/value.iteration.block.scope similarity index 100% rename from resources/fixtures/scopes/swift/value.iteration.block.scope rename to resources/fixtures/scopes/swift/value/value.iteration.block.scope diff --git a/resources/fixtures/scopes/swift/value.iteration.block2.scope b/resources/fixtures/scopes/swift/value/value.iteration.block2.scope similarity index 100% rename from resources/fixtures/scopes/swift/value.iteration.block2.scope rename to resources/fixtures/scopes/swift/value/value.iteration.block2.scope diff --git a/resources/fixtures/scopes/swift/value.iteration.block3.scope b/resources/fixtures/scopes/swift/value/value.iteration.block3.scope similarity index 100% rename from resources/fixtures/scopes/swift/value.iteration.block3.scope rename to resources/fixtures/scopes/swift/value/value.iteration.block3.scope diff --git a/resources/fixtures/scopes/swift/value.iteration.block4.scope b/resources/fixtures/scopes/swift/value/value.iteration.block4.scope similarity index 100% rename from resources/fixtures/scopes/swift/value.iteration.block4.scope rename to resources/fixtures/scopes/swift/value/value.iteration.block4.scope diff --git a/resources/fixtures/scopes/swift/value/value.iteration.class.scope b/resources/fixtures/scopes/swift/value/value.iteration.class.scope new file mode 100644 index 0000000000..10699070e9 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.iteration.class.scope @@ -0,0 +1,13 @@ +struct Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| struct Foo { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| struct Foo { } diff --git a/resources/fixtures/scopes/swift/value/value.iteration.document.scope b/resources/fixtures/scopes/swift/value/value.iteration.document.scope new file mode 100644 index 0000000000..54abd7726c --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.iteration.document.scope @@ -0,0 +1,12 @@ + +var foo: Int + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| var foo: Int +2| + < diff --git a/resources/fixtures/scopes/swift/value.iteration.enum.scope b/resources/fixtures/scopes/swift/value/value.iteration.enum.scope similarity index 100% rename from resources/fixtures/scopes/swift/value.iteration.enum.scope rename to resources/fixtures/scopes/swift/value/value.iteration.enum.scope diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 7279f9e03f..bc5d74ed69 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -3,8 +3,12 @@ [ (class_declaration) (protocol_declaration) - (for_statement) (property_declaration) + (for_statement) + (do_statement) + (while_statement) + (repeat_while_statement) + (switch_statement) ;; Disabled on purpose. We have a better definition of these below. ;; (if_statement) @@ -216,3 +220,48 @@ (_) @type ) ) @_.domain + +;;!! { (aaa: Int) -> Int in 0 } +(lambda_literal) @anonymousFunction + +;;!! do {} catch {} +;;! ^^^^^ +(do_statement + "do" @branch.start + "}" @branch.end + (catch_block) +) @branch.iteration + +;;!! do {} catch {} +;;! ^^^^^^^^ +(do_statement + (catch_block) @branch +) + +;;!! true ? 0 : 1 +;;! ^^^^ +;;! ^ +(ternary_expression + condition: (_) @condition + if_true: (_) @branch +) @condition.domain @branch.iteration + +;;!! true ? 0 : 1 +;;! ^ +(ternary_expression + if_false: (_) @branch +) + +;;!! while true {} +;;! ^^^^ +(while_statement + condition: (_) @condition +) @condition.domain + +;;!! repeat {} while true +;;! ^^^^ +(repeat_while_statement + condition: (_) @condition +) @condition.domain + +;; (switch_statement) From 4d53618d07e82e72ba3527725c4455f171a731cd Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 17:02:34 +0200 Subject: [PATCH 43/46] more fixtures --- .../src/scopeSupportFacets/swift.ts | 16 ++-- .../functionCall/functionCall.chain.scope | 19 +++++ .../functionCall.constructor.scope | 10 +++ .../functionCall/functionCall.enum.scope | 10 +++ .../functionCall/functionCall.method.scope | 10 +++ .../swift/functionCall/functionCall.scope | 10 +++ .../functionCallee/functionCallee.chain.scope | 25 ++++++ .../functionCallee.constructor.scope | 13 +++ .../functionCallee/functionCallee.enum.scope | 13 +++ .../functionCallee.method.scope | 13 +++ .../swift/functionCallee/functionCallee.scope | 13 +++ .../scopes/swift/name/name.field.enum.scope | 73 +++++++++++++++++ .../swift/name/name.field.interface.scope | 48 +++++++++++ .../namedFunction.constructor.scope | 21 +++++ .../namedFunction.iteration.class.scope | 13 +++ .../namedFunction.iteration.document.scope | 12 +++ .../namedFunction/namedFunction.method.scope | 21 +++++ .../swift/namedFunction/namedFunction.scope | 10 +++ .../scopes/swift/regularExpression.scope | 10 +++ .../statement/statement.assignment.scope | 10 +++ .../statement/statement.constructor.scope | 33 ++++++++ .../statement/statement.field.interface.scope | 33 ++++++++ .../swift/statement/statement.function.scope | 10 +++ .../statement/statement.functionCall.scope | 10 +++ .../statement.method.interface.scope | 33 ++++++++ .../swift/statement/statement.method.scope | 33 ++++++++ .../textFragment.regularExpression.scope | 10 +++ .../scopes/swift/value/value.assignment.scope | 17 ++++ .../scopes/swift/value/value.constant.scope | 8 +- .../swift/value/value.field.class.scope | 42 ++++++++++ .../scopes/swift/value/value.field.enum.scope | 22 +++++ .../scopes/swift/value/value.variable.scope | 20 +++++ resources/queries/swift.scm | 81 ++++++++++++++++--- 33 files changed, 697 insertions(+), 25 deletions(-) create mode 100644 resources/fixtures/scopes/swift/functionCall/functionCall.chain.scope create mode 100644 resources/fixtures/scopes/swift/functionCall/functionCall.constructor.scope create mode 100644 resources/fixtures/scopes/swift/functionCall/functionCall.enum.scope create mode 100644 resources/fixtures/scopes/swift/functionCall/functionCall.method.scope create mode 100644 resources/fixtures/scopes/swift/functionCall/functionCall.scope create mode 100644 resources/fixtures/scopes/swift/functionCallee/functionCallee.chain.scope create mode 100644 resources/fixtures/scopes/swift/functionCallee/functionCallee.constructor.scope create mode 100644 resources/fixtures/scopes/swift/functionCallee/functionCallee.enum.scope create mode 100644 resources/fixtures/scopes/swift/functionCallee/functionCallee.method.scope create mode 100644 resources/fixtures/scopes/swift/functionCallee/functionCallee.scope create mode 100644 resources/fixtures/scopes/swift/name/name.field.enum.scope create mode 100644 resources/fixtures/scopes/swift/name/name.field.interface.scope create mode 100644 resources/fixtures/scopes/swift/namedFunction/namedFunction.constructor.scope create mode 100644 resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.class.scope create mode 100644 resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.document.scope create mode 100644 resources/fixtures/scopes/swift/namedFunction/namedFunction.method.scope create mode 100644 resources/fixtures/scopes/swift/namedFunction/namedFunction.scope create mode 100644 resources/fixtures/scopes/swift/regularExpression.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.assignment.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.constructor.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.field.interface.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.function.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.functionCall.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.method.interface.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.method.scope create mode 100644 resources/fixtures/scopes/swift/textFragment/textFragment.regularExpression.scope create mode 100644 resources/fixtures/scopes/swift/value/value.assignment.scope create mode 100644 resources/fixtures/scopes/swift/value/value.field.class.scope create mode 100644 resources/fixtures/scopes/swift/value/value.field.enum.scope create mode 100644 resources/fixtures/scopes/swift/value/value.variable.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 65fc23f406..45ac5a6ca1 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -95,14 +95,12 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "functionCall.constructor": supported, "functionCall.method": supported, "functionCall.chain": supported, - "functionCall.generic": supported, "functionCall.enum": supported, functionCallee: supported, "functionCallee.constructor": supported, "functionCallee.method": supported, "functionCallee.chain": supported, - "functionCallee.generic": supported, "functionCallee.enum": supported, namedFunction: supported, @@ -324,23 +322,18 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "condition.for": notApplicable, "interior.for": notApplicable, - // Update statement - "statement.update": notApplicable, + // Generic function call + "functionCall.generic": notApplicable, + "functionCallee.generic": notApplicable, // Static initialization block "statement.static": notApplicable, "interior.static": notApplicable, - // Package declaration - "statement.package": notApplicable, - // Default argument value in closures "value.argument.formal.lambda": notApplicable, "value.argument.formal.lambda.iteration": notApplicable, - // Protocol property value - "value.field.interface": notApplicable, - // Document chapter: notApplicable, subSection: notApplicable, @@ -356,6 +349,9 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { part: notApplicable, // Miscellaneous + "value.field.interface": notApplicable, + "statement.package": notApplicable, + "statement.update": notApplicable, environment: notApplicable, selector: notApplicable, unit: notApplicable, diff --git a/resources/fixtures/scopes/swift/functionCall/functionCall.chain.scope b/resources/fixtures/scopes/swift/functionCall/functionCall.chain.scope new file mode 100644 index 0000000000..c73434c70d --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCall/functionCall.chain.scope @@ -0,0 +1,19 @@ +foo().bar() +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-0:5 + >-----< +0| foo().bar() + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:0-0:11 + >-----------< +0| foo().bar() + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCall/functionCall.constructor.scope b/resources/fixtures/scopes/swift/functionCall/functionCall.constructor.scope new file mode 100644 index 0000000000..c6d74f15a1 --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCall/functionCall.constructor.scope @@ -0,0 +1,10 @@ +Foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| Foo() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCall/functionCall.enum.scope b/resources/fixtures/scopes/swift/functionCall/functionCall.enum.scope new file mode 100644 index 0000000000..666ee9bb79 --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCall/functionCall.enum.scope @@ -0,0 +1,10 @@ +Foo.bar() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| Foo.bar() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCall/functionCall.method.scope b/resources/fixtures/scopes/swift/functionCall/functionCall.method.scope new file mode 100644 index 0000000000..6ab0ba4c3a --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCall/functionCall.method.scope @@ -0,0 +1,10 @@ +foo.bar() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:9 + >---------< +0| foo.bar() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCall/functionCall.scope b/resources/fixtures/scopes/swift/functionCall/functionCall.scope new file mode 100644 index 0000000000..00162e317c --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCall/functionCall.scope @@ -0,0 +1,10 @@ +foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCallee/functionCallee.chain.scope b/resources/fixtures/scopes/swift/functionCallee/functionCallee.chain.scope new file mode 100644 index 0000000000..b0b9872650 --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCallee/functionCallee.chain.scope @@ -0,0 +1,25 @@ +foo().bar() +--- + +[#1 Content] = +[#1 Removal] = 0:0-0:3 + >---< +0| foo().bar() + +[#1 Domain] = 0:0-0:5 + >-----< +0| foo().bar() + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 0:0-0:9 + >---------< +0| foo().bar() + +[#2 Domain] = 0:0-0:11 + >-----------< +0| foo().bar() + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCallee/functionCallee.constructor.scope b/resources/fixtures/scopes/swift/functionCallee/functionCallee.constructor.scope new file mode 100644 index 0000000000..16cc5263eb --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCallee/functionCallee.constructor.scope @@ -0,0 +1,13 @@ +Foo() +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| Foo() + +[Domain] = 0:0-0:5 + >-----< +0| Foo() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCallee/functionCallee.enum.scope b/resources/fixtures/scopes/swift/functionCallee/functionCallee.enum.scope new file mode 100644 index 0000000000..e36855d436 --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCallee/functionCallee.enum.scope @@ -0,0 +1,13 @@ +Foo.bar() +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| Foo.bar() + +[Domain] = 0:0-0:9 + >---------< +0| Foo.bar() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCallee/functionCallee.method.scope b/resources/fixtures/scopes/swift/functionCallee/functionCallee.method.scope new file mode 100644 index 0000000000..e77bc361ec --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCallee/functionCallee.method.scope @@ -0,0 +1,13 @@ +foo.bar() +--- + +[Content] = +[Removal] = 0:0-0:7 + >-------< +0| foo.bar() + +[Domain] = 0:0-0:9 + >---------< +0| foo.bar() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/functionCallee/functionCallee.scope b/resources/fixtures/scopes/swift/functionCallee/functionCallee.scope new file mode 100644 index 0000000000..2b075b5c33 --- /dev/null +++ b/resources/fixtures/scopes/swift/functionCallee/functionCallee.scope @@ -0,0 +1,13 @@ +foo() +--- + +[Content] = +[Removal] = 0:0-0:3 + >---< +0| foo() + +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.field.enum.scope b/resources/fixtures/scopes/swift/name/name.field.enum.scope new file mode 100644 index 0000000000..620d0d31c3 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.field.enum.scope @@ -0,0 +1,73 @@ +enum Foo: Int { + case bar = 0 + case baz = 1 +} +--- + +[#1 Content] = 0:5-0:8 + >---< +0| enum Foo: Int { + +[#1 Removal] = 0:4-0:8 + >----< +0| enum Foo: Int { + +[#1 Leading delimiter] = 0:4-0:5 + >-< +0| enum Foo: Int { + +[#1 Domain] = 0:0-3:1 + >--------------- +0| enum Foo: Int { +1| case bar = 0 +2| case baz = 1 +3| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:7-1:10 + >---< +1| case bar = 0 + +[#2 Removal] = 1:7-1:11 + >----< +1| case bar = 0 + +[#2 Leading delimiter] = 1:6-1:7 + >-< +1| case bar = 0 + +[#2 Trailing delimiter] = 1:10-1:11 + >-< +1| case bar = 0 + +[#2 Domain] = 1:2-1:14 + >------------< +1| case bar = 0 + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 2:7-2:10 + >---< +2| case baz = 1 + +[#3 Removal] = 2:7-2:11 + >----< +2| case baz = 1 + +[#3 Leading delimiter] = 2:6-2:7 + >-< +2| case baz = 1 + +[#3 Trailing delimiter] = 2:10-2:11 + >-< +2| case baz = 1 + +[#3 Domain] = 2:2-2:14 + >------------< +2| case baz = 1 + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.field.interface.scope b/resources/fixtures/scopes/swift/name/name.field.interface.scope new file mode 100644 index 0000000000..79748a14dd --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.field.interface.scope @@ -0,0 +1,48 @@ +protocol Foo { + var bar: Int { get set } +} +--- + +[#1 Content] = 0:9-0:12 + >---< +0| protocol Foo { + +[#1 Removal] = 0:9-0:13 + >----< +0| protocol Foo { + +[#1 Leading delimiter] = 0:8-0:9 + >-< +0| protocol Foo { + +[#1 Trailing delimiter] = 0:12-0:13 + >-< +0| protocol Foo { + +[#1 Domain] = 0:0-2:1 + >-------------- +0| protocol Foo { +1| var bar: Int { get set } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:6-1:9 + >---< +1| var bar: Int { get set } + +[#2 Removal] = 1:5-1:9 + >----< +1| var bar: Int { get set } + +[#2 Leading delimiter] = 1:5-1:6 + >-< +1| var bar: Int { get set } + +[#2 Domain] = 1:2-1:26 + >------------------------< +1| var bar: Int { get set } + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/namedFunction/namedFunction.constructor.scope b/resources/fixtures/scopes/swift/namedFunction/namedFunction.constructor.scope new file mode 100644 index 0000000000..6ec4d8e822 --- /dev/null +++ b/resources/fixtures/scopes/swift/namedFunction/namedFunction.constructor.scope @@ -0,0 +1,21 @@ +struct Foo { + init() {} +} +--- + +[Content] = +[Domain] = 1:2-1:11 + >---------< +1| init() {} + +[Removal] = 1:0-2:0 + >----------- +1| init() {} +2| } + < + +[Leading delimiter] = 1:0-1:2 + >--< +1| init() {} + +[Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.class.scope b/resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.class.scope new file mode 100644 index 0000000000..10699070e9 --- /dev/null +++ b/resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.class.scope @@ -0,0 +1,13 @@ +struct Foo { } +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:14 + >--------------< +0| struct Foo { } + + +[#2 Content] = +[#2 Domain] = 0:12-0:13 + >-< +0| struct Foo { } diff --git a/resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.document.scope b/resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.document.scope new file mode 100644 index 0000000000..46eb837954 --- /dev/null +++ b/resources/fixtures/scopes/swift/namedFunction/namedFunction.iteration.document.scope @@ -0,0 +1,12 @@ + +func foo() {} + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| func foo() {} +2| + < diff --git a/resources/fixtures/scopes/swift/namedFunction/namedFunction.method.scope b/resources/fixtures/scopes/swift/namedFunction/namedFunction.method.scope new file mode 100644 index 0000000000..aa9dcbf1e7 --- /dev/null +++ b/resources/fixtures/scopes/swift/namedFunction/namedFunction.method.scope @@ -0,0 +1,21 @@ +struct Foo { + func bar() {} +} +--- + +[Content] = +[Domain] = 1:2-1:15 + >-------------< +1| func bar() {} + +[Removal] = 1:0-2:0 + >--------------- +1| func bar() {} +2| } + < + +[Leading delimiter] = 1:0-1:2 + >--< +1| func bar() {} + +[Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/swift/namedFunction/namedFunction.scope b/resources/fixtures/scopes/swift/namedFunction/namedFunction.scope new file mode 100644 index 0000000000..73d215f7eb --- /dev/null +++ b/resources/fixtures/scopes/swift/namedFunction/namedFunction.scope @@ -0,0 +1,10 @@ +func foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| func foo() {} + +[Insertion delimiter] = "\n\n" diff --git a/resources/fixtures/scopes/swift/regularExpression.scope b/resources/fixtures/scopes/swift/regularExpression.scope new file mode 100644 index 0000000000..baee4f3624 --- /dev/null +++ b/resources/fixtures/scopes/swift/regularExpression.scope @@ -0,0 +1,10 @@ +/\d+$/ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:6 + >------< +0| /\d+$/ + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement/statement.assignment.scope b/resources/fixtures/scopes/swift/statement/statement.assignment.scope new file mode 100644 index 0000000000..acdb2b1498 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.assignment.scope @@ -0,0 +1,10 @@ +foo = 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:7 + >-------< +0| foo = 0 + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.constructor.scope b/resources/fixtures/scopes/swift/statement/statement.constructor.scope new file mode 100644 index 0000000000..078e314d6a --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.constructor.scope @@ -0,0 +1,33 @@ +struct Foo { + init() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| init() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:2-1:11 + >---------< +1| init() {} + +[#2 Removal] = 1:0-2:0 + >----------- +1| init() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| init() {} + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.field.interface.scope b/resources/fixtures/scopes/swift/statement/statement.field.interface.scope new file mode 100644 index 0000000000..b1180b554a --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.field.interface.scope @@ -0,0 +1,33 @@ +protocol Foo { + var bar: Int { get set } +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >-------------- +0| protocol Foo { +1| var bar: Int { get set } +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:2-1:26 + >------------------------< +1| var bar: Int { get set } + +[#2 Removal] = 1:0-2:0 + >-------------------------- +1| var bar: Int { get set } +2| } + < + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| var bar: Int { get set } + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.function.scope b/resources/fixtures/scopes/swift/statement/statement.function.scope new file mode 100644 index 0000000000..118724d315 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.function.scope @@ -0,0 +1,10 @@ +func foo() {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| func foo() {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.functionCall.scope b/resources/fixtures/scopes/swift/statement/statement.functionCall.scope new file mode 100644 index 0000000000..fb55b4580a --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.functionCall.scope @@ -0,0 +1,10 @@ +foo() +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:5 + >-----< +0| foo() + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.method.interface.scope b/resources/fixtures/scopes/swift/statement/statement.method.interface.scope new file mode 100644 index 0000000000..5f58bf8606 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.method.interface.scope @@ -0,0 +1,33 @@ +protocol Foo { + func bar() +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >-------------- +0| protocol Foo { +1| func bar() +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:2-1:12 + >----------< +1| func bar() + +[#2 Removal] = 1:0-2:0 + >------------ +1| func bar() +2| } + < + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| func bar() + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.method.scope b/resources/fixtures/scopes/swift/statement/statement.method.scope new file mode 100644 index 0000000000..339299f8ca --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.method.scope @@ -0,0 +1,33 @@ +struct Foo { + func bar() {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() {} +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:2-1:15 + >-------------< +1| func bar() {} + +[#2 Removal] = 1:0-2:0 + >--------------- +1| func bar() {} +2| } + < + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| func bar() {} + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/textFragment/textFragment.regularExpression.scope b/resources/fixtures/scopes/swift/textFragment/textFragment.regularExpression.scope new file mode 100644 index 0000000000..c8c2a5013d --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment/textFragment.regularExpression.scope @@ -0,0 +1,10 @@ +/\d+$/ +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:5 + >----< +0| /\d+$/ + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.assignment.scope b/resources/fixtures/scopes/swift/value/value.assignment.scope new file mode 100644 index 0000000000..e16f982248 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.assignment.scope @@ -0,0 +1,17 @@ +foo = 0 +--- + +[Content] = +[Domain] = 0:6-0:7 + >-< +0| foo = 0 + +[Removal] = 0:3-0:7 + >----< +0| foo = 0 + +[Leading delimiter] = 0:3-0:6 + >---< +0| foo = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.constant.scope b/resources/fixtures/scopes/swift/value/value.constant.scope index 6e9832c52a..58625925c9 100644 --- a/resources/fixtures/scopes/swift/value/value.constant.scope +++ b/resources/fixtures/scopes/swift/value/value.constant.scope @@ -5,12 +5,12 @@ let foo = 0 >-< 0| let foo = 0 -[Removal] = 0:8-0:11 - >---< +[Removal] = 0:7-0:11 + >----< 0| let foo = 0 -[Leading delimiter] = 0:8-0:10 - >--< +[Leading delimiter] = 0:7-0:10 + >---< 0| let foo = 0 [Domain] = 0:0-0:11 diff --git a/resources/fixtures/scopes/swift/value/value.field.class.scope b/resources/fixtures/scopes/swift/value/value.field.class.scope new file mode 100644 index 0000000000..c4b9b04f49 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.field.class.scope @@ -0,0 +1,42 @@ +struct Foo { + var bar = 0 + var baz: Int = 0 +} +--- + +[#1 Content] = 1:12-1:13 + >-< +1| var bar = 0 + +[#1 Removal] = 1:9-1:13 + >----< +1| var bar = 0 + +[#1 Leading delimiter] = 1:9-1:12 + >---< +1| var bar = 0 + +[#1 Domain] = 1:2-1:13 + >-----------< +1| var bar = 0 + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:17-2:18 + >-< +2| var baz: Int = 0 + +[#2 Removal] = 2:14-2:18 + >----< +2| var baz: Int = 0 + +[#2 Leading delimiter] = 2:14-2:17 + >---< +2| var baz: Int = 0 + +[#2 Domain] = 2:2-2:18 + >----------------< +2| var baz: Int = 0 + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.field.enum.scope b/resources/fixtures/scopes/swift/value/value.field.enum.scope new file mode 100644 index 0000000000..6261951de7 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.field.enum.scope @@ -0,0 +1,22 @@ +enum Foo: Int { + case bar = 0 +} +--- + +[Content] = 1:13-1:14 + >-< +1| case bar = 0 + +[Removal] = 1:10-1:14 + >----< +1| case bar = 0 + +[Leading delimiter] = 1:10-1:13 + >---< +1| case bar = 0 + +[Domain] = 1:2-1:14 + >------------< +1| case bar = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.variable.scope b/resources/fixtures/scopes/swift/value/value.variable.scope new file mode 100644 index 0000000000..06dc0be9f8 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.variable.scope @@ -0,0 +1,20 @@ +var foo = 0 +--- + +[Content] = 0:10-0:11 + >-< +0| var foo = 0 + +[Removal] = 0:7-0:11 + >----< +0| var foo = 0 + +[Leading delimiter] = 0:7-0:10 + >---< +0| var foo = 0 + +[Domain] = 0:0-0:11 + >-----------< +0| var foo = 0 + +[Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index bc5d74ed69..c427cbb4d0 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -4,11 +4,17 @@ (class_declaration) (protocol_declaration) (property_declaration) + (function_declaration) + (protocol_property_declaration) + (protocol_function_declaration) + (init_declaration) (for_statement) (do_statement) (while_statement) (repeat_while_statement) (switch_statement) + (assignment) + (call_expression) ;; Disabled on purpose. We have a better definition of these below. ;; (if_statement) @@ -79,6 +85,14 @@ (enum_class_body) ) @type @name.domain +;;!! case foo = 0 +;;! ^^^ +;;! ^ +(enum_entry + name: (_) @name @value.leading.endOf + raw_value: (_) @value +) @_.domain + ;;!! protocol Foo {} ;;! ^^^ (protocol_declaration @@ -193,34 +207,50 @@ "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf ) -;;!! let foo: Int = 0 -;;!! var foo: Int 0 +;;!! var foo: Int = 0 ;;! ^^^ ;;! ^^^ ;;! ^ (property_declaration - name: (_) @name + name: (_) @name @type.leading.endOf (type_annotation - ":" @type.leading (_) @type - )? - ( - "=" @value.leading - value: (_) @value - )? + ) @value.leading.endOf + value: (_)? @value ) @_.domain +;;!! var foo = 0 +;;! ^^^ +;;! ^ +( + (property_declaration + name: (_) @name @value.leading.endOf + value: (_)? @value + ) @_.domain + (#not-child-type? @_.domain type_annotation) +) + ;;!! let foo: Int { get set} ;;! ^^^ ;;! ^^^ (protocol_property_declaration - name: (_) @name + name: (pattern + bound_identifier: (_) @name + ) (type_annotation ":" @type.leading (_) @type ) ) @_.domain +;;!! foo = 0 +;;! ^^^ +;;! ^ +(assignment + target: (_) @name @value.leading.endOf + result: (_) @value +) + ;;!! { (aaa: Int) -> Int in 0 } (lambda_literal) @anonymousFunction @@ -264,4 +294,33 @@ condition: (_) @condition ) @condition.domain -;; (switch_statement) +;;!! /\d+$/ +( + (regex_literal) @regularExpression @textFragment + (#shrink-to-match! @textFragment "^/(?.*)/.*$") +) + +;;!! func foo() {} +;;! ^^^ +(function_declaration + name: (_) @name +) @namedFunction @name.domain + +;;!! init() {} +;;! ^^^^ +(init_declaration + name: _ @name +) @namedFunction @name.domain + +;;!! func foo() {} +;;! ^^^ +(protocol_function_declaration + name: (_) @name +) @name.domain + +;;!! foo() +;;! ^^^ +(call_expression + . + (_) @functionCallee +) @functionCall @functionCallee.domain From 9f20b969824bb8b45babb9d5999da453b0232ead Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 17:46:26 +0200 Subject: [PATCH 44/46] more statements --- .../swift/condition/condition.doWhile.scope | 20 ++++++ .../swift/interior/interior.lambda.scope | 22 ++++++ resources/fixtures/scopes/swift/list.scope | 10 +++ resources/fixtures/scopes/swift/map.scope | 10 +++ .../swift/name/name.assignment.compound.scope | 20 ++++++ .../name/name.assignment.destructuring.scope | 20 ++++++ .../scopes/swift/name/name.assignment.scope | 20 ++++++ .../scopes/swift/name/name.constructor.scope | 45 ++++++++++++ .../scopes/swift/name/name.function.scope | 17 +++++ .../swift/name/name.method.interface.scope | 45 ++++++++++++ .../scopes/swift/name/name.method.scope | 45 ++++++++++++ .../scopes/swift/name/name.typeAlias.scope | 24 +++++++ .../name/name.variable.destructuring.scope | 24 +++++++ .../statement.assignment.compound.scope | 10 +++ .../statement.assignment.destructuring.scope | 10 +++ .../swift/statement/statement.break.scope | 33 +++++++++ .../swift/statement/statement.continue.scope | 33 +++++++++ .../swift/statement/statement.import.scope | 10 +++ .../swift/statement/statement.return.scope | 33 +++++++++ .../swift/statement/statement.throw.scope | 33 +++++++++ .../swift/statement/statement.typeAlias.scope | 10 +++ .../statement.variable.destructuring.scope | 10 +++ .../swift/statement/statement.yield.scope | 60 ++++++++++++++++ .../scopes/swift/type/type.alias.scope | 10 +++ .../swift/type/type.return.lambda.scope | 17 +++++ .../swift/type/type.return.method.scope | 34 +++++++++ .../scopes/swift/type/type.return.scope | 20 ++++++ .../value.assignment.destructuring.scope | 20 ++++++ .../scopes/swift/value/value.assignment.scope | 7 +- .../swift/value/value.return.lambda.scope | 24 +++++++ .../scopes/swift/value/value.return.scope | 22 ++++++ .../scopes/swift/value/value.throw.scope | 22 ++++++ .../scopes/swift/value/value.typeAlias.scope | 20 ++++++ .../value/value.variable.destructuring.scope | 20 ++++++ .../scopes/swift/value/value.yield.scope | 24 +++++++ resources/queries/swift.scm | 71 +++++++++++++++++-- 36 files changed, 869 insertions(+), 6 deletions(-) create mode 100644 resources/fixtures/scopes/swift/condition/condition.doWhile.scope create mode 100644 resources/fixtures/scopes/swift/interior/interior.lambda.scope create mode 100644 resources/fixtures/scopes/swift/list.scope create mode 100644 resources/fixtures/scopes/swift/map.scope create mode 100644 resources/fixtures/scopes/swift/name/name.assignment.compound.scope create mode 100644 resources/fixtures/scopes/swift/name/name.assignment.destructuring.scope create mode 100644 resources/fixtures/scopes/swift/name/name.assignment.scope create mode 100644 resources/fixtures/scopes/swift/name/name.constructor.scope create mode 100644 resources/fixtures/scopes/swift/name/name.function.scope create mode 100644 resources/fixtures/scopes/swift/name/name.method.interface.scope create mode 100644 resources/fixtures/scopes/swift/name/name.method.scope create mode 100644 resources/fixtures/scopes/swift/name/name.typeAlias.scope create mode 100644 resources/fixtures/scopes/swift/name/name.variable.destructuring.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.assignment.compound.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.assignment.destructuring.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.break.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.continue.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.import.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.return.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.throw.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.typeAlias.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.variable.destructuring.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.yield.scope create mode 100644 resources/fixtures/scopes/swift/type/type.alias.scope create mode 100644 resources/fixtures/scopes/swift/type/type.return.lambda.scope create mode 100644 resources/fixtures/scopes/swift/type/type.return.method.scope create mode 100644 resources/fixtures/scopes/swift/type/type.return.scope create mode 100644 resources/fixtures/scopes/swift/value/value.assignment.destructuring.scope create mode 100644 resources/fixtures/scopes/swift/value/value.return.lambda.scope create mode 100644 resources/fixtures/scopes/swift/value/value.return.scope create mode 100644 resources/fixtures/scopes/swift/value/value.throw.scope create mode 100644 resources/fixtures/scopes/swift/value/value.typeAlias.scope create mode 100644 resources/fixtures/scopes/swift/value/value.variable.destructuring.scope create mode 100644 resources/fixtures/scopes/swift/value/value.yield.scope diff --git a/resources/fixtures/scopes/swift/condition/condition.doWhile.scope b/resources/fixtures/scopes/swift/condition/condition.doWhile.scope new file mode 100644 index 0000000000..e6fd0bfcb0 --- /dev/null +++ b/resources/fixtures/scopes/swift/condition/condition.doWhile.scope @@ -0,0 +1,20 @@ +repeat {} while true +--- + +[Content] = 0:16-0:20 + >----< +0| repeat {} while true + +[Removal] = 0:15-0:20 + >-----< +0| repeat {} while true + +[Leading delimiter] = 0:15-0:16 + >-< +0| repeat {} while true + +[Domain] = 0:0-0:20 + >--------------------< +0| repeat {} while true + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior/interior.lambda.scope b/resources/fixtures/scopes/swift/interior/interior.lambda.scope new file mode 100644 index 0000000000..02410e23ba --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.lambda.scope @@ -0,0 +1,22 @@ +{ () in 0 } +--- + +[#1 Content] = 0:2-0:9 + >-------< +0| { () in 0 } + +[#1 Removal] = +[#1 Domain] = 0:1-0:10 + >---------< +0| { () in 0 } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 0:8-0:9 + >-< +0| { () in 0 } + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/list.scope b/resources/fixtures/scopes/swift/list.scope new file mode 100644 index 0000000000..053c607f96 --- /dev/null +++ b/resources/fixtures/scopes/swift/list.scope @@ -0,0 +1,10 @@ +[aaa, bbb] +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| [aaa, bbb] + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/map.scope b/resources/fixtures/scopes/swift/map.scope new file mode 100644 index 0000000000..de639006a0 --- /dev/null +++ b/resources/fixtures/scopes/swift/map.scope @@ -0,0 +1,10 @@ +[aaa: 0, bbb: 1] +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:16 + >----------------< +0| [aaa: 0, bbb: 1] + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.assignment.compound.scope b/resources/fixtures/scopes/swift/name/name.assignment.compound.scope new file mode 100644 index 0000000000..443bb5b0a3 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.assignment.compound.scope @@ -0,0 +1,20 @@ +foo += 0 +--- + +[Content] = 0:0-0:3 + >---< +0| foo += 0 + +[Removal] = 0:0-0:4 + >----< +0| foo += 0 + +[Trailing delimiter] = 0:3-0:4 + >-< +0| foo += 0 + +[Domain] = 0:0-0:8 + >--------< +0| foo += 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.assignment.destructuring.scope b/resources/fixtures/scopes/swift/name/name.assignment.destructuring.scope new file mode 100644 index 0000000000..64188e3a7a --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.assignment.destructuring.scope @@ -0,0 +1,20 @@ +(foo, bar) = (0, 1) +--- + +[Content] = 0:0-0:10 + >----------< +0| (foo, bar) = (0, 1) + +[Removal] = 0:0-0:11 + >-----------< +0| (foo, bar) = (0, 1) + +[Trailing delimiter] = 0:10-0:11 + >-< +0| (foo, bar) = (0, 1) + +[Domain] = 0:0-0:19 + >-------------------< +0| (foo, bar) = (0, 1) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.assignment.scope b/resources/fixtures/scopes/swift/name/name.assignment.scope new file mode 100644 index 0000000000..ccbd90c654 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.assignment.scope @@ -0,0 +1,20 @@ +foo = 0 +--- + +[Content] = 0:0-0:3 + >---< +0| foo = 0 + +[Removal] = 0:0-0:4 + >----< +0| foo = 0 + +[Trailing delimiter] = 0:3-0:4 + >-< +0| foo = 0 + +[Domain] = 0:0-0:7 + >-------< +0| foo = 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.constructor.scope b/resources/fixtures/scopes/swift/name/name.constructor.scope new file mode 100644 index 0000000000..2be5987c57 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.constructor.scope @@ -0,0 +1,45 @@ +struct Foo { + init() {} +} +--- + +[#1 Content] = 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 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| init() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:2-1:6 + >----< +1| init() {} + +[#2 Leading delimiter] = 1:0-1:2 + >--< +1| init() {} + +[#2 Domain] = 1:2-1:11 + >---------< +1| init() {} + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.function.scope b/resources/fixtures/scopes/swift/name/name.function.scope new file mode 100644 index 0000000000..d9a1dd759b --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.function.scope @@ -0,0 +1,17 @@ +func foo() {} +--- + +[Content] = +[Removal] = 0:5-0:8 + >---< +0| func foo() {} + +[Leading delimiter] = 0:4-0:5 + >-< +0| func foo() {} + +[Domain] = 0:0-0:13 + >-------------< +0| func foo() {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.method.interface.scope b/resources/fixtures/scopes/swift/name/name.method.interface.scope new file mode 100644 index 0000000000..2ac409a430 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.method.interface.scope @@ -0,0 +1,45 @@ +protocol Foo { + func bar() +} +--- + +[#1 Content] = 0:9-0:12 + >---< +0| protocol Foo { + +[#1 Removal] = 0:9-0:13 + >----< +0| protocol Foo { + +[#1 Leading delimiter] = 0:8-0:9 + >-< +0| protocol Foo { + +[#1 Trailing delimiter] = 0:12-0:13 + >-< +0| protocol Foo { + +[#1 Domain] = 0:0-2:1 + >-------------- +0| protocol Foo { +1| func bar() +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:7-1:10 + >---< +1| func bar() + +[#2 Leading delimiter] = 1:6-1:7 + >-< +1| func bar() + +[#2 Domain] = 1:2-1:12 + >----------< +1| func bar() + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.method.scope b/resources/fixtures/scopes/swift/name/name.method.scope new file mode 100644 index 0000000000..4d07fa559a --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.method.scope @@ -0,0 +1,45 @@ +struct Foo { + func bar() {} +} +--- + +[#1 Content] = 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 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = 1:7-1:10 + >---< +1| func bar() {} + +[#2 Leading delimiter] = 1:6-1:7 + >-< +1| func bar() {} + +[#2 Domain] = 1:2-1:15 + >-------------< +1| func bar() {} + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.typeAlias.scope b/resources/fixtures/scopes/swift/name/name.typeAlias.scope new file mode 100644 index 0000000000..e6d5f7655f --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.typeAlias.scope @@ -0,0 +1,24 @@ +typealias Foo = Int +--- + +[Content] = 0:10-0:13 + >---< +0| typealias Foo = Int + +[Removal] = 0:10-0:14 + >----< +0| typealias Foo = Int + +[Leading delimiter] = 0:9-0:10 + >-< +0| typealias Foo = Int + +[Trailing delimiter] = 0:13-0:14 + >-< +0| typealias Foo = Int + +[Domain] = 0:0-0:19 + >-------------------< +0| typealias Foo = Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name/name.variable.destructuring.scope b/resources/fixtures/scopes/swift/name/name.variable.destructuring.scope new file mode 100644 index 0000000000..4441500242 --- /dev/null +++ b/resources/fixtures/scopes/swift/name/name.variable.destructuring.scope @@ -0,0 +1,24 @@ +let (foo, bar) = (0, 1) +--- + +[Content] = 0:4-0:14 + >----------< +0| let (foo, bar) = (0, 1) + +[Removal] = 0:4-0:15 + >-----------< +0| let (foo, bar) = (0, 1) + +[Leading delimiter] = 0:3-0:4 + >-< +0| let (foo, bar) = (0, 1) + +[Trailing delimiter] = 0:14-0:15 + >-< +0| let (foo, bar) = (0, 1) + +[Domain] = 0:0-0:23 + >-----------------------< +0| let (foo, bar) = (0, 1) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement/statement.assignment.compound.scope b/resources/fixtures/scopes/swift/statement/statement.assignment.compound.scope new file mode 100644 index 0000000000..b8bce690bc --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.assignment.compound.scope @@ -0,0 +1,10 @@ +foo += 0 +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:8 + >--------< +0| foo += 0 + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.assignment.destructuring.scope b/resources/fixtures/scopes/swift/statement/statement.assignment.destructuring.scope new file mode 100644 index 0000000000..7fb478aaa2 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.assignment.destructuring.scope @@ -0,0 +1,10 @@ +(foo, bar) = (0, 1) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| (foo, bar) = (0, 1) + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.break.scope b/resources/fixtures/scopes/swift/statement/statement.break.scope new file mode 100644 index 0000000000..28b797eae4 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.break.scope @@ -0,0 +1,33 @@ +while true { + break +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| while true { +1| break +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:9 + >-----< +1| break + +[#2 Removal] = 1:0-2:0 + >--------- +1| break +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| break + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.continue.scope b/resources/fixtures/scopes/swift/statement/statement.continue.scope new file mode 100644 index 0000000000..aed5ce8033 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.continue.scope @@ -0,0 +1,33 @@ +while true { + continue +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| while true { +1| continue +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| continue + +[#2 Removal] = 1:0-2:0 + >------------ +1| continue +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| continue + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.import.scope b/resources/fixtures/scopes/swift/statement/statement.import.scope new file mode 100644 index 0000000000..26c78c04aa --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.import.scope @@ -0,0 +1,10 @@ +import Foo +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| import Foo + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.return.scope b/resources/fixtures/scopes/swift/statement/statement.return.scope new file mode 100644 index 0000000000..3645950693 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.return.scope @@ -0,0 +1,33 @@ +func foo() { + return 0 +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| func foo() { +1| return 0 +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:12 + >--------< +1| return 0 + +[#2 Removal] = 1:0-2:0 + >------------ +1| return 0 +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| return 0 + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.throw.scope b/resources/fixtures/scopes/swift/statement/statement.throw.scope new file mode 100644 index 0000000000..bd051cdf16 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.throw.scope @@ -0,0 +1,33 @@ +func foo() throws { + throw Error +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------------- +0| func foo() throws { +1| throw Error +2| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-1:15 + >-----------< +1| throw Error + +[#2 Removal] = 1:0-2:0 + >--------------- +1| throw Error +2| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| throw Error + +[#2 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.typeAlias.scope b/resources/fixtures/scopes/swift/statement/statement.typeAlias.scope new file mode 100644 index 0000000000..3d8aef8034 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.typeAlias.scope @@ -0,0 +1,10 @@ +typealias Foo = Int +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| typealias Foo = Int + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.variable.destructuring.scope b/resources/fixtures/scopes/swift/statement/statement.variable.destructuring.scope new file mode 100644 index 0000000000..ab68eacf01 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.variable.destructuring.scope @@ -0,0 +1,10 @@ +let (foo, bar) = (0, 1) +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:23 + >-----------------------< +0| let (foo, bar) = (0, 1) + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement/statement.yield.scope b/resources/fixtures/scopes/swift/statement/statement.yield.scope new file mode 100644 index 0000000000..289f80ddc8 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.yield.scope @@ -0,0 +1,60 @@ +var foo: Int { + _read { + yield 0 + } +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-4:1 + >-------------- +0| var foo: Int { +1| _read { +2| yield 0 +3| } +4| } + -< + +[#1 Insertion delimiter] = "\n" + + +[#2 Content] = +[#2 Domain] = 1:4-3:5 + >------- +1| _read { +2| yield 0 +3| } + -----< + +[#2 Removal] = 1:0-4:0 + >----------- +1| _read { +2| yield 0 +3| } +4| } + < + +[#2 Leading delimiter] = 1:0-1:4 + >----< +1| _read { + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#3 Domain] = 2:8-2:15 + >-------< +2| yield 0 + +[#3 Removal] = 2:0-3:0 + >--------------- +2| yield 0 +3| } + < + +[#3 Leading delimiter] = 2:0-2:8 + >--------< +2| yield 0 + +[#3 Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/type/type.alias.scope b/resources/fixtures/scopes/swift/type/type.alias.scope new file mode 100644 index 0000000000..6509f283b1 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.alias.scope @@ -0,0 +1,10 @@ +typealias Foo = Int +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:19 + >-------------------< +0| typealias Foo = Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type/type.return.lambda.scope b/resources/fixtures/scopes/swift/type/type.return.lambda.scope new file mode 100644 index 0000000000..349ab30276 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.return.lambda.scope @@ -0,0 +1,17 @@ +{ () -> Int in 0 } +--- + +[Content] = +[Domain] = 0:8-0:11 + >---< +0| { () -> Int in 0 } + +[Removal] = 0:4-0:11 + >-------< +0| { () -> Int in 0 } + +[Leading delimiter] = 0:4-0:8 + >----< +0| { () -> Int in 0 } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type/type.return.method.scope b/resources/fixtures/scopes/swift/type/type.return.method.scope new file mode 100644 index 0000000000..4771a5b569 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.return.method.scope @@ -0,0 +1,34 @@ +struct Foo { + func bar() -> Int {} +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >------------ +0| struct Foo { +1| func bar() -> Int {} +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:18-1:21 + >---< +1| func bar() -> Int {} + +[#2 Removal] = 1:14-1:21 + >-------< +1| func bar() -> Int {} + +[#2 Leading delimiter] = 1:14-1:18 + >----< +1| func bar() -> Int {} + +[#2 Domain] = 1:4-1:24 + >--------------------< +1| func bar() -> Int {} + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type/type.return.scope b/resources/fixtures/scopes/swift/type/type.return.scope new file mode 100644 index 0000000000..34f6b31410 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.return.scope @@ -0,0 +1,20 @@ +func foo() -> Int {} +--- + +[Content] = 0:14-0:17 + >---< +0| func foo() -> Int {} + +[Removal] = 0:10-0:17 + >-------< +0| func foo() -> Int {} + +[Leading delimiter] = 0:10-0:14 + >----< +0| func foo() -> Int {} + +[Domain] = 0:0-0:20 + >--------------------< +0| func foo() -> Int {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.assignment.destructuring.scope b/resources/fixtures/scopes/swift/value/value.assignment.destructuring.scope new file mode 100644 index 0000000000..7ecdd946d6 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.assignment.destructuring.scope @@ -0,0 +1,20 @@ +(foo, bar) = (0, 1) +--- + +[Content] = 0:13-0:19 + >------< +0| (foo, bar) = (0, 1) + +[Removal] = 0:10-0:19 + >---------< +0| (foo, bar) = (0, 1) + +[Leading delimiter] = 0:10-0:13 + >---< +0| (foo, bar) = (0, 1) + +[Domain] = 0:0-0:19 + >-------------------< +0| (foo, bar) = (0, 1) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.assignment.scope b/resources/fixtures/scopes/swift/value/value.assignment.scope index e16f982248..6e89de0927 100644 --- a/resources/fixtures/scopes/swift/value/value.assignment.scope +++ b/resources/fixtures/scopes/swift/value/value.assignment.scope @@ -1,8 +1,7 @@ foo = 0 --- -[Content] = -[Domain] = 0:6-0:7 +[Content] = 0:6-0:7 >-< 0| foo = 0 @@ -14,4 +13,8 @@ foo = 0 >---< 0| foo = 0 +[Domain] = 0:0-0:7 + >-------< +0| foo = 0 + [Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.return.lambda.scope b/resources/fixtures/scopes/swift/value/value.return.lambda.scope new file mode 100644 index 0000000000..d0653a96a5 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.return.lambda.scope @@ -0,0 +1,24 @@ +{ () -> Int in 0 } +--- + +[Content] = 0:15-0:16 + >-< +0| { () -> Int in 0 } + +[Removal] = 0:15-0:17 + >--< +0| { () -> Int in 0 } + +[Leading delimiter] = 0:14-0:15 + >-< +0| { () -> Int in 0 } + +[Trailing delimiter] = 0:16-0:17 + >-< +0| { () -> Int in 0 } + +[Domain] = 0:0-0:18 + >------------------< +0| { () -> Int in 0 } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.return.scope b/resources/fixtures/scopes/swift/value/value.return.scope new file mode 100644 index 0000000000..b80c04ce5d --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.return.scope @@ -0,0 +1,22 @@ +func foo() { + return 0 +} +--- + +[Content] = 1:11-1:12 + >-< +1| return 0 + +[Removal] = 1:10-1:12 + >--< +1| return 0 + +[Leading delimiter] = 1:10-1:11 + >-< +1| return 0 + +[Domain] = 1:4-1:12 + >--------< +1| return 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.throw.scope b/resources/fixtures/scopes/swift/value/value.throw.scope new file mode 100644 index 0000000000..846a545b16 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.throw.scope @@ -0,0 +1,22 @@ +func foo() throws { + throw Error +} +--- + +[Content] = 1:10-1:15 + >-----< +1| throw Error + +[Removal] = 1:9-1:15 + >------< +1| throw Error + +[Leading delimiter] = 1:9-1:10 + >-< +1| throw Error + +[Domain] = 1:4-1:15 + >-----------< +1| throw Error + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.typeAlias.scope b/resources/fixtures/scopes/swift/value/value.typeAlias.scope new file mode 100644 index 0000000000..228a0b5b82 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.typeAlias.scope @@ -0,0 +1,20 @@ +typealias Foo = Int +--- + +[Content] = 0:16-0:19 + >---< +0| typealias Foo = Int + +[Removal] = 0:13-0:19 + >------< +0| typealias Foo = Int + +[Leading delimiter] = 0:13-0:16 + >---< +0| typealias Foo = Int + +[Domain] = 0:0-0:19 + >-------------------< +0| typealias Foo = Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.variable.destructuring.scope b/resources/fixtures/scopes/swift/value/value.variable.destructuring.scope new file mode 100644 index 0000000000..e7b643e077 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.variable.destructuring.scope @@ -0,0 +1,20 @@ +let (foo, bar) = (0, 1) +--- + +[Content] = 0:17-0:23 + >------< +0| let (foo, bar) = (0, 1) + +[Removal] = 0:14-0:23 + >---------< +0| let (foo, bar) = (0, 1) + +[Leading delimiter] = 0:14-0:17 + >---< +0| let (foo, bar) = (0, 1) + +[Domain] = 0:0-0:23 + >-----------------------< +0| let (foo, bar) = (0, 1) + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.yield.scope b/resources/fixtures/scopes/swift/value/value.yield.scope new file mode 100644 index 0000000000..87e2819c98 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.yield.scope @@ -0,0 +1,24 @@ +var foo: Int { + _read { + yield 0 + } +} +--- + +[Content] = 2:14-2:15 + >-< +2| yield 0 + +[Removal] = 2:13-2:15 + >--< +2| yield 0 + +[Leading delimiter] = 2:13-2:14 + >-< +2| yield 0 + +[Domain] = 2:8-2:15 + >-------< +2| yield 0 + +[Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index c427cbb4d0..bb7440c9ff 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -8,11 +8,14 @@ (protocol_property_declaration) (protocol_function_declaration) (init_declaration) + (import_declaration) + (typealias_declaration) (for_statement) (do_statement) (while_statement) (repeat_while_statement) (switch_statement) + (control_transfer_statement) (assignment) (call_expression) @@ -249,10 +252,33 @@ (assignment target: (_) @name @value.leading.endOf result: (_) @value +) @_.domain + +;;!! { () -> Int in 0 } +;;! ^^^ +(lambda_literal + (lambda_function_type + ")" @type.leading.endOf + name: (_)? @type + ) +) @anonymousFunction + +;;!! { () -> Int in 0 } +;;! ^ +(lambda_literal + (statements) @interior ) -;;!! { (aaa: Int) -> Int in 0 } -(lambda_literal) @anonymousFunction +;;!! { () -> Int in 0 } +;;! ^ +(lambda_literal + (statements + . + (_) @value + . + ) + (#not-type? @value control_transfer_statement) +) @value.domain ;;!! do {} catch {} ;;! ^^^^^ @@ -300,11 +326,18 @@ (#shrink-to-match! @textFragment "^/(?.*)/.*$") ) -;;!! func foo() {} +;;!! func foo() -> Int {} ;;! ^^^ +;;! ^^^ (function_declaration name: (_) @name -) @namedFunction @name.domain + ( + ")" @type.leading.endOf + "->" + . + name: (_) @type + )? +) @namedFunction @_.domain ;;!! init() {} ;;! ^^^^ @@ -324,3 +357,33 @@ . (_) @functionCallee ) @functionCall @functionCallee.domain + +;;!! typealias Foo = Int +;;! ^^^ +;;! ^^^ +(typealias_declaration + (_) @name @value.leading.endOf + "=" + (_) @value +) @type @_.domain + +;;!! return 0 +;;! ^ +;;!! yield 0 +;;! ^ +(control_transfer_statement + result: (_) @value +) @value.domain + +;;!! throw Error +;;! ^^^^^ +(control_transfer_statement + (throw_keyword) + (_) @value +) @value.domain + +;;!! [aaa, bbb] +(array_literal) @list + +;;!! [aaa: 0, bbb: 1] +(dictionary_literal) @map From f9ebb954073a98c0dbe0f2ddcaf2c003690ef08b Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 18:39:03 +0200 Subject: [PATCH 45/46] More fixtures --- .../src/scopeSupportFacets/swift.ts | 4 +- .../branch/branch.switchCase.iteration.scope | 7 ++ .../swift/branch/branch.switchCase.scope | 26 +++++ .../swift/branch/branch.switchCase2.scope | 26 +++++ .../condition.switchCase.iteration.scope | 7 ++ .../condition/condition.switchCase.scope | 24 +++++ .../condition/condition.switchCase2.scope | 24 +++++ .../scopes/swift/disqualifyDelimiter.scope | 5 + .../swift/interior/interior.switchCase.scope | 69 +++++++++++++ .../scopes/swift/key.mapPair.iteration.scope | 7 ++ .../fixtures/scopes/swift/key.mapPair.scope | 39 ++++++++ .../swift/statement/statement.switch.scope | 10 ++ .../swift/type/type.argument.catch.scope | 25 +++++ .../scopes/swift/type/type.cast.scope | 20 ++++ .../type/type.typeArgument.iteration.scope | 13 +++ .../scopes/swift/type/type.typeArgument.scope | 52 ++++++++++ .../value/value.assignment.compound.scope | 20 ++++ .../swift/value/value.mapPair.iteration.scope | 13 +++ .../scopes/swift/value/value.mapPair.scope | 39 ++++++++ .../scopes/swift/value/value.switch.scope | 24 +++++ resources/queries/swift.scm | 99 ++++++++++++++++++- 21 files changed, 547 insertions(+), 6 deletions(-) create mode 100644 resources/fixtures/scopes/swift/branch/branch.switchCase.iteration.scope create mode 100644 resources/fixtures/scopes/swift/branch/branch.switchCase.scope create mode 100644 resources/fixtures/scopes/swift/branch/branch.switchCase2.scope create mode 100644 resources/fixtures/scopes/swift/condition/condition.switchCase.iteration.scope create mode 100644 resources/fixtures/scopes/swift/condition/condition.switchCase.scope create mode 100644 resources/fixtures/scopes/swift/condition/condition.switchCase2.scope create mode 100644 resources/fixtures/scopes/swift/disqualifyDelimiter.scope create mode 100644 resources/fixtures/scopes/swift/interior/interior.switchCase.scope create mode 100644 resources/fixtures/scopes/swift/key.mapPair.iteration.scope create mode 100644 resources/fixtures/scopes/swift/key.mapPair.scope create mode 100644 resources/fixtures/scopes/swift/statement/statement.switch.scope create mode 100644 resources/fixtures/scopes/swift/type/type.argument.catch.scope create mode 100644 resources/fixtures/scopes/swift/type/type.cast.scope create mode 100644 resources/fixtures/scopes/swift/type/type.typeArgument.iteration.scope create mode 100644 resources/fixtures/scopes/swift/type/type.typeArgument.scope create mode 100644 resources/fixtures/scopes/swift/value/value.assignment.compound.scope create mode 100644 resources/fixtures/scopes/swift/value/value.mapPair.iteration.scope create mode 100644 resources/fixtures/scopes/swift/value/value.mapPair.scope create mode 100644 resources/fixtures/scopes/swift/value/value.switch.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 45ac5a6ca1..6c90d2062b 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -140,7 +140,6 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.break": supported, "statement.continue": supported, "statement.import": supported, - "statement.misc": supported, "statement.iteration.document": supported, "statement.iteration.class": supported, "statement.iteration.interface": supported, @@ -349,9 +348,10 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { part: notApplicable, // Miscellaneous - "value.field.interface": notApplicable, + "statement.misc": notApplicable, "statement.package": notApplicable, "statement.update": notApplicable, + "value.field.interface": notApplicable, environment: notApplicable, selector: notApplicable, unit: notApplicable, diff --git a/resources/fixtures/scopes/swift/branch/branch.switchCase.iteration.scope b/resources/fixtures/scopes/swift/branch/branch.switchCase.iteration.scope new file mode 100644 index 0000000000..d3a9cac808 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.switchCase.iteration.scope @@ -0,0 +1,7 @@ +switch value { } +--- + +[Content] = +[Domain] = 0:14-0:15 + >-< +0| switch value { } diff --git a/resources/fixtures/scopes/swift/branch/branch.switchCase.scope b/resources/fixtures/scopes/swift/branch/branch.switchCase.scope new file mode 100644 index 0000000000..bfddb08ac4 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.switchCase.scope @@ -0,0 +1,26 @@ +switch value { + case 0: + break +} +--- + +[Content] = +[Domain] = 1:4-3:0 + >------- +1| case 0: +2| break +3| } + < + +[Removal] = 1:0-3:0 + >----------- +1| case 0: +2| break +3| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| case 0: + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/branch/branch.switchCase2.scope b/resources/fixtures/scopes/swift/branch/branch.switchCase2.scope new file mode 100644 index 0000000000..d131381fbd --- /dev/null +++ b/resources/fixtures/scopes/swift/branch/branch.switchCase2.scope @@ -0,0 +1,26 @@ +switch value { + default: + break +} +--- + +[Content] = +[Domain] = 1:4-3:0 + >-------- +1| default: +2| break +3| } + < + +[Removal] = 1:0-3:0 + >------------ +1| default: +2| break +3| } + < + +[Leading delimiter] = 1:0-1:4 + >----< +1| default: + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/condition/condition.switchCase.iteration.scope b/resources/fixtures/scopes/swift/condition/condition.switchCase.iteration.scope new file mode 100644 index 0000000000..d3a9cac808 --- /dev/null +++ b/resources/fixtures/scopes/swift/condition/condition.switchCase.iteration.scope @@ -0,0 +1,7 @@ +switch value { } +--- + +[Content] = +[Domain] = 0:14-0:15 + >-< +0| switch value { } diff --git a/resources/fixtures/scopes/swift/condition/condition.switchCase.scope b/resources/fixtures/scopes/swift/condition/condition.switchCase.scope new file mode 100644 index 0000000000..b2c9b9dfc3 --- /dev/null +++ b/resources/fixtures/scopes/swift/condition/condition.switchCase.scope @@ -0,0 +1,24 @@ +switch value { + case 0: break +} +--- + +[Content] = 1:9-1:10 + >-< +1| case 0: break + +[Removal] = 1:8-1:10 + >--< +1| case 0: break + +[Leading delimiter] = 1:8-1:9 + >-< +1| case 0: break + +[Domain] = 1:4-2:0 + >------------- +1| case 0: break +2| } + < + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/condition/condition.switchCase2.scope b/resources/fixtures/scopes/swift/condition/condition.switchCase2.scope new file mode 100644 index 0000000000..15953d7311 --- /dev/null +++ b/resources/fixtures/scopes/swift/condition/condition.switchCase2.scope @@ -0,0 +1,24 @@ +switch value { + case 0, 1: break +} +--- + +[Content] = 1:9-1:13 + >----< +1| case 0, 1: break + +[Removal] = 1:8-1:13 + >-----< +1| case 0, 1: break + +[Leading delimiter] = 1:8-1:9 + >-< +1| case 0, 1: break + +[Domain] = 1:4-2:0 + >---------------- +1| case 0, 1: break +2| } + < + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/disqualifyDelimiter.scope b/resources/fixtures/scopes/swift/disqualifyDelimiter.scope new file mode 100644 index 0000000000..2e33285094 --- /dev/null +++ b/resources/fixtures/scopes/swift/disqualifyDelimiter.scope @@ -0,0 +1,5 @@ +let foo: () -> Int +--- +[Content] = 0:12-0:14 + >--< +0| let foo: () -> Int diff --git a/resources/fixtures/scopes/swift/interior/interior.switchCase.scope b/resources/fixtures/scopes/swift/interior/interior.switchCase.scope new file mode 100644 index 0000000000..2922310d29 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior/interior.switchCase.scope @@ -0,0 +1,69 @@ +switch value { + case 0: + bar + break + default: + bar + break +} +--- + +[#1 Content] = 1:4-6:13 + >------- +1| case 0: +2| bar +3| break +4| default: +5| bar +6| break + -------------< + +[#1 Removal] = +[#1 Domain] = 0:14-7:0 + > +0| switch value { +1| case 0: +2| bar +3| break +4| default: +5| bar +6| break +7| } + < + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 2:8-3:13 + >--- +2| bar +3| break + -------------< + +[#2 Removal] = +[#2 Domain] = 1:11-3:13 + > +1| case 0: +2| bar +3| break + -------------< + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 5:8-6:13 + >--- +5| bar +6| break + -------------< + +[#3 Removal] = +[#3 Domain] = 4:12-7:0 + > +4| default: +5| bar +6| break +7| } + < + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/key.mapPair.iteration.scope b/resources/fixtures/scopes/swift/key.mapPair.iteration.scope new file mode 100644 index 0000000000..e57fae7b83 --- /dev/null +++ b/resources/fixtures/scopes/swift/key.mapPair.iteration.scope @@ -0,0 +1,7 @@ +[foo: 0, bar: 1] +--- + +[Content] = +[Domain] = 0:1-0:15 + >--------------< +0| [foo: 0, bar: 1] diff --git a/resources/fixtures/scopes/swift/key.mapPair.scope b/resources/fixtures/scopes/swift/key.mapPair.scope new file mode 100644 index 0000000000..654be8d548 --- /dev/null +++ b/resources/fixtures/scopes/swift/key.mapPair.scope @@ -0,0 +1,39 @@ +[foo: 0, bar: 1] +--- + +[#1 Content] = 0:1-0:4 + >---< +0| [foo: 0, bar: 1] + +[#1 Removal] = 0:1-0:6 + >-----< +0| [foo: 0, bar: 1] + +[#1 Trailing delimiter] = 0:4-0:6 + >--< +0| [foo: 0, bar: 1] + +[#1 Domain] = 0:1-0:7 + >------< +0| [foo: 0, bar: 1] + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:9-0:12 + >---< +0| [foo: 0, bar: 1] + +[#2 Removal] = 0:9-0:14 + >-----< +0| [foo: 0, bar: 1] + +[#2 Trailing delimiter] = 0:12-0:14 + >--< +0| [foo: 0, bar: 1] + +[#2 Domain] = 0:9-0:15 + >------< +0| [foo: 0, bar: 1] + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/statement/statement.switch.scope b/resources/fixtures/scopes/swift/statement/statement.switch.scope new file mode 100644 index 0000000000..88ba119033 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement/statement.switch.scope @@ -0,0 +1,10 @@ +switch value {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| switch value {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/type/type.argument.catch.scope b/resources/fixtures/scopes/swift/type/type.argument.catch.scope new file mode 100644 index 0000000000..c781eb0df5 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.argument.catch.scope @@ -0,0 +1,25 @@ +do {} +catch let foo as Error {} +--- + +[Content] = 1:17-1:22 + >-----< +1| catch let foo as Error {} + +[Removal] = 1:17-1:23 + >------< +1| catch let foo as Error {} + +[Leading delimiter] = 1:16-1:17 + >-< +1| catch let foo as Error {} + +[Trailing delimiter] = 1:22-1:23 + >-< +1| catch let foo as Error {} + +[Domain] = 1:6-1:22 + >----------------< +1| catch let foo as Error {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type/type.cast.scope b/resources/fixtures/scopes/swift/type/type.cast.scope new file mode 100644 index 0000000000..db48958a91 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.cast.scope @@ -0,0 +1,20 @@ +foo as Int +--- + +[Content] = 0:7-0:10 + >---< +0| foo as Int + +[Removal] = 0:3-0:10 + >-------< +0| foo as Int + +[Leading delimiter] = 0:3-0:7 + >----< +0| foo as Int + +[Domain] = 0:0-0:10 + >----------< +0| foo as Int + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/type/type.typeArgument.iteration.scope b/resources/fixtures/scopes/swift/type/type.typeArgument.iteration.scope new file mode 100644 index 0000000000..0628170078 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.typeArgument.iteration.scope @@ -0,0 +1,13 @@ +let foo: Map +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:22 + >----------------------< +0| let foo: Map + + +[#2 Content] = +[#2 Domain] = 0:13-0:21 + >--------< +0| let foo: Map diff --git a/resources/fixtures/scopes/swift/type/type.typeArgument.scope b/resources/fixtures/scopes/swift/type/type.typeArgument.scope new file mode 100644 index 0000000000..3d6a00e1d0 --- /dev/null +++ b/resources/fixtures/scopes/swift/type/type.typeArgument.scope @@ -0,0 +1,52 @@ +let foo: Map +--- + +[#1 Content] = 0:9-0:22 + >-------------< +0| let foo: Map + +[#1 Removal] = 0:7-0:22 + >---------------< +0| let foo: Map + +[#1 Leading delimiter] = 0:7-0:9 + >--< +0| let foo: Map + +[#1 Domain] = 0:0-0:22 + >----------------------< +0| let foo: Map + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 0:13-0:16 + >---< +0| let foo: Map + +[#2 Removal] = 0:13-0:18 + >-----< +0| let foo: Map + +[#2 Trailing delimiter] = 0:16-0:18 + >--< +0| let foo: Map + +[#2 Insertion delimiter] = " " + + +[#3 Content] = +[#3 Domain] = 0:18-0:21 + >---< +0| let foo: Map + +[#3 Removal] = 0:16-0:21 + >-----< +0| let foo: Map + +[#3 Leading delimiter] = 0:16-0:18 + >--< +0| let foo: Map + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.assignment.compound.scope b/resources/fixtures/scopes/swift/value/value.assignment.compound.scope new file mode 100644 index 0000000000..0e71d5ba22 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.assignment.compound.scope @@ -0,0 +1,20 @@ +foo += 0 +--- + +[Content] = 0:7-0:8 + >-< +0| foo += 0 + +[Removal] = 0:3-0:8 + >-----< +0| foo += 0 + +[Leading delimiter] = 0:3-0:7 + >----< +0| foo += 0 + +[Domain] = 0:0-0:8 + >--------< +0| foo += 0 + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.mapPair.iteration.scope b/resources/fixtures/scopes/swift/value/value.mapPair.iteration.scope new file mode 100644 index 0000000000..f606502e89 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.mapPair.iteration.scope @@ -0,0 +1,13 @@ +[foo: 0, bar: 1] +--- + +[#1 Content] = +[#1 Domain] = 0:0-0:16 + >----------------< +0| [foo: 0, bar: 1] + + +[#2 Content] = +[#2 Domain] = 0:1-0:15 + >--------------< +0| [foo: 0, bar: 1] diff --git a/resources/fixtures/scopes/swift/value/value.mapPair.scope b/resources/fixtures/scopes/swift/value/value.mapPair.scope new file mode 100644 index 0000000000..e0a9e2fd28 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.mapPair.scope @@ -0,0 +1,39 @@ +[aaa: 0, bbb: 1] +--- + +[#1 Content] = 0:6-0:7 + >-< +0| [aaa: 0, bbb: 1] + +[#1 Removal] = 0:4-0:7 + >---< +0| [aaa: 0, bbb: 1] + +[#1 Leading delimiter] = 0:4-0:6 + >--< +0| [aaa: 0, bbb: 1] + +[#1 Domain] = 0:1-0:7 + >------< +0| [aaa: 0, bbb: 1] + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 0:14-0:15 + >-< +0| [aaa: 0, bbb: 1] + +[#2 Removal] = 0:12-0:15 + >---< +0| [aaa: 0, bbb: 1] + +[#2 Leading delimiter] = 0:12-0:14 + >--< +0| [aaa: 0, bbb: 1] + +[#2 Domain] = 0:9-0:15 + >------< +0| [aaa: 0, bbb: 1] + +[#2 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/value/value.switch.scope b/resources/fixtures/scopes/swift/value/value.switch.scope new file mode 100644 index 0000000000..b1f072b5c8 --- /dev/null +++ b/resources/fixtures/scopes/swift/value/value.switch.scope @@ -0,0 +1,24 @@ +switch value {} +--- + +[Content] = 0:7-0:12 + >-----< +0| switch value {} + +[Removal] = 0:7-0:13 + >------< +0| switch value {} + +[Leading delimiter] = 0:6-0:7 + >-< +0| switch value {} + +[Trailing delimiter] = 0:12-0:13 + >-< +0| switch value {} + +[Domain] = 0:0-0:15 + >---------------< +0| switch value {} + +[Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index bb7440c9ff..737021cfad 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -288,10 +288,15 @@ (catch_block) ) @branch.iteration -;;!! do {} catch {} -;;! ^^^^^^^^ +;;!! do {} catch let foo as Error {} +;;! ^^^^^^^^^^^^^^^^^^^^^^^^^ +;;! ^^^^^ (do_statement - (catch_block) @branch + (catch_block + (pattern + name: (_) @type + )? @type.domain + ) @branch ) ;;!! true ? 0 : 1 @@ -320,6 +325,32 @@ condition: (_) @condition ) @condition.domain +;;!! switch value { } +;;! ^^^^^ +;;! ^ +(switch_statement + expr: (_) @value + "{" @branch.iteration.start.endOf @condition.iteration.start.endOf + "}" @branch.iteration.end.startOf @condition.iteration.end.startOf +) @value.domain + +;;!! case 0: break +;;!! default: break +(switch_entry + ":" @interior.start.endOf + (statements) @interior.end.endOf +) @branch + +;;!! case 0: break +;;! ^ +(switch_entry + . + (switch_pattern) @condition.start + (switch_pattern)? @condition.end + . + ":" +) @condition.domain + ;;!! /\d+$/ ( (regex_literal) @regularExpression @textFragment @@ -386,4 +417,64 @@ (array_literal) @list ;;!! [aaa: 0, bbb: 1] -(dictionary_literal) @map +(dictionary_literal + "[" @collectionKey.iteration.start.endOf @value.iteration.start.endOf + "]" @collectionKey.iteration.end.startOf @value.iteration.end.startOf +) @map + +;;!! [aaa: 0, bbb: 1] +;;! ^^^ ^^^ +(dictionary_literal + key: (_) @collectionKey @collectionKey.domain.start + . + ":" + . + value: (_) @collectionKey.trailing.startOf @collectionKey.domain.end +) + +;;!! [aaa: 0, bbb: 1] +;;! ^ ^ +(dictionary_literal + key: (_) @value.leading.endOf @value.domain.start + . + ":" + . + value: (_) @value @value.domain.end +) + +;;!! foo as Int +;;! ^^^ +(as_expression + expr: (_) @type.leading.endOf + (_) @type + . +) @type.domain + +;;!! Map +;;! ^^^ ^^^ +(type_annotation + (user_type + (type_arguments + (_)? @type.leading.endOf + . + (_) @type + . + (_)? @type.trailing.startOf + ) + ) +) + +;;!! Map +;;! ^^^^^^^^ +(type_annotation + (user_type + (type_arguments + "<" @type.iteration.start.endOf + ">" @type.iteration.end.startOf + ) + ) +) + +(function_type + "->" @disqualifyDelimiter +) From 3f21949a6ee9503275e7208e2ef873b7e624e221 Mon Sep 17 00:00:00 2001 From: Andreas Arvidsson Date: Sun, 20 Sep 2026 19:33:26 +0200 Subject: [PATCH 46/46] Raw string --- packages/lib-common/src/scopeSupportFacets/swift.ts | 13 ++++++++----- .../fixtures/scopes/swift/string.singleLine2.scope | 10 ++++++++++ .../textFragment.string.singleLine2.scope | 10 ++++++++++ resources/queries/swift.scm | 13 ++++++++----- 4 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 resources/fixtures/scopes/swift/string.singleLine2.scope create mode 100644 resources/fixtures/scopes/swift/textFragment/textFragment.string.singleLine2.scope diff --git a/packages/lib-common/src/scopeSupportFacets/swift.ts b/packages/lib-common/src/scopeSupportFacets/swift.ts index 6c90d2062b..4bc8794d42 100644 --- a/packages/lib-common/src/scopeSupportFacets/swift.ts +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -5,7 +5,6 @@ const { supported, unsupported, notApplicable } = ScopeSupportFacetLevel; export const swiftScopeSupport: LanguageScopeSupportFacetMap = { disqualifyDelimiter: supported, - pairDelimiter: supported, anonymousFunction: supported, list: supported, map: supported, @@ -62,10 +61,6 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "argumentList.formal.lambda.singleLine": supported, "argumentList.formal.lambda.multiLine": supported, - "collectionItem.unenclosed.singleLine": supported, - "collectionItem.unenclosed.multiLine": supported, - "collectionItem.unenclosed.iteration": supported, - "branch.if": supported, "branch.if.elif.else": supported, "branch.if.else": supported, @@ -140,6 +135,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "statement.break": supported, "statement.continue": supported, "statement.import": supported, + "statement.yield": supported, "statement.iteration.document": supported, "statement.iteration.class": supported, "statement.iteration.interface": supported, @@ -207,6 +203,7 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { "value.field.class": supported, "value.field.enum": supported, "value.throw": supported, + "value.yield": supported, "value.switch": supported, "value.typeAlias": supported, "value.argument.actual": supported, @@ -347,11 +344,17 @@ export const swiftScopeSupport: LanguageScopeSupportFacetMap = { subParagraph: notApplicable, part: notApplicable, + // Collection items unenclosed + "collectionItem.unenclosed.singleLine": notApplicable, + "collectionItem.unenclosed.multiLine": notApplicable, + "collectionItem.unenclosed.iteration": notApplicable, + // Miscellaneous "statement.misc": notApplicable, "statement.package": notApplicable, "statement.update": notApplicable, "value.field.interface": notApplicable, + pairDelimiter: notApplicable, environment: notApplicable, selector: notApplicable, unit: notApplicable, diff --git a/resources/fixtures/scopes/swift/string.singleLine2.scope b/resources/fixtures/scopes/swift/string.singleLine2.scope new file mode 100644 index 0000000000..daad707e18 --- /dev/null +++ b/resources/fixtures/scopes/swift/string.singleLine2.scope @@ -0,0 +1,10 @@ +#"Hello world"# +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| #"Hello world"# + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment/textFragment.string.singleLine2.scope b/resources/fixtures/scopes/swift/textFragment/textFragment.string.singleLine2.scope new file mode 100644 index 0000000000..c6a28ce2a4 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment/textFragment.string.singleLine2.scope @@ -0,0 +1,10 @@ +#"Hello world"# +--- + +[Content] = +[Removal] = +[Domain] = 0:2-0:13 + >-----------< +0| #"Hello world"# + +[Insertion delimiter] = " " diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm index 737021cfad..2b8837bdb1 100644 --- a/resources/queries/swift.scm +++ b/resources/queries/swift.scm @@ -62,6 +62,14 @@ text: (_) @textFragment ) @string +;;!! #"Hello world"# +;;! ^^^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ +(raw_string_literal + (_) @textFragment + (#character-range! @textFragment 2 -2) +) @string + ;;!! """Hello world""" ;;! ^^^^^^^^^^^^^^^^^ ;;! ^^^^^^^^^^^ @@ -69,11 +77,6 @@ text: (_) @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 - ;;!! struct Foo {} ;;! ^^^ (class_declaration