Postfix cleanup phpstorm/138.167
authorAlexander Zolotov <Alexander.Zolotov@jetbrains.com>
Tue, 13 May 2014 09:45:46 +0000 (13:45 +0400)
committerAlexander Zolotov <Alexander.Zolotov@jetbrains.com>
Tue, 13 May 2014 09:48:37 +0000 (13:48 +0400)
platform/lang-impl/src/com/intellij/codeInsight/template/postfix/completion/PostfixTemplatesCompletionProvider.java

index 176e22df131f2ac5d76a564fb54c1b6c41076d8f..ee05406fbe6e981e91214afd76f31a25ded46126 100644 (file)
@@ -23,7 +23,9 @@ import com.intellij.codeInsight.template.CustomTemplateCallback;
 import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor;
 import com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings;
 import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate;
 import com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor;
 import com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings;
 import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate;
+import com.intellij.openapi.editor.Editor;
 import com.intellij.patterns.StandardPatterns;
 import com.intellij.patterns.StandardPatterns;
+import com.intellij.psi.PsiFile;
 import com.intellij.util.ProcessingContext;
 import org.jetbrains.annotations.NotNull;
 
 import com.intellij.util.ProcessingContext;
 import org.jetbrains.annotations.NotNull;
 
@@ -32,23 +34,24 @@ import static com.intellij.codeInsight.template.postfix.completion.PostfixTempla
 class PostfixTemplatesCompletionProvider extends CompletionProvider<CompletionParameters> {
   @Override
   protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
 class PostfixTemplatesCompletionProvider extends CompletionProvider<CompletionParameters> {
   @Override
   protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
+    Editor editor = parameters.getEditor();
     if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
     if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
-        parameters.getEditor().getCaretModel().getCaretCount() != 1) {
+        editor.getCaretModel().getCaretCount() != 1) {
       /**
        * disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
        */
       return;
     }
 
       /**
        * disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
        */
       return;
     }
 
-    PostfixLiveTemplate postfixLiveTemplate = getPostfixLiveTemplate(parameters.getOriginalFile(), parameters.getEditor());
+    PsiFile originalFile = parameters.getOriginalFile();
+    PostfixLiveTemplate postfixLiveTemplate = getPostfixLiveTemplate(originalFile, editor);
     if (postfixLiveTemplate != null) {
       postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
     if (postfixLiveTemplate != null) {
       postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
-      String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(
-        new CustomTemplateCallback(parameters.getEditor(), parameters.getOriginalFile()));
+      String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(new CustomTemplateCallback(editor, originalFile));
       if (possibleKey != null) {
         result = result.withPrefixMatcher(possibleKey);
         result.restartCompletionOnPrefixChange(
       if (possibleKey != null) {
         result = result.withPrefixMatcher(possibleKey);
         result.restartCompletionOnPrefixChange(
-          StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(parameters.getOriginalFile(), parameters.getOffset())));
+          StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(originalFile, parameters.getOffset())));
       }
     }
   }
       }
     }
   }