Skip to content

Commit 13a9a77

Browse files
committed
fix: use GenLSP loggin utility
1 parent 90ab70a commit 13a9a77

File tree

2 files changed

+12
-51
lines changed

2 files changed

+12
-51
lines changed

apps/expert/lib/expert/state.ex

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -129,14 +129,9 @@ defmodule Expert.State do
129129

130130
Expert.Project.Supervisor.stop(project)
131131

132-
GenLSP.notify(
132+
GenLSP.log(
133133
Expert.get_lsp(),
134-
%GenLSP.Notifications.WindowLogMessage{
135-
params: %GenLSP.Structures.LogMessageParams{
136-
type: GenLSP.Enumerations.MessageType.info(),
137-
message: "Stopping project node for #{Project.name(project)}"
138-
}
139-
}
134+
"Stopping project node for #{Project.name(project)}"
140135
)
141136

142137
project
@@ -278,15 +273,7 @@ defmodule Expert.State do
278273
{:ok, _pid} ->
279274
Logger.info("Project node started for #{Project.name(project)}")
280275

281-
GenLSP.notify(
282-
Expert.get_lsp(),
283-
%GenLSP.Notifications.WindowLogMessage{
284-
params: %GenLSP.Structures.LogMessageParams{
285-
type: GenLSP.Enumerations.MessageType.info(),
286-
message: "Started project node for #{Project.name(project)}"
287-
}
288-
}
289-
)
276+
GenLSP.log(Expert.get_lsp(), "Started project node for #{Project.name(project)}")
290277

291278
{:error, {reason, pid}} when reason in [:already_started, :already_present] ->
292279
{:ok, pid}
@@ -296,14 +283,9 @@ defmodule Expert.State do
296283
"Failed to start project node for #{Project.name(project)}: #{inspect(reason, pretty: true)}"
297284
)
298285

299-
GenLSP.notify(
286+
GenLSP.log(
300287
Expert.get_lsp(),
301-
%GenLSP.Notifications.WindowLogMessage{
302-
params: %GenLSP.Structures.LogMessageParams{
303-
type: GenLSP.Enumerations.MessageType.error(),
304-
message: "Failed to start project node for #{Project.name(project)}"
305-
}
306-
}
288+
"Failed to start project node for #{Project.name(project)}"
307289
)
308290

309291
{:error, reason}

apps/expert/test/expert/expert_test.exs

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,7 @@ defmodule ExpertTest do
9494

9595
assert_notification(
9696
"window/logMessage",
97-
%{
98-
"type" => 3,
99-
"message" => ^expected_message
100-
}
97+
%{"message" => ^expected_message}
10198
)
10299

103100
assert [project] = Expert.ActiveProjects.projects()
@@ -126,10 +123,7 @@ defmodule ExpertTest do
126123

127124
assert_notification(
128125
"window/logMessage",
129-
%{
130-
"type" => 3,
131-
"message" => ^expected_message
132-
}
126+
%{"message" => ^expected_message}
133127
)
134128

135129
assert [_project_1] = Expert.ActiveProjects.projects()
@@ -155,10 +149,7 @@ defmodule ExpertTest do
155149

156150
assert_notification(
157151
"window/logMessage",
158-
%{
159-
"type" => 3,
160-
"message" => ^expected_message
161-
}
152+
%{"message" => ^expected_message}
162153
)
163154

164155
assert [project_1, project_2] = Expert.ActiveProjects.projects()
@@ -185,10 +176,7 @@ defmodule ExpertTest do
185176

186177
assert_notification(
187178
"window/logMessage",
188-
%{
189-
"type" => 3,
190-
"message" => ^expected_message
191-
}
179+
%{"message" => ^expected_message}
192180
)
193181

194182
assert [project] = Expert.ActiveProjects.projects()
@@ -216,10 +204,7 @@ defmodule ExpertTest do
216204

217205
assert_notification(
218206
"window/logMessage",
219-
%{
220-
"type" => 3,
221-
"message" => ^expected_message
222-
}
207+
%{"message" => ^expected_message}
223208
)
224209

225210
assert [] = Expert.ActiveProjects.projects()
@@ -245,10 +230,7 @@ defmodule ExpertTest do
245230

246231
assert_notification(
247232
"window/logMessage",
248-
%{
249-
"type" => 3,
250-
"message" => ^expected_message
251-
}
233+
%{"message" => ^expected_message}
252234
)
253235

254236
file_uri = Path.join([secondary_project.root_uri, "lib", "secondary.ex"])
@@ -274,10 +256,7 @@ defmodule ExpertTest do
274256

275257
assert_notification(
276258
"window/logMessage",
277-
%{
278-
"type" => 3,
279-
"message" => ^expected_message
280-
}
259+
%{"message" => ^expected_message}
281260
)
282261

283262
assert [_main, project] = Expert.ActiveProjects.projects()

0 commit comments

Comments
 (0)