String (PsiFile context) { VirtualFile virtualFile = context.getVirtualFile(); while (virtualFile != null) { String contextUrl = virtualFile.getUrl(); String url = lastSelectedUrls.get(contextUrl); if (url != null) { return url; } virtualFile = virtualFile.getParent(); } if (lastSelectedFileUrl != null) { VirtualFile lastFile = VirtualFileManager.getInstance().findFileByUrl(lastSelectedFileUrl); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(context.getProject()).getFileIndex(); if (lastFile != null && ModuleUtilCore.findModuleForPsiElement(context) == fileIndex.getModuleForFile(lastFile)) { return lastSelectedFileUrl; } } return null; }