boolean (@NotNull final DataContext dataContext) { PsiDirectory directory = adjustForRename(dataContext, PsiElementRenameHandler.getElement(dataContext)); if (directory != null) { final VirtualFile virtualFile = directory.getVirtualFile(); final Project project = directory.getProject(); if (Comparing.equal(project.getBaseDir(), virtualFile)) return false; if (ProjectRootManager.getInstance(project).getFileIndex().isInContent(virtualFile)) { return true; } } return false; }