FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
hack-codegen/src/CodegenFactoryTrait.hack at main · hhvm/hack-codegen · GitHub
This repository was archived by the owner on Aug 25, 2025. It is now read-only.
hhvm
/
hack-codegen
Public archive
Notifications
You must be signed in to change notification settings
Fork
92
Star
348
Code
Issues
5
Pull requests
2
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
hack-codegen
/
src
/
CodegenFactoryTrait.hack
Copy path
More file actions
More file actions
Latest commit
History
History
History
243 lines (204 loc) · 6.94 KB
Breadcrumbs
hack-codegen
/
src
/
CodegenFactoryTrait.hack
Copy path
File metadata and controls
243 lines (204 loc) · 6.94 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
/*
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
*/
namespace
Facebook\HackCodegen
;
use
namespace HH\Lib\{C
,
Str
,
Vec}
;
/**
* Trait to implement `ICodegenFactory` if no special behavior is provided.
*
* You must implement `getConfig()`, but all other methods are final.
*/
trait
CodegenFactoryTrait
implements
ICodegenFactory
{
/*
* @selfdocumenting
*/
public
abstract
function
getConfig
():
IHackCodegenConfig
;
final
public
function
codegenConstructor
():
CodegenConstructor
{
return
new
CodegenConstructor
(
$this
->
getConfig());
}
final
public
function
codegenConstant
(
string
$name
):
CodegenConstant
{
return
new
CodegenConstant
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenConstantf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenConstant
{
return
new
CodegenConstant
(
$this
->
getConfig(), \
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenClassConstant
(
string
$name
,
):
CodegenClassConstant
{
return
new
CodegenClassConstant
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenClassConstantf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenClassConstant
{
return
new
CodegenClassConstant
(
$this
->
getConfig(), \
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenEnumMember
(
string
$name
):
CodegenEnumMember
{
return
new
CodegenEnumMember
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenEnumMemberf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenEnumMember
{
return
new
CodegenEnumMember
(
$this
->
getConfig(), \
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenTypeConstant
(
string
$name
):
CodegenTypeConstant
{
return
new
CodegenTypeConstant
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenTypeConstantf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenTypeConstant
{
return
new
CodegenTypeConstant
(
$this
->
getConfig(), \
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenFile
(
string
$file
):
CodegenFile
{
return
new
CodegenFile
(
$this
->
getConfig(),
$file
);
}
final
public
function
codegenFilef
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenFile
{
return
$this
->
codegenFile(\
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenFunction
(
string
$name
):
CodegenFunction
{
return
new
CodegenFunction
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenFunctionf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenFunction
{
return
$this
->
codegenFunction(\
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenClass
(
string
$name
):
CodegenClass
{
return
new
CodegenClass
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenClassf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenClass
{
return
$this
->
codegenClass(\
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenEnum
(
string
$name
,
string
$enumType
,
):
CodegenEnum
{
return
new
CodegenEnum
(
$this
->
getConfig(),
$name
,
$enumType
);
}
final
public
function
codegenInterface
(
string
$name
):
CodegenInterface
{
return
new
CodegenInterface
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenTrait
(
string
$name
):
CodegenTrait
{
return
new
CodegenTrait
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenMethod
(
string
$name
):
CodegenMethod
{
return
new
CodegenMethod
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenMethodf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenMethod
{
return
$this
->
codegenMethod(\
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenHackBuilder
():
HackBuilder
{
return
new
HackBuilder
(
$this
->
getConfig());
}
final
public
function
codegenImplementsInterface
(
string
$name
,
):
CodegenImplementsInterface
{
return
new
CodegenImplementsInterface
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenImplementsInterfaces
(
Traversable
<
string
>
$names
,
):
vec
<
CodegenImplementsInterface
> {
return
Vec
\
map
(
$names
,
$name
==>
$this
->
codegenImplementsInterface(
$name
));
}
final
public
function
codegenProperty
(
string
$name
):
CodegenProperty
{
return
new
CodegenProperty
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenPropertyf
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenProperty
{
return
$this
->
codegenProperty(\
vsprintf
(
$format
,
$args
));
}
final
public
function
codegenUsesTrait
(
string
$name
):
CodegenUsesTrait
{
return
new
CodegenUsesTrait
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenUsesTraits
(
Traversable
<
string
>
$names
,
):
vec
<
CodegenUsesTrait
> {
return
Vec
\
map
(
$names
,
$x
==>
$this
->
codegenUsesTrait(
$x
));
}
final
public
function
codegenGeneratedFromClass
(
string
$class
,
):
CodegenGeneratedFrom
{
return
new
CodegenGeneratedFrom
(
$this
->
getConfig(),
'
Generated from
'
.
$class
);
}
final
public
function
codegenGeneratedFromMethod
(
string
$class
,
string
$method
,
):
CodegenGeneratedFrom
{
return
new
CodegenGeneratedFrom
(
$this
->
getConfig(),
'
Generated from
'
.
$class
.
'
::
'
.
$method
.
'
()
'
,
);
}
final
public
function
codegenGeneratedFromMethodWithKey
(
string
$class
,
string
$method
,
string
$key
,
):
CodegenGeneratedFrom
{
return
new
CodegenGeneratedFrom
(
$this
->
getConfig(),
'
Generated from
'
.
$class
.
'
::
'
.
$method
.
"
()['
"
.
$key
.
"
']
"
,
);
}
final
public
function
codegenGeneratedFromScript
(
?
string
$script
=
null
,
):
CodegenGeneratedFrom
{
if
(
$script
===
null
) {
$last
=
\
debug_backtrace
()
|>
Vec
\
filter
($$,
$frame
==>
C
\
contains_key
(
$frame
,
'
file
'
))
|>
C
\
last
($$);
invariant
(
$last
!==
null
,
"
Couldn't get the strack trace. Please pass the script name to
"
.
'
codegenGeneratedFromScript
'
,
);
$script
=
$this
->
codegenFile(
$last
[
'
file
'
])
->
getRelativeFileName();
}
return
new
CodegenGeneratedFrom
(
$this
->
getConfig(),
'
To re-generate this file run
'
.
$script
,
);
}
final
public
function
codegenShape
(
CodegenShapeMember
...
$members
):
CodegenShape
{
return
new
CodegenShape
(
$this
->
getConfig(),
vec
(
$members
));
}
final
public
function
codegenType
(
string
$name
):
CodegenType
{
return
new
CodegenType
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenNewtype
(
string
$name
):
CodegenType
{
return
(
new
CodegenType
(
$this
->
getConfig(),
$name
))
->
newType();
}
final
public
function
codegenXHPAttribute
(
string
$name
):
CodegenXHPAttribute
{
return
new
CodegenXHPAttribute
(
$this
->
getConfig(),
$name
);
}
final
public
function
codegenXHPAttributef
(
Str
\
SprintfFormatString
$format
,
mixed
...
$args
):
CodegenXHPAttribute
{
return
$this
->
codegenXHPAttribute(\
vsprintf
(
$format
,
$args
));
}
}
Back
|
FazBrowse Home
|
New Git URL