[ruby/prism] Follow RuboCop's parser engine support
With the introduction of Prism::Translation::Parser to RuboCop (RuboCop AST), the number of arguments for RuboCop::AST::ProcessedSource#parser_class internal API will be changed: https://github.com/rubocop/rubocop-ast/pull/277
Prism::Translation::Parser
RuboCop::AST::ProcessedSource#parser_class
As a result, the following error will occur starting from the next release of RuboCop AST (< 1.30.0) :
$ bundle exec ruby -rrubocop/ast -rprism -rprism/translation/parser/rubocop -ve \ "p RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast" ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22] /Users/koic/src/github.com/ruby/prism/lib/prism/translation/parser/rubocop.rb:25:in `parser_class': wrong number of arguments (given 2, expected 1) (ArgumentError) from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:309:in `create_parser' from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:219:in `parse' from /Users/koic/src/github.com/rubocop/rubocop-ast/lib/rubocop/ast/processed_source.rb:47:in `initialize' from -e:1:in `new' from -e:1:in `<main>'
This PR prevents the above error by updating the monkey patch to support the new argument:
$ bundle exec ruby -rrubocop/ast -rprism -rprism/translation/parser/rubocop -ve \ "p RuboCop::AST::ProcessedSource.new('42', 80_82_73_83_77.33).ast" ruby 3.3.0 (2023-12-25 revision https://github.com/ruby/prism/commit/5124f9ac75) [x86_64-darwin22] s(:int, 42)
Moreover, to ensure compatibility with the existing RuboCop AST, conditional logic has been implemented to maintain backward compatibility.
https://github.com/ruby/prism/commit/8a6909f4d5
[ruby/prism] Follow RuboCop's parser engine support
With the introduction of
Prism::Translation::Parser
to RuboCop (RuboCop AST),the number of arguments for
RuboCop::AST::ProcessedSource#parser_class
internal API will be changed:https://github.com/rubocop/rubocop-ast/pull/277
Before¶
As a result, the following error will occur starting from the next release of RuboCop AST (< 1.30.0) :
After¶
This PR prevents the above error by updating the monkey patch to support the new argument:
Moreover, to ensure compatibility with the existing RuboCop AST, conditional logic
has been implemented to maintain backward compatibility.
https://github.com/ruby/prism/commit/8a6909f4d5