VirtualFile (@NotNull PsiElement element) { if (element instanceof VirtualFile) { return (VirtualFile) element; } else if (element instanceof PsiFile) { return ((PsiFile) element).getVirtualFile(); } else if (element instanceof PsiDirectory) { return ((PsiDirectory) element).getVirtualFile(); } else if (element instanceof PsiNamedElement) { final String name = ((PsiNamedElement)element).getName(); VirtualFile virtualFile = SearchEverywhereClassifier.EP_Manager.getVirtualFile(element); if (virtualFile != null) { if (StringUtil.equals(name, virtualFile.getNameWithoutExtension())) { return virtualFile; } } } return null; }