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

Method noMatches

basex-core/src/main/java/org/basex/query/expr/path/Step.java:339–358  ·  view source on GitHub ↗

Checks if the step will never yield results. @return true if steps will never yield results

()

Source from the content-addressed store, hash-verified

337 * @return {@code true} if steps will never yield results
338 */
339 private boolean noMatches() {
340 final Kind kind = test.kind;
341 if(kind.oneOf(Kind.GNODE, Kind.NODE)) return false;
342
343 return switch(axis) {
344 // attribute::element()
345 case ATTRIBUTE ->
346 kind != Kind.ATTRIBUTE;
347 // parent::comment()
348 case ANCESTOR, PARENT ->
349 isLeaf(kind);
350 // child::attribute()
351 case CHILD, DESCENDANT, FOLLOWING, FOLLOWING_OR_SELF, FOLLOWING_SIBLING,
352 FOLLOWING_SIBLING_OR_SELF, PRECEDING, PRECEDING_OR_SELF, PRECEDING_SIBLING,
353 PRECEDING_SIBLING_OR_SELF ->
354 kind.oneOf(Kind.ATTRIBUTE, Kind.DOCUMENT, Kind.NAMESPACE);
355 default ->
356 false;
357 };
358 }
359
360 /**
361 * Checks if the step will never yield results.

Callers 2

optimizeMethod · 0.95
optimizeMethod · 0.45

Calls 2

oneOfMethod · 0.95
isLeafMethod · 0.95

Tested by

no test coverage detected