From c733dc8825911c20f0fdf47fefe64289e557cc10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20V=C4=83n=20=C4=90=E1=BB=A9c?= <35915460+Goose97@users.noreply.github.com> Date: Fri, 30 Jun 2023 00:48:44 +0700 Subject: [PATCH] Improve aliased struct completions (#232) This PR allows aliased struct to be completed with %. It does so by correcting the subtype of the suggestion. Fixes #229 --- lib/elixir_sense/providers/suggestion/complete.ex | 2 +- test/elixir_sense/providers/suggestion/complete_test.exs | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/elixir_sense/providers/suggestion/complete.ex b/lib/elixir_sense/providers/suggestion/complete.ex index 0b5514f3..d9b92292 100644 --- a/lib/elixir_sense/providers/suggestion/complete.ex +++ b/lib/elixir_sense/providers/suggestion/complete.ex @@ -526,7 +526,7 @@ defmodule ElixirSense.Providers.Suggestion.Complete do name: name, full_name: inspect(mod), desc: {"", %{}}, - subtype: nil + subtype: Introspection.get_module_subtype(mod) } end end diff --git a/test/elixir_sense/providers/suggestion/complete_test.exs b/test/elixir_sense/providers/suggestion/complete_test.exs index 29907f02..4c0301ea 100644 --- a/test/elixir_sense/providers/suggestion/complete_test.exs +++ b/test/elixir_sense/providers/suggestion/complete_test.exs @@ -1452,6 +1452,13 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do assert entries |> Enum.any?(&(&1.name == "URI")) assert [%{name: "MyStruct"}] = expand('%ElixirSense.Providers.Suggestion.CompleteTest.') + + env = %Env{ + aliases: [{MyDate, Date}] + } + + entries = expand('%My', env, required_alias: true) + assert Enum.any?(entries, &(&1.name == "MyDate" and &1.subtype == :struct)) end @tag requires_elixir_1_14: true