Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use prism parser via translator #388

Merged
merged 4 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 (>= 0.24.0)
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.24.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
2 changes: 1 addition & 1 deletion lib/packwerk/file_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def call(relative_file)
For now, you can add this file to `packwerk.yml` `exclude` list.
Please file an issue and include this error message and stacktrace:

#{e.message} #{e.backtrace}"
#{e.message} #{e.backtrace&.join("\n")}"
MSG

offense = Parsers::ParseResult.new(file: relative_file, message: message)
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", ">= 0.24.0") # 0.24.0 fixes a performance issue with the parser translator

# For ERB parsing
spec.add_dependency("better_html")
Expand Down
Loading
Loading