+
+ /**
+ * Resolve type reference, as pointed to by the context's argument.
+ *
+ * @param ctx Statement context
+ * @return Resolved type
+ * @throws SourceException if the target type cannot be found
+ */
+ private static @NonNull TypeEffectiveStatement<TypeStatement> resolveType(final StmtContext<String, ?, ?> ctx) {
+ final String argument = ctx.coerceStatementArgument();
+ switch (argument) {
+ case BINARY:
+ return BuiltinEffectiveStatement.BINARY;
+ case BOOLEAN:
+ return BuiltinEffectiveStatement.BOOLEAN;
+ case EMPTY:
+ return BuiltinEffectiveStatement.EMPTY;
+ case INSTANCE_IDENTIFIER:
+ return BuiltinEffectiveStatement.INSTANCE_IDENTIFIER;
+ case INT8:
+ return BuiltinEffectiveStatement.INT8;
+ case INT16:
+ return BuiltinEffectiveStatement.INT16;
+ case INT32:
+ return BuiltinEffectiveStatement.INT32;
+ case INT64:
+ return BuiltinEffectiveStatement.INT64;
+ case STRING:
+ return BuiltinEffectiveStatement.STRING;
+ case UINT8:
+ return BuiltinEffectiveStatement.UINT8;
+ case UINT16:
+ return BuiltinEffectiveStatement.UINT16;
+ case UINT32:
+ return BuiltinEffectiveStatement.UINT32;
+ case UINT64:
+ return BuiltinEffectiveStatement.UINT64;
+ default:
+ final QName qname = StmtContextUtils.parseNodeIdentifier(ctx, argument);
+ final StmtContext<?, TypedefStatement, TypedefEffectiveStatement> typedef =
+ SourceException.throwIfNull(ctx.getFromNamespace(TypeNamespace.class, qname),
+ ctx.getStatementSourceReference(), "Type '%s' not found", qname);
+ return typedef.buildEffective().asTypeEffectiveStatement();
+ }
+ }