public static void runTemplate(Editor editor, TextRange textRange, List<String> stringList, TemplateImpl template) {
final Document document = editor.getDocument();
final RangeMarker range = document.createRangeMarker(textRange.getStartOffset(), textRange.getEndOffset());
setTemplateVariableValues(template, stringList);
WriteCommandAction writeCommandAction = new WriteCommandAction(editor.getProject()) {
@Override
protected void run(@NotNull Result result) throws Throwable {
document.deleteString(range.getStartOffset(), range.getEndOffset());
}
};
writeCommandAction.execute();
TemplateManager.getInstance(editor.getProject()).startTemplate(editor, "", template);
}