[OLINGO-434][OLINGO-435] Merge branch 'Olingo-434-435'
This commit is contained in:
commit
541d76652e
|
@ -130,7 +130,9 @@ TRUE : 'true';
|
|||
FALSE : 'false';
|
||||
BOOLEAN : T R U E | F A L S E;
|
||||
PLUS : '+';
|
||||
SIGN : PLUS | '%2B' |'-';
|
||||
|
||||
MINUS : '-';
|
||||
SIGN : PLUS | '%2B' | '-';
|
||||
INT : SIGN? DIGITS;
|
||||
DECIMAL : INT '.' DIGITS (('e'|'E') SIGN? DIGITS)?;
|
||||
NANINFINITY : 'NaN' | '-INF' | 'INF';
|
||||
|
@ -182,7 +184,7 @@ OR : 'or';
|
|||
|
||||
|
||||
NOT : 'not';
|
||||
MINUS :'-';
|
||||
|
||||
|
||||
IT : '$it';
|
||||
ITSLASH : '$it/';
|
||||
|
|
|
@ -191,7 +191,7 @@ contextFragment : REST; // the context fragment is only required on the clie
|
|||
commonExpr : OPEN commonExpr CLOSE #altPharenthesis
|
||||
| vE1=commonExpr (WSP HAS WSP) vE2=commonExpr #altHas
|
||||
| methodCallExpr #altMethod
|
||||
| ( unary WSP ) commonExpr #altUnary
|
||||
| ( unary WSP? ) commonExpr #altUnary
|
||||
| anyExpr #altAny
|
||||
| allExpr #altAll
|
||||
| memberExpr #altMember
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
package org.apache.olingo.server.core.uri.parser;
|
||||
|
||||
import org.antlr.v4.runtime.misc.NotNull;
|
||||
import org.antlr.v4.runtime.misc.ParseCancellationException;
|
||||
import org.antlr.v4.runtime.tree.ParseTree;
|
||||
import org.apache.olingo.commons.api.edm.Edm;
|
||||
|
@ -45,6 +46,7 @@ import org.apache.olingo.server.api.uri.UriResource;
|
|||
import org.apache.olingo.server.api.uri.UriResourcePartTyped;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.BinaryOperatorKind;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.MethodKind;
|
||||
import org.apache.olingo.server.api.uri.queryoption.expression.UnaryOperatorKind;
|
||||
import org.apache.olingo.server.core.uri.UriInfoImpl;
|
||||
import org.apache.olingo.server.core.uri.UriParameterImpl;
|
||||
import org.apache.olingo.server.core.uri.UriResourceActionImpl;
|
||||
|
@ -68,6 +70,7 @@ import org.apache.olingo.server.core.uri.UriResourceValueImpl;
|
|||
import org.apache.olingo.server.core.uri.UriResourceWithKeysImpl;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriLexer;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserBaseVisitor;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllEOFContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.AllExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.AltAddContext;
|
||||
|
@ -84,6 +87,7 @@ import org.apache.olingo.server.core.uri.antlr.UriParserParser.BatchEOFContext;
|
|||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.BooleanNonCaseContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.CastExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.CeilingMethodCallExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.CommonExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.ConcatMethodCallExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.ConstSegmentContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.ContainsMethodCallExprContext;
|
||||
|
@ -153,6 +157,7 @@ import org.apache.olingo.server.core.uri.antlr.UriParserParser.TopContext;
|
|||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.TotalOffsetMinutesMethodCallExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.TotalsecondsMethodCallExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.TrimMethodCallExprContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.UnaryContext;
|
||||
import org.apache.olingo.server.core.uri.antlr.UriParserParser.YearMethodCallExprContext;
|
||||
import org.apache.olingo.server.core.uri.queryoption.CountOptionImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.ExpandItemImpl;
|
||||
|
@ -168,6 +173,7 @@ import org.apache.olingo.server.core.uri.queryoption.SkipOptionImpl;
|
|||
import org.apache.olingo.server.core.uri.queryoption.SkipTokenOptionImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.SystemQueryOptionImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.TopOptionImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.AliasImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.BinaryImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.EnumerationImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.ExpressionImpl;
|
||||
|
@ -175,6 +181,7 @@ import org.apache.olingo.server.core.uri.queryoption.expression.LiteralImpl;
|
|||
import org.apache.olingo.server.core.uri.queryoption.expression.MemberImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.MethodImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.TypeLiteralImpl;
|
||||
import org.apache.olingo.server.core.uri.queryoption.expression.UnaryImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
@ -2156,4 +2163,18 @@ public class UriParseTreeVisitor extends UriParserBaseVisitor<Object> {
|
|||
return new ParseCancellationException(uriParserException);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitAltUnary(@NotNull UriParserParser.AltUnaryContext ctx) {
|
||||
UnaryImpl unary = new UnaryImpl();
|
||||
unary.setOperator(ctx.unary().NOT() == null? UnaryOperatorKind.MINUS: UnaryOperatorKind.NOT);
|
||||
unary.setOperand((ExpressionImpl) ctx.commonExpr().accept(this));
|
||||
return unary;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExpressionImpl visitAltAlias(@NotNull UriParserParser.AltAliasContext ctx) {
|
||||
AliasImpl alias = new AliasImpl();
|
||||
alias.setParameter("@"+ctx.odataIdentifier().getChild(0).getText());
|
||||
return alias;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,11 @@ public class TestLexer {
|
|||
// ; 0. URI
|
||||
// ;------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
public void testUnary() {
|
||||
test.run("- a eq a").isAllInput();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUriTokens() {
|
||||
test.globalMode(UriLexer.MODE_QUERY);
|
||||
|
|
|
@ -566,6 +566,13 @@ public class TestUriParserImpl {
|
|||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnary() throws UriParserException {
|
||||
testFilter.runESabc("not a").isCompr("<not <a>>");
|
||||
testFilter.runESabc("- a eq a").isCompr("<<- <a>> eq <a>>");
|
||||
testFilter.runESabc("-a eq a").isCompr("<<- <a>> eq <a>>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFilterComplexMixedPriority() throws UriParserException {
|
||||
testFilter.runESabc("a or c and e ").isCompr("< <a> or < <c> and <e> >>");
|
||||
|
@ -1052,6 +1059,12 @@ public class TestUriParserImpl {
|
|||
testUri.run("FICRTCollCTTwoPrimParam(ParameterInt16=1,ParameterString='2')/olingo.odata.test1.CTBase");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAlias() throws Exception {
|
||||
testUri.run("ESAllPrim", "$filter=PropertyInt16 eq @p1&@p1=1)")
|
||||
.goFilter().is("<<PropertyInt16> eq <@p1>>");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLambda() throws Exception {
|
||||
testUri.run("ESTwoKeyNav", "$filter=CollPropertyComp/all( l : true )")
|
||||
|
|
Loading…
Reference in New Issue