Static utility class that centralises flushing of all caches used by the text editor and language intelligence subsystems. It calls Flush or equivalent on lexers, intrinsic database, symbol table, language definitions, include resolver and per-file document symbol cache, wrapping each call with a PrismLog.Guard to isolate failures.
using Editor.Prism.Core;
using Editor.Prism.Text.Completion;
using Editor.Prism.Text.LanguageDb;
using Editor.Prism.Text.Lexer;
namespace Editor.Prism.Text;
/// <summary>
/// The one call that drops every cache the text editor and its language intelligence hold.
/// <para>
/// Everything under <c>Editor/Prism/Text</c> that memoises anything — the shared lexer instances, the
/// intrinsic name index, the s&box symbol table, the lazily built VFX language definition, the
/// include search roots and their file texts, and the per-file symbol tables harvested out of headers —
/// is reachable from here. <c>PrismHotloadIntegration.FlushRemainingCaches</c> calls this, so a hotload
/// can never leave a document lexing against word tables from the outgoing assembly.
/// </para>
/// <para>
/// Each subsystem also exposes its own <c>Flush()</c>, so a caller that knows exactly what went stale —
/// a project mounting, say, which only invalidates the include roots — can drop just that.
/// </para>
/// </summary>
public static class TextCaches
{
/// <summary>
/// Drops every text-editor cache. Never throws: each subsystem is flushed inside its own guard, so
/// one failing flush cannot leave the rest stale.
/// </summary>
public static void Flush()
{
PrismLog.Guard( "Flushing the Prism lexers", Lexers.Flush );
PrismLog.Guard( "Flushing the intrinsic database", IntrinsicDb.Flush );
PrismLog.Guard( "Flushing the s&box symbol table", SboxSymbols.Flush );
PrismLog.Guard( "Flushing the language definitions", LanguageDefinition.Flush );
PrismLog.Guard( "Flushing the include resolver", IncludeResolver.Flush );
PrismLog.Guard( "Flushing header symbol tables", DocumentSymbols.FlushFileCache );
}
}