chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1039258 - /incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
Date Fri, 26 Nov 2010 07:42:32 GMT
Author: jens
Date: Fri Nov 26 07:42:32 2010
New Revision: 1039258

URL: http://svn.apache.org/viewvc?rev=1039258&view=rev
Log:
cleanup of Query exception handling

Modified:
    incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g

Modified: incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
URL: http://svn.apache.org/viewvc/incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g?rev=1039258&r1=1039257&r2=1039258&view=diff
==============================================================================
--- incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
(original)
+++ incubator/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQueryWalker.g
Fri Nov 26 07:42:32 2010
@@ -61,14 +61,8 @@ options {
 package org.apache.chemistry.opencmis.server.support.query;
 
 import java.math.BigDecimal;
-
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.HashMap;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.chemistry.opencmis.server.support.query.*;
 }
 
 @members {
@@ -76,26 +70,11 @@ import org.apache.chemistry.opencmis.ser
 
     private QueryObject queryObj;
     private Tree wherePredicateTree;
-    public String errorMessage;
 
     public Tree getWherePredicateTree() {
     	return wherePredicateTree;
     }
     
-    @Override
-    public void displayRecognitionError(String[] tokenNames,
-            RecognitionException e) {
-        if (errorMessage == null) {
-            String hdr = getErrorHeader(e);
-            String msg = getErrorMessage(e, tokenNames);
-            errorMessage = hdr + " " + msg;
-        }
-    }
-
-    public String getErrorMessageString() {
-        return errorMessage;
-    }
-
     protected void mismatch(IntStream input, int ttype, BitSet follow)
         throws RecognitionException
     {
@@ -107,8 +86,10 @@ import org.apache.chemistry.opencmis.ser
     {
         throw e;
     }
+
 }
 
+
 // For CMIS SQL it will be sufficient to stop on first error:
 @rulecatch {
     catch (RecognitionException e) {
@@ -116,18 +97,27 @@ import org.apache.chemistry.opencmis.ser
     }
 }
 
-query [QueryObject qo, PredicateWalkerBase pw]
+query [QueryObject qo, PredicateWalkerBase pw] throws CmisQueryException
     @init {
         queryObj = qo;
     }:
     ^(SELECT select_list from_clause order_by_clause? where_clause)
     {
         wherePredicateTree = $where_clause.tree==null ? null : $where_clause.tree.getChild(0);
-        queryObj.resolveTypes();
+        boolean resolved = queryObj.resolveTypes();
         if (null != pw && null != $where_clause.tree)
-            pw.walkPredicate(wherePredicateTree);
+            pw.walkPredicate(wherePredicateTree);        
     }
+    {
+    	resolved
+    }?
     ;
+	catch[FailedPredicateException e]
+	{
+	    // change default text to preserved text which is useful
+	    e.predicateText = queryObj.getErrorMessage();
+	    throw e;
+	}      
 
 select_list:
       STAR
@@ -208,9 +198,15 @@ table_join:
 one_table returns [String alias]:
     ^(TABLE table_name correlation_name?)
       {
-          $alias = queryObj.addType($correlation_name.text, $table_name.text);
-      }
+          ($alias = queryObj.addType($correlation_name.text, $table_name.text)) != null
+      }?
     ;
+	catch[FailedPredicateException e]
+	{
+	    // change default text to preserved text which is useful
+	    e.predicateText = queryObj.getErrorMessage();
+	    throw e;
+	}      
 
 join_kind returns [String kind]:
       INNER { $kind = "INNER"; }



Mime
View raw message