Object (@NotNull Object element) { if (element == myRootElement) { return null; } if (element == myRootPsiElement) { return myRootElement; } if (element instanceof PsiFile) { PsiLanguageInjectionHost host = InjectedLanguageManager.getInstance(((PsiFile)element).getProject()).getInjectionHost((PsiFile)element); if (host != null) { return new Inject(host, (PsiElement)element); } } if (element instanceof Inject) { return ((Inject)element).getParent(); } if (element instanceof PsiElement) { return ((PsiElement)element).getContext(); } return null; }