Skip to content

Commit b70338e

Browse files
committed
Move hlint module to its own src dir
1 parent 34f5e41 commit b70338e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/Ide/Plugin/Hlint.hs renamed to hlint-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ descriptor plId = (defaultPluginDescriptor plId)
8787
{ pluginRules = rules
8888
, pluginCommands =
8989
[ 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
9191
]
9292
, pluginCodeActionProvider = Just codeActionProvider
9393
}
@@ -251,6 +251,21 @@ codeActionProvider _ _ plId docId _ context = (Right . LSP.List . map CACodeActi
251251

252252
-- ---------------------------------------------------------------------
253253

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+
254269
data ApplyOneParams = AOP
255270
{ file :: Uri
256271
, start_pos :: Position
@@ -288,7 +303,7 @@ applyHint ide nfp mhint =
288303
-- set Nothing as "position" for "applyRefactorings" because
289304
-- applyRefactorings expects the provided position to be _within_ the scope
290305
-- 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
292307
-- that contain refactorings, so they are often outside the refactorings' boundaries.
293308
-- Example:
294309
-- Given an expression "hlintTest = reid $ (myid ())"

0 commit comments

Comments
 (0)