void start(@NotNull TemplateImpl template,
             @Nullable PairProcessor<? super String, ? super String> processor,
             @Nullable Map<String, String> predefinedVarValues, int startCaretOffset) {
    LOG.assertTrue(!myStarted, "Already started");
    myStarted = true;

    PsiFile file = getPsiFile();
    setTemplate(template);
    myProcessor = processor;

    if (requiresWriteAction()) {
      myLiveTemplateProcessor.registerUndoableAction(this, myProject, getDocument());
    }

    myTemplateIndented = false;
    myCurrentVariableNumber = -1;
    setSegments(new TemplateSegments(getDocument()));
    myPrevTemplate = getTemplate();

    setPredefinedVariableValues(predefinedVarValues);

    if (getTemplate().isInline()) {
      int caretOffset = getCurrentCaretOffset(startCaretOffset);
      myTemplateRange = getDocument().createRangeMarker(caretOffset, caretOffset + getTemplate().getTemplateText().length());
    }
    else {
      preprocessTemplate(file, getCurrentCaretOffset(startCaretOffset), getTemplate().getTemplateText());
      int caretOffset = getCurrentCaretOffset(startCaretOffset);
      myTemplateRange = getDocument().createRangeMarker(caretOffset, caretOffset);
    }
    myTemplateRange.setGreedyToLeft(true);
    myTemplateRange.setGreedyToRight(true);

    myLiveTemplateProcessor.logTemplate(myProject, template, file.getLanguage());

    processAllExpressions(getTemplate());
  }
void start(@NotNull TemplateImpl template,
             @Nullable PairProcessor<? super String, ? super String> processor,
             @Nullable Map<String, String> predefinedVarValues, int startCaretOffset)