aboutsummaryrefslogtreecommitdiff
path: root/src/delombok/lombok
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-03-18 23:57:09 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-03-18 23:57:09 +0100
commit66f32d5073bc726f76f958471ea93ec5a29c354b (patch)
treecdad5343e429b8a243db02b9e826205099b1d34f /src/delombok/lombok
parent0ecc23766f18418f28d09291455777d59537ccc3 (diff)
downloadlombok-66f32d5073bc726f76f958471ea93ec5a29c354b.tar.gz
lombok-66f32d5073bc726f76f958471ea93ec5a29c354b.tar.bz2
lombok-66f32d5073bc726f76f958471ea93ec5a29c354b.zip
Fixed issue 459: Delombok would choke on try-with-resources.
Diffstat (limited to 'src/delombok/lombok')
-rw-r--r--src/delombok/lombok/delombok/PrettyCommentsPrinter.java28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
index 6e9a1c94..9c6a2bd7 100644
--- a/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
+++ b/src/delombok/lombok/delombok/PrettyCommentsPrinter.java
@@ -22,6 +22,11 @@
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
+
+/*
+ * Code derived from com.sun.tools.javac.tree.Pretty, from the langtools project.
+ * A version can be found at, for example, http://hg.openjdk.java.net/jdk7/build/langtools
+ */
package lombok.delombok;
import static com.sun.tools.javac.code.Flags.ANNOTATION;
@@ -981,6 +986,29 @@ public class PrettyCommentsPrinter extends JCTree.Visitor {
public void visitTry(JCTry tree) {
try {
print("try ");
+ List<?> resources = null;
+ try {
+ Field f = JCTry.class.getField("resources");
+ resources = (List<?>) f.get(tree);
+ } catch (Exception ignore) {
+ // In JDK6 and down this field does not exist; resources will retain its initializer value which is what we want.
+ }
+
+ if (resources != null && resources.nonEmpty()) {
+ boolean first = true;
+ print("(");
+ for (Object var0 : resources) {
+ JCTree var = (JCTree) var0;
+ if (!first) {
+ println();
+ indent();
+ }
+ printStat(var);
+ first = false;
+ }
+ print(") ");
+ }
+
printStat(tree.body);
for (List<JCCatch> l = tree.catchers; l.nonEmpty(); l = l.tail) {
printStat(l.head);