boolean (Lookup lookup) { if (!lookup.isCompletion()) return false; PsiElement psiElement = lookup.getPsiElement(); PsiFile file = lookup.getPsiFile(); if (!(file instanceof XmlFile) && psiElement != null) { file = psiElement.getContainingFile(); } if (file instanceof XmlFile) { if (psiElement != null) { PsiElement elementToTest = psiElement; if (elementToTest instanceof PsiWhiteSpace) { elementToTest = elementToTest.getParent(); // JSPX has whitespace with language Java } final Language language = elementToTest.getLanguage(); if (!(language instanceof XMLLanguage)) { return false; } } return true; } return false; }