Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions src/languages/java.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,24 @@ const nodeMatchers: Partial<
"method_declaration.identifier!",
"constructor_declaration.identifier!",
],
value: leadingMatcher(
[
"*[declarator][value]",
"assignment_expression[right]",
"return_statement[0]",
"*[value]",
],
["=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="],
value: cascadingMatcher(
leadingMatcher(
[
"*[declarator][value]",
"assignment_expression[right]",
"return_statement[0]",
"*[value]",
],
["=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="],
),
matcher(
patternFinder("switch_block_statement_group"),
childRangeSelector(["switch_label"], []),
),
matcher(
patternFinder("switch_rule"),
childRangeSelector(["switch_label"], []),
),
),
condition: conditionMatcher("*[condition]"),
argumentOrParameter: argumentMatcher("formal_parameters", "argument_list"),
Expand Down
1 change: 1 addition & 0 deletions src/languages/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const nodeMatchers: Partial<
],
),
patternMatcher("return_statement.~return!"),
patternMatcher("case_clause[consequence]"),
),
argumentOrParameter: cascadingMatcher(
argumentMatcher("parameters", "argument_list"),
Expand Down
9 changes: 6 additions & 3 deletions src/languages/scala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ 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]"),

Expand Down
43 changes: 43 additions & 0 deletions src/test/suite/fixtures/recorded/languages/java/clearValue4.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
languageId: java
command:
spokenForm: clear value
version: 3
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
class Aaa {
static void bbb() {
switch ("0") {
case ("0"):
break;
case ("1"):
break;
}
}
}
selections:
- anchor: {line: 3, character: 9}
active: {line: 3, character: 9}
marks: {}
finalState:
documentContents: |-
class Aaa {
static void bbb() {
switch ("0") {
case ("0"):

case ("1"):
break;
}
}
}
selections:
- anchor: {line: 4, character: 8}
active: {line: 4, character: 8}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: value}}]}]
43 changes: 43 additions & 0 deletions src/test/suite/fixtures/recorded/languages/java/clearValue5.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
languageId: java
command:
spokenForm: clear value
version: 3
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
class Aaa {
static void bbb() {
switch ("0") {
case ("0"):
break;
case ("1"):
break;
}
}
}
selections:
- anchor: {line: 4, character: 11}
active: {line: 4, character: 11}
marks: {}
finalState:
documentContents: |-
class Aaa {
static void bbb() {
switch ("0") {
case ("0"):

case ("1"):
break;
}
}
}
selections:
- anchor: {line: 4, character: 8}
active: {line: 4, character: 8}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: value}}]}]
41 changes: 41 additions & 0 deletions src/test/suite/fixtures/recorded/languages/java/clearValue6.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
languageId: java
command:
spokenForm: clear value
version: 3
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
class Aaa {
static void bbb() {
var s =
switch ("0") {
case "0" -> "zero";
case "1" -> "one";
};
}
}
selections:
- anchor: {line: 4, character: 14}
active: {line: 4, character: 14}
marks: {}
finalState:
documentContents: |-
class Aaa {
static void bbb() {
var s =
switch ("0") {
case "0" ->
case "1" -> "one";
};
}
}
selections:
- anchor: {line: 4, character: 20}
active: {line: 4, character: 20}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: value}}]}]
41 changes: 41 additions & 0 deletions src/test/suite/fixtures/recorded/languages/java/clearValue7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
languageId: java
command:
spokenForm: clear value
version: 3
targets:
- type: primitive
modifiers:
- type: containingScope
scopeType: {type: value}
usePrePhraseSnapshot: true
action: {name: clearAndSetSelection}
initialState:
documentContents: |-
class Aaa {
static void bbb() {
var s =
switch ("0") {
case "0" -> "zero";
case "1" -> "one";
};
}
}
selections:
- anchor: {line: 4, character: 23}
active: {line: 4, character: 23}
marks: {}
finalState:
documentContents: |-
class Aaa {
static void bbb() {
var s =
switch ("0") {
case "0" ->
case "1" -> "one";
};
}
}
selections:
- anchor: {line: 4, character: 20}
active: {line: 4, character: 20}
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: containingScope, scopeType: {type: value}}]}]
Original file line number Diff line number Diff line change
@@ -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}}]}]
Original file line number Diff line number Diff line change
@@ -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}}]}]
Original file line number Diff line number Diff line change
@@ -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}}]}]
Loading