asterixdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ti...@apache.org
Subject asterixdb git commit: reduce redundancy in syntax error messages
Date Mon, 10 Oct 2016 17:07:09 GMT
Repository: asterixdb
Updated Branches:
  refs/heads/master 82888fb89 -> e3c9f2738


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>


Project: http://git-wip-us.apache.org/repos/asf/asterixdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/asterixdb/commit/e3c9f273
Tree: http://git-wip-us.apache.org/repos/asf/asterixdb/tree/e3c9f273
Diff: http://git-wip-us.apache.org/repos/asf/asterixdb/diff/e3c9f273

Branch: refs/heads/master
Commit: e3c9f27387085688d4564c0bf3742903df800525
Parents: 82888fb
Author: Till Westmann <tillw@apache.org>
Authored: Sun Oct 9 11:09:26 2016 -0700
Committer: Till Westmann <tillw@apache.org>
Committed: Mon Oct 10 10:03:39 2016 -0700

----------------------------------------------------------------------
 .../asterix/lang/common/parser/ScopeChecker.java       | 13 +++++++------
 asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj  |  5 ++++-
 2 files changed, 11 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/asterixdb/blob/e3c9f273/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/parser/ScopeChecker.java
----------------------------------------------------------------------
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 @@ public class ScopeChecker {
         }
     }
 
-    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) {

http://git-wip-us.apache.org/repos/asf/asterixdb/blob/e3c9f273/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
----------------------------------------------------------------------
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 @@ class SQLPPParser extends ScopeChecker implements IParser {
                 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;
         }


Mime
View raw message