- @NonNull Absolute getActionPath(final @NonNull Class<? extends Action<?, ?, ?>> type) {
- final Absolute identifier = getRuntimeContext().getActionIdentifier(type);
- checkArgument(identifier != null, "Failed to find schema for %s", type);
- return identifier;
+ @NonNull Absolute getActionPath(final @NonNull ActionSpec<?, ?> spec) {
+ final var stack = SchemaInferenceStack.of(getRuntimeContext().getEffectiveModelContext());
+ final var it = toYangInstanceIdentifier(spec.path()).getPathArguments().iterator();
+ verify(it.hasNext(), "Unexpected empty instance identifier for %s", spec);
+
+ QNameModule lastNamespace;
+ do {
+ final var arg = it.next();
+ if (arg instanceof AugmentationIdentifier) {
+ final var augChildren = ((AugmentationIdentifier) arg).getPossibleChildNames();
+ verify(!augChildren.isEmpty(), "Invalid empty augmentation %s", arg);
+ lastNamespace = augChildren.iterator().next().getModule();
+ continue;
+ }
+
+ final var qname = arg.getNodeType();
+ final var stmt = stack.enterDataTree(qname);
+ lastNamespace = qname.getModule();
+ if (stmt instanceof ListEffectiveStatement) {
+ // Lists have two steps
+ verify(it.hasNext(), "Unexpected list termination at %s in %s", stmt, spec);
+ // Verify just to make sure we are doing the right thing
+ final var skipped = it.next();
+ verify(skipped instanceof NodeIdentifier, "Unexpected skipped list entry item %s in %s", skipped, spec);
+ verify(stmt.argument().equals(skipped.getNodeType()), "Mismatched list entry item %s in %s", skipped,
+ spec);
+ }
+ } while (it.hasNext());
+
+ final var stmt = stack.enterSchemaTree(BindingReflections.findQName(spec.type()).bindTo(lastNamespace));
+ verify(stmt instanceof ActionEffectiveStatement, "Action %s resolved to unexpected statement %s", spec, stmt);
+ return stack.toSchemaNodeIdentifier();