private static void computeShapeTextInstances(
            Shape shape,
            Collection<TextInstance> textInstances,
            Model model
    ) {
        textInstances.add(TextInstance.createShapeInstance(shape));

        for (Trait trait : shape.getAllTraits().values()) {
            model.getShape(trait.toShapeId()).ifPresent(traitShape -> {
                computeTextInstancesForAppliedTrait(trait.toNode(),
                        trait,
                        shape,
                        textInstances,
                        new ArrayDeque<>(),
                        model,
                        traitShape);
            });
        }
    }
Index containing the full set of {@link TextInstance}s associated with a model.
smithy-model/src/main/java/software/amazon/smithy/model/knowledge/TextIndex.java