private String getExpressionString(int index) {
    CharSequence text = getDocument().getCharsSequence();

    if (!getSegments().isValid(index)) return "";

    int start = getSegments().getSegmentStart(index);
    int end = getSegments().getSegmentEnd(index);

    return text.subSequence(start, end).toString();
  }
private String getExpressionString(int index)