private int getCurrentSegmentNumber() {
    int varNumber = myCurrentVariableNumber;
    if (varNumber == -1) {
      return -1;
    }
    String variableName = getTemplate().getVariableNameAt(varNumber);
    int segmentNumber = getTemplate().getVariableSegmentNumber(variableName);
    if (segmentNumber < 0) {
      Throwable trace = getTemplate().getBuildingTemplateTrace();
      LOG.error("No segment for variable: var=" + varNumber + "; name=" + variableName + "; " + presentTemplate(getTemplate()) +
                "; offset: " + getEditor().getCaretModel().getOffset(), CoreAttachmentFactory.createAttachment(getDocument()),
                new Attachment("trace.txt", trace != null ? ExceptionUtil.getThrowableText(trace) : "<empty>"));
    }
    return segmentNumber;
  }
private int getCurrentSegmentNumber()