asterixdb-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Till Westmann (Code Review)" <do-not-re...@asterixdb.incubator.apache.org>
Subject Change in asterixdb[master]: reduce redundancy in syntax error messages
Date Mon, 10 Oct 2016 17:03:41 GMT
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 <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Yingyi Bu <buyingyi@gmail.com>
---
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 <tillw@apache.org>
Gerrit-Reviewer: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Gerrit-Reviewer: Michael Blow <mblow@apache.org>
Gerrit-Reviewer: Till Westmann <tillw@apache.org>
Gerrit-Reviewer: Yingyi Bu <buyingyi@gmail.com>

Mime
View raw message