2 * Copyright (c) 2015, Facebook, Inc.
5 * This source code is licensed under the MIT license found in the
6 * LICENSE file in the "hack" directory of this source tree.
41 pos
: 'a
Pos.pos
; (* covers the span of just the identifier *)
42 span
: 'a
Pos.pos
; (* covers the span of the entire construct, including children *)
43 modifiers
: modifier list
;
44 children
: 'a t list
option;
45 params
: 'a t list
option;
46 docblock
: string option;
49 let rec to_absolute x
= {
52 full_name
= x
.full_name
;
54 pos
= Pos.to_absolute x
.pos
;
55 span
= Pos.to_absolute x
.span
;
56 modifiers
= x
.modifiers
;
57 children
= Option.map x
.children
(fun x
-> List.map x
to_absolute);
58 params
= Option.map x
.params
(fun x
-> List.map x
to_absolute);
59 docblock
= x
.docblock
;
62 let string_of_kind = function
63 | Function
-> "function"
66 | Property
-> "property"
69 | Interface
-> "interface"
71 | Typeconst
-> "typeconst"
74 | Typedef
-> "typedef"
76 let string_of_modifier = function
79 | Abstract
-> "abstract"
80 | Private
-> "private"
82 | Protected
-> "protected"
86 let function_kind_name = "function"
87 let type_id_kind_name = "type_id"
88 let method_kind_name = "method"
89 let property_kind_name = "property"
90 let class_const_kind_name = "class_const"
92 let get_symbol_id kind parent_class name
=
93 let prefix = match kind
with
94 | Function
-> Some
function_kind_name
95 | Class
| Typedef
| Enum
| Interface
| Trait
-> Some
type_id_kind_name
96 | Method
-> Some
method_kind_name
97 | Property
-> Some
property_kind_name
98 | Typeconst
| Const
-> Some
class_const_kind_name
99 | LocalVar
| Param
-> None
101 match prefix, parent_class
with
102 | Some
prefix, Some parent_class
->
103 Some
(Printf.sprintf
"%s::%s::%s" prefix parent_class name
)
104 | Some
prefix, None
->
105 Some
(Printf.sprintf
"%s::%s" prefix name
)