private void finishTemplate(boolean broken) {
    if (isDisposed()) return;
    Editor editor = getEditor();
    LookupManager instance = LookupManager.getInstance(myProject);
    if (instance != null) {
      instance.hideActiveLookup();
    }

    setFinalEditorState(broken);

    try {
      fireBeforeTemplateFinished(broken);
    }
    finally {
      try {
        cleanupTemplateState();
        if (editor != null) {
          TemplateManagerUtilBase.clearTemplateState(editor);
        }
        fireTemplateFinished(broken);
      }
      finally {
        Disposer.dispose(this);
      }
    }
  }
private void finishTemplate(boolean broken)