@@ -46,12 +46,20 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
46
46
47
47
% __MODULE__ { normalized | message: message , file: file , position: position }
48
48
else
49
- { type , file , position , stacktrace } =
49
+ { _type , file , position , stacktrace } =
50
50
extract_message_info ( diagnostic . message , root_path )
51
51
52
+ { file , position } =
53
+ get_file_and_position_with_stacktrace_fallback (
54
+ { file || diagnostic . file , position || diagnostic . position } ,
55
+ Map . get ( diagnostic , :stacktrace , [ ] ) ,
56
+ root_path ,
57
+ mixfile
58
+ )
59
+
52
60
normalized
53
61
|> maybe_update_file ( file , mixfile )
54
- |> maybe_update_position ( type , position , stacktrace )
62
+ |> maybe_update_position ( position , stacktrace )
55
63
end
56
64
end
57
65
@@ -85,21 +93,7 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
85
93
end
86
94
end
87
95
88
- defp maybe_update_position ( diagnostic , "TokenMissingError" , position , stacktrace ) do
89
- case extract_line_from_missing_hint ( diagnostic . message ) do
90
- line when is_integer ( line ) and line > 0 ->
91
- % { diagnostic | position: line }
92
-
93
- _ ->
94
- do_maybe_update_position ( diagnostic , position , stacktrace )
95
- end
96
- end
97
-
98
- defp maybe_update_position ( diagnostic , _type , position , stacktrace ) do
99
- do_maybe_update_position ( diagnostic , position , stacktrace )
100
- end
101
-
102
- defp do_maybe_update_position ( diagnostic , position , stacktrace ) do
96
+ defp maybe_update_position ( diagnostic , position , stacktrace ) do
103
97
cond do
104
98
position != nil ->
105
99
% { diagnostic | position: position }
@@ -191,16 +185,6 @@ defmodule ElixirLS.LanguageServer.Diagnostics do
191
185
false
192
186
end
193
187
194
- defp extract_line_from_missing_hint ( message ) do
195
- case Regex . run (
196
- ~r/ starting at line (\d +)\) / u ,
197
- message
198
- ) do
199
- [ _ , line ] -> String . to_integer ( line )
200
- _ -> nil
201
- end
202
- end
203
-
204
188
defp extract_line_from_stacktrace ( file , stacktrace ) do
205
189
Enum . find_value ( stacktrace , fn stack_item ->
206
190
with [ _ , _ , file_relative , line ] <-
0 commit comments