Skip to content

[cleanup] Remove unused/duplicated "applyRefactorings" #41

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions src/Refact/Apply.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
module Refact.Apply
(
runRefactoring
, applyRefactorings

-- * Support for runPipe in the main process
, Verbosity(..)
Expand All @@ -28,7 +27,6 @@ import Data.Maybe
import Data.List hiding (find)
import Data.Ord

import Control.Monad
import Control.Monad.State
import Control.Monad.Identity
import Data.Data
Expand All @@ -50,11 +48,10 @@ import Control.Arrow

import Debug.Trace

import Refact.Fixity
import Refact.Types hiding (SrcSpan)
import qualified Refact.Types as R
import Refact.Utils (Stmt, Pat, Name, Decl, M, Expr, Type, FunBind
, modifyAnnKey, replaceAnnKey, Import, toGhcSrcSpan)
, modifyAnnKey, replaceAnnKey, Import)

-- library access to perform the substitutions

Expand All @@ -64,26 +61,6 @@ refactOptions = stringOptions { epRigidity = RigidLayout }
rigidLayout :: DeltaOptions
rigidLayout = deltaOptions RigidLayout

-- | Apply a set of refactorings as supplied by hlint
applyRefactorings :: Maybe (Int, Int) -> [(String, [Refactoring R.SrcSpan])] -> FilePath -> IO String
applyRefactorings optionsPos inp file = do
(as, m) <- either (error . show) (uncurry applyFixities)
<$> parseModuleWithOptions rigidLayout file
let noOverlapInp = removeOverlap Silent inp
refacts = (fmap . fmap . fmap) (toGhcSrcSpan file) <$> noOverlapInp

posFilter (_, rs) =
case optionsPos of
Nothing -> True
Just p -> any (flip spans p . pos) rs
filtRefacts = filter posFilter refacts

-- need a check here to avoid overlap
(ares, res) <- return . flip evalState 0 $
foldM (uncurry runRefactoring) (as, m) (concatMap snd filtRefacts)
let output = runIdentity $ exactPrintWithOptions refactOptions res ares
return output

data Verbosity = Silent | Normal | Loud deriving (Eq, Show, Ord)

-- Filters out overlapping ideas, picking the first idea in a set of overlapping ideas.
Expand Down