Skip to content

Commit

Permalink
fixcrash on OTP 24.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Jan 5, 2022
1 parent 10e3d87 commit 72f3d4f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/elixir_sense/core/type_info.ex
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,14 @@ defmodule ElixirSense.Core.TypeInfo do
line_length = opts[:line_length] || @doc_spec_line_length
kind_size = kind |> to_string() |> String.length()

spec_ast
{sanitized, original} = sanitize_type_name(spec_ast)

sanitized
|> Macro.to_string()
|> (&"@#{kind} #{&1}").()
|> Code.format_string!(line_length: line_length)
|> to_string()
|> String.replace("__replace_me__", "#{original}")
|> Source.split_lines()
|> Enum.with_index()
|> Enum.map(fn
Expand All @@ -258,6 +261,14 @@ defmodule ElixirSense.Core.TypeInfo do
|> Enum.join("\n")
end

defp sanitize_type_name({:"::", meta1, [{type, meta2, args}, rest]}) do
{{:"::", meta1, [{:__replace_me__, meta2, args}, rest]}, type}
end

defp sanitize_type_name({type, meta, args}) do
{{:__replace_me__, meta, args}, type}
end

@spec get_type_docs(module, atom) :: [ElixirSense.Core.Normalized.Code.doc_entry_t()]
def get_type_docs(module, type_name) do
docs = NormalizedCode.get_docs(module, :type_docs) || []
Expand Down

0 comments on commit 72f3d4f

Please sign in to comment.