Skip to content

Commit 944c2e5

Browse files
committed
Add pattern matching support for java
1 parent ec3d294 commit 944c2e5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/languages/java.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
trailingMatcher,
77
matcher,
88
cascadingMatcher,
9+
patternMatcher,
910
} from "../util/nodeMatchers";
1011
import { childRangeSelector } from "../util/nodeSelectors";
1112
import { patternFinder } from "../util/nodeFinders";
@@ -85,7 +86,9 @@ const nodeMatchers: Partial<
8586
"assignment_expression[left]",
8687
"*[name]",
8788
"formal_parameter.identifier!",
89+
"switch_label.parenthesized_expression!"
8890
],
91+
collectionKey: ["switch_label.parenthesized_expression!"],
8992
namedFunction: ["method_declaration", "constructor_declaration"],
9093
type: trailingMatcher([
9194
"generic_type.type_arguments.type_identifier",
@@ -109,8 +112,12 @@ const nodeMatchers: Partial<
109112
],
110113
["=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="]
111114
),
112-
condition: conditionMatcher("*[condition]"),
115+
condition: cascadingMatcher(
116+
conditionMatcher("*[condition]"),
117+
),
113118
argumentOrParameter: argumentMatcher("formal_parameters", "argument_list"),
119+
subject: patternMatcher("switch_expression[condition]"),
120+
branch: ["switch_block_statement_group", "switch_rule"],
114121
};
115122

116123
export default createPatternMatchers(nodeMatchers);

0 commit comments

Comments
 (0)