You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2017/08/07 05:24:49 UTC
[1/2] groovy git commit: Convert antlr exceptions into
CompilationFailedException
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_6_X 858fb365f -> 65a21bac4
Convert antlr exceptions into CompilationFailedException
(cherry picked from commit b17fc4d)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/581faad9
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/581faad9
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/581faad9
Branch: refs/heads/GROOVY_2_6_X
Commit: 581faad9e70f6c558968786dbd614de14d164b26
Parents: 858fb36
Author: sunlan <su...@apache.org>
Authored: Mon Aug 7 12:50:40 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Mon Aug 7 13:24:37 2017 +0800
----------------------------------------------------------------------
.../apache/groovy/parser/antlr4/AstBuilder.java | 28 +++++++++++---------
1 file changed, 16 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/581faad9/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 520e581..ba314b9 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
@@ -169,22 +169,26 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
this.groovydocManager = new GroovydocManager(this);
}
- private GroovyParserRuleContext buildCST() {
+ private GroovyParserRuleContext buildCST() throws CompilationFailedException {
GroovyParserRuleContext result;
- // parsing have to wait util clearing is complete.
- AtnManager.RRWL.readLock().lock();
try {
- result = buildCST(PredictionMode.SLL);
- } catch (Throwable t) {
- // if some syntax error occurred in the lexer, no need to retry the powerful LL mode
- if (t instanceof GroovySyntaxError && GroovySyntaxError.LEXER == ((GroovySyntaxError) t).getSource()) {
- throw t;
- }
+ // parsing have to wait util clearing is complete.
+ AtnManager.RRWL.readLock().lock();
+ try {
+ result = buildCST(PredictionMode.SLL);
+ } catch (Throwable t) {
+ // if some syntax error occurred in the lexer, no need to retry the powerful LL mode
+ if (t instanceof GroovySyntaxError && GroovySyntaxError.LEXER == ((GroovySyntaxError) t).getSource()) {
+ throw t;
+ }
- result = buildCST(PredictionMode.LL);
- } finally {
- AtnManager.RRWL.readLock().unlock();
+ result = buildCST(PredictionMode.LL);
+ } finally {
+ AtnManager.RRWL.readLock().unlock();
+ }
+ } catch (Throwable t) {
+ throw createParsingFailedException(t);
}
return result;
[2/2] groovy git commit: Minor refactoring
Posted by su...@apache.org.
Minor refactoring
(cherry picked from commit b67f1e4)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/65a21bac
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/65a21bac
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/65a21bac
Branch: refs/heads/GROOVY_2_6_X
Commit: 65a21bac44d65b1be13760eb4a277aa6b96560b6
Parents: 581faad
Author: sunlan <su...@apache.org>
Authored: Mon Aug 7 12:55:39 2017 +0800
Committer: sunlan <su...@apache.org>
Committed: Mon Aug 7 13:24:43 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/65a21bac/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 ba314b9..c7b8dd1 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
@@ -188,7 +188,7 @@ public class AstBuilder extends GroovyParserBaseVisitor<Object> implements Groov
AtnManager.RRWL.readLock().unlock();
}
} catch (Throwable t) {
- throw createParsingFailedException(t);
+ throw convertException(t);
}
return result;
@@ -207,23 +207,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);
}
}