File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,7 @@ export let findCodeActionsInDiagnosticsMessage = ({
30
30
addUndefinedRecordFields ,
31
31
simpleConversion ,
32
32
topLevelUnitType ,
33
+ applyUncurried ,
33
34
] ;
34
35
35
36
for ( let action of actions ) {
@@ -294,6 +295,58 @@ let simpleConversion: codeActionExtractor = ({
294
295
return false ;
295
296
} ;
296
297
298
+ let applyUncurried : codeActionExtractor = ( {
299
+ line,
300
+ codeActions,
301
+ file,
302
+ range,
303
+ diagnostic,
304
+ } ) => {
305
+ if (
306
+ line . startsWith (
307
+ "This is an uncurried ReScript function. It must be applied with a dot."
308
+ )
309
+ ) {
310
+ const locOfOpenFnParens = {
311
+ line : range . end . line ,
312
+ character : range . end . character + 1 ,
313
+ } ;
314
+
315
+ codeActions [ file ] = codeActions [ file ] || [ ] ;
316
+ let codeAction : p . CodeAction = {
317
+ title : `Apply uncurried function call with dot` ,
318
+ edit : {
319
+ changes : {
320
+ [ file ] : [
321
+ {
322
+ range : {
323
+ start : locOfOpenFnParens ,
324
+ end : locOfOpenFnParens ,
325
+ } ,
326
+ /*
327
+ * Turns `fn(123)` into `fn(. 123)`.
328
+ */
329
+ newText : `. ` ,
330
+ } ,
331
+ ] ,
332
+ } ,
333
+ } ,
334
+ diagnostics : [ diagnostic ] ,
335
+ kind : p . CodeActionKind . QuickFix ,
336
+ isPreferred : true ,
337
+ } ;
338
+
339
+ codeActions [ file ] . push ( {
340
+ range,
341
+ codeAction,
342
+ } ) ;
343
+
344
+ return true ;
345
+ }
346
+
347
+ return false ;
348
+ } ;
349
+
297
350
let topLevelUnitType : codeActionExtractor = ( {
298
351
line,
299
352
codeActions,
You can’t perform that action at this time.
0 commit comments