Skip to content

Commit

Permalink
WIP: Prepare for Code Lens API change
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Jan 16, 2025
1 parent 27a3728 commit a872823
Show file tree
Hide file tree
Showing 5 changed files with 467 additions and 339 deletions.
4 changes: 3 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ gem "rubocop-minitest", "~> 0.36.0", require: false
gem "rubocop-rake", "~> 0.6.0", require: false
gem "rubocop-sorbet", "~> 0.8", require: false
gem "sorbet-static-and-runtime", platforms: :ruby
gem "tapioca", "~> 0.13", require: false, platforms: :ruby
# gem "tapioca", "~> 0.13", require: false, platforms: :ruby
gem "psych", "~> 5.1", require: false
gem "rails", "8.0.0"

platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo"
gem "tzinfo-data"
end

gem "ruby-lsp", path: "../ruby-lsp"
38 changes: 10 additions & 28 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
PATH
remote: ../ruby-lsp
specs:
ruby-lsp (0.23.5)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)

PATH
remote: .
specs:
Expand Down Expand Up @@ -125,7 +134,6 @@ GEM
timeout
net-smtp (0.5.0)
net-protocol
netrc (0.11.0)
nio4r (2.7.4)
nokogiri (1.16.7-arm64-darwin)
racc (~> 1.4)
Expand Down Expand Up @@ -183,9 +191,6 @@ GEM
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.2.1)
rbi (0.2.2)
prism (~> 1.0)
sorbet-runtime (>= 0.5.9204)
rbs (3.8.1)
logger
rdoc (6.7.0)
Expand Down Expand Up @@ -214,11 +219,6 @@ GEM
rubocop (~> 1.51)
rubocop-sorbet (0.8.7)
rubocop (>= 1)
ruby-lsp (0.23.3)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 4)
sorbet-runtime (>= 0.5.10782)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
securerandom (0.3.1)
Expand All @@ -230,25 +230,11 @@ GEM
sorbet-static-and-runtime (0.5.11635)
sorbet (= 0.5.11635)
sorbet-runtime (= 0.5.11635)
spoom (1.5.0)
erubi (>= 1.10.0)
prism (>= 0.28.0)
sorbet-static-and-runtime (>= 0.5.10187)
thor (>= 0.19.2)
sqlite3 (2.1.0-arm64-darwin)
sqlite3 (2.1.0-x64-mingw-ucrt)
sqlite3 (2.1.0-x86_64-darwin)
sqlite3 (2.1.0-x86_64-linux-gnu)
stringio (3.1.2)
tapioca (0.16.5)
bundler (>= 2.2.25)
netrc (>= 0.11.0)
parallel (>= 1.21.0)
rbi (~> 0.2)
sorbet-static-and-runtime (>= 0.5.11087)
spoom (>= 1.2.0)
thor (>= 1.2.0)
yard-sorbet
thor (1.3.2)
timeout (0.4.2)
tzinfo (2.0.6)
Expand All @@ -261,10 +247,6 @@ GEM
websocket-driver (0.7.6)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
yard (0.9.37)
yard-sorbet (0.9.0)
sorbet-runtime
yard
zeitwerk (2.7.1)

PLATFORMS
Expand All @@ -283,10 +265,10 @@ DEPENDENCIES
rubocop-rake (~> 0.6.0)
rubocop-shopify (~> 2.15)
rubocop-sorbet (~> 0.8)
ruby-lsp!
ruby-lsp-rails!
sorbet-static-and-runtime
sqlite3
tapioca (~> 0.13)
tzinfo
tzinfo-data

Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_lsp/ruby_lsp_rails/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def version
sig do
override.params(
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
uri: URI::Generic,
document: RubyLsp::Document[T.untyped],
dispatcher: Prism::Dispatcher,
).void
end
def create_code_lens_listener(response_builder, uri, dispatcher)
CodeLens.new(@rails_runner_client, T.must(@global_state), response_builder, uri, dispatcher)
def create_code_lens_listener(response_builder, document, dispatcher)
CodeLens.new(@rails_runner_client, T.must(@global_state), response_builder, document, dispatcher)
end

sig do
Expand Down
9 changes: 5 additions & 4 deletions lib/ruby_lsp/ruby_lsp_rails/code_lens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,16 @@ class CodeLens
client: RunnerClient,
global_state: GlobalState,
response_builder: ResponseBuilders::CollectionResponseBuilder[Interface::CodeLens],
uri: URI::Generic,
document: RubyLsp::Document[T.untyped],
dispatcher: Prism::Dispatcher,
).void
end
def initialize(client, global_state, response_builder, uri, dispatcher)
def initialize(client, global_state, response_builder, document, dispatcher)
@client = client
@global_state = global_state
@response_builder = response_builder
@path = T.let(uri.to_standardized_path, T.nilable(String))
@path = T.let(document.uri.to_standardized_path, T.nilable(String))
@document = document
@group_id = T.let(1, Integer)
@group_id_stack = T.let([], T::Array[Integer])
@constant_name_stack = T.let([], T::Array[[String, T.nilable(String)]])
Expand Down Expand Up @@ -264,7 +265,7 @@ def add_migrate_code_lens(node, name:, command:)
sig { params(node: Prism::Node, name: String, command: String, kind: Symbol).void }
def add_test_code_lens(node, name:, command:, kind:)
return unless @path
return unless @global_state.test_library == "rails"
return unless @document.test_library == "rails"

arguments = [
@path,
Expand Down
Loading

0 comments on commit a872823

Please sign in to comment.