@Override
    protected void check(Shape shape, IdRefTrait trait, StringNode node, Context context, Emitter emitter) {
        try {
            ShapeId target = node.expectShapeId();
            Shape resolved = context.model().getShape(target).orElse(null);

            if (resolved == null) {
                if (trait.failWhenMissing()) {
                    failWhenNoMatch(node,
                            trait,
                            emitter,
                            String.format(
                                    "Shape ID `%s` was not found in the model",
                                    target));
                }
            } else {
                if (!matchesSelector(trait, resolved, context)) {
                    failWhenNoMatch(node,
                            trait,
                            emitter,
                            String.format(
                                    "Shape ID `%s` does not match selector `%s`",
                                    resolved.getId(),
                                    trait.getSelector()));
                }
            }
        } catch (SourceException e) {
            emitter.accept(node, Severity.ERROR, e.getMessageWithoutLocation());
        }
    }
Validates that the value contained in a string shape is a valid shape ID
and that the shape ID targets a shape that is in the set of shapes
matching the selector.
smithy-model/src/main/java/software/amazon/smithy/model/validation/node/IdRefPlugin.java