if (chain.parent.node instanceof CatchStmt) { return true; }
Declaration decl = (Declaration) node;
Identifier id = decl.getIdentifier();
removedIdents.add(id);
Expression init = decl.getInitializer();
Statement replacement;
if (init != null) {
replacement = new ExpressionStmt(toAssignment(decl));
} else if (chain.parent.node instanceof ForEachLoop) {
replacement = new ExpressionStmt(new Reference(id));
} else {
replacement = new Noop(decl.getFilePosition());
}
changes.add(Pair.pair(chain.cast(Statement.class), replacement));
return true;
} else if (node instanceof MultiDeclaration) {
List<Expression> replacements = Lists.newArrayList();
for (Declaration decl : ((MultiDeclaration) node).children()) {
removedIdents.add(decl.getIdentifier());
if (decl.getInitializer() == null) { continue; }
visit(chain.child(decl).child(decl.getInitializer()));
Expression assign = toAssignment(decl);
replacements.add(assign);
}
Statement replacement;
if (replacements.isEmpty()) {
replacement = new Noop(node.getFilePosition());
} else if (replacements.size() == 1) {
Expression e = replacements.get(0);
replacement = new ExpressionStmt(e.getFilePosition(), e);