diff --git a/.gitignore b/.gitignore index fa67b4db01..50b4aceec7 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,7 @@ node_modules/ *.vsix .DS_Store .luacheckcache + +# 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..9b81761f9f 100644 --- a/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json +++ b/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/string.json @@ -628,6 +628,40 @@ } ] }, + { + "name": "scopes/swift/string.multiLine", + "languageId": "swift", + "facet": "string.multiLine", + "code": "\"\"\"\nHello\nworld\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-3:3", + "removal": "0:0-3:3" + } + ], + "domain": "0:0-3:3" + } + ] + }, + { + "name": "scopes/swift/string.singleLine", + "languageId": "swift", + "facet": "string.singleLine", + "code": "\"Hello world\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13", + "removal": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + } + ] + }, { "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..a853ccc740 100644 --- a/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json +++ b/packages/app-web-docs/src/docs/contributing/private-scopes/fixtures/textFragment.json @@ -1479,6 +1479,74 @@ } ] }, + { + "name": "scopes/swift/textFragment.comment.block", + "languageId": "swift", + "facet": "textFragment.comment.block", + "code": "/* Hello world */", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.line", + "languageId": "swift", + "facet": "textFragment.comment.line", + "code": "// Hello world", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:14", + "removal": "0:0-0:14" + } + ], + "domain": "0:0-0:14" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.multiLine", + "languageId": "swift", + "facet": "textFragment.string.multiLine", + "code": "\"\"\"\nHello\nworld\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:3-3:0", + "removal": "0:3-3:0" + } + ], + "domain": "0:3-3:0" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.singleLine", + "languageId": "swift", + "facet": "textFragment.string.singleLine", + "code": "\"Hello world\"", + "scopes": [ + { + "targets": [ + { + "content": "0:1-0:12", + "removal": "0:1-0:12" + } + ], + "domain": "0:1-0:12" + } + ] + }, { "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..672e98ccf6 --- /dev/null +++ b/packages/app-web-docs/src/docs/user/languages/fixtures/swift.json @@ -0,0 +1,1029 @@ +[ + { + "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 true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if", + "languageId": "swift", + "facet": "branch.if", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] + }, + { + "name": "scopes/swift/class.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": "/* Hello world */", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/comment.line", + "languageId": "swift", + "facet": "comment.line", + "code": "// Hello world", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:14", + "removal": "0:0-0:14" + } + ], + "domain": "0:0-0:14" + } + ] + }, + { + "name": "scopes/swift/condition.if", + "languageId": "swift", + "facet": "condition.if", + "code": "if (true) {}\nelse if (false) {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:3-0:9", + "removal": "0:3-0:10" + } + ], + "domain": "0:0-2:7" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:0-1:15" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:5-2:7" + } + ] + }, + { + "name": "scopes/swift/ifStatement", + "languageId": "swift", + "facet": "ifStatement", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7", + "removal": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/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 v in values { }", + "scopes": [ + { + "targets": [ + { + "content": "0:17-0:18", + "removal": "0:17-0:18" + } + ], + "domain": "0:17-0:18" + } + ] + }, + { + "name": "scopes/swift/interior.if", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }\nelse if (false) { }\nelse { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + }, + { + "targets": [ + { + "content": "1:17-1:18", + "removal": "1:17-1:18" + } + ], + "domain": "1:17-1:18" + }, + { + "targets": [ + { + "content": "1:18-2:6", + "removal": "1:17-2:7" + } + ], + "domain": "1:17-2:7" + }, + { + "targets": [ + { + "content": "2:6-2:7", + "removal": "2:6-2:7" + } + ], + "domain": "2:6-2:7" + } + ] + }, + { + "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:0-0:12" + } + ] + }, + { + "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:0-0:11" + } + ] + }, + { + "name": "scopes/swift/name.foreach", + "languageId": "swift", + "facet": "name.foreach", + "code": "for v in values {}", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:5", + "removal": "0:4-0:6" + } + ], + "domain": "0:0-0:18" + } + ] + }, + { + "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:0-0:15" + } + ] + }, + { + "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 v in values {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:18", + "removal": "0:0-0:18" + } + ], + "domain": "0:0-0:18" + } + ] + }, + { + "name": "scopes/swift/statement.if", + "languageId": "swift", + "facet": "statement.if", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7", + "removal": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/statement.interface", + "languageId": "swift", + "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": "\"\"\"\nHello\nworld\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-3:3", + "removal": "0:0-3:3" + } + ], + "domain": "0:0-3:3" + } + ] + }, + { + "name": "scopes/swift/string.singleLine", + "languageId": "swift", + "facet": "string.singleLine", + "code": "\"Hello world\"", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:13", + "removal": "0:0-0:13" + } + ], + "domain": "0:0-0:13" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.block", + "languageId": "swift", + "facet": "textFragment.comment.block", + "code": "/* Hello world */", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/textFragment.comment.line", + "languageId": "swift", + "facet": "textFragment.comment.line", + "code": "// Hello world", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:14", + "removal": "0:0-0:14" + } + ], + "domain": "0:0-0:14" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.multiLine", + "languageId": "swift", + "facet": "textFragment.string.multiLine", + "code": "\"\"\"\nHello\nworld\n\"\"\"", + "scopes": [ + { + "targets": [ + { + "content": "0:3-3:0", + "removal": "0:3-3:0" + } + ], + "domain": "0:3-3:0" + } + ] + }, + { + "name": "scopes/swift/textFragment.string.singleLine", + "languageId": "swift", + "facet": "textFragment.string.singleLine", + "code": "\"Hello world\"", + "scopes": [ + { + "targets": [ + { + "content": "0:1-0:12", + "removal": "0:1-0:12" + } + ], + "domain": "0:1-0:12" + } + ] + }, + { + "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:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, + { + "name": "scopes/swift/type.field.class", + "languageId": "swift", + "facet": "type.field.class", + "code": "struct Foo {\n var foo: Int = 0\n}", + "scopes": [ + { + "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": "0:0-2:1", + "removal": "0:0-2:1" + } + ], + "domain": "0:0-2:1" + }, + { + "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.interface", + "languageId": "swift", + "facet": "type.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, + { + "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": "\nlet foo: Int\n", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:0" + } + ], + "domain": "0:0-2:0" + } + ] + }, + { + "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 v in values {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:15", + "removal": "0:9-0:16" + } + ], + "domain": "0:0-0:18" + } + ] + }, + { + "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..f75a7a68a2 --- /dev/null +++ b/packages/app-web-docs/src/docs/user/languages/swift.mdx @@ -0,0 +1,336 @@ +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: If + +An if/elif/else statement + + + +#### 5. Statement: Interface + +An interface declaration + + + +#### 6. Statement (iteration class) + +Iteration scope for statements: class bodies. + + + +#### 7. 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: Interface + +An interface declaration + + + +#### 7. Type: Variable initialized + +Type of an initialized variable declaration + + + +#### 8. Type: Variable uninitialized + +Type of an uninitialized variable declaration + + + +#### 9. Type (iteration block) + +Iteration scope for types: statement blocks (body of functions/if-statements/for-loops/etc). + + + +#### 10. Type (iteration class) + +Iteration scope for types: class bodies. + + + +#### 11. Type (iteration document) + +Iteration scope for types: the entire document including leading and trailing empty lines. + + + +#### 12. 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..65c9bced30 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/branch.json @@ -3394,5 +3394,135 @@ "domain": "0:13-0:14" } ] + }, + { + "name": "scopes/swift/branch.if.elif.else", + "languageId": "swift", + "facet": "branch.if.elif.else", + "code": "if foo {}\nelse if bar {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:9", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:9" + }, + { + "targets": [ + { + "content": "1:0-1:14", + "removal": "1:0-2:0" + } + ], + "domain": "1:0-1:14" + }, + { + "targets": [ + { + "content": "1:0-2:7", + "removal": "0:9-2:7" + } + ], + "domain": "1:0-2:7" + }, + { + "targets": [ + { + "content": "1:5-1:14", + "removal": "1:5-2:0" + } + ], + "domain": "1:5-1:14" + }, + { + "targets": [ + { + "content": "1:5-2:7", + "removal": "1:5-2:7" + } + ], + "domain": "1:5-2:7" + }, + { + "targets": [ + { + "content": "2:0-2:7", + "removal": "1:14-2:7" + } + ], + "domain": "2:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.else", + "languageId": "swift", + "facet": "branch.if.else", + "code": "if true {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-1:0" + } + ], + "domain": "0:0-0:10" + }, + { + "targets": [ + { + "content": "0:0-1:7", + "removal": "0:0-1:7" + } + ], + "domain": "0:0-1:7" + }, + { + "targets": [ + { + "content": "1:0-1:7", + "removal": "0:10-1:7" + } + ], + "domain": "1:0-1:7" + } + ] + }, + { + "name": "scopes/swift/branch.if.iteration", + "languageId": "swift", + "facet": "branch.if.iteration", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/branch.if", + "languageId": "swift", + "facet": "branch.if", + "code": "if true {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:10", + "removal": "0:0-0:10" + } + ], + "domain": "0:0-0:10" + } + ] } ] diff --git a/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json b/packages/app-web-docs/src/docs/user/scopes/fixtures/class.json index 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..41be4947fa 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/comment.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/comment.json @@ -713,6 +713,40 @@ } ] }, + { + "name": "scopes/swift/comment.block", + "languageId": "swift", + "facet": "comment.block", + "code": "/* Hello world */", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:17", + "removal": "0:0-0:17" + } + ], + "domain": "0:0-0:17" + } + ] + }, + { + "name": "scopes/swift/comment.line", + "languageId": "swift", + "facet": "comment.line", + "code": "// Hello world", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:14", + "removal": "0:0-0:14" + } + ], + "domain": "0:0-0:14" + } + ] + }, { "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..e057e810bb 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/condition.json @@ -1896,6 +1896,41 @@ } ] }, + { + "name": "scopes/swift/condition.if", + "languageId": "swift", + "facet": "condition.if", + "code": "if (true) {}\nelse if (false) {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:3-0:9", + "removal": "0:3-0:10" + } + ], + "domain": "0:0-2:7" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:0-1:15" + }, + { + "targets": [ + { + "content": "1:8-1:15", + "removal": "1:8-1:16" + } + ], + "domain": "1:5-2:7" + } + ] + }, { "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..a80d6377d3 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/ifStatement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/ifStatement.json @@ -288,6 +288,23 @@ } ] }, + { + "name": "scopes/swift/ifStatement", + "languageId": "swift", + "facet": "ifStatement", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7", + "removal": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, { "name": "scopes/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..c2edf6b055 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/interior.json @@ -5109,6 +5109,118 @@ } ] }, + { + "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 v in values { }", + "scopes": [ + { + "targets": [ + { + "content": "0:17-0:18", + "removal": "0:17-0:18" + } + ], + "domain": "0:17-0:18" + } + ] + }, + { + "name": "scopes/swift/interior.if", + "languageId": "swift", + "facet": "interior.if", + "code": "if (true) { }\nelse if (false) { }\nelse { }", + "scopes": [ + { + "targets": [ + { + "content": "0:11-0:12", + "removal": "0:11-0:12" + } + ], + "domain": "0:11-0:12" + }, + { + "targets": [ + { + "content": "1:17-1:18", + "removal": "1:17-1:18" + } + ], + "domain": "1:17-1:18" + }, + { + "targets": [ + { + "content": "1:18-2:6", + "removal": "1:17-2:7" + } + ], + "domain": "1:17-2:7" + }, + { + "targets": [ + { + "content": "2:6-2:7", + "removal": "2:6-2:7" + } + ], + "domain": "2:6-2:7" + } + ] + }, + { + "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..f1650b6579 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/name.json @@ -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:0-0:12" + } + ] + }, + { + "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:0-0:11" + } + ] + }, + { + "name": "scopes/swift/name.foreach", + "languageId": "swift", + "facet": "name.foreach", + "code": "for v in values {}", + "scopes": [ + { + "targets": [ + { + "content": "0:4-0:5", + "removal": "0:4-0:6" + } + ], + "domain": "0:0-0:18" + } + ] + }, + { + "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:0-0:15" + } + ] + }, + { + "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..8f0fa3ead6 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/statement.json @@ -11464,6 +11464,139 @@ } ] }, + { + "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 v in values {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:18", + "removal": "0:0-0:18" + } + ], + "domain": "0:0-0:18" + } + ] + }, + { + "name": "scopes/swift/statement.if", + "languageId": "swift", + "facet": "statement.if", + "code": "if true {}\nelse if false {}\nelse {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:7", + "removal": "0:0-2:7" + } + ], + "domain": "0:0-2:7" + } + ] + }, + { + "name": "scopes/swift/statement.interface", + "languageId": "swift", + "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..e5acd38976 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/type.json @@ -7476,6 +7476,248 @@ } ] }, + { + "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:0-0:11", + "removal": "0:0-0:11" + } + ], + "domain": "0:0-0:11" + } + ] + }, + { + "name": "scopes/swift/type.field.class", + "languageId": "swift", + "facet": "type.field.class", + "code": "struct Foo {\n var foo: Int = 0\n}", + "scopes": [ + { + "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": "0:0-2:1", + "removal": "0:0-2:1" + } + ], + "domain": "0:0-2:1" + }, + { + "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.interface", + "languageId": "swift", + "facet": "type.interface", + "code": "protocol Foo {}", + "scopes": [ + { + "targets": [ + { + "content": "0:0-0:15", + "removal": "0:0-0:15" + } + ], + "domain": "0:0-0:15" + } + ] + }, + { + "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": "\nlet foo: Int\n", + "scopes": [ + { + "targets": [ + { + "content": "0:0-2:0" + } + ], + "domain": "0:0-2:0" + } + ] + }, + { + "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..bce55cb619 100644 --- a/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json +++ b/packages/app-web-docs/src/docs/user/scopes/fixtures/value.json @@ -9061,6 +9061,47 @@ } ] }, + { + "name": "scopes/swift/value.foreach", + "languageId": "swift", + "facet": "value.foreach", + "code": "for v in values {}", + "scopes": [ + { + "targets": [ + { + "content": "0:9-0:15", + "removal": "0:9-0:16" + } + ], + "domain": "0:0-0:18" + } + ] + }, + { + "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..db36ec0b68 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 @@ -989,6 +1001,10 @@ Default: `state` +##### Swift + + + ##### Talon @@ -1075,6 +1091,10 @@ Default: `state` +##### Swift + + + ##### TypeScript @@ -2095,6 +2115,10 @@ Default: `state` +##### Swift + + + ### Statement (iteration document) Iteration scope for statements: the entire document including leading and trailing empty lines. @@ -2203,6 +2227,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..abed32aee4 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 @@ -645,6 +665,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -879,6 +903,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -927,6 +955,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1019,6 +1051,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1089,6 +1125,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1137,6 +1177,10 @@ Default: `type` +##### Swift + + + ##### TypeScript @@ -1165,6 +1209,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..62d7f40da7 --- /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": supported, + + "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..5a5ed880ea --- /dev/null +++ b/resources/fixtures/scopes/swift/branch.if.iteration.scope @@ -0,0 +1,12 @@ +if true {} +else if false {} +else {} +--- + +[Content] = +[Domain] = 0:0-2:7 + >---------- +0| if true {} +1| else if false {} +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..5e8b51111c --- /dev/null +++ b/resources/fixtures/scopes/swift/comment.block.scope @@ -0,0 +1,10 @@ +/* Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/comment.line.scope b/resources/fixtures/scopes/swift/comment.line.scope new file mode 100644 index 0000000000..7d1477b8a1 --- /dev/null +++ b/resources/fixtures/scopes/swift/comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[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..547fac7183 --- /dev/null +++ b/resources/fixtures/scopes/swift/condition.if.scope @@ -0,0 +1,77 @@ +if (true) {} +else if (false) {} +else {} +--- + +[#1 Content] = 0:3-0:9 + >------< +0| if (true) {} + +[#1 Removal] = 0:3-0:10 + >-------< +0| if (true) {} + +[#1 Leading delimiter] = 0:2-0:3 + >-< +0| if (true) {} + +[#1 Trailing delimiter] = 0:9-0:10 + >-< +0| if (true) {} + +[#1 Domain] = 0:0-2:7 + >------------ +0| if (true) {} +1| else if (false) {} +2| else {} + -------< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = 1:8-1:15 + >-------< +1| else if (false) {} + +[#2 Removal] = 1:8-1:16 + >--------< +1| else if (false) {} + +[#2 Leading delimiter] = 1:7-1:8 + >-< +1| else if (false) {} + +[#2 Trailing delimiter] = 1:15-1:16 + >-< +1| else if (false) {} + +[#2 Domain] = 1:0-1:15 + >---------------< +1| else if (false) {} + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:8-1:15 + >-------< +1| else if (false) {} + +[#3 Removal] = 1:8-1:16 + >--------< +1| else if (false) {} + +[#3 Leading delimiter] = 1:7-1:8 + >-< +1| else if (false) {} + +[#3 Trailing delimiter] = 1:15-1:16 + >-< +1| else if (false) {} + +[#3 Domain] = 1:5-2:7 + >------------- +1| else if (false) {} +2| else {} + -------< + +[#3 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/ifStatement.scope b/resources/fixtures/scopes/swift/ifStatement.scope new file mode 100644 index 0000000000..e0d492e889 --- /dev/null +++ b/resources/fixtures/scopes/swift/ifStatement.scope @@ -0,0 +1,15 @@ +if true {} +else if false {} +else {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:7 + >---------- +0| if true {} +1| else if false {} +2| else {} + -------< + +[Insertion delimiter] = "\n" diff --git a/resources/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..b1842875b3 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.foreach.scope @@ -0,0 +1,10 @@ +for v in values { } +--- + +[Content] = +[Removal] = +[Domain] = 0:17-0:18 + >-< +0| for v in values { } + +[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..bfa0250542 --- /dev/null +++ b/resources/fixtures/scopes/swift/interior.if.scope @@ -0,0 +1,46 @@ +if (true) { } +else if (false) { } +else { } +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:11-0:12 + >-< +0| if (true) { } + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Removal] = +[#2 Domain] = 1:17-1:18 + >-< +1| else if (false) { } + +[#2 Insertion delimiter] = " " + + +[#3 Content] = 1:18-2:6 + >- +1| else if (false) { } +2| else { } + ------< + +[#3 Removal] = +[#3 Domain] = 1:17-2:7 + >-- +1| else if (false) { } +2| else { } + -------< + +[#3 Insertion delimiter] = " " + + +[#4 Content] = +[#4 Removal] = +[#4 Domain] = 2:6-2:7 + >-< +2| else { } + +[#4 Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/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..211086562c --- /dev/null +++ b/resources/fixtures/scopes/swift/name.class.scope @@ -0,0 +1,24 @@ +class Foo {} +--- + +[Content] = 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 {} + +[Domain] = 0:0-0:12 + >------------< +0| class Foo {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.enum.scope b/resources/fixtures/scopes/swift/name.enum.scope new file mode 100644 index 0000000000..09d2849071 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.enum.scope @@ -0,0 +1,24 @@ +enum Foo {} +--- + +[Content] = 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 {} + +[Domain] = 0:0-0:11 + >-----------< +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..76a1dd8dda --- /dev/null +++ b/resources/fixtures/scopes/swift/name.foreach.scope @@ -0,0 +1,24 @@ +for v in values {} +--- + +[Content] = 0:4-0:5 + >-< +0| for v in values {} + +[Removal] = 0:4-0:6 + >--< +0| for v in values {} + +[Leading delimiter] = 0:3-0:4 + >-< +0| for v in values {} + +[Trailing delimiter] = 0:5-0:6 + >-< +0| for v in values {} + +[Domain] = 0:0-0:18 + >------------------< +0| for v in values {} + +[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..6327dc4e46 --- /dev/null +++ b/resources/fixtures/scopes/swift/name.interface.scope @@ -0,0 +1,24 @@ +protocol Foo {} +--- + +[Content] = 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 {} + +[Domain] = 0:0-0:15 + >---------------< +0| protocol Foo {} + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/name.iteration.class.scope b/resources/fixtures/scopes/swift/name.iteration.class.scope 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..823a899261 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.foreach.scope @@ -0,0 +1,10 @@ +for v in values {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:18 + >------------------< +0| for v in values {} + +[Insertion delimiter] = "\n" diff --git a/resources/fixtures/scopes/swift/statement.if.scope b/resources/fixtures/scopes/swift/statement.if.scope new file mode 100644 index 0000000000..e0d492e889 --- /dev/null +++ b/resources/fixtures/scopes/swift/statement.if.scope @@ -0,0 +1,15 @@ +if true {} +else if false {} +else {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-2:7 + >---------- +0| if true {} +1| else if false {} +2| else {} + -------< + +[Insertion delimiter] = "\n" diff --git a/resources/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..322d7a6860 --- /dev/null +++ b/resources/fixtures/scopes/swift/string.multiLine.scope @@ -0,0 +1,17 @@ +""" +Hello +world +""" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-3:3 + >--- +0| """ +1| Hello +2| world +3| """ + ---< + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/string.singleLine.scope b/resources/fixtures/scopes/swift/string.singleLine.scope new file mode 100644 index 0000000000..4b26cf31b3 --- /dev/null +++ b/resources/fixtures/scopes/swift/string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:13 + >-------------< +0| "Hello world" + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.comment.block.scope b/resources/fixtures/scopes/swift/textFragment.comment.block.scope new file mode 100644 index 0000000000..af33f95d00 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.comment.block.scope @@ -0,0 +1,10 @@ +/* Hello world */ +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:17 + >-----------------< +0| /* Hello world */ + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.comment.line.scope b/resources/fixtures/scopes/swift/textFragment.comment.line.scope new file mode 100644 index 0000000000..6758f81490 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.comment.line.scope @@ -0,0 +1,10 @@ +// Hello world +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:14 + >--------------< +0| // Hello world + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope b/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope new file mode 100644 index 0000000000..a5531210d9 --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.string.multiLine.scope @@ -0,0 +1,17 @@ +""" +Hello +world +""" +--- + +[Content] = +[Removal] = +[Domain] = 0:3-3:0 + > +0| """ +1| Hello +2| world +3| """ + < + +[Insertion delimiter] = " " diff --git a/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope b/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope new file mode 100644 index 0000000000..85dcf5fa7f --- /dev/null +++ b/resources/fixtures/scopes/swift/textFragment.string.singleLine.scope @@ -0,0 +1,10 @@ +"Hello world" +--- + +[Content] = +[Removal] = +[Domain] = 0:1-0:12 + >-----------< +0| "Hello world" + +[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..70c26e7b58 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.enum.scope @@ -0,0 +1,10 @@ +enum Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:11 + >-----------< +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..4a358c8142 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.field.class.scope @@ -0,0 +1,19 @@ +struct Foo { + var foo: Int = 0 +} +--- + +[Content] = +[Domain] = 1:13-1:16 + >---< +1| var foo: Int = 0 + +[Removal] = 1:11-1:16 + >-----< +1| var foo: Int = 0 + +[Leading delimiter] = 1:11-1:13 + >--< +1| var foo: Int = 0 + +[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..b99cc0dab1 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.field.interface.scope @@ -0,0 +1,31 @@ +protocol Foo { + var foo: Int { set get } +} +--- + +[#1 Content] = +[#1 Removal] = +[#1 Domain] = 0:0-2:1 + >-------------- +0| protocol Foo { +1| var foo: Int { set get } +2| } + -< + +[#1 Insertion delimiter] = " " + + +[#2 Content] = +[#2 Domain] = 1:13-1:16 + >---< +1| var foo: Int { set get } + +[#2 Removal] = 1:11-1:16 + >-----< +1| var foo: Int { set get } + +[#2 Leading delimiter] = 1:11-1:13 + >--< +1| var foo: Int { set get } + +[#2 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.interface.scope b/resources/fixtures/scopes/swift/type.interface.scope new file mode 100644 index 0000000000..eb75796f70 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.interface.scope @@ -0,0 +1,10 @@ +protocol Foo {} +--- + +[Content] = +[Removal] = +[Domain] = 0:0-0:15 + >---------------< +0| protocol Foo {} + +[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..41725916d2 --- /dev/null +++ b/resources/fixtures/scopes/swift/type.iteration.document.scope @@ -0,0 +1,12 @@ + +let foo: Int + +--- + +[Content] = +[Domain] = 0:0-2:0 + > +0| +1| let foo: Int +2| + < 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..d89b2cb282 --- /dev/null +++ b/resources/fixtures/scopes/swift/value.foreach.scope @@ -0,0 +1,24 @@ +for v in values {} +--- + +[Content] = 0:9-0:15 + >------< +0| for v in values {} + +[Removal] = 0:9-0:16 + >-------< +0| for v in values {} + +[Leading delimiter] = 0:8-0:9 + >-< +0| for v in values {} + +[Trailing delimiter] = 0:15-0:16 + >-< +0| for v in values {} + +[Domain] = 0:0-0:18 + >------------------< +0| for v in values {} + +[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..766a2ce1a7 --- /dev/null +++ b/resources/playground/rust.rs @@ -0,0 +1,8 @@ +fn hello() { + let apple: Bool = false + if true { + //1 + } else if false { + //2 + } +} diff --git a/resources/playground/swift.swift b/resources/playground/swift.swift new file mode 100644 index 0000000000..9db2eea02f --- /dev/null +++ b/resources/playground/swift.swift @@ -0,0 +1,15 @@ +protocol ExampleProtocol: ParentProtocol { + var foo: Type {set get} +} + +struct ExampleStruct: ParentStruct { + var foo: Type +} + +enum ExampleEnumeration: ParentEnumeration { + +} + +struct MultiInheritanceStruct: ParentStruct, ParentProtocol, OtherParentProtocol { + +} diff --git a/resources/queries/swift.scm b/resources/queries/swift.scm new file mode 100644 index 0000000000..c8b9ffbd62 --- /dev/null +++ b/resources/queries/swift.scm @@ -0,0 +1,134 @@ +;; https://github.com/alex-pinkus/tree-sitter-swift/blob/with-generated-files/src/grammar.json + +[ + (class_declaration) + (protocol_declaration) + (for_statement) + + ;; Disabled on purpose. We have a better definition of these below. + ;; (if_statement) +] @statement + +;; document-wide +( + (source_file) @statementNameValueType.iteration @class.iteration @namedFunction.iteration + (#document-range! @statementNameValueType.iteration @class.iteration @namedFunction.iteration) +) + +;;!! { } +;;! ^ +(_ + "{" @statementNameValueType.iteration.start.endOf @class.iteration.start.endOf @namedFunction.iteration.start.endOf + "}" @statementNameValueType.iteration.end.startOf @class.iteration.end.startOf @namedFunction.iteration.end.startOf +) + +(_ + "{" @interior.start.endOf + "}" @interior.end.startOf +) + +;;!! // Hello world +;;! ^^^^^^^^^^^^^^ +(comment) @comment @textFragment + +;;!! /* Hello world */ +;;! ^^^^^^^^^^^^^^^^^ +(multiline_comment) @comment @textFragment + +;;!! "Hello world" +;;! ^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ +(line_string_literal + text: (_) @textFragment +) @string + +;;!! """Hello world""" +;;! ^^^^^^^^^^^^^^^^^ +;;! ^^^^^^^^^^^ +(multi_line_string_literal + text: (_) @textFragment +) @string + +;; extended delimiter/"raw" strings (both multiline and single line) -- waiting on better tree-sitter support for these +;;(raw_string_literal +;; text: (_) @interior @textFragment +;;) @string + +;; if statement +( + (if_statement) @ifStatement @statement @branch.iteration + (#not-parent-type? @ifStatement if_statement) +) + +;; if statement w/ condition & child branches +( + (if_statement + "if" @branch.start @branch.removal.start + condition: (_) @condition + "}" @branch.end @branch.removal.end + (else)? @branch.removal.end.startOf + ) @condition.domain + (#not-parent-type? @condition.domain else) +) + +;; else if +( + (else) @branch.start @condition.domain.start + (if_statement + condition: (_) @condition @condition.domain.end + "}" @branch.end + ) +) + +;; else +( + (else) @branch.start + "}" @branch.end +) + +;; generic property delc +(property_declaration + name: (_) @name +) @statement @name.domain + +;;!! struct Foo {} +;;! ^^^ +(class_declaration + name: (_) @name + (class_body) +) @class @name.domain + +;;!! enum Foo {} +;;! ^^^ +(class_declaration + name: (_) @name + (enum_class_body) +) @type @name.domain + +;;!! protocol Foo {} +;;! ^^^ +(protocol_declaration + name: (_) @name +) @type @name.domain + +;; For loop +(for_statement + "for" + item: (_) @name + (type_annotation + ":" @type.leading + . + _ @type @name.trailing + )? + "in" + collection: (_) @value +) @_.domain + +;; generic type annotation +( + (type_annotation + ":" @type.leading + . + _ @type + ) +)