diff --git a/include/rbs/ast.h b/include/rbs/ast.h index 53bc3fb95..feddcaf0a 100644 --- a/include/rbs/ast.h +++ b/include/rbs/ast.h @@ -941,12 +941,20 @@ typedef struct rbs_types_variable { typedef union rbs_ast_ruby_annotations { rbs_node_t base; + rbs_ast_ruby_annotations_block_param_type_annotation_t block_param_type_annotation; + rbs_ast_ruby_annotations_class_alias_annotation_t class_alias_annotation; rbs_ast_ruby_annotations_colon_method_type_annotation_t colon_method_type_annotation; + rbs_ast_ruby_annotations_double_splat_param_type_annotation_t double_splat_param_type_annotation; + rbs_ast_ruby_annotations_instance_variable_annotation_t instance_variable_annotation; rbs_ast_ruby_annotations_method_types_annotation_t method_types_annotation; + rbs_ast_ruby_annotations_module_alias_annotation_t module_alias_annotation; + rbs_ast_ruby_annotations_module_self_annotation_t module_self_annotation; rbs_ast_ruby_annotations_node_type_assertion_t node_type_assertion; + rbs_ast_ruby_annotations_param_type_annotation_t param_type_annotation; rbs_ast_ruby_annotations_return_type_annotation_t return_type_annotation; rbs_ast_ruby_annotations_skip_annotation_t skip_annotation; - rbs_ast_ruby_annotations_param_type_annotation_t param_type_annotation; + rbs_ast_ruby_annotations_splat_param_type_annotation_t splat_param_type_annotation; + rbs_ast_ruby_annotations_type_application_annotation_t type_application_annotation; } rbs_ast_ruby_annotations_t; /// `rbs_ast_symbol_t` models user-defined identifiers like class names, method names, etc. diff --git a/rust/ruby-rbs-sys/build.rs b/rust/ruby-rbs-sys/build.rs index 3b72bea6d..c4ff9d13c 100644 --- a/rust/ruby-rbs-sys/build.rs +++ b/rust/ruby-rbs-sys/build.rs @@ -103,19 +103,10 @@ fn generate_bindings(include_path: &Path) -> Result { <%- end -%> typedef union rbs_ast_ruby_annotations { rbs_node_t base; - rbs_ast_ruby_annotations_colon_method_type_annotation_t colon_method_type_annotation; - rbs_ast_ruby_annotations_method_types_annotation_t method_types_annotation; - rbs_ast_ruby_annotations_node_type_assertion_t node_type_assertion; - rbs_ast_ruby_annotations_return_type_annotation_t return_type_annotation; - rbs_ast_ruby_annotations_skip_annotation_t skip_annotation; - rbs_ast_ruby_annotations_param_type_annotation_t param_type_annotation; +<%- annotation_nodes.each do |node| -%> + <%= node.c_type_name %> <%= node.c_name.delete_prefix("rbs_ast_ruby_annotations_") %>; +<%- end -%> } rbs_ast_ruby_annotations_t; /// `rbs_ast_symbol_t` models user-defined identifiers like class names, method names, etc. diff --git a/templates/template.rb b/templates/template.rb index c44370366..b581ddbd7 100644 --- a/templates/template.rb +++ b/templates/template.rb @@ -385,9 +385,16 @@ def locals Node.new(node, fields, locations, constructor_params) end + sorted_nodes = nodes.sort_by { _1.descr.ruby_full_name } + + annotation_nodes = sorted_nodes + .select { _1.descr.ruby_full_name.start_with?("RBS::AST::Ruby::Annotations::") } + .sort_by(&:c_name) + { - nodes: nodes.sort_by { _1.descr.ruby_full_name }, - enums: enum_desc + nodes: sorted_nodes, + enums: enum_desc, + annotation_nodes: annotation_nodes, } end end