Language (PsiFile psiFile, int mostProbablyCorrectLanguageOffset, int end) { final PsiElement elt = psiFile.findElementAt(mostProbablyCorrectLanguageOffset); if (elt == null) return psiFile.getLanguage(); if (elt instanceof PsiWhiteSpace) { final int incremented = elt.getTextRange().getEndOffset() + 1; if (incremented <= end) { return getLanguageAtOffset(psiFile, incremented, end); } } return PsiUtilCore.findLanguageFromElement(elt); }