String (@NotNull final DataContext dataContext) { final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return null; } VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext); if (file == null) { return null; } if (!file.isDirectory()) { file = file.getParent(); if (file == null) { return null; } } final VirtualFile sourceRoot = ProjectRootManager.getInstance(project).getFileIndex().getSourceRootForFile(file); if (sourceRoot == null) return null; return FileUtil.getRelativePath(getIOFile(sourceRoot), getIOFile(file)); }