TextRange (@NotNull Editor editor, @NotNull PsiFile psiFile) { int offset = TargetElementUtil.adjustOffset(psiFile, editor.getDocument(), editor.getCaretModel().getOffset()); PsiElement contextElement = psiFile.findElementAt(offset); if (contextElement == null) return EMPTY_RANGE; return EP.allForLanguage(contextElement.getLanguage()).stream() .map(handler -> handler.getCodeBlockRange(contextElement)) .filter(codeBlockRange -> !codeBlockRange.isEmpty()) .findFirst().orElse(EMPTY_RANGE); }