private static boolean isExpressionTemplate(List<PsiElement> elements) {
    if (elements.size() != 1) {
      return false;
    }
    final PsiElement element = elements.get(0);
    return element instanceof PsiExpression ||
           element instanceof PsiExpressionStatement && element.getLastChild() instanceof PsiErrorElement;
  }
private static boolean isExpressionTemplate(List<PsiElement> elements)