@@ -30,17 +30,35 @@ fun_to_quoted(Function) ->
3030
3131% % has_unquotes
3232
33- has_unquotes ({unquote , _ , [_ ]}) -> true ;
34- has_unquotes ({unquote_splicing , _ , [_ ]}) -> true ;
35- has_unquotes ({{'.' , _ , [_ , unquote ]}, _ , [_ ]}) -> true ;
36- has_unquotes ({Var , _ , Ctx }) when is_atom (Var ), is_atom (Ctx ) -> false ;
37- has_unquotes ({Name , _ , Args }) when is_list (Args ) ->
38- has_unquotes (Name ) orelse lists :any (fun has_unquotes /1 , Args );
39- has_unquotes ({Left , Right }) ->
40- has_unquotes (Left ) orelse has_unquotes (Right );
41- has_unquotes (List ) when is_list (List ) ->
42- lists :any (fun has_unquotes /1 , List );
43- has_unquotes (_Other ) -> false .
33+ has_unquotes (Ast ) -> has_unquotes (Ast , 0 ).
34+
35+ has_unquotes ({quote , _ , [Child ]}, QuoteLevel ) ->
36+ has_unquotes (Child , QuoteLevel + 1 );
37+ has_unquotes ({quote , _ , [QuoteOpts , Child ]}, QuoteLevel ) ->
38+ case disables_unquote (QuoteOpts ) of
39+ true -> false ;
40+ _ -> has_unquotes (Child , QuoteLevel + 1 )
41+ end ;
42+ has_unquotes ({Unquote , _ , [Child ]}, QuoteLevel )
43+ when Unquote == unquote ; Unquote == unquote_splicing ->
44+ case QuoteLevel of
45+ 0 -> true ;
46+ _ -> has_unquotes (Child , QuoteLevel - 1 )
47+ end ;
48+ has_unquotes ({{'.' , _ , [_ , unquote ]}, _ , [_ ]}, _ ) -> true ;
49+ has_unquotes ({Var , _ , Ctx }, _ ) when is_atom (Var ), is_atom (Ctx ) -> false ;
50+ has_unquotes ({Name , _ , Args }, QuoteLevel ) when is_list (Args ) ->
51+ has_unquotes (Name ) orelse lists :any (fun (Child ) -> has_unquotes (Child , QuoteLevel ) end , Args );
52+ has_unquotes ({Left , Right }, QuoteLevel ) ->
53+ has_unquotes (Left , QuoteLevel ) orelse has_unquotes (Right , QuoteLevel );
54+ has_unquotes (List , QuoteLevel ) when is_list (List ) ->
55+ lists :any (fun (Child ) -> has_unquotes (Child , QuoteLevel ) end , List );
56+ has_unquotes (_Other , _ ) -> false .
57+
58+ disables_unquote ([{unquote , false } | _ ]) -> true ;
59+ disables_unquote ([{bind_quoted , _ } | _ ]) -> true ;
60+ disables_unquote ([_H | T ]) -> disables_unquote (T );
61+ disables_unquote (_ ) -> false .
4462
4563% % Apply the line from site call on quoted contents.
4664% % Receives a Key to look for the default line as argument.
0 commit comments