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

Method inline

basex-core/src/main/java/org/basex/query/expr/path/Path.java:1145–1186  ·  view source on GitHub ↗
(final InlineContext ic)

Source from the content-addressed store, hash-verified

1143 }
1144
1145 @Override
1146 public final Expr inline(final InlineContext ic) throws QueryException {
1147 boolean changed = false;
1148 if(root != null) {
1149 final Expr inlined = root.inline(ic);
1150 if(inlined != null) {
1151 root = inlined;
1152 changed = true;
1153 }
1154 } else if(ic.var == null) {
1155 // relative path: assign new root
1156 root = ic.copy();
1157 changed = true;
1158 }
1159
1160 // optimize steps with new root context
1161 final CompileContext cc = ic.cc;
1162 final int sl = steps.length;
1163 final Expr rt = root != null ? root : cc.qc.focus.value;
1164 if(changed) cc.get(rt, true, () -> {
1165 for(int s = 0; s < sl; s++) {
1166 steps[s] = steps[s].optimize(cc);
1167 cc.updateFocus(steps[s], true);
1168 }
1169 return null;
1170 });
1171
1172 changed |= ic.var != null && cc.ok(rt, true, () -> {
1173 boolean chngd = false;
1174 for(int s = 0; s < sl; s++) {
1175 final Expr step = steps[s].inline(ic);
1176 if(step != null) {
1177 steps[s] = step;
1178 chngd = true;
1179 }
1180 cc.updateFocus(steps[s], true);
1181 }
1182 return chngd;
1183 });
1184
1185 return changed ? optimize(cc) : null;
1186 }
1187
1188 @Override
1189 public final boolean accept(final ASTVisitor visitor) {

Callers

nothing calls this directly

Calls 6

getMethod · 0.95
optimizeMethod · 0.95
updateFocusMethod · 0.95
okMethod · 0.95
inlineMethod · 0.65
copyMethod · 0.45

Tested by

no test coverage detected