livetemplate lookup refactoring: extracted template starting code to the static metho... appcode/171.54 clion/171.55
authorAlexandr Evstigneev <Alexandr.Evstigneev@jetbrains.com>
Thu, 13 Oct 2016 08:22:29 +0000 (11:22 +0300)
committerAlexandr Evstigneev <Alexandr.Evstigneev@jetbrains.com>
Thu, 13 Oct 2016 08:24:57 +0000 (11:24 +0300)
platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElementImpl.java

index 2ddf92cfe1ff764c48c9b500e0c865d7ede68c31..783459f8893c922660d569f4c19bb1a25e8b3b90 100644 (file)
@@ -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);
   }
 }