-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathCompletionDecorators.ml
295 lines (248 loc) · 14.2 KB
/
CompletionDecorators.ml
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
let local =
[
( "as",
Some "as(\"$0\")",
[
{|The `@as` decorator is commonly used on record types to alias record field names to a different JavaScript attribute name.
This is useful to map to JavaScript attribute names that cannot be expressed in ReScript (such as keywords).
It is also possible to map a ReScript record to a JavaScript array by passing indices to the `@as` decorator.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#as-decorator).|};
] );
( "dead",
None,
[
{|The `@dead` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis.
`@dead` suppresses reporting on the value/type, but can also be used to force the analysis to consider a value as dead. Typically used to acknowledge cases of dead code you are not planning to address right now, but can be searched easily later.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#dead-decorator).
> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|};
] );
( "deriving",
Some "deriving($0)",
[
{|When the `@deriving` decorator is applied to a record type, it expands the type into a factory function plus a set of getter/setter functions for its fields.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#deriving-decorator).|};
] );
( "deprecated",
Some "deprecated(\"$0\")",
[
{|The `@deprecated` decorator is used to add deprecation notes to types, values and submodules. The compiler and editor tooling will yield a warning whenever a deprecated entity is being used.
Alternatively, use the `@@deprecated` decorator to add a deprecation warning to the file level.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#expression-deprecated-decorator).|};
] );
( "doesNotRaise",
None,
[
{|The `@doesNotRaise` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis.
`@doesNotRaise` is uses to override the analysis and state that an expression does not raise any exceptions,
even though the analysis reports otherwise. This can happen for example in the case of array access where
the analysis does not perform range checks but takes a conservative stance that any access
could potentially raise.
[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md).
> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|};
] );
( "genType",
None,
[
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#gentype-decorator).|};
] );
( "genType.as",
Some "genType.as(\"$0\")",
[
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems.
[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|};
] );
( "genType.import",
None,
[
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems.
[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|};
] );
( "genType.opaque",
None,
[
{|The @genType decorator may be used to export ReScript values and types to JavaScript, and import JavaScript values and types into ReScript. It allows seamless integration of compiled ReScript modules in existing TypeScript, Flow, or plain JavaScript codebases, without loosing type information across different type systems.
[Read more and see examples in the documentation](https://rescript-lang.org/docs/gentype/latest/usage).|};
] );
( "get",
None,
[
{|The `@get` decorator is used to bind to a property of an object.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-decorator).|};
] );
( "get_index",
None,
[
{|The `@get_index` decorator is used to access a dynamic property on an object, or an index of an array.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#get-index-decorator).|};
] );
( "inline",
None,
[
{|The `@inline` decorator tells the compiler to inline its value in every place the binding is being used, rather than use a variable.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#inline-decorator).|};
] );
( "int",
None,
[
{|The `@int` decorator can be used with polymorphic variants and the @as decorator on externals to modify the compiled JavaScript to use integers for the values instead of strings.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#int-decorator).|};
] );
( "live",
None,
[
{|The `@live` decorator is for reanalyze, a static analysis tool for ReScript that can do dead code analysis.
`@live` tells the dead code analysis that the value should be considered live, even though it might appear to be dead. This is typically used in case of FFI where there are indirect ways to access values. It can be added to everything that could otherwise be considered unused by the dead code analysis - values, functions, arguments, records, individual record fields, and so on.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#live-decorator).
Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|};
] );
( "meth",
None,
[
{|The `@meth` decorator is used to call a function on a JavaScript object, and avoid issues with currying.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#meth-decorator).|};
] );
( "module",
Some "module(\"$0\")",
[
{|The `@module` decorator is used to bind to a JavaScript module.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-decorator).|};
] );
( "new",
None,
[
{|
The `@new` decorator is used whenever you need to bind to a JavaScript class constructor that requires the new keword for instantiation.|
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#new-decorator).|};
] );
( "obj",
None,
[
{|The `@obj` decorator is used to create functions that return JavaScript objects with properties that match the function's parameter labels.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#obj-decorator).|};
] );
( "raises",
Some "raises(\"$0\")",
[
{|The `@raises` decorator is for reanalyze, a static analysis tool for ReScript that can perform exception analysis.
`@raises` acknowledges that a function can raise exceptions that are not caught, and suppresses
a warning in that case. Callers of the functions are then subjected to the same rule.
Example `@raises(Exn)` or `@raises([E1, E2, E3])` for multiple exceptions.
[Read more and see examples in the documentation](https://github.com/rescript-association/reanalyze/blob/master/EXCEPTION.md).
> Hint: Did you know you can run an interactive code analysis in your project by running the command `> ReScript: Start Code Analyzer`? Try it!|};
] );
( "react.component",
None,
[
{|The `@react.component` decorator is used to annotate functions that are RescriptReact components.
You will need this decorator whenever you want to use a ReScript / React component in ReScript JSX expressions.
Note: The `@react.component` decorator requires the `jsx` config to be set in your `rescript.json`/`bsconfig.json` to enable the required React transformations.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#react-component-decorator).|};
] );
( "jsx.component",
None,
[
{|The `@jsx.component` decorator is used to annotate functions that are JSX components used with ReScript's [generic JSX transform](https://rescript-lang.org/docs/manual/latest/jsx#generic-jsx-transform-jsx-beyond-react-experimental).
You will need this decorator whenever you want to use a JSX component in ReScript JSX expressions.|};
] );
( "return",
Some "return(${1:nullable})",
[
{|The `@return` decorator is used to control how `null` and `undefined` values are converted to option types in ReScript.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#return-decorator).|};
] );
( "scope",
Some "scope(\"$0\")",
[
{|The `@scope` decorator is used with other decorators such as `@val` and `@module` to declare a parent scope for the binding.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#scope-decorator).|};
] );
( "send",
None,
[
{|The `@send` decorator is used to bind to a method on an object or array.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#send-decorator).|};
] );
( "set",
None,
[
{|The `@set` decorator is used to set a property of an object.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-decorator).|};
] );
( "set_index",
None,
[
{|The `@set_index` decorator is used to set a dynamic property on an object, or an index of an array.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#set-index-decorator).|};
] );
( "string",
None,
[
{|The `@string` decorator can be used with polymorphic variants and the `@as` decorator on externals to modify the string values used for the variants in the compiled JavaScript.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#string-decorator).|};
] );
( "this",
None,
[
{|The `@this` decorator may be used to bind to an external callback function that require access to a this context.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#this-decorator).|};
] );
( "unboxed",
None,
[
{|The `@unboxed` decorator provides a way to unwrap variant constructors that have a single argument, or record objects that have a single field.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unboxed-decorator).|};
] );
( "uncurry",
None,
[
{|The `@uncurry` decorator can be used to mark any callback argument within an external function as an uncurried function without the need for any explicit uncurried function syntax (`(.) => { ... }`).
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#uncurry-decorator).|};
] );
( "unwrap",
None,
[
{|The `@unwrap` decorator may be used when binding to external functions that accept multiple types for an argument.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#unwrap-decorator).|};
] );
( "val",
None,
[
{|The `@val` decorator allows you to bind to JavaScript values that are on the global scope.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#val-decorator).|};
] );
( "variadic",
None,
[
{|The `@variadic` decorator is used to model JavaScript functions that take a variable number of arguments, where all arguments are of the same type.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#variadic-decorator).|};
] );
]
let toplevel =
[
( "deprecated",
Some "deprecated(\"$0\")",
[
{|The `@@deprecated` decorator is used to add a deprecation note to the file-level of a module. The compiler and editor tooling will yield a warning whenever a deprecated file module is being used.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-deprecated-decorator).|};
] );
( "directive",
Some "directive(\"$0\")",
[
{|The `@@directive` decorator will output that string verbatim at the very top of the generated JavaScript file, before any imports.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#directive-decorator).|};
] );
( "warning",
Some "warning(\"$0\")",
[
{|The `@@warning` decorator is used to modify the enabled compiler warnings for the current module. See here for all available warning numbers.
[Read more and see examples in the documentation](https://rescript-lang.org/syntax-lookup#module-warning-decorator).
|};
] );
( "jsxConfig",
Some "jsxConfig({$0})",
[
{|The `@@jsxConfig` decorator is used to change the config for JSX on the fly.
[Read more and see examples in the documentation](https://rescript-lang.org/docs/manual/latest/jsx#file-level-configuration).|};
] );
]