int (@NotNull PsiFile injectedFile, int injectedOffset) { if (injectedOffset < 0) return injectedOffset; var visitor = new PsiRecursiveElementWalkingVisitor() { int unescapedOffset = 0; int escapedOffset = 0; @Override public void visitElement(@NotNull PsiElement element) { String leafText = InjectedLanguageUtilBase.getUnescapedLeafText(element, false); if (leafText != null) { unescapedOffset += leafText.length(); escapedOffset += element.getTextLength(); if (escapedOffset >= injectedOffset) { unescapedOffset -= escapedOffset - injectedOffset; stopWalking(); } } super.visitElement(element); } }; injectedFile.accept(visitor); return visitor.unescapedOffset; }