@@ -859,9 +859,12 @@ defmodule Kernel.ParallelCompiler do
859859 )
860860
861861 for { file , _ , description , stacktrace } <- deadlock do
862+ file = Path . absname ( file )
863+
862864 % {
863865 severity: :error ,
864- file: Path . absname ( file ) ,
866+ file: file ,
867+ source: file ,
865868 position: nil ,
866869 message: description ,
867870 stacktrace: stacktrace ,
@@ -889,13 +892,14 @@ defmodule Kernel.ParallelCompiler do
889892 ] )
890893 end
891894
892- defp to_error ( file , kind , reason , stack ) do
893- { line , span } = get_line_span ( file , reason , stack )
894- file = Path . absname ( file )
895+ defp to_error ( source , kind , reason , stack ) do
896+ { file , line , span } = get_snippet_info ( source , reason , stack )
897+ source = Path . absname ( source )
895898 message = :unicode . characters_to_binary ( Kernel.CLI . format_error ( kind , reason , stack ) )
896899
897900 % {
898- file: file ,
901+ file: file || source ,
902+ source: source ,
899903 position: line || 0 ,
900904 message: message ,
901905 severity: :error ,
@@ -905,47 +909,47 @@ defmodule Kernel.ParallelCompiler do
905909 }
906910 end
907911
908- defp get_line_span (
912+ defp get_snippet_info (
909913 _file ,
910- % { line: line , column: column , end_line: end_line , end_column: end_column } ,
914+ % { file: file , line: line , column: column , end_line: end_line , end_column: end_column } ,
911915 _stack
912916 )
913917 when is_integer ( line ) and line > 0 and is_integer ( column ) and column >= 0 and
914918 is_integer ( end_line ) and end_line > 0 and is_integer ( end_column ) and end_column >= 0 do
915- { { line , column } , { end_line , end_column } }
919+ { Path . absname ( file ) , { line , column } , { end_line , end_column } }
916920 end
917921
918- defp get_line_span ( _file , % { line: line , column: column } , _stack )
922+ defp get_snippet_info ( _file , % { file: file , line: line , column: column } , _stack )
919923 when is_integer ( line ) and line > 0 and is_integer ( column ) and column >= 0 do
920- { { line , column } , nil }
924+ { Path . absname ( file ) , { line , column } , nil }
921925 end
922926
923- defp get_line_span ( _file , % { line: line } , _stack ) when is_integer ( line ) and line > 0 do
924- { line , nil }
927+ defp get_snippet_info ( _file , % { line: line } , _stack ) when is_integer ( line ) and line > 0 do
928+ { nil , line , nil }
925929 end
926930
927- defp get_line_span ( file , :undef , [ { _ , _ , _ , [ ] } , { _ , _ , _ , info } | _ ] ) do
928- get_line_span_from_stacktrace_info ( info , file )
931+ defp get_snippet_info ( file , :undef , [ { _ , _ , _ , [ ] } , { _ , _ , _ , info } | _ ] ) do
932+ get_snippet_info_from_stacktrace_info ( info , file )
929933 end
930934
931- defp get_line_span ( file , _reason , [ { _ , _ , _ , [ file: expanding ] } , { _ , _ , _ , info } | _ ] )
935+ defp get_snippet_info ( file , _reason , [ { _ , _ , _ , [ file: expanding ] } , { _ , _ , _ , info } | _ ] )
932936 when expanding in [ ~c" expanding macro" , ~c" expanding struct" ] do
933- get_line_span_from_stacktrace_info ( info , file )
937+ get_snippet_info_from_stacktrace_info ( info , file )
934938 end
935939
936- defp get_line_span ( file , _reason , [ { _ , _ , _ , info } | _ ] ) do
937- get_line_span_from_stacktrace_info ( info , file )
940+ defp get_snippet_info ( file , _reason , [ { _ , _ , _ , info } | _ ] ) do
941+ get_snippet_info_from_stacktrace_info ( info , file )
938942 end
939943
940- defp get_line_span ( _ , _ , _ ) do
941- { nil , nil }
944+ defp get_snippet_info ( _ , _ , _ ) do
945+ { nil , nil , nil }
942946 end
943947
944- defp get_line_span_from_stacktrace_info ( info , file ) do
948+ defp get_snippet_info_from_stacktrace_info ( info , file ) do
945949 if Keyword . get ( info , :file ) == to_charlist ( Path . relative_to_cwd ( file ) ) do
946- { Keyword . get ( info , :line ) , nil }
950+ { nil , Keyword . get ( info , :line ) , nil }
947951 else
948- { nil , nil }
952+ { nil , nil , nil }
949953 end
950954 end
951955end
0 commit comments