@@ -87,7 +87,7 @@ descriptor plId = (defaultPluginDescriptor plId)
87
87
{ pluginRules = rules
88
88
, pluginCommands =
89
89
[ PluginCommand " applyOne" " Apply a single hint" applyOneCmd
90
- -- , PluginCommand "applyAll" "Apply all hints to the file" applyAllCmd
90
+ , PluginCommand " applyAll" " Apply all hints to the file" applyAllCmd
91
91
]
92
92
, pluginCodeActionProvider = Just codeActionProvider
93
93
}
@@ -251,6 +251,21 @@ codeActionProvider _ _ plId docId _ context = (Right . LSP.List . map CACodeActi
251
251
252
252
-- ---------------------------------------------------------------------
253
253
254
+ applyAllCmd :: CommandFunction Uri
255
+ applyAllCmd _lf ide uri = do
256
+ let file = maybe (error $ show uri ++ " is not a file" )
257
+ toNormalizedFilePath'
258
+ (uriToFilePath' uri)
259
+ logm $ " applyAllCmd:file=" ++ show file
260
+ res <- applyHint ide file Nothing
261
+ logm $ " applyAllCmd:res=" ++ show res
262
+ return $
263
+ case res of
264
+ Left err -> (Left (responseError (T. pack $ " applyAll: " ++ show err)), Nothing )
265
+ Right fs -> (Right Null , Just (WorkspaceApplyEdit , ApplyWorkspaceEditParams fs))
266
+
267
+ -- ---------------------------------------------------------------------
268
+
254
269
data ApplyOneParams = AOP
255
270
{ file :: Uri
256
271
, start_pos :: Position
@@ -288,7 +303,7 @@ applyHint ide nfp mhint =
288
303
-- set Nothing as "position" for "applyRefactorings" because
289
304
-- applyRefactorings expects the provided position to be _within_ the scope
290
305
-- of each refactoring it will apply.
291
- -- But "Idea"s returned by HLint pont to starting position of the expressions
306
+ -- But "Idea"s returned by HLint point to starting position of the expressions
292
307
-- that contain refactorings, so they are often outside the refactorings' boundaries.
293
308
-- Example:
294
309
-- Given an expression "hlintTest = reid $ (myid ())"
0 commit comments