From 4377a64340d340e6a0d73c060517d8fb81b6196f Mon Sep 17 00:00:00 2001 From: Koichi ITO Date: Thu, 25 Jun 2020 20:12:32 +0900 Subject: [PATCH] Support `Parser::Ruby28` Parser gem has been started development for Ruby 2.8 (edge Ruby). https://github.com/whitequark/parser/pull/677 This PR supports `Parser::Ruby28`, the early adapters will be able to try edge Ruby with RuboCop. I will open a PR later to new Ruby 2.8 (3.0) syntax supported by Parser. --- CHANGELOG.md | 1 + lib/rubocop/ast/processed_source.rb | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7fa72123..3ef4ad28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ * [#31](https://github.com/rubocop-hq/rubocop-ast/pull/31): NodePattern now uses `param === node` to match params, which allows Regexp, Proc, Set in addition to Nodes and literals. ([@marcandre][]) * [#41](https://github.com/rubocop-hq/rubocop-ast/pull/41): Add `delimiters` and related predicates for `RegexpNode`. ([@owst][]) * [#46](https://github.com/rubocop-hq/rubocop-ast/pull/46): Basic support for [non-legacy AST output from parser](https://github.com/whitequark/parser/#usage). Note that there is no support (yet) in main RuboCop gem. ([@marcandre][]) +* [#48](https://github.com/rubocop-hq/rubocop-ast/pull/48): Support `Parser::Ruby28` for Ruby 2.8 (3.0) parser. ([@koic][]) ## 0.0.3 (2020-05-15) diff --git a/lib/rubocop/ast/processed_source.rb b/lib/rubocop/ast/processed_source.rb index cc58f2ed5..212ccd1c5 100644 --- a/lib/rubocop/ast/processed_source.rb +++ b/lib/rubocop/ast/processed_source.rb @@ -2,6 +2,7 @@ require 'digest/sha1' +# rubocop:disable Metrics/ClassLength module RuboCop module AST # ProcessedSource contains objects which are generated by Parser @@ -176,6 +177,9 @@ def parser_class(ruby_version) when 2.7 require 'parser/ruby27' Parser::Ruby27 + when 2.8 + require 'parser/ruby28' + Parser::Ruby28 else raise ArgumentError, "RuboCop found unknown Ruby version: #{ruby_version.inspect}" @@ -201,3 +205,4 @@ def create_parser(ruby_version) end end end +# rubocop:enable Metrics/ClassLength