Skip to content

Commit

Permalink
Merge pull request #227 from Shopify/at-yarp
Browse files Browse the repository at this point in the history
Migrate parsing to YARP
  • Loading branch information
Morriar authored Sep 7, 2023
2 parents 8446df7 + 2a4a820 commit f5f1c43
Show file tree
Hide file tree
Showing 33 changed files with 41,982 additions and 13,938 deletions.
11 changes: 4 additions & 7 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ PATH
remote: .
specs:
rbi (0.0.17)
ast
parser (>= 3.0.0)
sorbet-runtime (>= 0.5.9204)
unparser (>= 0.5.6)
yarp (>= 0.10.0)

GEM
remote: https://rubygems.org/
Expand All @@ -15,7 +13,6 @@ GEM
base64 (0.1.1)
builder (3.2.4)
byebug (11.1.3)
diff-lcs (1.5.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
minitest (5.19.0)
Expand Down Expand Up @@ -57,6 +54,7 @@ GEM
sorbet-static (= 0.5.10993)
sorbet-runtime (0.5.10993)
sorbet-static (0.5.10993-universal-darwin-21)
sorbet-static (0.5.10993-universal-darwin-22)
sorbet-static (0.5.10993-x86_64-linux)
sorbet-static-and-runtime (0.5.10993)
sorbet (= 0.5.10993)
Expand All @@ -76,16 +74,15 @@ GEM
yard-sorbet
thor (1.2.2)
unicode-display_width (2.4.2)
unparser (0.6.8)
diff-lcs (~> 1.3)
parser (>= 3.2.0)
yard (0.9.34)
yard-sorbet (0.8.1)
sorbet-runtime (>= 0.5)
yard (>= 0.9)
yarp (0.10.0)

PLATFORMS
arm64-darwin-21
arm64-darwin-22
x86_64-linux

DEPENDENCIES
Expand Down
15 changes: 15 additions & 0 deletions lib/rbi/loc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ module RBI
class Loc
extend T::Sig

class << self
extend T::Sig

sig { params(file: String, yarp_location: YARP::Location).returns(Loc) }
def from_yarp(file, yarp_location)
new(
file: file,
begin_line: yarp_location.start_line,
end_line: yarp_location.end_line,
begin_column: yarp_location.start_column,
end_column: yarp_location.end_column + 1, # TODO: Why is this off by one?
)
end
end

sig { returns(T.nilable(String)) }
attr_reader :file

Expand Down
Loading

0 comments on commit f5f1c43

Please sign in to comment.