Module fold

Source
Expand description

Transformation of an owned AST.

Each method of the Fold trait is a hook that can be overridden to customize the behavior when transforming the corresponding type of node. By default, every method recursively transforms the substructure of the input by invoking the right folder method on each of its fields.

pub trait Fold<T: AstInfo, T2: AstInfo> {
    /* ... */

    fn fold_function(&mut self, node: Function<T>) -> Function<T2> {
        fold_function(self, node)
    }

    /* ... */
}

pub fn fold_function<F, T: AstInfo, T2: AstInfo>(folder: &mut F, node: Function<T>) -> Function<T2>
where
    F: Fold<T, T2> + ?Sized,
{
    Function {
        name: folder.fold_item_name(node.name),
        args: folder.fold_function_args(node.args),
        filter: node.filter.map(|filter| Box::new(folder.fold_expr(*filter))),
        over: node.over.map(|over| folder.fold_window_spec(over)),
        distinct: node.distinct,
   }
}

Of particular note to the fold transformation is its handling of the AST’s generic parameter. The Fold trait is defined so that references to T in the input are replaced by references to T2 in the output. If transformation of T is not required, implement Fold such that T and T2 refer to the same concrete type, and then provide trivial implementations of any methods that fold T’s associated types.

The FoldNode trait is implemented for every node in the AST and can be used to write generic functions that apply a Fold implementation to any node in the AST.

§Implementation notes

This module is automatically generated by the crate’s build script. Changes to the AST will be automatically propagated to the fold transformation.

This approach to AST transformations is inspired by the syn crate. These module docs are directly derived from the syn::fold module docs.

Traits§

Fold
FoldNode

Functions§

fold_abbreviated_grant_or_revoke_statement
fold_abbreviated_grant_statement
fold_abbreviated_revoke_statement
fold_alter_cluster_action
fold_alter_cluster_statement
fold_alter_connection_action
fold_alter_connection_option
fold_alter_connection_option_name
fold_alter_connection_statement
fold_alter_default_privileges_statement
fold_alter_index_action
fold_alter_index_statement
fold_alter_network_policy_statement
fold_alter_object_rename_statement
fold_alter_object_swap_statement
fold_alter_owner_statement
fold_alter_retain_history_statement
fold_alter_role_option
fold_alter_role_statement
fold_alter_secret_statement
fold_alter_set_cluster_statement
fold_alter_sink_action
fold_alter_sink_statement
fold_alter_source_action
fold_alter_source_add_subsource_option
fold_alter_source_add_subsource_option_name
fold_alter_source_statement
fold_alter_system_reset_all_statement
fold_alter_system_reset_statement
fold_alter_system_set_statement
fold_alter_table_add_column_statement
fold_as_of
fold_assignment
fold_avro_doc_on
fold_avro_schema
fold_avro_schema_option
fold_avro_schema_option_name
fold_catalog_name
fold_close_statement
fold_cluster_alter_option
fold_cluster_alter_option_name
fold_cluster_alter_option_value
fold_cluster_alter_until_ready_option
fold_cluster_alter_until_ready_option_name
fold_cluster_feature
fold_cluster_feature_name
fold_cluster_option
fold_cluster_option_name
fold_cluster_schedule_option_value
fold_column_def
fold_column_name
fold_column_option
fold_column_option_def
fold_column_versioned
fold_comment_object_type
fold_comment_statement
fold_commit_statement
fold_connection_default_aws_privatelink
fold_connection_option
fold_connection_option_name
fold_continual_task_option
fold_continual_task_option_name
fold_continual_task_stmt
fold_copy_direction
fold_copy_option
fold_copy_option_name
fold_copy_relation
fold_copy_statement
fold_copy_target
fold_create_cluster_replica_statement
fold_create_cluster_statement
fold_create_connection_option
fold_create_connection_option_name
fold_create_connection_statement
fold_create_connection_type
fold_create_continual_task_statement
fold_create_continual_task_sugar
fold_create_database_statement
fold_create_index_statement
fold_create_materialized_view_statement
fold_create_network_policy_statement
fold_create_role_statement
fold_create_schema_statement
fold_create_secret_statement
fold_create_sink_connection
fold_create_sink_option
fold_create_sink_option_name
fold_create_sink_statement
fold_create_source_connection
fold_create_source_option
fold_create_source_option_name
fold_create_source_statement
fold_create_subsource_option
fold_create_subsource_option_name
fold_create_subsource_statement
fold_create_table_from_source_statement
fold_create_table_statement
fold_create_type_as
fold_create_type_list_option
fold_create_type_list_option_name
fold_create_type_map_option
fold_create_type_map_option_name
fold_create_type_statement
fold_create_view_statement
fold_create_webhook_source_body
fold_create_webhook_source_check
fold_create_webhook_source_check_options
fold_create_webhook_source_filter_header
fold_create_webhook_source_header
fold_create_webhook_source_include_headers
fold_create_webhook_source_map_header
fold_create_webhook_source_secret
fold_create_webhook_source_statement
fold_csr_config_option
fold_csr_config_option_name
fold_csr_connection
fold_csr_connection_avro
fold_csr_connection_protobuf
fold_csr_seed_avro
fold_csr_seed_protobuf
fold_csr_seed_protobuf_schema
fold_csv_columns
fold_cte
fold_cte_block
fold_cte_mut_rec
fold_cte_mut_rec_column_def
fold_date_time_field
fold_deallocate_statement
fold_declare_statement
fold_deferred_item_name
fold_delete_statement
fold_discard_statement
fold_discard_target
fold_distinct
fold_doc_on_identifier
fold_doc_on_schema
fold_drop_objects_statement
fold_drop_owned_statement
fold_execute_statement
fold_explain_format
fold_explain_plan_option
fold_explain_plan_option_name
fold_explain_plan_statement
fold_explain_pushdown_statement
fold_explain_sink_schema_for
fold_explain_sink_schema_statement
fold_explain_stage
fold_explain_timestamp_statement
fold_explainee
fold_expr
fold_external_reference_export
fold_external_references
fold_fetch_direction
fold_fetch_option
fold_fetch_option_name
fold_fetch_statement
fold_format
fold_format_specifier
fold_function
fold_function_args
fold_grant_privileges_statement
fold_grant_role_statement
fold_grant_target_all_specification
fold_grant_target_specification
fold_grant_target_specification_inner
fold_homogenizing_function
fold_ident
fold_ident_error
fold_if_exists_behavior
fold_index_option
fold_index_option_name
fold_insert_source
fold_insert_statement
fold_inspect_shard_statement
fold_interval_value
fold_is_expr_construct
fold_join
fold_join_constraint
fold_join_operator
fold_kafka_broker
fold_kafka_broker_aws_privatelink
fold_kafka_broker_aws_privatelink_option
fold_kafka_broker_aws_privatelink_option_name
fold_kafka_broker_tunnel
fold_kafka_sink_config_option
fold_kafka_sink_config_option_name
fold_kafka_sink_key
fold_kafka_source_config_option
fold_kafka_source_config_option_name
fold_key_constraint
fold_limit
fold_load_generator
fold_load_generator_option
fold_load_generator_option_name
fold_map_entry
fold_materialized_view_option
fold_materialized_view_option_name
fold_mut_rec_block
fold_mut_rec_block_option
fold_mut_rec_block_option_name
fold_my_sql_config_option
fold_my_sql_config_option_name
fold_named_plan
fold_network_policy_option
fold_network_policy_option_name
fold_network_policy_rule_definition
fold_network_policy_rule_option
fold_network_policy_rule_option_name
fold_notice_severity
fold_object_type
fold_op
fold_order_by_expr
fold_pg_config_option
fold_pg_config_option_name
fold_prepare_statement
fold_privilege
fold_privilege_specification
fold_protobuf_schema
fold_qualified_replica
fold_query
fold_raise_statement
fold_reader_schema_selection_strategy
fold_reassign_owned_statement
fold_refresh_at_option_value
fold_refresh_every_option_value
fold_refresh_option_value
fold_replica_definition
fold_replica_option
fold_replica_option_name
fold_reset_variable_statement
fold_revoke_privileges_statement
fold_revoke_role_statement
fold_role_attribute
fold_rollback_statement
fold_schema
fold_select
fold_select_item
fold_select_option
fold_select_option_name
fold_select_statement
fold_set_expr
fold_set_operator
fold_set_role_var
fold_set_transaction_statement
fold_set_variable_statement
fold_set_variable_to
fold_set_variable_value
fold_show_columns_statement
fold_show_create_cluster_statement
fold_show_create_connection_statement
fold_show_create_index_statement
fold_show_create_materialized_view_statement
fold_show_create_sink_statement
fold_show_create_source_statement
fold_show_create_table_statement
fold_show_create_view_statement
fold_show_object_type
fold_show_objects_statement
fold_show_statement
fold_show_statement_filter
fold_show_variable_statement
fold_sink_envelope
fold_source_envelope
fold_source_error_policy
fold_source_include_metadata
fold_sql_server_config_option
fold_sql_server_config_option_name
fold_start_transaction_statement
fold_statement
fold_subscribe_option
fold_subscribe_option_name
fold_subscribe_output
fold_subscribe_relation
fold_subscribe_statement
fold_subscript_position
fold_system_object_type
fold_table_alias
fold_table_constraint
fold_table_factor
fold_table_from_source_columns
fold_table_from_source_option
fold_table_from_source_option_name
fold_table_option
fold_table_option_name
fold_table_with_joins
fold_target_role_specification
fold_transaction_access_mode
fold_transaction_isolation_level
fold_transaction_mode
fold_unresolved_database_name
fold_unresolved_item_name
fold_unresolved_object_name
fold_unresolved_schema_name
fold_update_statement
fold_validate_connection_statement
fold_value
fold_value_error
fold_values
fold_version
fold_view_definition
fold_window_frame
fold_window_frame_bound
fold_window_frame_units
fold_window_spec
fold_with_option_value