@@ -133,6 +133,9 @@ interface codeActionExtractorConfig {
133
133
134
134
type codeActionExtractor = ( config : codeActionExtractorConfig ) => boolean ;
135
135
136
+ // This action extracts hints the compiler emits for misspelled identifiers, and
137
+ // offers to replace the misspelled name with the correct name suggested by the
138
+ // compiler.
136
139
let didYouMeanAction : codeActionExtractor = ( {
137
140
codeActions,
138
141
diagnostic,
@@ -176,6 +179,10 @@ let didYouMeanAction: codeActionExtractor = ({
176
179
return false ;
177
180
} ;
178
181
182
+ // This action handles when the compiler errors on certain fields of a record
183
+ // being undefined. We then offers an action that inserts all of the record
184
+ // fields, with an `assert false` dummy value. `assert false` is so applying the
185
+ // code action actually compiles.
179
186
let addUndefinedRecordFields : codeActionExtractor = ( {
180
187
array,
181
188
codeActions,
@@ -281,6 +288,8 @@ let addUndefinedRecordFields: codeActionExtractor = ({
281
288
return false ;
282
289
} ;
283
290
291
+ // This action detects suggestions of converting between mismatches in types
292
+ // that the compiler tells us about.
284
293
let simpleConversion : codeActionExtractor = ( {
285
294
line,
286
295
codeActions,
@@ -325,6 +334,8 @@ let simpleConversion: codeActionExtractor = ({
325
334
return false ;
326
335
} ;
327
336
337
+ // This action will apply a curried function (essentially inserting a dot in the
338
+ // correct place).
328
339
let applyUncurried : codeActionExtractor = ( {
329
340
line,
330
341
codeActions,
@@ -377,6 +388,9 @@ let applyUncurried: codeActionExtractor = ({
377
388
return false ;
378
389
} ;
379
390
391
+ // This action detects the compiler erroring when it finds a top level value
392
+ // that's not `unit`, and offers to wrap that value in `ignore`, which will make
393
+ // it compile.
380
394
let topLevelUnitType : codeActionExtractor = ( {
381
395
line,
382
396
codeActions,
@@ -449,6 +463,12 @@ let transformVariant = (variant: string): string | null => {
449
463
return text ;
450
464
} ;
451
465
466
+ // This action detects missing cases for exhaustive pattern matches, and offers
467
+ // to insert dummy branches (using `assert false`) for those branches. Right now
468
+ // it works on single variants/polyvariants with and without payloads. In the
469
+ // future it could be made to work on anything the compiler tell us about, but
470
+ // the compiler needs to emit proper ReScript in the error messages for that to
471
+ // work.
452
472
let simpleAddMissingCases : codeActionExtractor = ( {
453
473
line,
454
474
codeActions,
@@ -548,6 +568,9 @@ let simpleAddMissingCases: codeActionExtractor = ({
548
568
return false ;
549
569
} ;
550
570
571
+ // This detects concrete variables or values put in a position which expects an
572
+ // optional of that same type, and offers to wrap the value/variable in
573
+ // `Some()`.
551
574
let simpleWrapOptionalWithSome : codeActionExtractor = ( {
552
575
line,
553
576
codeActions,
@@ -609,6 +632,8 @@ let simpleWrapOptionalWithSome: codeActionExtractor = ({
609
632
return false ;
610
633
} ;
611
634
635
+ // This detects when an optional is passed into a non optional slot, and offers
636
+ // to insert a switch for unwrapping that optional.
612
637
let simpleUnwrapOptional : codeActionExtractor = ( {
613
638
line,
614
639
codeActions,
0 commit comments