TextRange (@NotNull PsiFile file, @NotNull PsiElement element) { InjectedLanguageManager injectedManager = InjectedLanguageManager.getInstance(file.getProject()); Pair<PsiElement, TextRange> pair = getNameIdentifierRangeInCurrentRoot(file, element); if (pair == null) return null; return injectedManager.injectedToHost(pair.getFirst(), pair.getSecond()); }