diff --git a/.gitignore b/.gitignore index fa67b4db01..f15bf11b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,10 @@ node_modules/ *.vsix .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/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 1ea8d96bd6..f9f5fa85c2 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 @@ -1479,6 +1479,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 f109683831..ffbdb3c37c 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 @@ -317,6 +325,10 @@ The following are internal scopes. They are not intended for user interaction or +##### Swift + + + ##### YAML @@ -409,6 +421,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..bcd8c61da1 --- /dev/null +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json @@ -0,0 +1,958 @@ +[ + { + "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" + }, + { + "targets": [ + { + "content": "1:13-2:6" + } + ], + "domain": "1:13-2:6" + } + ] + }, + { + "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.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", + "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.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", + "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/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", + "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/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", + "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/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", + "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.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", + "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" + }, + { + "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" + } + ] + }, + { + "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/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 new file mode 100644 index 0000000000..705a5d4a36 --- /dev/null +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -0,0 +1,324 @@ +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 + + + +#### 2. Class (iteration class) + +Iteration scope for classes: class bodies. + + + +### 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: 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 + +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 + + + +#### 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 + +A class/struct declaration + + + +#### 2. Statement: Enum + +An enum declaration + + + +#### 3. Statement: Foreach + +A for-each loop + + + +#### 4. Statement: Interface + +An interface declaration + + + +#### 5. Statement (iteration class) + +Iteration scope for statements: class bodies. + + + +#### 6. Statement (iteration interface) + +Iteration scope for statements: interface bodies. + + + +### Type + +#### 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 + +Iterable in a for-each loop + + + +#### 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. + +### 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 896554cdc0..324618f479 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. @@ -497,6 +509,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 ff74cb5a05..c795ae0d05 100644 --- a/packages/app-web-docs/src/docs/user/scopes/class.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/class.mdx @@ -111,6 +111,10 @@ Default: `class` +##### Swift + + + ##### TypeScript @@ -147,6 +151,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/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 21c811de61..4cf3a0ad6e 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 a08cd6e975..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 @@ -3394,5 +3394,143 @@ "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" + }, + { + "targets": [ + { + "content": "1:13-2:6" + } + ], + "domain": "1:13-2:6" + } + ] + }, + { + "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 a25d6d31cf..84a9966218 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 @@ -819,6 +819,47 @@ } ] }, + { + "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", + "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 81ad1e4777..ada5586e01 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 @@ -1896,6 +1896,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 25e54c8dc0..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,91 @@ } ] }, + { + "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", + "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/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 60af9cf303..84644cffd4 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 @@ -12381,6 +12381,146 @@ } ] }, + { + "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/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 8ffb3574ac..0df1bdf3d5 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 @@ -11464,6 +11464,122 @@ } ] }, + { + "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/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 016f6d24a5..86ae9b145f 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 @@ -7476,6 +7476,231 @@ } ] }, + { + "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", + "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" + }, + { + "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" + } + ] + }, { "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 c016ad2d23..3a7de39b7b 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,47 @@ } ] }, + { + "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/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/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 8e477ba797..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 @@ -503,6 +515,10 @@ Cursorless ID: `interior` +##### Swift + + + ##### Talon @@ -535,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 eb9fab5fbe..56ef1e3363 100644 --- a/packages/app-web-docs/src/docs/user/scopes/name.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/name.mdx @@ -583,6 +583,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -739,6 +743,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -943,6 +951,10 @@ Default: `name` +##### Swift + + + ##### Talon @@ -1087,6 +1099,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -1683,6 +1699,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -1811,6 +1831,10 @@ Default: `name` +##### Swift + + + ##### TypeScript @@ -1843,6 +1867,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 6d1af43396..485511592c 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 @@ -539,6 +543,10 @@ Default: `state` +##### Swift + + + ##### TypeScript @@ -731,6 +739,10 @@ Default: `state` +##### Swift + + + ##### Talon @@ -1075,6 +1087,10 @@ Default: `state` +##### Swift + + + ##### TypeScript @@ -2095,6 +2111,10 @@ Default: `state` +##### Swift + + + ### Statement (iteration document) Iteration scope for statements: the entire document including leading and trailing empty lines. @@ -2203,6 +2223,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 ba0e80816f..b919b1da7c 100644 --- a/packages/app-web-docs/src/docs/user/scopes/type.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/type.mdx @@ -453,6 +453,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -499,6 +503,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -557,6 +565,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -585,6 +597,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -617,6 +633,10 @@ Default: `type` +##### Swift + + + ### Type: Interface An interface declaration @@ -879,6 +899,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -927,6 +951,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1019,6 +1047,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1089,6 +1121,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1137,6 +1173,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1165,6 +1205,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 6c395878ed..b454b94c50 100644 --- a/packages/app-web-docs/src/docs/user/scopes/value.mdx +++ b/packages/app-web-docs/src/docs/user/scopes/value.mdx @@ -615,6 +615,10 @@ Default: `value` +##### Swift + + + ##### Talon @@ -1459,6 +1463,10 @@ Default: `value` +##### Swift + + + ##### TypeScript 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", }, diff --git a/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts b/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts index fff865031c..88da1193a4 100644 --- a/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts +++ b/packages/lib-common/src/scopeSupportFacets/languageScopeSupport.ts @@ -28,6 +28,7 @@ import { scmScopeSupport } from "./scm"; import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; import { scssScopeSupport } from "./scss"; import { shellscriptScopeSupport } from "./shellscript"; +import { swiftScopeSupport } from "./swift"; import { talonScopeSupport } from "./talon"; import { talonListScopeSupport } from "./talonList"; import { typescriptScopeSupport } from "./typescript"; @@ -70,6 +71,7 @@ export const languageScopeSupport: Record< scm: scmScopeSupport, scss: scssScopeSupport, shellscript: shellscriptScopeSupport, + 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..21b28667bd --- /dev/null +++ b/packages/lib-common/src/scopeSupportFacets/swift.ts @@ -0,0 +1,410 @@ +import type { LanguageScopeSupportFacetMap } from "./scopeSupportFacets.types"; +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, + "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": unsupported, + "condition.ternary": unsupported, + "branch.ternary.iteration": unsupported, + + // for loop + "statement.foreach": supported, + "name.foreach": supported, + "value.foreach": supported, + "type.foreach": supported, + "interior.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, + "interior.try": unsupported, + "branch.try.iteration": unsupported, + + // switch + "statement.switch": unsupported, + "branch.switchCase": unsupported, + "condition.switchCase": 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, + "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, + + // 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": unsupported, + + "statement.iteration.class": supported, + "class.iteration.class": supported, + "namedFunction.iteration.class": unsupported, + "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": supported, + "type.interface": unsupported, + + "statement.iteration.interface": supported, + "name.iteration.interface": supported, + "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, + + // constructors + "namedFunction.constructor": unsupported, + "statement.constructor": unsupported, + "name.constructor": unsupported, + "interior.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, + "statement.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; 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 (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 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, + + // 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, + + "type.constant": supported, + "type.variable.uninitialized": supported, + "type.variable.initialized": supported, + "type.field.class": supported, + "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, + + "value.assignment": unsupported, + "value.assignment.destructuring": unsupported, + "value.assignment.compound": unsupported, + + // 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, + + // 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": supported, + + // general per-block iteration (not branches) + "statement.iteration.block": unsupported, + "name.iteration.block": unsupported, + "value.iteration.block": unsupported, + "type.iteration.block": supported, + + // 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, + "value.mapPair": unsupported, + "value.mapPair.iteration": unsupported, + + // 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, + + // 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, + + // 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.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.alias": unsupported, + "type.cast": unsupported, + "type.typeArgument.iteration": unsupported, + + // misc + regularExpression: unsupported, + disqualifyDelimiter: unsupported, + pairDelimiter: unsupported, + "textFragment.regularExpression": unsupported, + "statement.import": 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, + 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: 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, + "statement.static": 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..c8aa5e8b4e --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.elif.else.scope @@ -0,0 +1,95 @@ +if foo {} +else if bar {} +else {} +--- + +[#1 Content] = +[#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 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] = 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 new file mode 100644 index 0000000000..fb73666f03 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.else.scope @@ -0,0 +1,41 @@ +if true {} +else {} +--- + +[#1 Content] = +[#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-1:7 + >---------- +0| if true {} +1| else {} + -------< + +[#2 Insertion delimiter] = "\n" + + +[#3 Content] = +[#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 new file mode 100644 index 0000000000..59553c1851 --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -0,0 +1,20 @@ +if foo {} +else if bar {} +else {} +--- + +[#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/branch.if.scope b/resources/fixtures/scopes/swift/branch.if.scope new file mode 100644 index 0000000000..95d75aa3fb --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.scope @@ -0,0 +1,10 @@ +if true {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| if true {} + +[Insertion delimiter] = "\n" 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..a3ec5f3456 --- /dev/null +++ b/resources/fixtures/scopes/swift/class.iteration.class.scope @@ -0,0 +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/class.scope b/resources/fixtures/scopes/swift/class.scope new file mode 100644 index 0000000000..80a9ab592c --- /dev/null +++ b/resources/fixtures/scopes/swift/class.scope @@ -0,0 +1,10 @@ +struct Foo {} +--- + +[Content] = +[Removal] = +[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 new file mode 100644 index 0000000000..a469659c87 --- /dev/null +++ b/resources/fixtures/scopes/swift/comment.line.scope @@ -0,0 +1,10 @@ +// aaa +--- + +[Content] = +[Removal] = +[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 new file mode 100644 index 0000000000..39fee6c27b --- /dev/null +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -0,0 +1,24 @@ +if foo {} +--- + +[Content] = 0:3-0:6 + >---< +0| if foo {} + +[Removal] = 0:3-0:7 + >----< +0| if foo {} + +[Leading delimiter] = 0:2-0:3 + >-< +0| if foo {} + +[Trailing delimiter] = 0:6-0:7 + >-< +0| if foo {} + +[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 new file mode 100644 index 0000000000..95d75aa3fb --- /dev/null +++ b/resources/fixtures/scopes/swift/ifStatement.scope @@ -0,0 +1,10 @@ +if true {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:10 + >----------< +0| if true {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/interior.class.scope b/resources/fixtures/scopes/swift/interior.class.scope new file mode 100644 index 0000000000..13ef2f4d94 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.class.scope @@ -0,0 +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 new file mode 100644 index 0000000000..d96875b078 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.enum.scope @@ -0,0 +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 new file mode 100644 index 0000000000..ac81619891 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.foreach.scope @@ -0,0 +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.if.scope b/resources/fixtures/scopes/swift/interior.if.scope new file mode 100644 index 0000000000..9a35dae364 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.if.scope @@ -0,0 +1,10 @@ +if foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:8-0:10 + >--< +0| if foo { } + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/interior.interface.scope b/resources/fixtures/scopes/swift/interior.interface.scope new file mode 100644 index 0000000000..675578b704 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.interface.scope @@ -0,0 +1,10 @@ +protocol Foo { } +--- + +[Content] = +[Removal] = +[Domain] = 0:14-0:15 + >-< +0| protocol Foo { } + +[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..c4ecaeeb34 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.class.scope @@ -0,0 +1,21 @@ +class Foo {} +--- + +[Content] = +[Domain] = 0:6-0:9 + >---< +0| class Foo {} + +[Removal] = 0:6-0:10 + >----< +0| class Foo {} + +[Leading delimiter] = 0:5-0:6 + >-< +0| class Foo {} + +[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 new file mode 100644 index 0000000000..2162ad8604 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.enum.scope @@ -0,0 +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/name.foreach.scope b/resources/fixtures/scopes/swift/name.foreach.scope new file mode 100644 index 0000000000..c8e077322e --- /dev/null +++ b/resources/fixtures/scopes/swift/name.foreach.scope @@ -0,0 +1,24 @@ +for foo in bar {} +--- + +[Content] = 0:4-0:7 + >---< +0| for foo in bar {} + +[Removal] = 0:4-0:8 + >----< +0| for foo in bar {} + +[Leading delimiter] = 0:3-0:4 + >-< +0| for foo in bar {} + +[Trailing delimiter] = 0:7-0:8 + >-< +0| for foo in bar {} + +[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 new file mode 100644 index 0000000000..7268b1a3e0 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.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/fixtures/scopes/swift/name.iteration.class.scope b/resources/fixtures/scopes/swift/name.iteration.class.scope new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.class.scope @@ -0,0 +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 new file mode 100644 index 0000000000..9034c4ee11 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.enum.scope @@ -0,0 +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 new file mode 100644 index 0000000000..7db5025f1b --- /dev/null +++ b/resources/fixtures/scopes/swift/name.iteration.interface.scope @@ -0,0 +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/statement.class.scope b/resources/fixtures/scopes/swift/statement.class.scope new file mode 100644 index 0000000000..a6008d311f --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.class.scope @@ -0,0 +1,10 @@ +class Foo {} +--- + +[Content] = +[Removal] = +[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 new file mode 100644 index 0000000000..88dd9cd028 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.enum.scope @@ -0,0 +1,10 @@ +enum Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +0| enum Foo {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.foreach.scope b/resources/fixtures/scopes/swift/statement.foreach.scope new file mode 100644 index 0000000000..005a6562ec --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.foreach.scope @@ -0,0 +1,10 @@ +for foo in bar {} +--- + +[Content] = +[Removal] = +[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 new file mode 100644 index 0000000000..ea6dad63a6 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.interface.scope @@ -0,0 +1,10 @@ +protocol Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| protocol Foo {} + +[Insertion delimiter] = "\n" 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..a3ec5f3456 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.class.scope @@ -0,0 +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 new file mode 100644 index 0000000000..7db5025f1b --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.iteration.interface.scope @@ -0,0 +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/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 new file mode 100644 index 0000000000..e47b42fed9 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +// aaa +--- + +[Content] = +[Removal] = +[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.constant.scope b/resources/fixtures/scopes/swift/type.constant.scope new file mode 100644 index 0000000000..386c29221d --- /dev/null +++ b/resources/fixtures/scopes/swift/type.constant.scope @@ -0,0 +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 new file mode 100644 index 0000000000..2162ad8604 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.enum.scope @@ -0,0 +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 new file mode 100644 index 0000000000..8e772e72e1 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.field.class.scope @@ -0,0 +1,39 @@ +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 new file mode 100644 index 0000000000..13d746a265 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -0,0 +1,19 @@ +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 new file mode 100644 index 0000000000..b33e662415 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.foreach.scope @@ -0,0 +1,36 @@ +for foo: Type in bar {} +--- + +[#1 Content] = 0:9-0:13 + >----< +0| for foo: Type in bar {} + +[#1 Removal] = 0:7-0:13 + >------< +0| for foo: Type in bar {} + +[#1 Leading delimiter] = 0:7-0:9 + >--< +0| for foo: Type in bar {} + +[#1 Domain] = 0:0-0:23 + >-----------------------< +0| for foo: Type in bar {} + +[#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 new file mode 100644 index 0000000000..c5bbfd9099 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.block.scope @@ -0,0 +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 new file mode 100644 index 0000000000..a3ec5f3456 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.class.scope @@ -0,0 +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 new file mode 100644 index 0000000000..7db5025f1b --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.interface.scope @@ -0,0 +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 new file mode 100644 index 0000000000..d8d205f9e1 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.variable.initialized.scope @@ -0,0 +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 new file mode 100644 index 0000000000..98b51069c8 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.variable.uninitialized.scope @@ -0,0 +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.foreach.scope b/resources/fixtures/scopes/swift/value.foreach.scope new file mode 100644 index 0000000000..d1ab264c5d --- /dev/null +++ b/resources/fixtures/scopes/swift/value.foreach.scope @@ -0,0 +1,24 @@ +for foo in bar {} +--- + +[Content] = 0:11-0:14 + >---< +0| for foo in bar {} + +[Removal] = 0:11-0:15 + >----< +0| for foo in bar {} + +[Leading delimiter] = 0:10-0:11 + >-< +0| for foo in bar {} + +[Trailing delimiter] = 0:14-0:15 + >-< +0| for foo in bar {} + +[Domain] = 0:0-0:17 + >-----------------< +0| for foo in bar {} + +[Insertion delimiter] = " " 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..9034c4ee11 --- /dev/null +++ b/resources/fixtures/scopes/swift/value.iteration.enum.scope @@ -0,0 +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/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..1cfa874e89 --- /dev/null +++ b/resources/playground/rust.rs @@ -0,0 +1,8 @@ +fn hello() { + let apple: Bool = false + if true { + //1 + } else if false { + //2 + } +} \ No newline at end of file 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/playground/swift/cursorless-test-project/test.swift b/resources/playground/swift/cursorless-test-project/test.swift new file mode 100644 index 0000000000..24cba1c6d8 --- /dev/null +++ b/resources/playground/swift/cursorless-test-project/test.swift @@ -0,0 +1,104 @@ +let pipis: Bool = true + +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."# + +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 +} + +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 { + let foo = 222222 + } + } + } +} \ No newline at end of file diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm new file mode 100644 index 0000000000..63a2980998 --- /dev/null +++ b/resources/queries/swift.scm @@ -0,0 +1,178 @@ +;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json + +;; document-wide +( + (source_file) @value.iteration @type.iteration @interior.iteration + (#document-range! @value.iteration @type.iteration @interior.iteration) +) + +( + (source_file) @class.iteration @statement.iteration @name.iteration + (#document-range! @class.iteration @statement.iteration @name.iteration) +) + +;; 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 + body: (protocol_body + "{" @interior.start.endOf + "}" @interior.end.startOf + ) +) @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 + 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 + ;;(type_annotation: + ;; ":" + ;;) +) @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 + ) +) + +;; 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 + body: (class_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 + +;; For loop +( + (for_statement + "for" + item: (_) @name + (type_annotation + ":" @type.leading + . + _ @type @name.trailing + )? + "in" + collection: (_) @value + ) @statement @_.domain +) + +;; generic type annotation +( + (type_annotation + ":" @type.leading + . + _ @type + ) +)