PsiLanguageInjectionHost (@NotNull PsiElement injectedElement) { PsiFile file = injectedElement.getContainingFile(); VirtualFile virtualFile = file == null ? null : file.getVirtualFile(); if (virtualFile instanceof VirtualFileWindow) { // use utility method in case the file's overridden getContext() PsiElement host = FileContextUtil.getFileContext(file); if (host instanceof PsiLanguageInjectionHost) { return (PsiLanguageInjectionHost)host; } } return InjectedLanguageUtilBase.findInjectionHost(file); }