From 12fb0aad0bb05fb02accba027d4b64103fe647f9 Mon Sep 17 00:00:00 2001 From: Tom Copeland Date: Thu, 1 Jul 2004 15:57:44 +0000 Subject: [PATCH] Adding some more content to the AST display git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@2782 51baf565-9d33-0410-a72c-fc3788e3496d --- .../sourceforge/pmd/ast/ASTTryStatement.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/pmd/src/net/sourceforge/pmd/ast/ASTTryStatement.java b/pmd/src/net/sourceforge/pmd/ast/ASTTryStatement.java index 351ad26f22..e21c9c7020 100644 --- a/pmd/src/net/sourceforge/pmd/ast/ASTTryStatement.java +++ b/pmd/src/net/sourceforge/pmd/ast/ASTTryStatement.java @@ -35,10 +35,10 @@ public class ASTTryStatement extends SimpleNode { return hasFinally; } - /** - * Call hasFinally() before you call this method - */ public ASTBlock getFinallyBlock() { + if (!hasFinally) { + throw new RuntimeException("ASTTryStatement.getFinallyBlock() called, but no finally statement exists"); + } return (ASTBlock) jjtGetChild(jjtGetNumChildren() - 1); } @@ -60,4 +60,20 @@ public class ASTTryStatement extends SimpleNode { public Object jjtAccept(JavaParserVisitor visitor, Object data) { return visitor.visit(this, data); } + + public void dump(String prefix) { + String x = ""; + if (hasCatch) { + x += ":(has catch)"; + } + if (hasFinally) { + if (x == "") { + x += ":"; + } + x += "(has finally)"; + } + System.out.println(toString(prefix) + x); + dumpChildren(prefix); + } + }