Skip to content

Commit e64a3cf

Browse files
authored
Add progress indication for DSL operations (#2176)
### Motivation Sometimes RBI generation can take a while and the user has no hints that anything is happening. This PR adds progress notifications, so that the user has visual hints that Tapioca is running when a file is saved. ### Implementation There's not much, I just wrapped our execution in the progress block.
2 parents 8416663 + b8d3c6f commit e64a3cf

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

lib/ruby_lsp/tapioca/server_addon.rb

+19-5
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,36 @@ def execute(request, params)
2424
halt_upon_load_error: false,
2525
).load_dsl_extensions_and_compilers
2626
when "dsl"
27-
fork { dsl(params[:constants]) }
27+
fork do
28+
with_notification_wrapper("dsl", "Generating DSL RBIs") do
29+
dsl(params[:constants])
30+
end
31+
end
2832
when "route_dsl"
2933
fork do
30-
constants = ::Tapioca::Dsl::Compilers::UrlHelpers.gather_constants
31-
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::UrlHelpers", "ActiveSupportConcern")
34+
with_notification_wrapper("route_dsl", "Generating route DSL RBIs") do
35+
constants = ::Tapioca::Dsl::Compilers::UrlHelpers.gather_constants
36+
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::UrlHelpers", "ActiveSupportConcern")
37+
end
3238
end
3339
when "fixtures_dsl"
3440
fork do
35-
constants = ::Tapioca::Dsl::Compilers::ActiveRecordFixtures.gather_constants
36-
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::ActiveRecordFixtures")
41+
with_notification_wrapper("fixture_dsl", "Generating fixture DSL RBIs") do
42+
constants = ::Tapioca::Dsl::Compilers::ActiveRecordFixtures.gather_constants
43+
dsl(constants.map(&:name), "--only=Tapioca::Dsl::Compilers::ActiveRecordFixtures")
44+
end
3745
end
3846
end
3947
end
4048

4149
private
4250

51+
def with_notification_wrapper(request_name, title, &block)
52+
with_progress(request_name, title) do
53+
with_notification_error_handling(request_name, &block)
54+
end
55+
end
56+
4357
def dsl(constants, *args)
4458
load("tapioca/cli.rb") # Reload the CLI to reset thor defaults between requests
4559

0 commit comments

Comments
 (0)