MCPcopy Create free account
hub / github.com/BaseXdb/basex / simplifyFor

Method simplifyFor

basex-core/src/main/java/org/basex/query/expr/List.java:230–253  ·  view source on GitHub ↗
(final Simplify mode, final CompileContext cc)

Source from the content-addressed store, hash-verified

228 }
229
230 @Override
231 public Expr simplifyFor(final Simplify mode, final CompileContext cc) throws QueryException {
232 Expr expr = this;
233 if(mode.oneOf(Simplify.EBV, Simplify.PREDICATE)) {
234 // E[A, B] → E[A | B]
235 expr = toUnion(cc);
236 } else if(mode == Simplify.DISTINCT) {
237 final int el = exprs.length;
238 final ExprList list = new ExprList(el);
239 for(final Expr ex : exprs) list.addUnique(ex.simplifyFor(mode, cc));
240 exprs = list.finish();
241 if(exprs.length != el) {
242 // remove duplicate list expressions
243 expr = List.get(cc, info, exprs);
244 } else if(seqType().type == BasicType.INTEGER) {
245 // merge numbers and ranges
246 expr = toRange();
247 }
248 } else {
249 final Expr[] ex = simplifyAll(mode, cc);
250 if(ex != exprs) expr = List.get(cc, info, ex);
251 }
252 return cc.simplify(this, expr, mode);
253 }
254
255 /**
256 * If possible, rewrites the list to a union expression.

Callers

nothing calls this directly

Calls 9

toUnionMethod · 0.95
getMethod · 0.95
toRangeMethod · 0.95
simplifyAllMethod · 0.80
oneOfMethod · 0.65
seqTypeMethod · 0.65
addUniqueMethod · 0.45
finishMethod · 0.45
simplifyMethod · 0.45

Tested by

no test coverage detected