From f4a2923714f177e04187a7898951218aa43ecc5b Mon Sep 17 00:00:00 2001 From: Alexandr Evstigneev Date: Thu, 13 Oct 2016 11:22:29 +0300 Subject: [PATCH] livetemplate lookup refactoring: extracted template starting code to the static method to be able to re-use it --- .../template/impl/LiveTemplateLookupElementImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElementImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElementImpl.java index 2ddf92cfe1ff..783459f8893c 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElementImpl.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElementImpl.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.template.impl; import com.intellij.codeInsight.completion.InsertionContext; +import com.intellij.codeInsight.template.Template; import com.intellij.codeInsight.template.TemplateManager; import com.intellij.openapi.util.text.StringUtil; import org.jetbrains.annotations.NotNull; @@ -46,8 +47,12 @@ public class LiveTemplateLookupElementImpl extends LiveTemplateLookupElement { @Override public void handleInsert(InsertionContext context) { + startTemplate(context, myTemplate); + } + + public static void startTemplate(InsertionContext context, @NotNull Template template) { context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset()); context.setAddCompletionChar(false); - TemplateManager.getInstance(context.getProject()).startTemplate(context.getEditor(), myTemplate); + TemplateManager.getInstance(context.getProject()).startTemplate(context.getEditor(), template); } }