diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-02-28 15:48:17 -0500 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-02-29 16:29:16 +0000 |
| commit | cd8d1018bbca086427f66bdba646bb4f387c32b4 (patch) | |
| tree | b0a417da0ef4a00f73edbaed99a9ef36ba61e2b0 /prism | |
| parent | 5891c70b3839238433a47aa7c9b984a630b4b0db (diff) | |
[ruby/prism] Resync RBI and test it in CI
https://github.com/ruby/prism/commit/4ef4032774
Diffstat (limited to 'prism')
| -rw-r--r-- | prism/extension.c | 7 | ||||
| -rw-r--r-- | prism/templates/lib/prism/serialize.rb.erb | 1 | ||||
| -rwxr-xr-x | prism/templates/template.rb | 59 |
3 files changed, 42 insertions, 25 deletions
diff --git a/prism/extension.c b/prism/extension.c index 7bcb5f65c1..ed56a6c513 100644 --- a/prism/extension.c +++ b/prism/extension.c @@ -1254,13 +1254,6 @@ Init_prism(void) { */ rb_define_const(rb_cPrism, "VERSION", rb_str_new2(EXPECTED_PRISM_VERSION)); - /** - * The backend of the parser that prism is using to parse Ruby code. This - * can be either :CEXT or :FFI. On runtimes that support C extensions, we - * default to :CEXT. Otherwise we use :FFI. - */ - rb_define_const(rb_cPrism, "BACKEND", ID2SYM(rb_intern("CEXT"))); - // First, the functions that have to do with lexing and parsing. rb_define_singleton_method(rb_cPrism, "dump", dump, -1); rb_define_singleton_method(rb_cPrism, "dump_file", dump_file, -1); diff --git a/prism/templates/lib/prism/serialize.rb.erb b/prism/templates/lib/prism/serialize.rb.erb index 1356496a5e..5e195d9bbc 100644 --- a/prism/templates/lib/prism/serialize.rb.erb +++ b/prism/templates/lib/prism/serialize.rb.erb @@ -91,7 +91,6 @@ module Prism case load_varuint when 0 then InlineComment.new(load_location) when 1 then EmbDocComment.new(load_location) - when 2 then DATAComment.new(load_location) end end end diff --git a/prism/templates/template.rb b/prism/templates/template.rb index fd55d5228b..a6da307e04 100755 --- a/prism/templates/template.rb +++ b/prism/templates/template.rb @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# typed: false require "erb" require "fileutils" @@ -28,7 +29,7 @@ module Prism end # A comment attached to a field or node. - class Comment + class ConfigComment attr_reader :value def initialize(value) @@ -40,7 +41,7 @@ module Prism end def each_java_line(&block) - Comment.new(JavaDoc.escape(value)).each_line(&block) + ConfigComment.new(JavaDoc.escape(value)).each_line(&block) end end @@ -56,11 +57,11 @@ module Prism end def each_comment_line(&block) - Comment.new(comment).each_line(&block) if comment + ConfigComment.new(comment).each_line(&block) if comment end def each_comment_java_line(&block) - Comment.new(comment).each_java_line(&block) if comment + ConfigComment.new(comment).each_java_line(&block) if comment end def semantic_field? @@ -122,7 +123,13 @@ module Prism end def rbi_class - "Prism::#{ruby_type}" + if specific_kind + "Prism::#{specific_kind}" + elsif union_kind + "T.any(#{union_kind.map { |kind| "Prism::#{kind}" }.join(", ")})" + else + "Prism::Node" + end end def check_field_kind @@ -148,7 +155,13 @@ module Prism end def rbi_class - "T.nilable(Prism::#{ruby_type})" + if specific_kind + "T.nilable(Prism::#{specific_kind})" + elsif union_kind + "T.nilable(T.any(#{union_kind.map { |kind| "Prism::#{kind}" }.join(", ")}))" + else + "T.nilable(Prism::Node)" + end end def check_field_kind @@ -174,7 +187,13 @@ module Prism end def rbi_class - "T::Array[Prism::#{ruby_type}]" + if specific_kind + "T::Array[Prism::#{specific_kind}]" + elsif union_kind + "T::Array[T.any(#{union_kind.map { |kind| "Prism::#{kind}" }.join(", ")})]" + else + "T::Array[Prism::Node]" + end end def java_type @@ -406,11 +425,11 @@ module Prism end def each_comment_line(&block) - Comment.new(comment).each_line(&block) + ConfigComment.new(comment).each_line(&block) end def each_comment_java_line(&block) - Comment.new(comment).each_java_line(&block) + ConfigComment.new(comment).each_java_line(&block) end def semantic_fields @@ -494,6 +513,7 @@ module Prism when ".rb" <<~HEADING # frozen_string_literal: true + =begin This file is generated by the templates/template.rb script and should not be modified manually. See #{filepath} @@ -509,13 +529,16 @@ module Prism HEADING when ".rbi" - <<~HEADING - =begin - This file is generated by the templates/template.rb script and should not be - modified manually. See #{filepath} - if you are looking to modify the template - =end - HEADING + <<~HEADING + # typed: strict + + =begin + This file is generated by the templates/template.rb script and should not be + modified manually. See #{filepath} + if you are looking to modify the template + =end + + HEADING else <<~HEADING /******************************************************************************/ @@ -525,6 +548,7 @@ module Prism /* if you are looking to modify the */ /* template */ /******************************************************************************/ + HEADING end @@ -598,7 +622,8 @@ module Prism "src/prettyprint.c", "src/serialize.c", "src/token_type.c", - "rbi/prism.rbi", + "rbi/prism/node.rbi", + "rbi/prism/visitor.rbi", "sig/prism.rbs", "sig/prism/dsl.rbs", "sig/prism/mutation_compiler.rbs", |
