@Override
    public Collection<Line> loadContext(FromSourceLocation source) {
        SourceLocation location = source.getSourceLocation();

        // Ignore the components that were generated and have no location.
        if (location == SourceLocation.NONE) {
            return Collections.emptyList();
        }

        // Use the cache if possible (e.g., multiple validation events for the same shape).
        if (location.equals(lastLoadedLocation)) {
            return lastLoadedLocationLines;
        }

        // Open a new file if no file is open, or it differs from the source location file.
        if (lastLoadedLocation == null || !lastLoadedLocation.getFilename().equals(location.getFilename())) {
            loadNextFile(location);
        }

        int line = location.getLine();

        if (!isValidLine(line)) {
            LOGGER.finer(() -> "Attempted to load context for an invalid source location: " + location);
            lastLoadedLocationLines = Collections.emptyList();
        } else if (model == null) {
            int start = Math.max(0, line - defaultCodeLines);
            lastLoadedLocationLines = lines.subList(start, line);
        } else {
            lastLoadedLocationLines = parseLines(source);
        }

        return lastLoadedLocationLines;
    }
This class loads model files into memory, one at a time, and either shows leading lines up to a source location or
shows lines that are relevant to a source location use context from a {@link Model}.

<p>Sort sequences of {@link SourceLocation}s before calling {@link #loadContext(FromSourceLocation)} to avoid
needing to open and parse the same file more than once.

@see SourceContextLoader#createLineBasedLoader
@see SourceContextLoader#createModelAwareLoader
smithy-model/src/main/java/software/amazon/smithy/model/loader/sourcecontext/DefaultSourceLoader.java