@Override
  public List<TextRange> select(@NotNull PsiElement e, @NotNull CharSequence editorText, final int cursorOffset, @NotNull Editor editor) {
    PsiElement host = PsiTreeUtil.getParentOfType(e, PsiLanguageInjectionHost.class);
    if (host == null) return Collections.emptyList();


    TextRange realRange = ElementManipulators.getValueTextRange(host)
      .shiftRight(host.getTextRange().getStartOffset());
    if (!realRange.contains(cursorOffset)) return Collections.emptyList();

    PsiElement valueElement = findValueElement(host, realRange);

    // Returning segments too early would cause selectWord to ignore Psi hierarchy
    TextRange elementRange = e.getTextRange();
    if (!valueElement.equals(e)
        && ContainerUtil.find(valueElement.getChildren(), el -> elementRange.contains(el.getTextRange())) == null) {
      return Collections.emptyList();
    }

    realRange = limitToCurrentLineAndStripWhiteSpace(editorText, cursorOffset, realRange);

    BitSet charEscapeLocations = isWithinLiteral(e, host)
                                 ? findCharEscapeLocations(editor, editorText, host.getTextRange(), realRange.getStartOffset())
                                 : new BitSet(0);

    BitSet compositeIndexes = createCompositeIndexesSet(valueElement, realRange.getStartOffset());
    List<TextRange> segments = buildSegments(editorText, cursorOffset, realRange, charEscapeLocations, compositeIndexes);
    if (!segments.isEmpty()) {
      int endOffsetAlignment = segments.get(segments.size() - 1).getEndOffset();
      for (ListIterator<TextRange> it = segments.listIterator(); it.hasNext(); ) {
        TextRange r = it.next();
        if (r.getEndOffset() > cursorOffset) continue;
        it.set(TextRange.create(r.getStartOffset(), endOffsetAlignment));
      }
      segments.add(realRange);
    }
    return segments;
  }
@Override
  public List<TextRange> select(@NotNull PsiElement e, @NotNull CharSequence editorText, final int cursorOffset, @NotNull Editor editor)