Skip to content

Commit

Permalink
Add progress indication for DSL operations
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Jan 29, 2025
1 parent 0dbc149 commit d715e51
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions lib/ruby_lsp/tapioca/server_addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,38 @@ def execute(request, params)
halt_upon_load_error: false,
).load_dsl_extensions_and_compilers
when "dsl"
fork { dsl(params[:constants]) }
fork do
with_notification_wrapper("dsl", "Generating DSL RBIs") do
dsl(params[:constants])
end_progress("dsl")
end
end
when "route_dsl"
fork do
constants = ::Tapioca::Dsl::Compilers::UrlHelpers.gather_constants
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::UrlHelpers", "ActiveSupportConcern")
with_notification_wrapper("route_dsl", "Generating route DSL RBIs") do
constants = ::Tapioca::Dsl::Compilers::UrlHelpers.gather_constants
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::UrlHelpers", "ActiveSupportConcern")
end
end
when "fixtures_dsl"
fork do
constants = ::Tapioca::Dsl::Compilers::ActiveRecordFixtures.gather_constants
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::ActiveRecordFixtures")
with_notification_wrapper("fixture_dsl", "Generating fixture DSL RBIs") do
constants = ::Tapioca::Dsl::Compilers::ActiveRecordFixtures.gather_constants
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::ActiveRecordFixtures")
end_progress("fixture-dsl")
end
end
end
end

private

def with_notification_wrapper(request_name, title, &block)
with_progress(request_name, title) do
with_notification_error_handling(request_name, &block)
end
end

def dsl(constants, *args)
load("tapioca/cli.rb") # Reload the CLI to reset thor defaults between requests

Expand Down

0 comments on commit d715e51

Please sign in to comment.