Skip to content

Commit 1f373b9

Browse files
committed
add details to typesystem warnings
1 parent 0634719 commit 1f373b9

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

apps/language_server/lib/language_server/diagnostics.ex

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,44 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
453453

454454
defp build_related_information(diagnostic, uri, source_file) do
455455
case diagnostic.details do
456+
%{typing_traces: typing_traces} ->
457+
# %{
458+
# name: :a,
459+
# type: :variable,
460+
# context: nil,
461+
# traces: [
462+
# %{
463+
# meta: [line: 16, column: 7],
464+
# file: "lib/type_errors.ex",
465+
# formatted_type: ":asd",
466+
# formatted_expr: "a = :asd",
467+
# formatted_hints: []
468+
# }
469+
# ]
470+
# }
471+
472+
for typing_trace <- typing_traces, trace <- typing_trace.traces do
473+
case typing_trace.type do
474+
:variable ->
475+
line = trace.meta |> Keyword.get(:line, 1)
476+
column = trace.meta |> Keyword.get(:column, 1)
477+
478+
message = "given type: #{trace.formatted_type}"
479+
480+
%{
481+
"location" => %{
482+
"uri" => uri,
483+
"range" =>
484+
range(
485+
{line, column},
486+
source_file
487+
)
488+
},
489+
"message" => message
490+
}
491+
end
492+
end
493+
456494
# for backwards compatibility with elixir < 1.16
457495
{:error, %kind{} = payload} when kind == MismatchedDelimiterError ->
458496
[

0 commit comments

Comments
 (0)