diff --git a/cursorless-talon/src/modifiers/scopes.py b/cursorless-talon/src/modifiers/scopes.py index 4b5850286d..ba392eb623 100644 --- a/cursorless-talon/src/modifiers/scopes.py +++ b/cursorless-talon/src/modifiers/scopes.py @@ -46,6 +46,8 @@ "selector": "selector", "state": "statement", "string": "string", + "subject": "subject", + "branch": "branch", "type": "type", "value": "value", "condition": "condition", diff --git a/schemas/cursorless-snippets.json b/schemas/cursorless-snippets.json index ee81d89e11..bd85546837 100644 --- a/schemas/cursorless-snippets.json +++ b/schemas/cursorless-snippets.json @@ -73,11 +73,13 @@ "argumentOrParameter", "anonymousFunction", "attribute", + "branch", "class", "className", "collectionItem", "collectionKey", "comment", + "condition", "functionCall", "functionName", "ifStatement", @@ -88,6 +90,7 @@ "regularExpression", "statement", "string", + "subject", "type", "value", "condition", diff --git a/src/languages/java.ts b/src/languages/java.ts index a49c0e2126..959f308d2d 100644 --- a/src/languages/java.ts +++ b/src/languages/java.ts @@ -6,6 +6,7 @@ import { trailingMatcher, matcher, cascadingMatcher, + patternMatcher, } from "../util/nodeMatchers"; import { childRangeSelector } from "../util/nodeSelectors"; import { patternFinder } from "../util/nodeFinders"; @@ -88,6 +89,12 @@ const nodeMatchers: Partial< "assignment_expression[left]", "*[name]", "formal_parameter.identifier!", + "switch_label.parenthesized_expression![0]", + "switch_rule.switch_label![0]", + ], + collectionKey: [ + "switch_label.parenthesized_expression![0]", + "switch_rule.switch_label![0]", ], namedFunction: ["method_declaration", "constructor_declaration"], type: trailingMatcher([ @@ -112,8 +119,26 @@ const nodeMatchers: Partial< ], ["=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="], ), - condition: conditionMatcher("*[condition]"), + condition: cascadingMatcher( + conditionMatcher("while_statement[condition]"), + conditionMatcher("if_statement[condition]"), + conditionMatcher("do_statement[condition]"), + conditionMatcher("ternary_expression[condition]"), + patternMatcher("switch_label.parenthesized_expression![0]"), + patternMatcher("switch_rule.switch_label![0]"), + ), argumentOrParameter: argumentMatcher("formal_parameters", "argument_list"), + subject: "switch_expression[condition][0]", + branch: cascadingMatcher( + matcher( + patternFinder("switch_block_statement_group"), + childRangeSelector(["switch_label"], []), + ), + matcher( + patternFinder("switch_rule"), + childRangeSelector(["switch_label"], []), + ), + ), }; export default createPatternMatchers(nodeMatchers); diff --git a/src/languages/python.ts b/src/languages/python.ts index bd1251844f..af5a624caa 100644 --- a/src/languages/python.ts +++ b/src/languages/python.ts @@ -89,7 +89,10 @@ const nodeMatchers: Partial< argumentSelectionExtractor(), ), ), - collectionKey: trailingMatcher(["pair[key]"], [":"]), + collectionKey: cascadingMatcher( + trailingMatcher(["pair[key]"], [":"]), + patternMatcher("case_clause[pattern]"), + ), ifStatement: "if_statement", anonymousFunction: "lambda?.lambda", functionCall: "call", @@ -99,7 +102,10 @@ const nodeMatchers: Partial< className: "class_definition[name]", namedFunction: "decorated_definition?.function_definition", functionName: "function_definition[name]", - condition: conditionMatcher("*[condition]"), + condition: cascadingMatcher( + conditionMatcher("*[condition]"), + patternMatcher("case_clause[pattern]"), + ), type: leadingMatcher( ["function_definition[return_type]", "*[type]"], [":", "->"], @@ -110,6 +116,7 @@ const nodeMatchers: Partial< "typed_parameter.identifier!", "parameters.identifier!", "*[name]", + "case_clause[pattern]", ], value: cascadingMatcher( leadingMatcher( @@ -132,11 +139,14 @@ const nodeMatchers: Partial< ], ), patternMatcher("return_statement.~return!"), + patternMatcher("case_clause[consequence]"), ), argumentOrParameter: cascadingMatcher( argumentMatcher("parameters", "argument_list"), matcher(patternFinder("call.generator_expression!"), childRangeSelector()), ), + subject: "match_statement[subject]", + branch: "case_clause", }; export default createPatternMatchers(nodeMatchers); diff --git a/src/languages/rust.ts b/src/languages/rust.ts index 8976393dec..958ea08b77 100644 --- a/src/languages/rust.ts +++ b/src/languages/rust.ts @@ -145,7 +145,10 @@ const nodeMatchers: Partial< 1, ), string: ["raw_string_literal", "string_literal"], - ifStatement: ["if_expression", "if_let_expression"], + ifStatement: cascadingMatcher( + patternMatcher("if_expression", "if_let_expression"), + leadingMatcher(["match_pattern[condition]"], ["if"]), + ), functionCall: ["call_expression", "macro_invocation", "struct_expression"], functionCallee: "call_expression[function]", comment: ["line_comment", "block_comment"], @@ -188,7 +191,9 @@ const nodeMatchers: Partial< ), collectionKey: cascadingMatcher( trailingMatcher(["field_initializer[name]", "field_pattern[name]"], [":"]), + patternMatcher("match_pattern"), ), + condition: ["match_pattern"], name: cascadingMatcher( patternMatcher( "let_declaration.identifier!", @@ -202,6 +207,7 @@ const nodeMatchers: Partial< "let_declaration[pattern]", "constrained_type_parameter[left]", "where_predicate[left]", + "match_pattern", "field_declaration[name]", ), trailingMatcher(["field_initializer[name]", "field_pattern[name]"], [":"]), @@ -218,6 +224,8 @@ const nodeMatchers: Partial< matcher(returnValueFinder), ), attribute: trailingMatcher(["mutable_specifier", "attribute_item"]), + subject: "match_expression[value]", + branch: ["match_arm", "if_expression[consequence]", "else_clause.block!"], }; export default createPatternMatchers(nodeMatchers); diff --git a/src/languages/scala.ts b/src/languages/scala.ts index 2e20fe51f0..24533c32ba 100644 --- a/src/languages/scala.ts +++ b/src/languages/scala.ts @@ -3,6 +3,8 @@ import { argumentMatcher, leadingMatcher, conditionMatcher, + cascadingMatcher, + patternMatcher, } from "../util/nodeMatchers"; import { NodeMatcherAlternative } from "../typings/Types"; import { SimpleScopeTypeType } from "../typings/targetDescriptor.types"; @@ -17,6 +19,7 @@ const nodeMatchers: Partial< "object_definition[name]", "trait_definition[name]", ], + collectionKey: "case_clause[pattern]", ifStatement: "if_expression", @@ -35,7 +38,7 @@ const nodeMatchers: Partial< "bindings", ), - name: ["*[name]", "*[pattern]"], + name: ["*[name]", "*[pattern]", "case_clause[pattern]"], functionName: "function_definition[name]", // *[type] does not work here because while we want most of these we don't want "compound" types, @@ -61,12 +64,19 @@ const nodeMatchers: Partial< ], [":"], ), - value: leadingMatcher( - ["*[value]", "*[default_value]", "type_definition[type]"], - ["="], + value: cascadingMatcher( + patternMatcher("case_clause[body]"), + leadingMatcher( + ["*[value]", "*[default_value]", "type_definition[type]"], + ["="], + ), ), - condition: conditionMatcher("*[condition]"), - + condition: cascadingMatcher( + conditionMatcher("*[condition]"), + patternMatcher("case_clause[pattern]"), + ), + subject: "match_expression[value]", + branch: "case_clause", // Scala features unsupported in Cursorless terminology // - Pattern matching diff --git a/src/test/suite/fixtures/recorded/languages/java/changeBranchAir.yml b/src/test/suite/fixtures/recorded/languages/java/changeBranchAir.yml new file mode 100644 index 0000000000..b09d9f12b7 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeBranchAir.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change branch air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + default.a: + start: {line: 15, character: 12} + end: {line: 15, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 15, character: 24} + active: {line: 15, character: 24} + thatMark: + - anchor: {line: 15, character: 24} + active: {line: 15, character: 24} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeBranchBlueEach.yml b/src/test/suite/fixtures/recorded/languages/java/changeBranchBlueEach.yml new file mode 100644 index 0000000000..c7529a4c17 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeBranchBlueEach.yml @@ -0,0 +1,73 @@ +languageId: java +command: + spokenForm: change branch blue each + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: blue, character: e} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + blue.e: + start: {line: 3, character: 12} + end: {line: 3, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 4, character: 16} + active: {line: 4, character: 16} + thatMark: + - anchor: {line: 4, character: 16} + active: {line: 4, character: 16} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: e}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeConditionAir.yml b/src/test/suite/fixtures/recorded/languages/java/changeConditionAir.yml new file mode 100644 index 0000000000..4af9b3106c --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeConditionAir.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change condition air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + default.a: + start: {line: 15, character: 12} + end: {line: 15, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 15, character: 17} + active: {line: 15, character: 17} + thatMark: + - anchor: {line: 15, character: 17} + active: {line: 15, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeConditionBlueEach.yml b/src/test/suite/fixtures/recorded/languages/java/changeConditionBlueEach.yml new file mode 100644 index 0000000000..0db8ab3d87 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeConditionBlueEach.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change condition blue each + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: blue, character: e} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + blue.e: + start: {line: 3, character: 12} + end: {line: 3, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case(): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 3, character: 17} + active: {line: 3, character: 17} + thatMark: + - anchor: {line: 3, character: 17} + active: {line: 3, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: e}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeKeyBlueEach.yml b/src/test/suite/fixtures/recorded/languages/java/changeKeyBlueEach.yml new file mode 100644 index 0000000000..c46150b39a --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeKeyBlueEach.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change key blue each + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: blue, character: e} + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + blue.e: + start: {line: 3, character: 12} + end: {line: 3, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case(): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 3, character: 17} + active: {line: 3, character: 17} + thatMark: + - anchor: {line: 3, character: 17} + active: {line: 3, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: e}, modifiers: [{type: containingScope, scopeType: {type: collectionKey}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeKeyCap.yml b/src/test/suite/fixtures/recorded/languages/java/changeKeyCap.yml new file mode 100644 index 0000000000..66d500198a --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeKeyCap.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change key cap + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + default.c: + start: {line: 16, character: 12} + end: {line: 16, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 16, character: 17} + active: {line: 16, character: 17} + thatMark: + - anchor: {line: 16, character: 17} + active: {line: 16, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, modifiers: [{type: containingScope, scopeType: {type: collectionKey}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeNameAir.yml b/src/test/suite/fixtures/recorded/languages/java/changeNameAir.yml new file mode 100644 index 0000000000..08ab625294 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeNameAir.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change name air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + default.a: + start: {line: 15, character: 12} + end: {line: 15, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 15, character: 17} + active: {line: 15, character: 17} + thatMark: + - anchor: {line: 15, character: 17} + active: {line: 15, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeNameBlueCap.yml b/src/test/suite/fixtures/recorded/languages/java/changeNameBlueCap.yml new file mode 100644 index 0000000000..f39b299927 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeNameBlueCap.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change name blue cap + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: blue, character: c} + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + blue.c: + start: {line: 6, character: 12} + end: {line: 6, character: 16} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case(): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 6, character: 17} + active: {line: 6, character: 17} + thatMark: + - anchor: {line: 6, character: 17} + active: {line: 6, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: c}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeSubjectBlueWhale.yml b/src/test/suite/fixtures/recorded/languages/java/changeSubjectBlueWhale.yml new file mode 100644 index 0000000000..1d552ac964 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeSubjectBlueWhale.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change subject blue whale + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: blue, character: w} + modifiers: + - type: containingScope + scopeType: {type: subject} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + blue.w: + start: {line: 2, character: 8} + end: {line: 2, character: 14} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch () { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 2, character: 16} + active: {line: 2, character: 16} + thatMark: + - anchor: {line: 2, character: 16} + active: {line: 2, character: 16} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: w}, modifiers: [{type: containingScope, scopeType: {type: subject}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/changeSubjectWhale.yml b/src/test/suite/fixtures/recorded/languages/java/changeSubjectWhale.yml new file mode 100644 index 0000000000..6a202ebc97 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/changeSubjectWhale.yml @@ -0,0 +1,74 @@ +languageId: java +command: + spokenForm: change subject whale + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: w} + modifiers: + - type: containingScope + scopeType: {type: subject} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch (arg[0]) { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 22, character: 0} + active: {line: 22, character: 0} + marks: + default.w: + start: {line: 14, character: 16} + end: {line: 14, character: 22} +finalState: + documentContents: | + class C { + static void main(String args[]) { + switch (arg[0]) { + case("0"): + System.out.println("zero"); + break; + case("1"): + System.out.println("one"); + break; + default: + System.out.println("other"); + break; + }; + + var s = switch () { + case "0" -> "zero"; + case "1" -> "one"; + default -> "other"; + }; + System.out.println(s); + } + } + selections: + - anchor: {line: 14, character: 24} + active: {line: 14, character: 24} + thatMark: + - anchor: {line: 14, character: 24} + active: {line: 14, character: 24} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: w}, modifiers: [{type: containingScope, scopeType: {type: subject}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeConditionAir.yml b/src/test/suite/fixtures/recorded/languages/python/changeConditionAir.yml new file mode 100644 index 0000000000..9fcb8a33ea --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeConditionAir.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change condition air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 18} + active: {line: 3, character: 21} + marks: + default.a: + start: {line: 3, character: 4} + end: {line: 3, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case : + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} + thatMark: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeConditionSun2.yml b/src/test/suite/fixtures/recorded/languages/python/changeConditionSun2.yml new file mode 100644 index 0000000000..3925b4088b --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeConditionSun2.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change condition sun + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: s} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 9, character: 0} + active: {line: 9, character: 0} + marks: + default.s: + start: {line: 3, character: 4} + end: {line: 3, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case : + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} + thatMark: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeKeyAir.yml b/src/test/suite/fixtures/recorded/languages/python/changeKeyAir.yml new file mode 100644 index 0000000000..b64e38fba2 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeKeyAir.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change key air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 18} + active: {line: 3, character: 21} + marks: + default.a: + start: {line: 3, character: 4} + end: {line: 3, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case : + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} + thatMark: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: collectionKey}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeNameAir.yml b/src/test/suite/fixtures/recorded/languages/python/changeNameAir.yml new file mode 100644 index 0000000000..25ab057839 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeNameAir.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change name air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 18} + active: {line: 3, character: 21} + marks: + default.a: + start: {line: 3, character: 4} + end: {line: 3, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case : + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} + thatMark: + - anchor: {line: 3, character: 9} + active: {line: 3, character: 9} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeSubjectHarp.yml b/src/test/suite/fixtures/recorded/languages/python/changeSubjectHarp.yml new file mode 100644 index 0000000000..f0b2904d8f --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeSubjectHarp.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change subject harp + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: h} + modifiers: + - type: containingScope + scopeType: {type: subject} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 9, character: 0} + active: {line: 9, character: 0} + marks: + default.h: + start: {line: 0, character: 0} + end: {line: 0, character: 5} +finalState: + documentContents: | + match : + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: h}, modifiers: [{type: containingScope, scopeType: {type: subject}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeValueBlueEach.yml b/src/test/suite/fixtures/recorded/languages/python/changeValueBlueEach.yml new file mode 100644 index 0000000000..b1a38726bc --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeValueBlueEach.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change value blue each + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: blue, character: e} + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 9, character: 0} + active: {line: 9, character: 0} + marks: + blue.e: + start: {line: 1, character: 4} + end: {line: 1, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 2, character: 8} + active: {line: 2, character: 8} + thatMark: + - anchor: {line: 2, character: 8} + active: {line: 2, character: 8} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: blue, character: e}, modifiers: [{type: containingScope, scopeType: {type: value}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/changeValueCap2.yml b/src/test/suite/fixtures/recorded/languages/python/changeValueCap2.yml new file mode 100644 index 0000000000..036fa89236 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/changeValueCap2.yml @@ -0,0 +1,48 @@ +languageId: python +command: + spokenForm: change value cap + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 9, character: 0} + active: {line: 9, character: 0} + marks: + default.c: + start: {line: 5, character: 4} + end: {line: 5, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 6, character: 8} + active: {line: 6, character: 8} + thatMark: + - anchor: {line: 6, character: 8} + active: {line: 6, character: 8} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, modifiers: [{type: containingScope, scopeType: {type: value}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckBranchCap.yml b/src/test/suite/fixtures/recorded/languages/python/chuckBranchCap.yml new file mode 100644 index 0000000000..294c377de5 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckBranchCap.yml @@ -0,0 +1,30 @@ +languageId: Log +command: + spokenForm: chuck branch cap + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: c} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: remove} +initialState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + marks: + default.c: + start: {line: 5, character: 4} + end: {line: 5, character: 8} +finalState: + documentContents: "" + selections: + - anchor: {line: 0, character: 0} + active: {line: 0, character: 0} + thatMark: + - anchor: {line: 5, character: 0} + active: {line: 5, character: 0} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: c}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/python/chuckSun.yml b/src/test/suite/fixtures/recorded/languages/python/chuckSun.yml new file mode 100644 index 0000000000..98e0e629d6 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/python/chuckSun.yml @@ -0,0 +1,45 @@ +languageId: python +command: + spokenForm: chuck sun + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: s} + usePrePhraseSnapshot: true + action: {name: remove} +initialState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + case ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 9, character: 0} + active: {line: 9, character: 0} + marks: + default.s: + start: {line: 3, character: 4} + end: {line: 3, character: 8} +finalState: + documentContents: | + match command.split(): + case ["quit"]: + print("quit") + ["go", direction] | []: + print("going", direction) + case ["drop", *objects]: + print("drop", objects) + case _: + print(f"Sorry, I couldn't understand {command!r}") + selections: + - anchor: {line: 9, character: 0} + active: {line: 9, character: 0} + thatMark: + - anchor: {line: 3, character: 4} + active: {line: 3, character: 4} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, modifiers: []}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeBranchOne.yml b/src/test/suite/fixtures/recorded/languages/rust/changeBranchOne.yml new file mode 100644 index 0000000000..8cddb83a2d --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeBranchOne.yml @@ -0,0 +1,46 @@ +languageId: rust +command: + spokenForm: change branch one + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '1'} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + fn main() { + let foo = if true { + 1 + } else if false { + 2 + } else { + 3 + }; + } + selections: + - anchor: {line: 3, character: 20} + active: {line: 5, character: 5} + marks: + default.1: + start: {line: 2, character: 8} + end: {line: 2, character: 9} +finalState: + documentContents: | + fn main() { + let foo = if true else if false { + 2 + } else { + 3 + }; + } + selections: + - anchor: {line: 1, character: 22} + active: {line: 1, character: 22} + thatMark: + - anchor: {line: 1, character: 22} + active: {line: 1, character: 22} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: '1'}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeBranchThree.yml b/src/test/suite/fixtures/recorded/languages/rust/changeBranchThree.yml new file mode 100644 index 0000000000..170c28b193 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeBranchThree.yml @@ -0,0 +1,46 @@ +languageId: rust +command: + spokenForm: change branch three + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '3'} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + fn main() { + let foo = if true { + 1 + } else if false { + 2 + } else { + 3 + }; + } + selections: + - anchor: {line: 3, character: 20} + active: {line: 5, character: 5} + marks: + default.3: + start: {line: 6, character: 8} + end: {line: 6, character: 9} +finalState: + documentContents: | + fn main() { + let foo = if true { + 1 + } else if false { + 2 + } else ; + } + selections: + - anchor: {line: 5, character: 11} + active: {line: 5, character: 11} + thatMark: + - anchor: {line: 5, character: 11} + active: {line: 5, character: 11} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: '3'}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeBranchTwo.yml b/src/test/suite/fixtures/recorded/languages/rust/changeBranchTwo.yml new file mode 100644 index 0000000000..bac3399e8f --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeBranchTwo.yml @@ -0,0 +1,46 @@ +languageId: rust +command: + spokenForm: change branch two + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '2'} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + fn main() { + let foo = if true { + 1 + } else if false { + 2 + } else { + 3 + }; + } + selections: + - anchor: {line: 3, character: 20} + active: {line: 5, character: 5} + marks: + default.2: + start: {line: 4, character: 8} + end: {line: 4, character: 9} +finalState: + documentContents: | + fn main() { + let foo = if true { + 1 + } else if false else { + 3 + }; + } + selections: + - anchor: {line: 3, character: 20} + active: {line: 3, character: 20} + thatMark: + - anchor: {line: 3, character: 20} + active: {line: 3, character: 20} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: '2'}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeConditionSun.yml b/src/test/suite/fixtures/recorded/languages/rust/changeConditionSun.yml new file mode 100644 index 0000000000..58855eac68 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeConditionSun.yml @@ -0,0 +1,38 @@ +languageId: rust +command: + spokenForm: change condition sun + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: s} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match user { + User { first_name: "John" } => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 2, character: 27} + active: {line: 2, character: 54} + marks: + default.s: + start: {line: 1, character: 4} + end: {line: 1, character: 8} +finalState: + documentContents: | + match user { + => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} + thatMark: + - anchor: {line: 1, character: 4} + active: {line: 1, character: 4} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeNameFine3.yml b/src/test/suite/fixtures/recorded/languages/rust/changeNameFine3.yml new file mode 100644 index 0000000000..7594688e9d --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeNameFine3.yml @@ -0,0 +1,38 @@ +languageId: rust +command: + spokenForm: change name fine + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: f} + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match user { + User { first_name: "John" } => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 2, character: 27} + active: {line: 2, character: 54} + marks: + default.f: + start: {line: 2, character: 11} + end: {line: 2, character: 21} +finalState: + documentContents: | + match user { + User { first_name: "John" } => {}, + => {} + } + selections: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} + thatMark: + - anchor: {line: 2, character: 4} + active: {line: 2, character: 4} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeSubject.yml b/src/test/suite/fixtures/recorded/languages/rust/changeSubject.yml new file mode 100644 index 0000000000..7b42f2709e --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeSubject.yml @@ -0,0 +1,34 @@ +languageId: rust +command: + spokenForm: change subject + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: subject} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match user { + User { first_name: "John" } => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 2, character: 27} + active: {line: 2, character: 54} + marks: {} +finalState: + documentContents: | + match { + User { first_name: "John" } => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} + thatMark: + - anchor: {line: 0, character: 6} + active: {line: 0, character: 6} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: subject}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/changeValueSun.yml b/src/test/suite/fixtures/recorded/languages/rust/changeValueSun.yml new file mode 100644 index 0000000000..11e083e6c7 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/changeValueSun.yml @@ -0,0 +1,38 @@ +languageId: rust +command: + spokenForm: change value sun + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: s} + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + match user { + User { first_name: "John" } => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 2, character: 27} + active: {line: 2, character: 54} + marks: + default.s: + start: {line: 1, character: 4} + end: {line: 1, character: 8} +finalState: + documentContents: | + match user { + User { first_name: "John" } => , + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 1, character: 35} + active: {line: 1, character: 35} + thatMark: + - anchor: {line: 1, character: 35} + active: {line: 1, character: 35} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, modifiers: [{type: containingScope, scopeType: {type: value}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/rust/chuckIfState.yml b/src/test/suite/fixtures/recorded/languages/rust/chuckIfState.yml new file mode 100644 index 0000000000..c54d7dee96 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/rust/chuckIfState.yml @@ -0,0 +1,34 @@ +languageId: rust +command: + spokenForm: chuck if state + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: ifStatement} + usePrePhraseSnapshot: true + action: {name: remove} +initialState: + documentContents: | + match user { + User { first_name: "John" } => {}, + User { first_name } if first_name.starts_with("P") => {} + } + selections: + - anchor: {line: 2, character: 27} + active: {line: 2, character: 54} + marks: {} +finalState: + documentContents: | + match user { + User { first_name: "John" } => {}, + User { first_name } => {} + } + selections: + - anchor: {line: 2, character: 23} + active: {line: 2, character: 23} + thatMark: + - anchor: {line: 2, character: 23} + active: {line: 2, character: 23} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: ifStatement}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeBranch.yml b/src/test/suite/fixtures/recorded/languages/scala/changeBranch.yml new file mode 100644 index 0000000000..53bab976fe --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeBranch.yml @@ -0,0 +1,37 @@ +languageId: scala +command: + spokenForm: change branch + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 17} + marks: {} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 2} + active: {line: 1, character: 2} + thatMark: + - anchor: {line: 1, character: 2} + active: {line: 1, character: 2} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeCondition.yml b/src/test/suite/fixtures/recorded/languages/scala/changeCondition.yml new file mode 100644 index 0000000000..fac70d30cd --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeCondition.yml @@ -0,0 +1,38 @@ +languageId: scala +command: + spokenForm: change condition + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 17} + marks: {} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} + thatMark: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeConditionAir.yml b/src/test/suite/fixtures/recorded/languages/scala/changeConditionAir.yml new file mode 100644 index 0000000000..c7352fde6d --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeConditionAir.yml @@ -0,0 +1,42 @@ +languageId: scala +command: + spokenForm: change condition air + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: a} + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 2} + active: {line: 4, character: 2} + marks: + default.a: + start: {line: 3, character: 2} + end: {line: 3, character: 6} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 7} + active: {line: 3, character: 7} + thatMark: + - anchor: {line: 3, character: 7} + active: {line: 3, character: 7} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeKey.yml b/src/test/suite/fixtures/recorded/languages/scala/changeKey.yml new file mode 100644 index 0000000000..eaadc2bcdb --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeKey.yml @@ -0,0 +1,38 @@ +languageId: scala +command: + spokenForm: change key + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 17} + marks: {} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} + thatMark: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: collectionKey}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeKeySun.yml b/src/test/suite/fixtures/recorded/languages/scala/changeKeySun.yml new file mode 100644 index 0000000000..f0f331f2e1 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeKeySun.yml @@ -0,0 +1,42 @@ +languageId: scala +command: + spokenForm: change key sun + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: s} + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 2} + active: {line: 4, character: 2} + marks: + default.s: + start: {line: 2, character: 2} + end: {line: 2, character: 6} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 2, character: 7} + active: {line: 2, character: 7} + thatMark: + - anchor: {line: 2, character: 7} + active: {line: 2, character: 7} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, modifiers: [{type: containingScope, scopeType: {type: collectionKey}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeName.yml b/src/test/suite/fixtures/recorded/languages/scala/changeName.yml new file mode 100644 index 0000000000..1d66804dd5 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeName.yml @@ -0,0 +1,38 @@ +languageId: scala +command: + spokenForm: change name + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 17} + marks: {} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} + thatMark: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeNameEach.yml b/src/test/suite/fixtures/recorded/languages/scala/changeNameEach.yml new file mode 100644 index 0000000000..f601d61e4d --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeNameEach.yml @@ -0,0 +1,42 @@ +languageId: scala +command: + spokenForm: change name each + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: e} + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 2} + active: {line: 4, character: 2} + marks: + default.e: + start: {line: 1, character: 2} + end: {line: 1, character: 6} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} + thatMark: + - anchor: {line: 1, character: 7} + active: {line: 1, character: 7} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeSubject.yml b/src/test/suite/fixtures/recorded/languages/scala/changeSubject.yml new file mode 100644 index 0000000000..a0108cb86e --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeSubject.yml @@ -0,0 +1,38 @@ +languageId: scala +command: + spokenForm: change subject + version: 2 + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: subject} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 2} + active: {line: 4, character: 2} + marks: {} +finalState: + documentContents: | + def matchTest(x: Int): String = match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 0, character: 32} + active: {line: 0, character: 32} + thatMark: + - anchor: {line: 0, character: 32} + active: {line: 0, character: 32} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: subject}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeSubjectTrap.yml b/src/test/suite/fixtures/recorded/languages/scala/changeSubjectTrap.yml new file mode 100644 index 0000000000..c48bc6100e --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeSubjectTrap.yml @@ -0,0 +1,42 @@ +languageId: scala +command: + spokenForm: change subject trap + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: t} + modifiers: + - type: containingScope + scopeType: {type: subject} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 6, character: 0} + active: {line: 6, character: 0} + marks: + default.t: + start: {line: 0, character: 34} + end: {line: 0, character: 39} +finalState: + documentContents: | + def matchTest(x: Int): String = match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 0, character: 32} + active: {line: 0, character: 32} + thatMark: + - anchor: {line: 0, character: 32} + active: {line: 0, character: 32} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: t}, modifiers: [{type: containingScope, scopeType: {type: subject}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeValueZero.yml b/src/test/suite/fixtures/recorded/languages/scala/changeValueZero.yml new file mode 100644 index 0000000000..40332f920f --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeValueZero.yml @@ -0,0 +1,42 @@ +languageId: scala +command: + spokenForm: change value zero + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '0'} + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 6, character: 0} + active: {line: 6, character: 0} + marks: + default.0: + start: {line: 1, character: 7} + end: {line: 1, character: 8} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 12} + active: {line: 1, character: 12} + thatMark: + - anchor: {line: 1, character: 12} + active: {line: 1, character: 12} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: '0'}, modifiers: [{type: containingScope, scopeType: {type: value}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/changeValueZero2.yml b/src/test/suite/fixtures/recorded/languages/scala/changeValueZero2.yml new file mode 100644 index 0000000000..a44d355154 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/changeValueZero2.yml @@ -0,0 +1,42 @@ +languageId: scala +command: + spokenForm: change value zero + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: '0'} + modifiers: + - type: containingScope + scopeType: {type: value} + usePrePhraseSnapshot: true + action: {name: clearAndSetSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 2} + active: {line: 4, character: 2} + marks: + default.0: + start: {line: 1, character: 7} + end: {line: 1, character: 8} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 12} + active: {line: 1, character: 12} + thatMark: + - anchor: {line: 1, character: 12} + active: {line: 1, character: 12} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: '0'}, modifiers: [{type: containingScope, scopeType: {type: value}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/chuckBranchSun.yml b/src/test/suite/fixtures/recorded/languages/scala/chuckBranchSun.yml new file mode 100644 index 0000000000..abc81466b0 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/chuckBranchSun.yml @@ -0,0 +1,41 @@ +languageId: scala +command: + spokenForm: chuck branch sun + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: s} + modifiers: + - type: containingScope + scopeType: {type: branch} + usePrePhraseSnapshot: true + action: {name: remove} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 3, character: 2} + active: {line: 4, character: 2} + marks: + default.s: + start: {line: 2, character: 2} + end: {line: 2, character: 6} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 2, character: 2} + active: {line: 3, character: 2} + thatMark: + - anchor: {line: 2, character: 2} + active: {line: 2, character: 2} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: s}, modifiers: [{type: containingScope, scopeType: {type: branch}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/scala/takeZip.yml b/src/test/suite/fixtures/recorded/languages/scala/takeZip.yml new file mode 100644 index 0000000000..a632531060 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/scala/takeZip.yml @@ -0,0 +1,39 @@ +languageId: scala +command: + spokenForm: take zip + version: 2 + targets: + - type: primitive + mark: {type: decoratedSymbol, symbolColor: default, character: z} + usePrePhraseSnapshot: true + action: {name: setSelection} +initialState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 6, character: 0} + active: {line: 6, character: 0} + marks: + default.z: + start: {line: 1, character: 13} + end: {line: 1, character: 17} +finalState: + documentContents: | + def matchTest(x: Int): String = x match { + case 0 => "zero" + case 1 => "one" + case 2 => "two" + case _ => "other" + } + selections: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 17} + thatMark: + - anchor: {line: 1, character: 13} + active: {line: 1, character: 17} +fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: z}, modifiers: []}] diff --git a/src/typings/targetDescriptor.types.ts b/src/typings/targetDescriptor.types.ts index e039ef09b8..1533e3eb46 100644 --- a/src/typings/targetDescriptor.types.ts +++ b/src/typings/targetDescriptor.types.ts @@ -81,11 +81,13 @@ export type SimpleScopeTypeType = | "argumentOrParameter" | "anonymousFunction" | "attribute" + | "branch" | "class" | "className" | "collectionItem" | "collectionKey" | "comment" + | "condition" | "functionCall" | "functionCallee" | "functionName" @@ -108,6 +110,7 @@ export type SimpleScopeTypeType = | "sectionLevelFive" | "sectionLevelSix" | "selector" + | "subject" | "unit" | "xmlBothTags" | "xmlElement"