PsiFile (@NotNull PsiElement element) { PsiFile containingFile = element.getContainingFile(); if (containingFile == null) return null; if (containingFile.getViewProvider() instanceof InjectedFileViewProvider) { PsiElement host = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile); if (host != null) containingFile = host.getContainingFile(); } return containingFile; }