Skip to content

Commit 471cdd2

Browse files
authored
Special case handling of Phoenix 'live' dir when suggesting module names (#705)
When generating a live view with mix phx.gen.live the view and all related files are put under my_project_web/live/* Similar to other Phoenix paths (e.g. /controllers) this directory is not a part of the generated module names, and the suggested module names when auto-completing should account for that convention.
1 parent 9aebbe8 commit 471cdd2

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

apps/language_server/lib/language_server/providers/completion.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,8 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
650650
"channels",
651651
"plugs",
652652
"endpoints",
653-
"sockets"
653+
"sockets",
654+
"live"
654655
] do
655656
if String.ends_with?(project_web_dir, "_web") do
656657
# by convention Phoenix doesn't use these folders as part of the module names

apps/language_server/test/providers/completion_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,8 @@ defmodule ElixirLS.LanguageServer.Providers.CompletionTest do
11641164
{"MyProjectWeb.MyView", "views/my_view.ex"},
11651165
{"MyProjectWeb.MyChannel", "channels/my_channel.ex"},
11661166
{"MyProjectWeb.MyEndpoint", "endpoints/my_endpoint.ex"},
1167-
{"MyProjectWeb.MySocket", "sockets/my_socket.ex"}
1167+
{"MyProjectWeb.MySocket", "sockets/my_socket.ex"},
1168+
{"MyProjectWeb.MyviewLive.MyComponent", "live/myview_live/my_component.ex"}
11681169
]
11691170
|> Enum.each(fn {expected_module_name, partial_path} ->
11701171
path = "some/path/my_project/lib/my_project_web/#{partial_path}"

0 commit comments

Comments
 (0)