Till Westmann has submitted this change and it was merged. Change subject: reduce redundancy in syntax error messages ......................................................................
reduce redundancy in syntax error messages Change-Id: I526c0b24d47ac4ee7b492b34387929627e51affc Reviewed-on: https://asterix-gerrit.ics.uci.edu/1266 Sonar-Qube: Jenkins <[email protected]> Tested-by: Jenkins <[email protected]> Integration-Tests: Jenkins <[email protected]> Reviewed-by: Yingyi Bu <[email protected]> --- M asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java M asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj 2 files changed, 11 insertions(+), 7 deletions(-) Approvals: Yingyi Bu: Looks good to me, approved Jenkins: Verified; No violations found; Verified diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java index 07aa473..767eacb 100644 --- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java +++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java @@ -199,13 +199,14 @@ } } - protected String fixQuotes(String token) { + protected static String fixQuotes(String token) { + final String stripped = stripQuotes(token); + return stripped != null ? "'" + stripped + "'" : token; + } + + protected static String stripQuotes(String token) { final int last = token.length() - 1; - if (token.charAt(0) == '"' && token.charAt(last) == '"') { - return "'" + token.substring(1, last) + "'"; - } else { - return token; - } + return token.charAt(0) == '"' && token.charAt(last) == '"' ? token.substring(1, last) : null; } protected static String addEscapes(String str) { diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj index 6c4bc5c..566d9e9 100644 --- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj +++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj @@ -298,7 +298,10 @@ message += fixQuotes(tokenImage[0]); break; } - message += fixQuotes(tokenImage[tok.kind]) + " "; + final String fixedTokenImage = tokenImage[tok.kind]; + if (! tok.image.equalsIgnoreCase(stripQuotes(fixedTokenImage))) { + message += fixQuotes(fixedTokenImage) + " "; + } message += quot + addEscapes(tok.image) + quot; tok = tok.next; } -- To view, visit https://asterix-gerrit.ics.uci.edu/1266 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: merged Gerrit-Change-Id: I526c0b24d47ac4ee7b492b34387929627e51affc Gerrit-PatchSet: 3 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: Till Westmann <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-Reviewer: Till Westmann <[email protected]> Gerrit-Reviewer: Yingyi Bu <[email protected]>
