Skip to content

Commit f28af33

Browse files
authored
fix(elixir): compiler diagnostics have iodata (#18)
Fixes #15
1 parent 5a21596 commit f28af33

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

Diff for: lib/next_ls/extensions/elixir_extension.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ defmodule NextLS.ElixirExtension do
3838
# be responsible for this. The open documents live in the LSP process
3939
DiagnosticCache.put(state.cache, :elixir, d.file, %GenLSP.Structures.Diagnostic{
4040
severity: severity(d.severity),
41-
message: d.message,
41+
message: IO.iodata_to_binary(d.message),
4242
source: d.compiler_name,
4343
range: range(d.position)
4444
})

Diff for: mix.exs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule NextLS.MixProject do
3030
# Run "mix help deps" to learn about dependencies.
3131
defp deps do
3232
[
33-
{:gen_lsp, "~> 0.1"},
33+
{:gen_lsp, "~> 0.2"},
3434
{:ex_doc, ">= 0.0.0", only: :dev},
3535
{:dialyxir, ">= 0.0.0", only: [:dev, :test], runtime: false}
3636
]

Diff for: mix.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"earmark_parser": {:hex, :earmark_parser, "1.4.32", "fa739a0ecfa34493de19426681b23f6814573faee95dfd4b4aafe15a7b5b32c6", [:mix], [], "hexpm", "b8b0dd77d60373e77a3d7e8afa598f325e49e8663a51bcc2b88ef41838cca755"},
44
"erlex": {:hex, :erlex, "0.2.6", "c7987d15e899c7a2f34f5420d2a2ea0d659682c06ac607572df55a43753aa12e", [:mix], [], "hexpm", "2ed2e25711feb44d52b17d2780eabf998452f6efda104877a3881c2f8c0c0c75"},
55
"ex_doc": {:hex, :ex_doc, "0.29.4", "6257ecbb20c7396b1fe5accd55b7b0d23f44b6aa18017b415cb4c2b91d997729", [:mix], [{:earmark_parser, "~> 1.4.31", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1", [hex: :makeup_erlang, repo: "hexpm", optional: false]}], "hexpm", "2c6699a737ae46cb61e4ed012af931b57b699643b24dabe2400a8168414bc4f5"},
6-
"gen_lsp": {:hex, :gen_lsp, "0.1.2", "5aa8ec2ff69c8a075a30da211ee89214d117ea18eb1fbe91c80662d390389010", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.1", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "a46ae73c6034f7c95af15b746abf660fefdd1d3635ff4dfe2aacdd9315caf573"},
6+
"gen_lsp": {:hex, :gen_lsp, "0.2.0", "ee37d8731a50119db5286913aaf118a74bdfa34cafb2b650c7cdf149dc004eba", [:mix], [{:jason, "~> 1.3", [hex: :jason, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.5 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:schematic, "~> 0.2", [hex: :schematic, repo: "hexpm", optional: false]}, {:typed_struct, "~> 0.3.0", [hex: :typed_struct, repo: "hexpm", optional: false]}], "hexpm", "a0ac8a88615860ac512e75c6d727f292c090702899eca4b40931060cfce30ca2"},
77
"jason": {:hex, :jason, "1.4.0", "e855647bc964a44e2f67df589ccf49105ae039d4179db7f6271dfd3843dc27e6", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "79a3791085b2a0f743ca04cec0f7be26443738779d09302e01318f97bdb82121"},
88
"makeup": {:hex, :makeup, "1.1.0", "6b67c8bc2882a6b6a445859952a602afc1a41c2e08379ca057c0f525366fc3ca", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "0a45ed501f4a8897f580eabf99a2e5234ea3e75a4373c8a52824f6e873be57a6"},
99
"makeup_elixir": {:hex, :makeup_elixir, "0.16.1", "cc9e3ca312f1cfeccc572b37a09980287e243648108384b97ff2b76e505c3555", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.2.3 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "e127a341ad1b209bd80f7bd1620a15693a9908ed780c3b763bccf7d200c767c6"},
1010
"makeup_erlang": {:hex, :makeup_erlang, "0.1.1", "3fcb7f09eb9d98dc4d208f49cc955a34218fc41ff6b84df7c75b3e6e533cc65f", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "174d0809e98a4ef0b3309256cbf97101c6ec01c4ab0b23e926a9e17df2077cbb"},
1111
"nimble_options": {:hex, :nimble_options, "1.0.2", "92098a74df0072ff37d0c12ace58574d26880e522c22801437151a159392270e", [:mix], [], "hexpm", "fd12a8db2021036ce12a309f26f564ec367373265b53e25403f0ee697380f1b8"},
1212
"nimble_parsec": {:hex, :nimble_parsec, "1.3.1", "2c54013ecf170e249e9291ed0a62e5832f70a476c61da16f6aac6dca0189f2af", [:mix], [], "hexpm", "2682e3c0b2eb58d90c6375fc0cc30bc7be06f365bf72608804fb9cffa5e1b167"},
13-
"schematic": {:hex, :schematic, "0.1.1", "75981b1eea5624e44f723e5ba270b892911d381a4417f20a0bd94f3854da0041", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "13ae4b35b81806febd7fc0251959e59aa28cc1600ba9e0e77f85cb4f303b8a35"},
13+
"schematic": {:hex, :schematic, "0.2.0", "ac710efbd98b8f4b3d137f8ebac6f9a17da917bb4d1296b487ac4157fb74c806", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "d4bc93bac2e7d04869fd6ced9df82c092c154fc648677512bc7c75d9a2655be3"},
1414
"telemetry": {:hex, :telemetry, "1.2.1", "68fdfe8d8f05a8428483a97d7aab2f268aaff24b49e0f599faa091f1d4e7f61c", [:rebar3], [], "hexpm", "dad9ce9d8effc621708f99eac538ef1cbe05d6a874dd741de2e689c47feafed5"},
1515
"typed_struct": {:hex, :typed_struct, "0.3.0", "939789e3c1dca39d7170c87f729127469d1315dcf99fee8e152bb774b17e7ff7", [:mix], [], "hexpm", "c50bd5c3a61fe4e198a8504f939be3d3c85903b382bde4865579bc23111d1b6d"},
1616
}

Diff for: test/next_ls/extensions/elixir_extension_test.exs

+34-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,20 @@ defmodule NextLS.ElixirExtensionTest do
3535
details: nil
3636
}
3737

38+
with_iodata = %Mix.Task.Compiler.Diagnostic{
39+
file: "/Users/mitchell/src/next_ls/lib/next_ls/runtime.ex",
40+
severity: :warning,
41+
message: [
42+
"ElixirExtension.foo/0",
43+
" is undefined (module ",
44+
"ElixirExtension",
45+
" is not available or is yet to be defined)"
46+
],
47+
position: 29,
48+
compiler_name: "Elixir",
49+
details: nil
50+
}
51+
3852
start_and_end = %Mix.Task.Compiler.Diagnostic{
3953
file: "lib/baz.ex",
4054
severity: :hint,
@@ -44,11 +58,30 @@ defmodule NextLS.ElixirExtensionTest do
4458
details: nil
4559
}
4660

47-
send(extension, {:compiler, [only_line, line_and_col, start_and_end]})
61+
send(extension, {:compiler, [only_line, line_and_col, start_and_end, with_iodata]})
4862

4963
assert_receive :publish
5064

5165
assert %{
66+
with_iodata.file => [
67+
%GenLSP.Structures.Diagnostic{
68+
severity: 2,
69+
message:
70+
"ElixirExtension.foo/0" <>
71+
" is undefined (module " <> "ElixirExtension" <> " is not available or is yet to be defined)",
72+
source: "Elixir",
73+
range: %GenLSP.Structures.Range{
74+
start: %GenLSP.Structures.Position{
75+
line: 28,
76+
character: 0
77+
},
78+
end: %GenLSP.Structures.Position{
79+
line: 28,
80+
character: 999
81+
}
82+
}
83+
}
84+
],
5285
only_line.file => [
5386
%GenLSP.Structures.Diagnostic{
5487
severity: 2,

0 commit comments

Comments
 (0)