File tree Expand file tree Collapse file tree
plugins/hls-refactor-plugin
src/Development/IDE/Plugin Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -608,9 +608,10 @@ suggestDeleteUnusedBinding
608608 in ([(" Delete ‘" <> name <> " ’" , edits) | not (null edits)])
609609 | otherwise = []
610610 where
611- hsmodSigs = [L l sig | L l (SigD _ sig) <- hsmodDecls]
611+ hsmodDeclsWithDocs = balanceCommentsList hsmodDecls
612+ hsmodSigs = [L l sig | L l (SigD _ sig) <- hsmodDeclsWithDocs]
612613 relatedRanges indexedContent name =
613- concatMap (findRelatedSpans indexedContent name . reLoc) hsmodDecls
614+ concatMap (findRelatedSpans indexedContent name . reLoc) hsmodDeclsWithDocs
614615 toRange = realSrcSpanToRange
615616 extendForSpaces = extendToIncludePreviousNewlineIfPossible
616617
Original file line number Diff line number Diff line change @@ -13,7 +13,10 @@ module Development.IDE.Plugin.CodeAction.ExactPrint (
1313 hideSymbol ,
1414 liftParseAST ,
1515
16- wildCardSymbol
16+ wildCardSymbol ,
17+
18+ -- * Re-exports
19+ balanceCommentsList ,
1720) where
1821
1922import Control.Monad
Original file line number Diff line number Diff line change @@ -2534,21 +2534,40 @@ deleteUnusedDefinitionTests = testGroup "delete unused definition action"
25342534 , " some = ()"
25352535 ]
25362536 , knownBrokenForGhcVersions [GHC96 , GHC98 ] " Not implemented for GHC <9.10 (AST changed)" $
2537- testSession " delete unused top level binding with Haddock comment" $
2537+ testSession " delete unused leading top level binding with Haddock comment" $
25382538 testFor
25392539 [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
25402540 , " module A (some) where"
25412541 , " "
2542- , " -- | line docs for f"
2543- , " f :: Int"
2544- -- TODO: , "-- ^ trailing docs for f"
2545- , " f = 1"
2542+ , " -- | line docs for foo"
2543+ , " foo :: Int"
2544+ , " foo = 1"
25462545 , " "
25472546 , " some = ()"
25482547 ]
25492548 (5 , 0 )
25502549 1
2551- " Delete ‘f’"
2550+ " Delete ‘foo’"
2551+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
2552+ , " module A (some) where"
2553+ , " "
2554+ , " some = ()"
2555+ ]
2556+ , knownBrokenForGhcVersions [GHC96 , GHC98 ] " Not implemented for GHC <9.10 (AST changed)" $
2557+ testSession " delete unused trailing top level binding with Haddock comment" $
2558+ testFor
2559+ [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
2560+ , " module A (some) where"
2561+ , " "
2562+ , " oof = 1"
2563+ , " oof :: Int"
2564+ , " -- ^ trailing docs for oof"
2565+ , " "
2566+ , " some = ()"
2567+ ]
2568+ (3 , 0 )
2569+ 1
2570+ " Delete ‘oof’"
25522571 [ " {-# OPTIONS_GHC -Wunused-top-binds #-}"
25532572 , " module A (some) where"
25542573 , " "
You can’t perform that action at this time.
0 commit comments