public static List<Diagnostic> resolveInheritances(ParseContext context) {
        List<Diagnostic> diagnostics = new ArrayList<>();
        Set<String> documentInheritanceURIs = new HashSet<>();

        for (SchemaNode inheritanceNode : context.unresolvedInheritanceNodes()) {
            if (inheritanceNode.getSymbol().getType() == SymbolType.DOCUMENT) {
                resolveDocumentInheritance(inheritanceNode, context, diagnostics).ifPresent(
                    parentURI -> documentInheritanceURIs.add(parentURI)
                );
            }
        }

        for (SchemaNode inheritanceNode : context.unresolvedInheritanceNodes()) {
            if (inheritanceNode.getSymbol().getType() == SymbolType.STRUCT) {
                resolveStructInheritance(inheritanceNode, context, diagnostics);
            }

            if (inheritanceNode.getSymbol().getType() == SymbolType.RANK_PROFILE) {
                resolveRankProfileInheritance(inheritanceNode, context, diagnostics);
            }

            if (inheritanceNode.getSymbol().getType() == SymbolType.DOCUMENT_SUMMARY) {
                resolveDocumentSummaryInheritance(inheritanceNode, context, diagnostics);
            }
        }

        if (context.inheritsSchemaNode() != null) {
            String inheritsSchemaName = context.inheritsSchemaNode().getText();

            Optional<Symbol> schemaSymbol = context.schemaIndex().getSchemaDefinition(inheritsSchemaName);

            if (schemaSymbol.isPresent()) {
                SchemaDocument parent = context.scheduler().getSchemaDocument(schemaSymbol.get().getFileURI());

                if (parent != null) {
                    if (!documentInheritanceURIs.contains(parent.getFileURI())) {
                        diagnostics.add(new SchemaDiagnostic.Builder()
                                .setRange( context.inheritsSchemaNode().getRange())
                                .setMessage( "The schema document must explicitly inherit from " + inheritsSchemaName + " because the containing schema does so.")
                                .setSeverity( DiagnosticSeverity.Error)
                                .setCode(DiagnosticCode.EXPLICITLY_INHERIT_DOCUMENT)
                                .build() );
                        context.schemaIndex().getDocumentInheritanceGraph().addInherits(context.fileURI(), parent.getFileURI());
                    }

                    context.schemaIndex().insertSymbolReference(schemaSymbol.get(), context.inheritsSchemaNode().getSymbol());
                }
            }
        }

        context.clearUnresolvedInheritanceNodes();

        return diagnostics;
    }
Assuming first parsing step is done, use the list of unresolved inheritance
declarations to register the inheritance at index.
@return List of diagnostic found during inheritance handling
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/schemadocument/resolvers/InheritanceResolver.java