SelectInContext (OpenFileDescriptor descriptor) { VirtualFile file = descriptor.getFile(); Document document = !file.isValid() ? null : FileDocumentManager.getInstance().getDocument(file); if (document == null) return null; PsiFile psiFile = PsiDocumentManager.getInstance(descriptor.getProject()).getPsiFile(document); if (psiFile == null) return null; return new SmartSelectInContext(psiFile, psiFile, () -> { descriptor.navigate(false); FileEditor[] allEditors = FileEditorManager.getInstance(descriptor.getProject()).getAllEditors(descriptor.getFile()); return ArrayUtil.getFirstElement(allEditors); }); }