DocumentWindow (@NotNull PsiElement element) { PsiFile file = element.getContainingFile(); if (file == null) { return null; } Document document = PsiDocumentManager.getInstance(file.getProject()).getCachedDocument(file); return document instanceof DocumentWindow ? (DocumentWindow)document : null; }