@@ -31,13 +31,20 @@ defmodule Mix.Task.Compiler do
3131 defmodule Diagnostic do
3232 @ moduledoc """
3333 Diagnostic information such as a warning or compilation error.
34+
35+ If there is a file and position, then the diagnostic is precise
36+ and you can use the given file and position for generating snippets,
37+ IDEs annotations, and so on.
38+
39+ Otherwise, a stacktrace may be given, which you can place your own
40+ heuristics to provide better reporting.
3441 """
3542
3643 @ type t :: % __MODULE__ {
37- file: Path . t ( ) ,
44+ file: Path . t ( ) | nil ,
3845 severity: severity ,
3946 message: IO . chardata ( ) ,
40- position: position ,
47+ position: Code . position ( ) ,
4148 compiler_name: String . t ( ) ,
4249 details: Exception . t ( ) | any ,
4350 stacktrace: Exception . stacktrace ( ) ,
@@ -61,21 +68,6 @@ defmodule Mix.Task.Compiler do
6168 """
6269 @ type severity :: :error | :warning | :information | :hint
6370
64- @ typedoc """
65- Where in a file the diagnostic applies. Can be either a line number,
66- a `{line, column}` tuple, a range specified as `{start_line, start_col,
67- end_line, end_col}`. `0` line represents unknown.
68-
69- Line numbers are one-based, and column numbers in a range are zero-based and refer
70- to the cursor position at the start of the character at that index. For example,
71- to indicate that a diagnostic applies to the first `n` characters of the
72- first line, the range would be `{1, 0, 1, n}`.
73- """
74- @ type position ::
75- non_neg_integer
76- | { pos_integer , non_neg_integer }
77- | { pos_integer , non_neg_integer , pos_integer , non_neg_integer }
78-
7971 @ enforce_keys [ :file , :severity , :message , :position , :compiler_name ]
8072 defstruct [
8173 :file ,
0 commit comments