From 4d83713e240fc2253cff4c9b7773565eb04281df Mon Sep 17 00:00:00 2001 From: Markus Schirp Date: Fri, 20 Sep 2024 21:26:21 +0000 Subject: [PATCH] Upgrade to unparser 0.7.x interface --- Gemfile | 2 ++ Gemfile.lock | 13 +++++++++---- lib/mutant/parser.rb | 6 +++--- mutant.gemspec | 2 +- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Gemfile b/Gemfile index 00ec4f4e9..6a66a43e4 100644 --- a/Gemfile +++ b/Gemfile @@ -4,4 +4,6 @@ source 'https://rubygems.org' gemspec name: 'mutant' +gem 'unparser', path: '../unparser' + eval_gemfile 'Gemfile.shared' diff --git a/Gemfile.lock b/Gemfile.lock index b75ba2413..453d3eb3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,10 @@ +PATH + remote: ../unparser + specs: + unparser (0.7.0) + diff-lcs (~> 1.3) + parser (>= 3.3.0) + PATH remote: . specs: @@ -6,7 +13,7 @@ PATH parser (~> 3.3.0) regexp_parser (~> 2.9.0) sorbet-runtime (~> 0.5.0) - unparser (~> 0.6.14) + unparser (~> 0.7.0) GEM remote: https://rubygems.org/ @@ -57,9 +64,6 @@ GEM sorbet-runtime (0.5.11422) strscan (3.1.0) unicode-display_width (2.5.0) - unparser (0.6.14) - diff-lcs (~> 1.3) - parser (>= 3.3.0) PLATFORMS ruby @@ -70,6 +74,7 @@ DEPENDENCIES rspec-core (~> 3.10) rspec-its (~> 1.3.0) rubocop (~> 1.7) + unparser! BUNDLED WITH 2.5.6 diff --git a/lib/mutant/parser.rb b/lib/mutant/parser.rb index 0f2e8b623..d46a1275a 100644 --- a/lib/mutant/parser.rb +++ b/lib/mutant/parser.rb @@ -24,11 +24,11 @@ def call(path) private def parse(source) - node, comments = Unparser.parse_with_comments(source) + ast = Unparser.parse_ast_either(source).from_right AST.new( - node:, - comment_associations: ::Parser::Source::Comment.associate_by_identity(node, comments) + comment_associations: ::Parser::Source::Comment.associate_by_identity(ast.node, ast.comments), + node: ast.node ) end diff --git a/mutant.gemspec b/mutant.gemspec index 1a747c9b4..0016a0da2 100644 --- a/mutant.gemspec +++ b/mutant.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency('parser', '~> 3.3.0') gem.add_runtime_dependency('regexp_parser', '~> 2.9.0') gem.add_runtime_dependency('sorbet-runtime', '~> 0.5.0') - gem.add_runtime_dependency('unparser', '~> 0.6.14') + gem.add_runtime_dependency('unparser', '~> 0.7.0') gem.add_development_dependency('rspec', '~> 3.10') gem.add_development_dependency('rspec-core', '~> 3.10')