Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit d95045b

Browse files
committed
Snapshot to show stack error
1 parent 7987e8c commit d95045b

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

hie-apply-refact/Haskell/Ide/ApplyRefactPlugin.hs

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import Control.Exception
66
import Control.Monad.IO.Class
77
import qualified Data.Text as T
88
import Data.Vinyl
9+
import Haskell.Ide.Engine.MonadFunctions
910
import Haskell.Ide.Engine.PluginDescriptor
1011
import Haskell.Ide.Engine.PluginUtils
1112
import Haskell.Ide.Engine.SemanticTypes
1213
import qualified Language.Haskell.GhcMod as GM (defaultOptions)
1314
import Language.Haskell.HLint
1415
import System.Directory
16+
import System.Exit
1517
import System.FilePath.Posix
1618
import System.IO
1719
import System.IO.Extra
@@ -53,17 +55,29 @@ applyOneCmd = CmdSync $ \_ctxs req -> do
5355
Right _ -> return $ IdeResponseError (IdeError InternalError
5456
"ApplyRefactPlugin.demoteCmd: ghc’s exhaustiveness checker is broken" Nothing)
5557

56-
-- demote :: RefactSettings -> GM.Options -> FilePath -> SimpPos -> IO [FilePath]
5758

5859
-- ---------------------------------------------------------------------
5960

60-
applyHint :: FilePath -> Pos -> IO HieDiff
61+
applyHint :: FilePath -> Pos -> IO (Either t HieDiff)
6162
applyHint file pos = do
6263
withTempFile $ \f -> do
63-
let opts = "--output " ++ f
64-
hlint ["--refactor", "-", "--refactor-options=" ++ show opts, file]
65-
diff <- makeDiffResult file f
66-
return diff
64+
absFile <- makeAbsolute file
65+
-- hlint /tmp/Foo.hs --refactor --refactor-options="-o /tmp/Bar.hs --pos 2,8"
66+
67+
-- let opts = "-o " ++ f
68+
let opts = "-o /tmp/BarOne.hs"
69+
-- let hlintOpts = [absFile, "--refactor", "--refactor-options=" ++ show opts ]
70+
let hlintOpts = ["/tmp/Foo.hs", "--refactor", "--refactor-options=" ++ opts ]
71+
-- let hlintOpts = ["/tmp/Foo.hs", "--refactor" ]
72+
logm $ "applyHint=" ++ show hlintOpts
73+
res <- catchException $ hlint hlintOpts
74+
logm $ "applyHint:res=" ++ show res
75+
case res of
76+
Left ExitSuccess -> do
77+
diff <- makeDiffResult file f
78+
logm $ "applyHint:diff=" ++ show diff
79+
return $ Right diff
80+
_ -> return res
6781

6882
-- ---------------------------------------------------------------------
6983

0 commit comments

Comments
 (0)