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));
}
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;
}
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