2 * Copyright (c) Facebook, Inc. and its affiliates.
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the "hack" directory of this source tree.
10 module SN
= Naming_special_names
12 (* TODO: generalize the arity check / argument check here to handle attributes
13 * in general, not just __Deprecated *)
14 let deprecated ~kind
(_
, name
) attrs
=
15 let attr = Naming_attributes.find
SN.UserAttributes.uaDeprecated attrs
in
18 | Some
{ ua_name
= _
; ua_params
= [msg
] }
19 | Some
{ ua_name
= _
; ua_params
= [msg
; _
] } ->
21 match Nast_eval.static_string msg
with
23 let name = Utils.strip_ns
name in
24 let deprecated_prefix =
25 Printf.sprintf
"The %s %s is deprecated: " kind
name
27 Some
(deprecated_prefix ^ msg
)
29 Errors.attribute_param_type p
"static string literal";
32 | Some
{ ua_name
= (pos
, _
); ua_params
= [] } ->
33 Errors.attribute_too_few_arguments pos
SN.UserAttributes.uaDeprecated
1;
35 | Some
{ ua_name
= (pos
, _
); ua_params
= _
} ->
36 Errors.attribute_too_many_arguments pos
SN.UserAttributes.uaDeprecated
2;