Use $$ prefix for exception handling variables, since $ used for local variables

This commit is contained in:
Alexey Andreev 2016-12-04 20:52:57 +03:00
parent 973231752f
commit 730d3f3070
2 changed files with 8 additions and 8 deletions

View File

@ -678,7 +678,7 @@ public class Renderer implements RenderingManager {
variableNames.add(statementRenderer.variableName(i));
}
if (hasTryCatch) {
variableNames.add("$je");
variableNames.add("$$je");
}
if (!variableNames.isEmpty()) {
writer.append("var ");
@ -725,7 +725,7 @@ public class Renderer implements RenderingManager {
}
boolean hasTryCatch = tryCatchFinder.tryCatchFound;
if (hasTryCatch) {
variableNames.add("$je");
variableNames.add("$$je");
}
variableNames.add(context.pointerName());
variableNames.add(context.tempVarName());

View File

@ -1355,25 +1355,25 @@ public class StatementRenderer implements ExprVisitor, StatementVisitor {
protectedBody = nextStatement.getProtectedBody();
}
visitStatements(protectedBody);
writer.outdent().append("}").ws().append("catch").ws().append("($e)")
writer.outdent().append("}").ws().append("catch").ws().append("($$e)")
.ws().append("{").indent().softNewLine();
writer.append("$je").ws().append("=").ws().append("$e.$javaException;").softNewLine();
writer.append("$$je").ws().append("=").ws().append("$$e.$javaException;").softNewLine();
for (TryCatchStatement catchClause : sequence) {
writer.append("if").ws().append("($je");
writer.append("if").ws().append("($$je");
if (catchClause.getExceptionType() != null) {
writer.ws().append("&&").ws().append("$je instanceof ")
writer.ws().append("&&").ws().append("$$je instanceof ")
.appendClass(catchClause.getExceptionType());
}
writer.append(")").ws().append("{").indent().softNewLine();
if (catchClause.getExceptionVariable() != null) {
writer.append(variableName(catchClause.getExceptionVariable())).ws().append("=").ws()
.append("$je;").softNewLine();
.append("$$je;").softNewLine();
}
visitStatements(catchClause.getHandler());
writer.outdent().append("}").ws().append("else ");
}
writer.append("{").indent().softNewLine();
writer.append("throw $e;").softNewLine();
writer.append("throw $$e;").softNewLine();
writer.outdent().append("}").softNewLine();
writer.outdent().append("}").softNewLine();
} catch (IOException e) {