Merge branch 'set-original' of https://github.com/dzharkov/intellij-community
[idea/community.git] / platform / lang-impl / src / com / intellij / codeInsight / template / postfix / templates / PostfixLiveTemplate.java
index 08ba6c04aa0bc91de62d66a2d8d67ed5283a6545..a4c108495182e361281f696ae5990dad4a5e0756 100644 (file)
@@ -221,9 +221,7 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
   private static void expandTemplate(@NotNull final PostfixTemplate template,
                                      @NotNull final Editor editor,
                                      @NotNull final PsiElement context) {
-    ApplicationManager.getApplication().runWriteAction(() -> {
-      CommandProcessor.getInstance().executeCommand(context.getProject(), () -> template.expand(context, editor), "Expand postfix template", POSTFIX_TEMPLATE_ID);
-    });
+    ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(context.getProject(), () -> template.expand(context, editor), "Expand postfix template", POSTFIX_TEMPLATE_ID));
   }
 
 
@@ -232,14 +230,12 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
 
     final int currentOffset = editor.getCaretModel().getOffset();
     final int newOffset = currentOffset - key.length();
-    ApplicationManager.getApplication().runWriteAction(() -> {
-      CommandProcessor.getInstance().runUndoTransparentAction(() -> {
-        Document document = editor.getDocument();
-        document.deleteString(newOffset, currentOffset);
-        editor.getCaretModel().moveToOffset(newOffset);
-        PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
-      });
-    });
+    ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().runUndoTransparentAction(() -> {
+      Document document = editor.getDocument();
+      document.deleteString(newOffset, currentOffset);
+      editor.getCaretModel().moveToOffset(newOffset);
+      PsiDocumentManager.getInstance(file.getProject()).commitDocument(document);
+    }));
     return newOffset;
   }
 
@@ -267,12 +263,7 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
 
     final PsiElement context = CustomTemplateCallback.getContext(copyFile, positiveOffset(newOffset));
     final Document finalCopyDocument = copyDocument;
-    return new Condition<PostfixTemplate>() {
-      @Override
-      public boolean value(PostfixTemplate template) {
-        return template != null && template.isEnabled(provider) && template.isApplicable(context, finalCopyDocument, newOffset);
-      }
-    };
+    return template -> template != null && template.isEnabled(provider) && template.isApplicable(context, finalCopyDocument, newOffset);
   }
 
   @NotNull