From 427a6b2ecfa940edcb12aada466e8b0fb3d778a5 Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Tue, 7 May 2024 10:50:48 +0200 Subject: [PATCH] do not crash if metadata cannot be rendered to markdown --- .../lib/language_server/markdown_utils.ex | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/language_server/lib/language_server/markdown_utils.ex b/apps/language_server/lib/language_server/markdown_utils.ex index 24968feee..00e0b8f50 100644 --- a/apps/language_server/lib/language_server/markdown_utils.ex +++ b/apps/language_server/lib/language_server/markdown_utils.ex @@ -78,15 +78,15 @@ defmodule ElixirLS.LanguageServer.MarkdownUtils do "**Equivalent** #{name}/#{arity}" end - defp get_metadata_entry_md({:deprecated, text}) do + defp get_metadata_entry_md({:deprecated, text}) when is_binary(text) do "**Deprecated** #{text}" end - defp get_metadata_entry_md({:since, text}) do + defp get_metadata_entry_md({:since, text}) when is_binary(text) do "**Since** #{text}" end - defp get_metadata_entry_md({:group, text}) do + defp get_metadata_entry_md({:group, text}) when is_binary(text) do "**Group** #{text}" end @@ -102,15 +102,15 @@ defmodule ElixirLS.LanguageServer.MarkdownUtils do "**Built-in**" end - defp get_metadata_entry_md({:implementing, module}) do + defp get_metadata_entry_md({:implementing, module}) when is_atom(module) do "**Implementing behaviour** #{inspect(module)}" end - defp get_metadata_entry_md({:implementing_module_app, app}) do + defp get_metadata_entry_md({:implementing_module_app, app}) when is_atom(app) do "**Behaviour defined in application** #{to_string(app)}" end - defp get_metadata_entry_md({:app, app}) do + defp get_metadata_entry_md({:app, app}) when is_atom(app) do "**Application** #{to_string(app)}" end @@ -132,7 +132,7 @@ defmodule ElixirLS.LanguageServer.MarkdownUtils do defp get_metadata_entry_md({:defaults, _}), do: nil - defp get_metadata_entry_md({:delegate_to, {m, f, a}}) do + defp get_metadata_entry_md({:delegate_to, {m, f, a}}) when is_atom(m) and is_atom(f) and is_integer(a) do "**Delegates to** #{inspect(m)}.#{f}/#{a}" end