Skip to content

Commit adaf501

Browse files
BuonOmorafiss
authored andcommitted
chore: switch from parser to prism
Parser is being softly deprecated. See whitequark/parser#1046
1 parent 93f0a4c commit adaf501

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ group :development, :test do
6060

6161
# Gems used for tests meta-programming.
6262
gem "parser"
63+
gem "prism" # Parser is being softly deprecated, but Prism doesn't have rewriting capabilities
6364

6465
# Gems used by the ActiveRecord test suite
6566
gem "bcrypt", "~> 3.1"

test/support/copy_cat.rb

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# frozen_string_literal: true
22

3-
require "parser/current"
3+
require "parser"
4+
require "prism"
45

56
module CopyCat
67
module NoWarnRewrite
@@ -23,13 +24,13 @@ def warn(message, category: nil, **kwargs)
2324
def copy_methods(new_klass, old_klass, *methods, debug: false, &block)
2425
methods.each do |met|
2526
file, _ = old_klass.instance_method(met).source_location
26-
ast = find_method(Parser::CurrentRuby.parse_file(file), met)
27+
ast = find_method(Prism::Translation::Parser.parse_file(file), met)
2728
code =
2829
if block_given?
2930
source = ast.location.expression.source
3031
buffer = Parser::Source::Buffer.new(met, source: source)
3132
# We need to recompute the ast to have correct locations.
32-
ast = Parser::CurrentRuby.parse(source)
33+
ast = Prism::Translation::Parser.parse(source)
3334

3435
if debug
3536
puts "=" * 80

0 commit comments

Comments
 (0)