From 706128fd3a894cde5683d0d287afb76823e2af20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=B6m=C3=B6ri?= Date: Fri, 26 Nov 2021 12:09:00 +0100 Subject: [PATCH] Improve error_info() type `erlfmt_scan` returns `erl_anno:location()` in errors however `erlfmt_parse` mostly returns full `erlfmt_scan:anno()` maps. The errors from the parser also surface in the return value of `erlfmt:read_nodes[_string]` --- src/erlfmt.erl | 4 +++- src/erlfmt_parse.yrl | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/erlfmt.erl b/src/erlfmt.erl index 0569471..1b3b590 100644 --- a/src/erlfmt.erl +++ b/src/erlfmt.erl @@ -34,7 +34,9 @@ -export_type([error_info/0, config_option/0, config/0, pragma/0]). --type error_info() :: {file:name_all(), erl_anno:location(), module(), Reason :: any()}. +-type error_info() :: { + file:name_all(), erl_anno:location() | erlfmt_scan:anno(), module(), Reason :: any() +}. -type pragma() :: require | insert | delete | ignore. -type config_option() :: {pragma, pragma()} | {print_width, pos_integer()} | verbose. -type config() :: [config_option()]. diff --git a/src/erlfmt_parse.yrl b/src/erlfmt_parse.yrl index 8afc35b..61c302e 100644 --- a/src/erlfmt_parse.yrl +++ b/src/erlfmt_parse.yrl @@ -1034,7 +1034,7 @@ Erlang code. %% XXX. To be refined. -type error_description() :: term(). --type error_info() :: {erl_anno:line(), module(), error_description()}. +-type error_info() :: {erl_anno:location() | erlfmt_scan:anno(), module(), error_description()}. -type token() :: erlfmt_scan:token(). %% mkop(Op, Arg) -> {op,Anno,Op,Arg}.