+ // Exists only to support {SubstatementContext,InferredStatementContext}.getSchemaPath()
+ @Deprecated
+ final @NonNull Optional<SchemaPath> substatementGetSchemaPath() {
+ if (schemaPath == null) {
+ schemaPath = createSchemaPath(coerceParentContext());
+ }
+ return Optional.ofNullable(schemaPath);
+ }
+
+ @Deprecated
+ private SchemaPath createSchemaPath(final Mutable<?, ?, ?> parent) {
+ final Optional<SchemaPath> maybeParentPath = parent.getSchemaPath();
+ verify(maybeParentPath.isPresent(), "Parent %s does not have a SchemaPath", parent);
+ final SchemaPath parentPath = maybeParentPath.get();
+
+ if (StmtContextUtils.isUnknownStatement(this)) {
+ return parentPath.createChild(getPublicDefinition().getStatementName());
+ }
+ final Object argument = getStatementArgument();
+ if (argument instanceof QName) {
+ final QName qname = (QName) argument;
+ if (producesDeclared(UsesStatement.class)) {
+ return maybeParentPath.orElse(null);
+ }
+
+ return parentPath.createChild(qname);
+ }
+ if (argument instanceof String) {
+ // FIXME: This may yield illegal argument exceptions
+ final Optional<StmtContext<A, D, E>> originalCtx = getOriginalCtx();
+ final QName qname = StmtContextUtils.qnameFromArgument(originalCtx.orElse(this), (String) argument);
+ return parentPath.createChild(qname);
+ }
+ if (argument instanceof SchemaNodeIdentifier
+ && (producesDeclared(AugmentStatement.class) || producesDeclared(RefineStatement.class)
+ || producesDeclared(DeviationStatement.class))) {
+
+ return parentPath.createChild(((SchemaNodeIdentifier) argument).getNodeIdentifiers());
+ }
+
+ // FIXME: this does not look right
+ return maybeParentPath.orElse(null);