void () { if (isFinished()) { return; } if (getTemplate() == null) { LOG.error("Template disposed: " + myPrevTemplate); return; } //some psi operations may block the document, unblock here unblockDocument(); myDocumentChangesTerminateTemplate = false; final int oldVar = myCurrentVariableNumber; int nextVariableNumber = getNextVariableNumber(oldVar); if (nextVariableNumber == -1) { calcResults(false); ApplicationManager.getApplication().runWriteAction(() -> reformat()); finishTemplate(false); return; } focusCurrentHighlighter(false); calcResults(false); doReformat(); setCurrentVariableNumber(nextVariableNumber); focusCurrentExpression(); fireCurrentVariableChanged(oldVar); }