public void clearDocument(String fileURI) {

        // create once instead of repeatedly for each symbol. Slow operation.
        URI fileURIURI = URI.create(fileURI);

        // First: remove symbols listed as a reference for a definition
        // At the same time, remove the reference from the reference -> definition lookup table
        for (Map.Entry<Symbol, List<Symbol>> entry : symbolReferences.entrySet()) {
            List<Symbol> references = entry.getValue();

            List<Symbol> replacedReferences = new ArrayList<>();
            for (Symbol symbol : references) {
                if (symbol.fileURIEquals(fileURIURI)) {
                    definitionOfReference.remove(symbol);
                } else {
                    replacedReferences.add(symbol);
                }
            }

            entry.setValue(replacedReferences);
        }

        // For each definition: remove their list of references and then remove the definition itself.
        for (var list : symbolDefinitions.values()) {
            for (int i = list.size() - 1; i >= 0; i--) {
                Symbol symbol = list.get(i);
                if (symbol.fileURIEquals(fileURIURI)) {
                    symbolReferences.remove(symbol);

                    structInheritanceGraph.clearInheritsList(symbol);
                    rankProfileInheritanceGraph.clearInheritsList(symbol);
                    documentSummaryInheritanceGraph.clearInheritsList(symbol);
                    documentReferenceGraph.clearInheritsList(symbol);

                    list.remove(i);
                }
            }
        }

        // Clear unresolved symbols from this document
        this.unresolvedSymbols.removeIf(symbol -> symbol.fileURIEquals(fileURIURI));

        this.fieldIndex.clearFieldsByURI(fileURIURI);

        if (fileURI.endsWith(".sd")) {
            documentInheritanceGraph.clearInheritsList(fileURI);
            // Add the node back:)
            documentInheritanceGraph.createNodeIfNotExists(fileURI);
        }
    }
Clears the index for symbols in the specified file

@param fileURI the URI of the document to be cleared
integration/schema-language-server/language-server/src/main/java/ai/vespa/schemals/index/SchemaIndex.java