Skip to content
This repository was archived by the owner on Jan 2, 2021. It is now read-only.

Commit

Permalink
Clean up whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
pepeiborra committed Sep 3, 2020
1 parent 496226f commit 4c975b9
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/Development/IDE/Plugin/CodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ suggestRemoveRedundantImport ParsedModule{pm_parsed_source = L _ HsModule{hsmod

suggestDeleteUnusedBinding :: ParsedModule -> Maybe T.Text -> Diagnostic -> [(T.Text, [TextEdit])]
suggestDeleteUnusedBinding
ParsedModule{pm_parsed_source = L _ HsModule{hsmodDecls}}
ParsedModule{pm_parsed_source = L _ HsModule{hsmodDecls}}
contents
Diagnostic{_range=_range,..}
-- Foo.hs:4:1: warning: [-Wunused-binds] Defined but not used: ‘f’
Expand All @@ -205,7 +205,7 @@ suggestDeleteUnusedBinding
name
(L (RealSrcSpan l) (ValD (extractNameAndMatchesFromFunBind -> Just (lname, matches)))) =
case lname of
(L nLoc _name) | isTheBinding nLoc ->
(L nLoc _name) | isTheBinding nLoc ->
let findSig (L (RealSrcSpan l) (SigD sig)) = findRelatedSigSpan indexedContent name l sig
findSig _ = []
in
Expand All @@ -214,11 +214,11 @@ suggestDeleteUnusedBinding
_ -> concatMap (findRelatedSpanForMatch indexedContent name) matches
findRelatedSpans _ _ _ = []

extractNameAndMatchesFromFunBind
:: HsBind GhcPs
extractNameAndMatchesFromFunBind
:: HsBind GhcPs
-> Maybe (Located (IdP GhcPs), [LMatch GhcPs (LHsExpr GhcPs)])
extractNameAndMatchesFromFunBind
FunBind
extractNameAndMatchesFromFunBind
FunBind
{ fun_id=lname
, fun_matches=MG {mg_alts=L _ matches}
} = Just (lname, matches)
Expand All @@ -234,17 +234,17 @@ suggestDeleteUnusedBinding

-- Second of the tuple means there is only one match
findRelatedSigSpan1 :: String -> Sig GhcPs -> Maybe (SrcSpan, Bool)
findRelatedSigSpan1 name (TypeSig lnames _) =
findRelatedSigSpan1 name (TypeSig lnames _) =
let maybeIdx = findIndex (\(L _ id) -> isSameName id name) lnames
in case maybeIdx of
Nothing -> Nothing
Just _ | length lnames == 1 -> Just (getLoc $ head lnames, True)
Just idx ->
Just idx ->
let targetLname = getLoc $ lnames !! idx
startLoc = srcSpanStart targetLname
endLoc = srcSpanEnd targetLname
startLoc' = if idx == 0
then startLoc
startLoc' = if idx == 0
then startLoc
else srcSpanEnd . getLoc $ lnames !! (idx - 1)
endLoc' = if idx == 0 && idx < length lnames - 1
then srcSpanStart . getLoc $ lnames !! (idx + 1)
Expand All @@ -263,7 +263,7 @@ suggestDeleteUnusedBinding
name
(L _ Match{m_grhss=GRHSs{grhssLocalBinds}}) = do
case grhssLocalBinds of
(L _ (HsValBinds (ValBinds bag lsigs))) ->
(L _ (HsValBinds (ValBinds bag lsigs))) ->
if isEmptyBag bag
then []
else concatMap (findRelatedSpanForHsBind indexedContent name lsigs) bag
Expand All @@ -278,10 +278,10 @@ suggestDeleteUnusedBinding
-> [LSig GhcPs]
-> LHsBind GhcPs
-> [Range]
findRelatedSpanForHsBind
findRelatedSpanForHsBind
indexedContent
name
lsigs
name
lsigs
(L (RealSrcSpan l) (extractNameAndMatchesFromFunBind -> Just (lname, matches))) =
if isTheBinding (getLoc lname)
then
Expand Down

0 comments on commit 4c975b9

Please sign in to comment.