Skip to content
Draft
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
33 changes: 17 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PATH
parallel (>= 1.21.0)
rbi (>= 0.3.7)
require-hooks (>= 0.2.2)
rubydex (>= 0.1.0.beta10)
rubydex (>= 0.2.3)
sorbet-static-and-runtime (>= 0.6.12698)
spoom (>= 1.7.9)
thor (>= 1.2.0)
Expand Down Expand Up @@ -310,7 +310,7 @@ GEM
rbi (0.3.10)
prism (~> 1.0)
rbs (>= 4.0.1)
rbs (4.0.2)
rbs (4.1.0.pre.1)
logger
prism (>= 1.6.0)
tsort
Expand Down Expand Up @@ -349,17 +349,18 @@ GEM
rubocop-sorbet (0.12.0)
lint_roller
rubocop (>= 1.75.2)
ruby-lsp (0.26.9)
ruby-lsp (0.27.0.beta3)
language_server-protocol (~> 3.17.0)
prism (>= 1.2, < 2.0)
rbs (>= 3, < 5)
ruby-lsp-rails (0.4.8)
ruby-lsp (>= 0.26.0, < 0.27.0)
rubydex (~> 0.2.0, < 0.3.0)
ruby-lsp-rails (0.5.0.beta1)
ruby-lsp (>= 0.27.0.beta2, < 0.28.0)
ruby-progressbar (1.13.0)
rubydex (0.2.0-aarch64-linux)
rubydex (0.2.0-arm64-darwin)
rubydex (0.2.0-x86_64-darwin)
rubydex (0.2.0-x86_64-linux)
rubydex (0.2.3-aarch64-linux)
rubydex (0.2.3-arm64-darwin)
rubydex (0.2.3-x86_64-darwin)
rubydex (0.2.3-x86_64-linux)
securerandom (0.4.1)
shopify-money (4.1.0)
bigdecimal (>= 3.0)
Expand Down Expand Up @@ -582,7 +583,7 @@ CHECKSUMS
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
rbi (0.3.10) sha256=a4fd8e7786845ffd6533c512da2bda8722ce8565071ee4ad489b403f77c61d2b
rbs (4.0.2) sha256=af75671e66cd03434cc546622741ebf83f6197ec4328375805306330bf78ef25
rbs (4.1.0.pre.1) sha256=d078568ca2acb006889f2934ecb486294bf672ad8394f295dc4cfa878e99156d
rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192
redis (5.4.0) sha256=798900d869418a9fc3977f916578375b45c38247a556b61d58cba6bb02f7d06b
redis-client (0.28.0) sha256=888892f9cd8787a41c0ece00bdf5f556dfff7770326ce40bb2bc11f1bfec824b
Expand All @@ -595,13 +596,13 @@ CHECKSUMS
rubocop-rspec (3.9.0) sha256=8fa70a3619408237d789aeecfb9beef40576acc855173e60939d63332fdb55e2
rubocop-shopify (2.18.0) sha256=dafa25e5617ce4600ff86b1de3d5b78e43ab3d58cc5729df38e492b8e10294eb
rubocop-sorbet (0.12.0) sha256=195521e132500555819313df5accaaf56bf721a63de3e5b7b1d0b25f696b1f39
ruby-lsp (0.26.9) sha256=33a01c001c00a76b4e821efc04ed7572983430f31ca5d6f3e343d0b6ccab4129
ruby-lsp-rails (0.4.8) sha256=f09d1f926d4063deeb2f3049311925c20dfe6c912371e3bcd04a265a865c44ae
ruby-lsp (0.27.0.beta3) sha256=348fd10c945c85b6f280f507c1e00632ab48fcbf9e6ac1779b7fc75f2f878d71
ruby-lsp-rails (0.5.0.beta1) sha256=045bf4abb8ca914da8efb50263c94af6ba5b0dea0a893ef357e4693f08747f9d
ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33
rubydex (0.2.0-aarch64-linux) sha256=1c9b0e0fd82d629aed0bd5cd2ea91ce278dd2cd4acb1251305c03c9ca2439fe5
rubydex (0.2.0-arm64-darwin) sha256=8c0ad11bd6a103de7e9fea2fddd55dc7d7ea5635ef9751c1569b6418185381a5
rubydex (0.2.0-x86_64-darwin) sha256=06baad305bd09a49f9abcfae5e1aa1f54d71bdae6d42d148035dab5bcaf7660a
rubydex (0.2.0-x86_64-linux) sha256=28071b3189f80daf5ed76ad87faaf95665f987cdebc2b5203876536253442616
rubydex (0.2.3-aarch64-linux) sha256=f666ff383430cc800cb0889d52c77da7457e99165b5eef7c0d45491a5fafea87
rubydex (0.2.3-arm64-darwin) sha256=997d7895a0208ec3d7ef922c9d29243b62e10c67bc3c2396a9f978d7df117390
rubydex (0.2.3-x86_64-darwin) sha256=de4890f91bedb59bfefb90c528939e52475da3afa105feaf855594ad527b0fb9
rubydex (0.2.3-x86_64-linux) sha256=796a54c1af9f8868c87bf92fee5f9ccc39ffd40eb8386e0875058a18beb76b09
securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1
shopify-money (4.1.0) sha256=680100a7a1176f2e3e69f34f9647d3cb36cf74cdb230308062bdeb56d41d4991
sidekiq (8.1.3) sha256=a42f51aca3705d21cb50f37f5ec07e69de8708e126be4cf94b45cf15b84b3762
Expand Down
30 changes: 19 additions & 11 deletions lib/ruby_lsp/tapioca/addon.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# typed: strict
# frozen_string_literal: true

RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.23.10", "< 0.27")
RubyLsp::Addon.depend_on_ruby_lsp!(">= 0.27.0.beta3", "< 0.28")

begin
# The Tapioca add-on depends on the Rails add-on to add a runtime component to the runtime server. We can allow the
Expand All @@ -24,7 +24,7 @@ def initialize

@global_state = nil #: RubyLsp::GlobalState?
@rails_runner_client = Rails::NullClient.new #: RubyLsp::Rails::RunnerClient
@index = nil #: RubyIndexer::Index?
@graph = nil #: Rubydex::Graph?
@file_checksums = {} #: Hash[String, String]
@lockfile_diff = nil #: String?
@outgoing_queue = nil #: Thread::Queue?
Expand All @@ -36,13 +36,13 @@ def activate(global_state, outgoing_queue)
@global_state = global_state
return unless @global_state.enabled_feature?(:tapiocaAddon)

@index = @global_state.index
@graph = @global_state.graph
@outgoing_queue = outgoing_queue
Thread.new do
# Get a handle to the Rails add-on's runtime client. The call to `rails_runner_client` will block this thread
# until the server has finished booting, but it will not block the main LSP. This has to happen inside of a
# thread
addon = ::RubyLsp::Addon.get("Ruby LSP Rails", ">= 0.4.0", "< 0.5") #: as ::RubyLsp::Rails::Addon
addon = ::RubyLsp::Addon.get("Ruby LSP Rails", ">= 0.5.0.beta1", "< 0.6") #: as ::RubyLsp::Rails::Addon
@rails_runner_client = addon.rails_runner_client
@outgoing_queue << Notification.window_log_message("Activating Tapioca add-on v#{version}")
@rails_runner_client.register_server_addon(File.expand_path("server_addon.rb", __dir__))
Expand Down Expand Up @@ -91,9 +91,10 @@ def workspace_did_change_watched_files(changes)
has_route_change = false #: bool
has_fixtures_change = false #: bool
needs_compiler_reload = false #: bool
index = @index #: as !nil
graph = @graph #: as !nil
constants = [] #: Array[String]

constants = changes.flat_map do |change|
changes.each do |change|
path = URI(change[:uri]).to_standardized_path #: String?
next unless path && file_updated?(change, path)

Expand All @@ -114,13 +115,20 @@ def workspace_did_change_watched_files(changes)
next
end

entries = index.entries_for(change[:uri])
next unless entries
document = graph.document(change[:uri])
next unless document

entries.filter_map do |entry|
entry.name if entry.class == RubyIndexer::Entry::Class || entry.class == RubyIndexer::Entry::Module
document.definitions.each do |definition|
next unless definition.is_a?(Rubydex::ClassDefinition) || definition.is_a?(Rubydex::ModuleDefinition)

declaration = definition.declaration
constants << declaration.name if declaration
end
end.compact
end

# Definitions coming from different files might map to the same declaration, so we can save a bit of redundant
# work by making sure it's deduped
constants.uniq!

return if constants.empty? && !has_route_change && !has_fixtures_change && !needs_compiler_reload

Expand Down
Loading
Loading