Skip to content

Commit

Permalink
Proof of concept: Use prism parser
Browse files Browse the repository at this point in the history
  • Loading branch information
exterm committed Feb 1, 2024
1 parent cc72e73 commit 3333cba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
7 changes: 2 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PATH
constant_resolver (>= 0.2.0)
parallel
parser
prism
sorbet-runtime (>= 0.5.9914)
zeitwerk (>= 2.6.1)

Expand Down Expand Up @@ -60,15 +61,11 @@ GEM
method_source (>= 0.6.7)
rake (>= 0.9.2.2)
method_source (1.0.0)
mini_portile2 (2.8.4)
minitest (5.16.2)
minitest-focus (1.3.1)
minitest (>= 4, < 6)
mocha (1.14.0)
netrc (0.11.0)
nokogiri (1.15.3)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.15.3-x86_64-linux)
Expand All @@ -77,6 +74,7 @@ GEM
parser (3.2.2.0)
ast (~> 2.4.1)
prettier_print (0.1.0)
prism (0.20.0)
pry (0.14.1)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -179,7 +177,6 @@ GEM
zeitwerk (2.6.4)

PLATFORMS
ruby
x86_64-darwin
x86_64-darwin-20
x86_64-linux
Expand Down
4 changes: 2 additions & 2 deletions lib/packwerk/parsers/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# frozen_string_literal: true

require "parser"
require "parser/current"
require "prism"

module Packwerk
module Parsers
Expand All @@ -11,7 +11,7 @@ class Ruby

include ParserInterface

class RaiseExceptionsParser < Parser::CurrentRuby
class RaiseExceptionsParser < Prism::Translation::Parser
extend T::Sig

sig { params(builder: T.untyped).void }
Expand Down
1 change: 1 addition & 0 deletions packwerk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Gem::Specification.new do |spec|
# For Ruby parsing
spec.add_dependency("ast")
spec.add_dependency("parser")
spec.add_dependency("prism")

# For ERB parsing
spec.add_dependency("better_html")
Expand Down
2 changes: 1 addition & 1 deletion test/unit/packwerk/file_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class FileProcessorTest < Minitest::Test
assert_equal 0, processed_file.unresolved_references.count
offenses = processed_file.offenses
assert_equal 1, offenses.length
assert_equal "Syntax error: unexpected token $end", offenses.first.message
assert_equal "Syntax error: expected a delimiter to close the parameters", offenses.first.message
end

test "#call with a path that can't be parsed outputs error message" do
Expand Down

0 comments on commit 3333cba

Please sign in to comment.