diff --git a/src/languages/java.ts b/src/languages/java.ts index bfe8ff4a23..89e610e4e6 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"; @@ -52,6 +53,21 @@ const STATEMENT_TYPES = [ "field_declaration", ]; +/** + * Tree-sitter patterns to capture the pattern in a case clause, eg + * + * ```java + * case foo: + * break + * ``` + * + * This would target `foo`. + */ +const caseClausePatternPatterns = [ + "switch_rule.switch_label![0]", + "switch_label.parenthesized_expression![0]", +]; + const nodeMatchers: Partial< Record > = { @@ -88,7 +104,9 @@ const nodeMatchers: Partial< "assignment_expression[left]", "*[name]", "formal_parameter.identifier!", + ...caseClausePatternPatterns, ], + collectionKey: caseClausePatternPatterns, namedFunction: ["method_declaration", "constructor_declaration"], type: trailingMatcher([ "generic_type.type_arguments.type_identifier", @@ -112,7 +130,13 @@ 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(...caseClausePatternPatterns), + ), argumentOrParameter: argumentMatcher("formal_parameters", "argument_list"), switchStatementSubject: "switch_expression[condition][0]", }; diff --git a/src/languages/python.ts b/src/languages/python.ts index f628909b1d..9fba3f9acc 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", @@ -107,6 +110,7 @@ const nodeMatchers: Partial< // Ternaries patternMatcher("conditional_expression[1]"), + patternMatcher("case_clause[pattern]"), ), type: leadingMatcher( ["function_definition[return_type]", "*[type]"], @@ -118,6 +122,7 @@ const nodeMatchers: Partial< "typed_parameter.identifier!", "parameters.identifier!", "*[name]", + "case_clause[pattern]", ], value: cascadingMatcher( leadingMatcher( diff --git a/src/languages/rust.ts b/src/languages/rust.ts index 196abc7cd0..79fbe948b7 100644 --- a/src/languages/rust.ts +++ b/src/languages/rust.ts @@ -148,7 +148,11 @@ const nodeMatchers: Partial< string: ["raw_string_literal", "string_literal"], ifStatement: ["if_expression", "if_let_expression"], condition: cascadingMatcher( - patternMatcher("while_expression[condition]", "if_expression[condition]"), + patternMatcher( + "while_expression[condition]", + "if_expression[condition]", + "match_pattern", + ), matcher( patternFinder("while_let_expression", "if_let_expression"), childRangeSelector(["while", "if", "block"], [], { @@ -204,6 +208,7 @@ const nodeMatchers: Partial< ), collectionKey: cascadingMatcher( trailingMatcher(["field_initializer[name]", "field_pattern[name]"], [":"]), + patternMatcher("match_pattern"), ), name: cascadingMatcher( patternMatcher( @@ -219,6 +224,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]"], [":"]), diff --git a/src/languages/scala.ts b/src/languages/scala.ts index 426131ef73..8eeddb96ff 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 "../core/commandRunner/typings/PartialTargetDescriptor.types"; @@ -17,6 +19,7 @@ const nodeMatchers: Partial< "object_definition[name]", "trait_definition[name]", ], + collectionKey: "case_clause[pattern]", ifStatement: "if_expression", @@ -36,7 +39,7 @@ const nodeMatchers: Partial< ), switchStatementSubject: "match_expression[value]", - 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, @@ -66,7 +69,10 @@ const nodeMatchers: Partial< ["*[value]", "*[default_value]", "type_definition[type]"], ["="], ), - condition: conditionMatcher("*[condition]"), + condition: cascadingMatcher( + conditionMatcher("*[condition]"), + patternMatcher("case_clause[pattern]"), + ), // Scala features unsupported in Cursorless terminology // - Pattern matching diff --git a/src/test/suite/fixtures/recorded/languages/java/clearCondition.yml b/src/test/suite/fixtures/recorded/languages/java/clearCondition.yml new file mode 100644 index 0000000000..a3f48bd623 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/clearCondition.yml @@ -0,0 +1,41 @@ +languageId: java +command: + version: 4 + spokenForm: clear condition + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: condition} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + class Aaa { + static void bbb() { + var s = + switch ("0") { + case "0" -> "zero"; + case "1" -> "one"; + }; + } + } + selections: + - anchor: {line: 4, character: 24} + active: {line: 4, character: 24} + marks: {} +finalState: + documentContents: |- + class Aaa { + static void bbb() { + var s = + switch ("0") { + case -> "zero"; + case "1" -> "one"; + }; + } + } + selections: + - anchor: {line: 4, character: 17} + active: {line: 4, character: 17} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: condition}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/clearKey.yml b/src/test/suite/fixtures/recorded/languages/java/clearKey.yml new file mode 100644 index 0000000000..9b7c4c592b --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/clearKey.yml @@ -0,0 +1,41 @@ +languageId: java +command: + version: 4 + spokenForm: clear key + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: collectionKey} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + class Aaa { + static void bbb() { + var s = + switch ("0") { + case "0" -> "zero"; + case "1" -> "one"; + }; + } + } + selections: + - anchor: {line: 4, character: 24} + active: {line: 4, character: 24} + marks: {} +finalState: + documentContents: |- + class Aaa { + static void bbb() { + var s = + switch ("0") { + case -> "zero"; + case "1" -> "one"; + }; + } + } + selections: + - anchor: {line: 4, character: 17} + active: {line: 4, character: 17} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: collectionKey}}]}] diff --git a/src/test/suite/fixtures/recorded/languages/java/clearName2.yml b/src/test/suite/fixtures/recorded/languages/java/clearName2.yml new file mode 100644 index 0000000000..3c4522b6c6 --- /dev/null +++ b/src/test/suite/fixtures/recorded/languages/java/clearName2.yml @@ -0,0 +1,41 @@ +languageId: java +command: + version: 4 + spokenForm: clear name + action: {name: clearAndSetSelection} + targets: + - type: primitive + modifiers: + - type: containingScope + scopeType: {type: name} + usePrePhraseSnapshot: true +initialState: + documentContents: |- + class Aaa { + static void bbb() { + var s = + switch ("0") { + case "0" -> "zero"; + case "1" -> "one"; + }; + } + } + selections: + - anchor: {line: 4, character: 24} + active: {line: 4, character: 24} + marks: {} +finalState: + documentContents: |- + class Aaa { + static void bbb() { + var s = + switch ("0") { + case -> "zero"; + case "1" -> "one"; + }; + } + } + selections: + - anchor: {line: 4, character: 17} + active: {line: 4, character: 17} +fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: name}}]}] 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/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/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}}]}]