@@ -640,7 +640,6 @@ map -> struct_op struct_expr eol map_args : {'%', meta_from_token('$1'), ['$2',
640640
641641Erlang code .
642642
643- -define (file (), get (elixir_parser_file )).
644643-define (columns (), get (elixir_parser_columns )).
645644-define (token_metadata (), get (elixir_token_metadata )).
646645
@@ -729,10 +728,12 @@ build_op(AST, {_Kind, Location, '//'}, Right) ->
729728
730729build_op ({UOp , _ , [Left ]}, {_Kind , {Line , Column , _ } = Location , 'in' }, Right ) when ? rearrange_uop (UOp ) ->
731730 % % TODO: Remove "not left in right" rearrangement on v2.0
732- elixir_errors :erl_warn ({Line , Column }, ? file (),
731+ warn (
732+ {Line , Column },
733733 " \" not expr1 in expr2\" is deprecated. "
734734 " Instead use \" expr1 not in expr2\" if you require Elixir v1.5+, "
735- " or \" not(expr1 in expr2)\" if you have to support earlier Elixir versions" ),
735+ " or \" not(expr1 in expr2)\" if you have to support earlier Elixir versions"
736+ ),
736737 Meta = meta_from_location (Location ),
737738 {UOp , Meta , [{'in' , Meta , [Left , Right ]}]};
738739
@@ -1169,21 +1170,22 @@ error_invalid_kw_identifier({_, Location, KW}) ->
11691170
11701171% % TODO: Make this an error on v2.0
11711172warn_trailing_comma ({',' , {Line , Column , _ }}) ->
1172- elixir_errors :erl_warn ({Line , Column }, ? file (),
1173- " trailing commas are not allowed inside function/macro call arguments"
1174- ).
1173+ warn ({Line , Column }, " trailing commas are not allowed inside function/macro call arguments" ).
11751174
11761175% % TODO: Make this an error on v2.0
11771176warn_empty_paren ({_ , {Line , Column , _ }}) ->
1178- elixir_errors :erl_warn ({Line , Column }, ? file (),
1177+ warn (
1178+ {Line , Column },
11791179 " invalid expression (). "
11801180 " If you want to invoke or define a function, make sure there are "
11811181 " no spaces between the function name and its arguments. If you wanted "
1182- " to pass an empty block or code, pass a value instead, such as a nil or an atom" ).
1182+ " to pass an empty block or code, pass a value instead, such as a nil or an atom"
1183+ ).
11831184
11841185% % TODO: Make this an error on v2.0
11851186warn_pipe ({arrow_op , {Line , Column , _ }, Op }, {_ , [_ | _ ], [_ | _ ]}) ->
1186- elixir_errors :erl_warn ({Line , Column }, ? file (),
1187+ warn (
1188+ {Line , Column },
11871189 io_lib :format (
11881190 " parentheses are required when piping into a function call. For example:\n\n "
11891191 " foo 1 ~ts bar 2 ~ts baz 3\n\n "
@@ -1197,6 +1199,14 @@ warn_pipe(_Token, _) ->
11971199 ok .
11981200
11991201warn_empty_stab_clause ({stab_op , {Line , Column , _ }, '->' }) ->
1200- elixir_errors :erl_warn ({Line , Column }, ? file (),
1202+ warn (
1203+ {Line , Column },
12011204 " an expression is always required on the right side of ->. "
1202- " Please provide a value after ->" ).
1205+ " Please provide a value after ->"
1206+ ).
1207+
1208+ warn (LineColumn , Message ) ->
1209+ case get (elixir_parser_warning_file ) of
1210+ nil -> ok ;
1211+ File -> elixir_errors :erl_warn (LineColumn , File , Message )
1212+ end .
0 commit comments