Skip to content

Commit

Permalink
Purge consolidated protocols before compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsamson committed Nov 21, 2020
1 parent 32b6226 commit c534d6a
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions apps/language_server/test/server_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,76 @@ defmodule ElixirLS.LanguageServer.ServerTest do
end)
end

test "protocol rebuild does not trigger consolidation warnings", %{server: server} do
in_fixture(__DIR__, "protocols", fn ->
uri = SourceFile.path_to_uri(Path.absname("lib/implementations.ex"))

Server.receive_packet(server, initialize_req(1, root_uri(), %{}))
Server.receive_packet(server, notification("initialized"))

Server.receive_packet(
server,
did_change_configuration(%{"elixirLS" => %{"dialyzerEnabled" => true}})
)

assert_receive notification("window/logMessage", %{"message" => "Compile took" <> _}), 3000

assert_receive notification("window/logMessage", %{
"message" => "[ElixirLS Dialyzer] Done writing manifest" <> _
}),
3000

v2_text = """
defimpl Protocols.Example, for: List do
def some(t), do: t
end
defimpl Protocols.Example, for: String do
def some(t), do: t
end
defimpl Protocols.Example, for: Map do
def some(t), do: t
end
"""

Server.receive_packet(server, did_open(uri, "elixir", 1, v2_text))
File.write!("lib/implementations.ex", v2_text)
Server.receive_packet(server, did_save(uri))

assert_receive notification("window/logMessage", %{"message" => "Compile took" <> _}), 3000
assert_receive notification("textDocument/publishDiagnostics", %{"diagnostics" => []}), 3000

Process.sleep(2000)

v2_text = """
defimpl Protocols.Example, for: List do
def some(t), do: t
end
defimpl Protocols.Example, for: String do
def some(t), do: t
end
defimpl Protocols.Example, for: Map do
def some(t), do: t
end
defimpl Protocols.Example, for: Atom do
def some(t), do: t
end
"""

Server.receive_packet(server, did_open(uri, "elixir", 1, v2_text))
File.write!("lib/implementations.ex", v2_text)
Server.receive_packet(server, did_save(uri))

assert_receive notification("window/logMessage", %{"message" => "Compile took" <> _}), 3000
assert_receive notification("textDocument/publishDiagnostics", %{"diagnostics" => []}), 3000
refute_receive notification("textDocument/publishDiagnostics", _), 3000
end)
end

defp with_new_server(func) do
server = start_supervised!({Server, nil})
packet_capture = start_supervised!({PacketCapture, self()})
Expand Down

0 comments on commit c534d6a

Please sign in to comment.