diff --git a/data/fixtures/recorded/languages/kotlin/changeCall4.yml b/data/fixtures/recorded/languages/kotlin/changeCall4.yml new file mode 100644 index 0000000000..53b66985b6 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeCall4.yml @@ -0,0 +1,33 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change call + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: functionCall} + usePrePhraseSnapshot: true +initialState: + documentContents: | + enum class Color(val hex: String) { + RED("#FF0000"), + GREEN("#00FF00"), + BLUE("#0000FF") + } + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + marks: {} +finalState: + documentContents: | + enum class Color(val hex: String) { + RED("#FF0000"), + , + BLUE("#0000FF") + } + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} diff --git a/data/fixtures/recorded/languages/kotlin/changeClassName3.yml b/data/fixtures/recorded/languages/kotlin/changeClassName3.yml new file mode 100644 index 0000000000..3c6aad44e9 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeClassName3.yml @@ -0,0 +1,33 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change class name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: className} + usePrePhraseSnapshot: true +initialState: + documentContents: | + class MyClass { + companion object NamedCompanion { + fun greet() = "Hello!" + } + } + selections: + - anchor: {line: 2, character: 30} + active: {line: 2, character: 30} + marks: {} +finalState: + documentContents: | + class MyClass { + companion object { + fun greet() = "Hello!" + } + } + selections: + - anchor: {line: 1, character: 21} + active: {line: 1, character: 21} diff --git a/data/fixtures/recorded/languages/kotlin/changeLambda2.yml b/data/fixtures/recorded/languages/kotlin/changeLambda2.yml new file mode 100644 index 0000000000..e1d5eb907f --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeLambda2.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change lambda + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: anonymousFunction} + usePrePhraseSnapshot: true +initialState: + documentContents: "val lambda = { x: Int -> x * 2 }" + selections: + - anchor: {line: 0, character: 26} + active: {line: 0, character: 26} + marks: {} +finalState: + documentContents: "val lambda = " + selections: + - anchor: {line: 0, character: 13} + active: {line: 0, character: 13} diff --git a/data/fixtures/recorded/languages/kotlin/changeName.yml b/data/fixtures/recorded/languages/kotlin/changeName.yml new file mode 100644 index 0000000000..04a8234113 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeName.yml @@ -0,0 +1,29 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun add(a: Int, b: Int) { + return a + b; + } + selections: + - anchor: {line: 0, character: 12} + active: {line: 0, character: 12} + marks: {} +finalState: + documentContents: |- + fun add(: Int, b: Int) { + return a + b; + } + selections: + - anchor: {line: 0, character: 8} + active: {line: 0, character: 8} diff --git a/data/fixtures/recorded/languages/kotlin/changeName2.yml b/data/fixtures/recorded/languages/kotlin/changeName2.yml new file mode 100644 index 0000000000..56acf769c7 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeName2.yml @@ -0,0 +1,29 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun main() { + val f = { a: Int, b: Int -> a + b } + } + selections: + - anchor: {line: 1, character: 20} + active: {line: 1, character: 20} + marks: {} +finalState: + documentContents: |- + fun main() { + val f = { : Int, b: Int -> a + b } + } + selections: + - anchor: {line: 1, character: 14} + active: {line: 1, character: 14} diff --git a/data/fixtures/recorded/languages/kotlin/changeName3.yml b/data/fixtures/recorded/languages/kotlin/changeName3.yml new file mode 100644 index 0000000000..d30cc87656 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeName3.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: typealias Predicate = (T) -> Boolean + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: typealias = (T) -> Boolean + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} diff --git a/data/fixtures/recorded/languages/kotlin/changeName4.yml b/data/fixtures/recorded/languages/kotlin/changeName4.yml new file mode 100644 index 0000000000..2200c77741 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeName4.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: "class Person(val firstName: String, var isEmployed: Boolean = true)" + selections: + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} + marks: {} +finalState: + documentContents: "class Person(val : String, var isEmployed: Boolean = true)" + selections: + - anchor: {line: 0, character: 17} + active: {line: 0, character: 17} diff --git a/data/fixtures/recorded/languages/kotlin/changeName5.yml b/data/fixtures/recorded/languages/kotlin/changeName5.yml new file mode 100644 index 0000000000..b28a620b9d --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeName5.yml @@ -0,0 +1,33 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change name + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: | + class MyClass { + companion object NamedCompanion { + fun greet() = "Hello!" + } + } + selections: + - anchor: {line: 1, character: 37} + active: {line: 1, character: 37} + marks: {} +finalState: + documentContents: | + class MyClass { + companion object { + fun greet() = "Hello!" + } + } + selections: + - anchor: {line: 1, character: 21} + active: {line: 1, character: 21} diff --git a/data/fixtures/recorded/languages/kotlin/changeRound.yml b/data/fixtures/recorded/languages/kotlin/changeRound.yml new file mode 100644 index 0000000000..e23db68bc4 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeRound.yml @@ -0,0 +1,31 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change round + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: surroundingPair, delimiter: parentheses} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun main() { + // my (test) function + print("hello (test) world") + } + selections: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 13} + marks: {} +finalState: + documentContents: |- + fun main() { + // my function + print("hello (test) world") + } + selections: + - anchor: {line: 1, character: 10} + active: {line: 1, character: 10} diff --git a/data/fixtures/recorded/languages/kotlin/changeRound2.yml b/data/fixtures/recorded/languages/kotlin/changeRound2.yml new file mode 100644 index 0000000000..89a647216b --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeRound2.yml @@ -0,0 +1,31 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change round + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: surroundingPair, delimiter: parentheses} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun main() { + // my (test) function + print("hello (test) world") + } + selections: + - anchor: {line: 2, character: 22} + active: {line: 2, character: 22} + marks: {} +finalState: + documentContents: |- + fun main() { + // my (test) function + print("hello world") + } + selections: + - anchor: {line: 2, character: 17} + active: {line: 2, character: 17} diff --git a/data/fixtures/recorded/languages/kotlin/changeType.yml b/data/fixtures/recorded/languages/kotlin/changeType.yml new file mode 100644 index 0000000000..4bf62293a5 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType.yml @@ -0,0 +1,29 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun main() { + val f: suspend (a: Int) -> Int = { x -> x } + } + selections: + - anchor: {line: 1, character: 39} + active: {line: 1, character: 39} + marks: {} +finalState: + documentContents: |- + fun main() { + val f: = { x -> x } + } + selections: + - anchor: {line: 1, character: 11} + active: {line: 1, character: 11} diff --git a/data/fixtures/recorded/languages/kotlin/changeType10.yml b/data/fixtures/recorded/languages/kotlin/changeType10.yml new file mode 100644 index 0000000000..468ab93941 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType10.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: "class Person(val firstName: String, var isEmployed: Boolean = true)" + selections: + - anchor: {line: 0, character: 14} + active: {line: 0, character: 14} + marks: {} +finalState: + documentContents: "class Person(val firstName: , var isEmployed: Boolean = true)" + selections: + - anchor: {line: 0, character: 28} + active: {line: 0, character: 28} diff --git a/data/fixtures/recorded/languages/kotlin/changeType11.yml b/data/fixtures/recorded/languages/kotlin/changeType11.yml new file mode 100644 index 0000000000..769c6ee6e8 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType11.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: "class Person(val firstName: String, var isEmployed: Boolean = true)" + selections: + - anchor: {line: 0, character: 38} + active: {line: 0, character: 38} + marks: {} +finalState: + documentContents: "class Person(val firstName: String, var isEmployed: = true)" + selections: + - anchor: {line: 0, character: 52} + active: {line: 0, character: 52} diff --git a/data/fixtures/recorded/languages/kotlin/changeType2.yml b/data/fixtures/recorded/languages/kotlin/changeType2.yml new file mode 100644 index 0000000000..6f2c85391b --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType2.yml @@ -0,0 +1,31 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun main() { + val m: Map = mapOf("a" to "b", "c" to "d") + print(m) + } + selections: + - anchor: {line: 1, character: 19} + active: {line: 1, character: 19} + marks: {} +finalState: + documentContents: |- + fun main() { + val m: Map<, String> = mapOf("a" to "b", "c" to "d") + print(m) + } + selections: + - anchor: {line: 1, character: 15} + active: {line: 1, character: 15} diff --git a/data/fixtures/recorded/languages/kotlin/changeType3.yml b/data/fixtures/recorded/languages/kotlin/changeType3.yml new file mode 100644 index 0000000000..5a93f91eae --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType3.yml @@ -0,0 +1,29 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun add(a: Int, b: Int): @Target Int { + return a + b + } + selections: + - anchor: {line: 0, character: 9} + active: {line: 0, character: 9} + marks: {} +finalState: + documentContents: |- + fun add(a: , b: Int): @Target Int { + return a + b + } + selections: + - anchor: {line: 0, character: 11} + active: {line: 0, character: 11} diff --git a/data/fixtures/recorded/languages/kotlin/changeType4.yml b/data/fixtures/recorded/languages/kotlin/changeType4.yml new file mode 100644 index 0000000000..0a920b6111 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType4.yml @@ -0,0 +1,29 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun add(a: Int, b: Int): @Target Int { + return a + b + } + selections: + - anchor: {line: 1, character: 16} + active: {line: 1, character: 16} + marks: {} +finalState: + documentContents: |- + fun add(a: Int, b: Int): { + return a + b + } + selections: + - anchor: {line: 0, character: 25} + active: {line: 0, character: 25} diff --git a/data/fixtures/recorded/languages/kotlin/changeType5.yml b/data/fixtures/recorded/languages/kotlin/changeType5.yml new file mode 100644 index 0000000000..8ff3526a5a --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType5.yml @@ -0,0 +1,29 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + fun add(a: Int, b: Int): @Target Int where T : String { + return a + b + } + selections: + - anchor: {line: 1, character: 16} + active: {line: 1, character: 16} + marks: {} +finalState: + documentContents: |- + fun add(a: Int, b: Int): where T : String { + return a + b + } + selections: + - anchor: {line: 0, character: 29} + active: {line: 0, character: 29} diff --git a/data/fixtures/recorded/languages/kotlin/changeType6.yml b/data/fixtures/recorded/languages/kotlin/changeType6.yml new file mode 100644 index 0000000000..72521df03f --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType6.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: "fun add(a: Int, b: Int): @Target Int where T : String" + selections: + - anchor: {line: 0, character: 1} + active: {line: 0, character: 1} + marks: {} +finalState: + documentContents: "fun add(a: Int, b: Int): where T : String" + selections: + - anchor: {line: 0, character: 29} + active: {line: 0, character: 29} diff --git a/data/fixtures/recorded/languages/kotlin/changeType7.yml b/data/fixtures/recorded/languages/kotlin/changeType7.yml new file mode 100644 index 0000000000..b3ada3d611 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType7.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: "fun add(a: Int, b: Int): @Target Int" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "fun add(a: Int, b: Int): " + selections: + - anchor: {line: 0, character: 29} + active: {line: 0, character: 29} diff --git a/data/fixtures/recorded/languages/kotlin/changeType8.yml b/data/fixtures/recorded/languages/kotlin/changeType8.yml new file mode 100644 index 0000000000..a5b3c52fb8 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType8.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: typealias Predicate = (T) -> Boolean + selections: + - anchor: {line: 0, character: 10} + active: {line: 0, character: 10} + marks: {} +finalState: + documentContents: "typealias Predicate = " + selections: + - anchor: {line: 0, character: 25} + active: {line: 0, character: 25} diff --git a/data/fixtures/recorded/languages/kotlin/changeType9.yml b/data/fixtures/recorded/languages/kotlin/changeType9.yml new file mode 100644 index 0000000000..0b57d676b2 --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeType9.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change type + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: type} + usePrePhraseSnapshot: true +initialState: + documentContents: typealias Predicate = (T) -> Boolean + selections: + - anchor: {line: 0, character: 25} + active: {line: 0, character: 25} + marks: {} +finalState: + documentContents: "typealias Predicate = " + selections: + - anchor: {line: 0, character: 25} + active: {line: 0, character: 25} diff --git a/data/fixtures/recorded/languages/kotlin/changeValue.yml b/data/fixtures/recorded/languages/kotlin/changeValue.yml new file mode 100644 index 0000000000..022a184aee --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeValue.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: typealias Predicate = (T) -> Boolean + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "typealias Predicate = " + selections: + - anchor: {line: 0, character: 25} + active: {line: 0, character: 25} diff --git a/data/fixtures/recorded/languages/kotlin/changeValue2.yml b/data/fixtures/recorded/languages/kotlin/changeValue2.yml new file mode 100644 index 0000000000..022a184aee --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeValue2.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: typealias Predicate = (T) -> Boolean + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: {} +finalState: + documentContents: "typealias Predicate = " + selections: + - anchor: {line: 0, character: 25} + active: {line: 0, character: 25} diff --git a/data/fixtures/recorded/languages/kotlin/changeValue3.yml b/data/fixtures/recorded/languages/kotlin/changeValue3.yml new file mode 100644 index 0000000000..1ad10839dd --- /dev/null +++ b/data/fixtures/recorded/languages/kotlin/changeValue3.yml @@ -0,0 +1,23 @@ +languageId: kotlin +command: + version: 7 + spokenForm: change value + action: + name: clearAndSetSelection + target: + type: primitive + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true +initialState: + documentContents: "class Person(val firstName: String, var isEmployed: Boolean = true)" + selections: + - anchor: {line: 0, character: 37} + active: {line: 0, character: 37} + marks: {} +finalState: + documentContents: "class Person(val firstName: String, var isEmployed: Boolean = )" + selections: + - anchor: {line: 0, character: 62} + active: {line: 0, character: 62} diff --git a/queries/kotlin.scm b/queries/kotlin.scm index 37c51e85c8..2febea3ad8 100644 --- a/queries/kotlin.scm +++ b/queries/kotlin.scm @@ -27,6 +27,9 @@ (object_declaration (type_identifier) @name @className ) @class @_.domain +(companion_object + (type_identifier) @name @className +) @class @_.domain (function_declaration (simple_identifier) @name @functionName @@ -34,6 +37,7 @@ (secondary_constructor) @namedFunction (anonymous_function) @anonymousFunction +(lambda_literal) @anonymousFunction (if_expression) @ifStatement @@ -48,6 +52,9 @@ (call_expression) (constructor_invocation) (constructor_delegation_call) + (enum_entry + (value_arguments) + ) ] @functionCall (when_entry) @branch @@ -133,3 +140,306 @@ (when_subject) @private.switchStatementSubject (#child-range! @private.switchStatementSubject 0 -1 true true) ) @_.domain + +(type_alias + "typealias" + . + (_) @name.start + (_)? @name.end + . + "=" + . + (_) @value.start @type.start +) @value.end.endOf @type.end.endOf @_.domain + +(class_parameter + (simple_identifier) @name +) @_.domain + +(class_parameter + ":" + . + (_) @type.start + (_)? @type.end + . + "=" + (_) @value +) @_.domain + +;; Known issue: this won't work with multiple-node types. +(class_parameter + ":" + . + (_) @type + . +) @_.domain + +;; (type_parameter +;; (type_identifier) @name @type +;; ) @name.domain + +;; (type_parameter +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf + +;; (type_constraint +;; (type_identifier) @name @type +;; ) @name.domain + +;; (type_constraint +;; ":" +;; . +;; (_) @type.start +;; ) @type.end.endOf + +;; TODO Resume tests here + +;; Function declarations with type constraints +(function_declaration + ":" + . + (_) @type.start + (_)? @type.end + . + (type_constraints) +) @_.domain + +;; Function declarations with no type constraints but with body +( + (function_declaration + ":" + . + (_) @type.start + (_)? @type.end + . + (function_body) + ) @_.domain + (#not-type? @type.end "type_constraints") +) + +;; Function declaration without body or type constraints +( + (function_declaration + ":" + . + (_) @type.start + (_)? @type.end + . + ) @_.domain + (#not-type? @type.end "function_body") + (#not-type? @type.end "type_constraints") +) + +(variable_declaration + (simple_identifier) @name +) @_.domain + +(variable_declaration + ":" + . + (_) @type.start +) @type.end.endOf @_.domain + +(property_declaration + (variable_declaration + (simple_identifier) @name + ) +) @_.domain + +(property_declaration + "=" + . + (_) @value +) @_.domain + +(property_declaration + (property_delegate + (_) @value + ) +) @_.domain + +(property_declaration + (variable_declaration + ":" + . + (_) @type.start + ) @type.end.endOf +) @_.domain + +(for_statement + (variable_declaration + (simple_identifier) @name + ) +) @_.domain + +(for_statement + "in" + . + (_) @value +) @_.domain + +(for_statement + (variable_declaration + ":" + . + (_) @type.start + ) @type.end.endOf +) @_.domain + +(when_subject + (variable_declaration + (simple_identifier) @name + ) +) @_.domain + +(when_subject + "=" + . + (_) @value +) @_.domain + +(when_subject + (variable_declaration + ":" + . + (_) @type.start + ) @type.end.endOf +) @_.domain + +(getter + ":" + . + (_) @type.start + (_)? @type.end + (function_body) +) @_.domain + +(setter + ":" + . + (_) @type.start + (_)? @type.end + (function_body) +) @_.domain + +(parameter_with_optional_type + (simple_identifier) @name +) @_.domain + +(parameter_with_optional_type + ":" + . + (_) @type.start +) @type.end.endOf @_.domain + +;; Function parameter without default +(function_value_parameters + (parameter + (simple_identifier) @name + ":" + . + (_) @type.start + ) @type.end.endOf @_.domain +) + +;; Function parameter with default +(function_value_parameters + (parameter + (simple_identifier) @name + ":" + . + (_) @type.start + ) @type.end.endOf @_.domain.start + . + "=" + . + (_) @value @_.domain.end +) + +(type_arguments + (type_projection) @type +) + +(anonymous_function + ":" + . + (_) @type.start + (_)? @type.end + . + (function_body) +) @_.domain + +( + (anonymous_function + ":" + . + (_) @type.start + (_)? @type.end + . + ) @_.domain + (#not-type? @type.end "function_body") +) + +(catch_block + (simple_identifier) @name + ":" + . + (_) @type.start + (_)? @type.end + . + ")" +) @_.domain + +(jump_expression + [ + "return" + "throw" + ] + . + (_) @value +) @_.domain + +;; TODO fix Cursorless error +;; (jump_expression +;; "return@" +;; . +;; (label) +;; . +;; (_) @value +;; ) @_.domain + +(_ + (function_body + "=" + . + (_) @value + ) +) @_.domain + +(assignment + (directly_assignable_expression) @name + (_) @value + . +) @_.domain + +(value_argument + (simple_identifier) @name + "=" + . + (_) @value.start +) @value.end.endOf @_.domain + +(class_body + . + "{" @type.iteration.start.endOf + "}" @type.iteration.end.startOf + . +) + +;; TODO add more type iteration scopes + +;; TODO add functionCallee and argumentOrParameter, looking at functionCall + +;; TODO add (label) support