boolean () { Place shreds; synchronized (myLock) { shreds = myShreds; // assumption: myShreds list is immutable } return ReadActionCache.getInstance().allowInWriteAction( () -> { // can grab PsiLock in SmartPsiPointer.restore() // will check the 0th element manually (to avoid getting .getHost() twice) for (int i = 1; i < shreds.size(); i++) { PsiLanguageInjectionHost.Shred shred = shreds.get(i); if (!shred.isValid()) return false; } PsiLanguageInjectionHost.Shred firstShred = shreds.get(0); PsiLanguageInjectionHost host = firstShred.getHost(); if (host == null || firstShred.getHostRangeMarker() == null) return false; VirtualFile virtualFile = FileDocumentManager.getInstance().getFile(this); return virtualFile != null && ((PsiManagerEx)host.getManager()).getFileManager().findCachedViewProvider(virtualFile) != null; }); }