aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse/handlers
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-11-03 00:43:05 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-11-03 00:43:05 +0100
commitfcf39d88b489d03bc93cecf0e98e7ffbb7a162aa (patch)
treecaf72086c976d4502f7341e8b6f42cc1a54794d9 /src/core/lombok/eclipse/handlers
parentf1cf083890c223bf7245190264438740ee724bc9 (diff)
parent17bcfda43b9e939ac22d5247ef98905741650432 (diff)
downloadlombok-fcf39d88b489d03bc93cecf0e98e7ffbb7a162aa.tar.gz
lombok-fcf39d88b489d03bc93cecf0e98e7ffbb7a162aa.tar.bz2
lombok-fcf39d88b489d03bc93cecf0e98e7ffbb7a162aa.zip
Merge branch 'master' of github.com:rzwitserloot/lombok
Diffstat (limited to 'src/core/lombok/eclipse/handlers')
-rw-r--r--src/core/lombok/eclipse/handlers/HandleCleanup.java28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleCleanup.java b/src/core/lombok/eclipse/handlers/HandleCleanup.java
index d296e96b..33ab7fb9 100644
--- a/src/core/lombok/eclipse/handlers/HandleCleanup.java
+++ b/src/core/lombok/eclipse/handlers/HandleCleanup.java
@@ -37,9 +37,13 @@ import org.eclipse.jdt.internal.compiler.ast.Assignment;
import org.eclipse.jdt.internal.compiler.ast.Block;
import org.eclipse.jdt.internal.compiler.ast.CaseStatement;
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
+import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
+import org.eclipse.jdt.internal.compiler.ast.IfStatement;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.MemberValuePair;
import org.eclipse.jdt.internal.compiler.ast.MessageSend;
+import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
+import org.eclipse.jdt.internal.compiler.ast.OperatorIds;
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
import org.eclipse.jdt.internal.compiler.ast.Statement;
import org.eclipse.jdt.internal.compiler.ast.SwitchStatement;
@@ -157,7 +161,29 @@ public class HandleCleanup implements EclipseAnnotationHandler<Cleanup> {
}
unsafeClose.nameSourcePosition = nameSourcePosition;
unsafeClose.selector = cleanupName.toCharArray();
- finallyBlock[0] = unsafeClose;
+
+
+ int pS = ast.sourceStart, pE = ast.sourceEnd;
+ long p = (long)pS << 32 | pE;
+
+ SingleNameReference varName = new SingleNameReference(decl.name, p);
+ Eclipse.setGeneratedBy(varName, ast);
+ NullLiteral nullLiteral = new NullLiteral(pS, pE);
+ Eclipse.setGeneratedBy(nullLiteral, ast);
+ EqualExpression equalExpression = new EqualExpression(varName, nullLiteral, OperatorIds.NOT_EQUAL);
+ equalExpression.sourceStart = pS; equalExpression.sourceEnd = pE;
+ Eclipse.setGeneratedBy(equalExpression, ast);
+
+ Block closeBlock = new Block(0);
+ closeBlock.statements = new Statement[1];
+ closeBlock.statements[0] = unsafeClose;
+ Eclipse.setGeneratedBy(closeBlock, ast);
+ IfStatement ifStatement = new IfStatement(equalExpression, closeBlock, 0, 0);
+ Eclipse.setGeneratedBy(ifStatement, ast);
+
+
+
+ finallyBlock[0] = ifStatement;
tryStatement.finallyBlock = new Block(0);
Eclipse.setGeneratedBy(tryStatement.finallyBlock, ast);
tryStatement.finallyBlock.statements = finallyBlock;