substitutes="try { @body*; } catch (@ex___) { @handler*; }")
public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
Map<String, ParseTreeNode> bindings = this.match(node);
if (bindings != null) {
Identifier ex = (Identifier) bindings.get("ex");
TryStmt ts = (TryStmt) node;
CatchStmt cs = ts.getCatchClause();
if (isSynthetic(ex)) {
return substV(
"body", rw.expand(bindings.get("body"), scope),
"ex", rw.noexpand(ex),
"handler", rw.expand(
bindings.get("handler"), Scope.fromCatchStmt(scope, cs)));
}
}
return NONE;
}
},
new Rule() {
@Override
@RuleDescription(
name="syntheticCatches2",
synopsis="Pass through synthetic variables which are unmentionable.",
reason="Catching unmentionable exceptions helps maintain invariants.",
matches=(
"try { @body*; } catch (/* synthetic */ @ex___) { @handler*; }"
+ " finally { @cleanup*; }"),
substitutes=(
"try { @body*; } catch (/* synthetic */ @ex___) { @handler*; }"
+ " finally { @cleanup*; }"))
public ParseTreeNode fire(ParseTreeNode node, Scope scope) {
Map<String, ParseTreeNode> bindings = this.match(node);
if (bindings != null) {
TryStmt ts = (TryStmt) node;
CatchStmt cs = ts.getCatchClause();
Identifier ex = (Identifier) bindings.get("ex");
if (isSynthetic(ex)) {
return substV(
"body", rw.expand(bindings.get("body"), scope),
"ex", rw.noexpand(ex),