private static boolean endsWithTemplate(@Nullable ASTNode astNode) {
    while (astNode != null) {
      if (astNode instanceof OuterLanguageElement) return true;
      astNode = astNode.getLastChildNode();
    }
    return false;
  }
private static boolean endsWithTemplate(@Nullable ASTNode astNode)