public TextRange getRangeInElement() {
    final PsiElement element = commandElement();
    if (element == null) {
      return TextRange.from(0, getTextLength());
    }

    return TextRange.from(element.getStartOffsetInParent(), element.getTextLength());
  }
  protected void updateTitle(@Nullable V variable, String value) {
    if (variable == null) return;

    final String variableText = variable.getText();
    final PsiElement identifier = variable.getNameIdentifier();
    if (identifier != null) {
      final int startOffsetInParent = identifier.getStartOffsetInParent();
      setPreviewText(
          variableText.substring(0, startOffsetInParent)
              + value
              + variableText.substring(startOffsetInParent + identifier.getTextLength()));
    } else {
      setPreviewText(variableText.replaceFirst(variable.getName(), value));
    }
    revalidate();
  }