From 1c2556b1f7b26ea0b70d356d9eeefb638560a46f Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 15 Nov 2010 00:44:16 +0100 Subject: In javac, use ListBuffer to append --- src/core/lombok/javac/handlers/HandleCleanup.java | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/core/lombok/javac/handlers/HandleCleanup.java') diff --git a/src/core/lombok/javac/handlers/HandleCleanup.java b/src/core/lombok/javac/handlers/HandleCleanup.java index cbbdc007..bfe357ef 100644 --- a/src/core/lombok/javac/handlers/HandleCleanup.java +++ b/src/core/lombok/javac/handlers/HandleCleanup.java @@ -50,6 +50,7 @@ import com.sun.tools.javac.tree.JCTree.JCStatement; import com.sun.tools.javac.tree.JCTree.JCTypeCast; import com.sun.tools.javac.tree.JCTree.JCVariableDecl; import com.sun.tools.javac.util.List; +import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Name; /** @@ -93,14 +94,14 @@ public class HandleCleanup implements JavacAnnotationHandler { } boolean seenDeclaration = false; - List tryBlock = List.nil(); - List newStatements = List.nil(); + ListBuffer newStatements = ListBuffer.lb(); + ListBuffer tryBlock = ListBuffer.lb(); for (JCStatement statement : statements) { if (!seenDeclaration) { if (statement == decl) seenDeclaration = true; - newStatements = newStatements.append(statement); + newStatements.append(statement); } else { - tryBlock = tryBlock.append(statement); + tryBlock.append(statement); } } @@ -108,8 +109,7 @@ public class HandleCleanup implements JavacAnnotationHandler { annotationNode.addError("LOMBOK BUG: Can't find this local variable declaration inside its parent."); return true; } - - doAssignmentCheck(annotationNode, tryBlock, decl.name); + doAssignmentCheck(annotationNode, tryBlock.toList(), decl.name); TreeMaker maker = annotationNode.getTreeMaker(); JCFieldAccess cleanupMethod = maker.Select(maker.Ident(decl.name), annotationNode.toName(cleanupName)); @@ -123,14 +123,14 @@ public class HandleCleanup implements JavacAnnotationHandler { JCBlock finalizer = maker.Block(0, List.of(ifNotNullCleanup)); - newStatements = newStatements.append(maker.Try(maker.Block(0, tryBlock), List.nil(), finalizer)); + newStatements.append(maker.Try(maker.Block(0, tryBlock.toList()), List.nil(), finalizer)); if (blockNode instanceof JCBlock) { - ((JCBlock)blockNode).stats = newStatements; + ((JCBlock)blockNode).stats = newStatements.toList(); } else if (blockNode instanceof JCCase) { - ((JCCase)blockNode).stats = newStatements; + ((JCCase)blockNode).stats = newStatements.toList(); } else if (blockNode instanceof JCMethodDecl) { - ((JCMethodDecl)blockNode).body.stats = newStatements; + ((JCMethodDecl)blockNode).body.stats = newStatements.toList(); } else throw new AssertionError("Should not get here"); ancestor.rebuild(); -- cgit