public void Clear(HashSet <IDsDocument?> modules)
 {
     lock (lockObj) {
         foreach (var kv in cachedItems.ToArray())
         {
             if (InModifiedModuleHelper.IsInModifiedModule(modules, kv.Key.Nodes) ||
                 IsInModifiedModule(documentService, modules, kv.Value))
             {
                 cachedItems.Remove(kv.Key);
                 continue;
             }
         }
     }
 }
        static bool IsInModifiedModule(IDsDocumentService documentService, HashSet <IDsDocument?> modules, Item item)
        {
            var result = item.Content;

            if (result is null && !(item.WeakContent is null))
            {
                result = (DocumentViewerContent?)item.WeakContent.Target;
            }
            var refs = result?.ReferenceCollection;

            if (refs is null)
            {
                return(false);
            }
            return(InModifiedModuleHelper.IsInModifiedModule(documentService, modules, refs.Select(a => a.Data.Reference)));
        }