@@ -3,26 +3,14 @@ defmodule Kernel.ParallelCompiler do
33 A module responsible for compiling and requiring files in parallel.
44 """
55
6- @ typedoc "The line. 0 indicates no line."
7- @ type line ( ) :: non_neg_integer ( )
8- @ type position ( ) :: line ( ) | { pos_integer ( ) , column :: non_neg_integer }
9-
10- @ type diagnostic ( severity ) :: % {
11- file: Path . t ( ) ,
12- severity: severity ,
13- message: String . t ( ) ,
14- position: position ,
15- stacktrace: Exception . stacktrace ( )
16- }
17-
186 @ type info :: % {
19- runtime_warnings: [ diagnostic ( :warning ) ] ,
20- compile_warnings: [ diagnostic ( :warning ) ]
7+ runtime_warnings: [ Code . diagnostic ( :warning ) ] ,
8+ compile_warnings: [ Code . diagnostic ( :warning ) ]
219 }
2210
2311 # Deprecated types
24- @ type warning ( ) :: { file :: Path . t ( ) , position ( ) , message :: String . t ( ) }
25- @ type error ( ) :: { file :: Path . t ( ) , position ( ) , message :: String . t ( ) }
12+ @ type warning ( ) :: { file :: Path . t ( ) , Code . position ( ) , message :: String . t ( ) }
13+ @ type error ( ) :: { file :: Path . t ( ) , Code . position ( ) , message :: String . t ( ) }
2614
2715 @ doc """
2816 Starts a task for parallel compilation.
@@ -71,7 +59,7 @@ defmodule Kernel.ParallelCompiler do
7159 resolved.
7260
7361 It returns `{:ok, modules, warnings}` or `{:error, errors, warnings}`
74- by default but we recommend using `return_maps : true` so it returns
62+ by default but we recommend using `return_diagnostics : true` so it returns
7563 diagnostics as maps as well as a map of compilation information.
7664 The map has the shape of:
7765
@@ -115,14 +103,14 @@ defmodule Kernel.ParallelCompiler do
115103
116104 * `:beam_timestamp` - the modification timestamp to give all BEAM files
117105
118- * `:return_maps ` (since v1.15.0) - returns maps with information instead of
106+ * `:return_diagnostics ` (since v1.15.0) - returns maps with information instead of
119107 a list of warnings and returns diagnostics as maps instead of tuples
120108
121109 """
122110 @ doc since: "1.6.0"
123111 @ spec compile ( [ Path . t ( ) ] , keyword ( ) ) ::
124112 { :ok , [ atom ] , [ warning ] | info ( ) }
125- | { :error , [ error ] | [ diagnostic ( :error ) ] , [ warning ] | info ( ) }
113+ | { :error , [ error ] | [ Code . diagnostic ( :error ) ] , [ warning ] | info ( ) }
126114 def compile ( files , options \\ [ ] ) when is_list ( options ) do
127115 spawn_workers ( files , :compile , options )
128116 end
@@ -135,7 +123,7 @@ defmodule Kernel.ParallelCompiler do
135123 @ doc since: "1.6.0"
136124 @ spec compile_to_path ( [ Path . t ( ) ] , Path . t ( ) , keyword ( ) ) ::
137125 { :ok , [ atom ] , [ warning ] | info ( ) }
138- | { :error , [ error ] | [ diagnostic ( :error ) ] , [ warning ] | info ( ) }
126+ | { :error , [ error ] | [ Code . diagnostic ( :error ) ] , [ warning ] | info ( ) }
139127 def compile_to_path ( files , path , options \\ [ ] ) when is_binary ( path ) and is_list ( options ) do
140128 spawn_workers ( files , { :compile , path } , options )
141129 end
@@ -147,7 +135,7 @@ defmodule Kernel.ParallelCompiler do
147135 automatically solved between files.
148136
149137 It returns `{:ok, modules, warnings}` or `{:error, errors, warnings}`
150- by default but we recommend using `return_maps : true` so it returns
138+ by default but we recommend using `return_diagnostics : true` so it returns
151139 diagnostics as maps as well as a map of compilation information.
152140 The map has the shape of:
153141
@@ -172,14 +160,6 @@ defmodule Kernel.ParallelCompiler do
172160 spawn_workers ( files , :require , options )
173161 end
174162
175- @ doc """
176- Prints a diagnostic returned by the compiler into stderr.
177- """
178- @ doc since: "1.15.0"
179- def print_diagnostic ( diagnostic ) do
180- :elixir_errors . print_diagnostic ( diagnostic )
181- end
182-
183163 @ doc false
184164 # TODO: Deprecate me on Elixir v1.19
185165 def print_warning ( { file , location , warning } ) do
@@ -239,7 +219,7 @@ defmodule Kernel.ParallelCompiler do
239219 end
240220
241221 # TODO: Require this to be set from Elixir v1.19
242- if Keyword . get ( options , :return_maps , false ) do
222+ if Keyword . get ( options , :return_diagnostics , false ) do
243223 { status , modules_or_errors , info }
244224 else
245225 to_tuples = & Enum . map ( & 1 , fn diag -> { diag . file , diag . position , diag . message } end )
0 commit comments