Repository: groovy Updated Branches: refs/heads/master b17fc4dbf -> b67f1e478
Minor refactoring Project: http://git-wip-us.apache.org/repos/asf/groovy/repo Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/b67f1e47 Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/b67f1e47 Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/b67f1e47 Branch: refs/heads/master Commit: b67f1e478e23d5b2e7c3c09fcbcb9c8c8611b390 Parents: b17fc4d Author: sunlan <sun...@apache.org> Authored: Mon Aug 7 12:55:39 2017 +0800 Committer: sunlan <sun...@apache.org> Committed: Mon Aug 7 12:55:39 2017 +0800 ---------------------------------------------------------------------- .../apache/groovy/parser/antlr4/AstBuilder.java | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/groovy/blob/b67f1e47/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java ---------------------------------------------------------------------- diff --git a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java index dbe9c43..8421f99 100644 --- a/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java +++ b/subprojects/parser-antlr4/src/main/java/org/apache/groovy/parser/antlr4/AstBuilder.java @@ -190,7 +190,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov AtnManager.RRWL.readLock().unlock(); } } catch (Throwable t) { - throw createParsingFailedException(t); + throw convertException(t); } return result; @@ -209,23 +209,25 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov return parser.compilationUnit(); } + public CompilationFailedException convertException(Throwable t) { + CompilationFailedException cfe; + + if (t instanceof CompilationFailedException) { + cfe = (CompilationFailedException) t; + } else if (t instanceof ParseCancellationException) { + cfe = createParsingFailedException(t.getCause()); + } else { + cfe = createParsingFailedException(t); + } + + return cfe; + } + public ModuleNode buildAST() { try { return (ModuleNode) this.visit(this.buildCST()); } catch (Throwable t) { - CompilationFailedException cfe; - - if (t instanceof CompilationFailedException) { - cfe = (CompilationFailedException) t; - } else if (t instanceof ParseCancellationException) { - cfe = createParsingFailedException(t.getCause()); - } else { - cfe = createParsingFailedException(t); - } - -// LOGGER.log(Level.SEVERE, "Failed to build AST", cfe); - - throw cfe; + throw convertException(t); } }