chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r1653312 - in /chemistry/opencmis/trunk/chemistry-opencmis-server: chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/ chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmi...
Date Tue, 20 Jan 2015 17:46:44 GMT
Author: jens
Date: Tue Jan 20 17:46:44 2015
New Revision: 1653312

URL: http://svn.apache.org/r1653312
Log:
Correct parsing of EOF for strict query parser, fix bug [CMIS-850]

Modified:
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictParser.g
    chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java?rev=1653312&r1=1653311&r2=1653312&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-inmemory/src/test/java/org/apache/chemistry/opencmis/inmemory/query/QueryParseTest.java
Tue Jan 20 17:46:44 2015
@@ -494,10 +494,11 @@ public class QueryParseTest extends Abst
         String statement = "SELECT p1 FROM MyType WHERE p1 LIKE 'abc*' IN_FOLDER('def')";
         try {
             checkTreeWhere(statement);
+            fail("Parsing query with tokens after end of statement should fail.");
         } catch (Exception e) {
             LOG.debug("Exception is: ", e);
             assertTrue(e instanceof CmisInvalidArgumentException);
-            assertTrue(e.getMessage().contains("illegal tokens after end"));
+            assertTrue(e.getMessage().contains("missing EOF at "));
         }
     }
 

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictParser.g
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictParser.g?rev=1653312&r1=1653311&r2=1653312&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictParser.g
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/antlr3/org/apache/chemistry/opencmis/server/support/query/CmisQlStrictParser.g
Tue Jan 20 17:46:44 2015
@@ -64,13 +64,35 @@ package org.apache.chemistry.opencmis.se
 }
 
 @members {
+    private List<String> errorMessages = new ArrayList<String>();
+
     public boolean hasErrors() {
-    	return gCmisBaseGrammar.hasErrors();
+    	return errorMessages.size() > 0 ||  gCmisBaseGrammar.hasErrors();
     }
 
+	public String getStrictParserErrorMessages() {
+		StringBuffer allMessages = new StringBuffer();
+		
+		for (String msg : errorMessages)
+			allMessages.append(msg).append('\n');
+			
+		return allMessages.toString();
+	}
+	
 	public String getErrorMessages() {
-    	return gCmisBaseGrammar.getErrorMessages();
+	    if (errorMessages.size() > 0) {
+	        return getStrictParserErrorMessages();
+	    } else {
+    	    return gCmisBaseGrammar.getErrorMessages();
+    	}
+	}
+	
+	@Override
+    // Instead of sending all errors to System.err collect them in a list
+	public void emitErrorMessage(String msg) {
+		errorMessages.add(msg);
 	}
+	
 }
 
   // Rules can't be empty so we have one dummy rule here

Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java?rev=1653312&r1=1653311&r2=1653312&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
(original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/main/java/org/apache/chemistry/opencmis/server/support/query/QueryUtilStrict.java
Tue Jan 20 17:46:44 2015
@@ -27,7 +27,7 @@ import org.antlr.runtime.tree.CommonTree
 import org.antlr.runtime.tree.CommonTreeNodeStream;
 import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
 import org.apache.chemistry.opencmis.server.support.TypeManager;
-import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser_CmisBaseGrammar.query_return;
+import org.apache.chemistry.opencmis.server.support.query.CmisQlStrictParser.root_return;
 
 public class QueryUtilStrict extends QueryUtilBase<CmisQueryWalker> {
 
@@ -53,7 +53,7 @@ public class QueryUtilStrict extends Que
         tokens = new CommonTokenStream(lexer);
         CmisQlStrictParser parser = new CmisQlStrictParser(tokens);
 
-        query_return parsedStatement = parser.query();
+        root_return parsedStatement = parser.root();
         if (lexer.hasErrors()) {
             throw new CmisInvalidArgumentException(lexer.getErrorMessages());
         } else if (parser.hasErrors()) {



Mime
View raw message