Skip to content

Commit a5c749b

Browse files
committed
Demote no access to virtual file to debug messages
1 parent dcf81a1 commit a5c749b

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

src/Haskell/Ide/Engine/Plugin/ApplyRefact.hs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,10 @@ applyOneCmd = CmdSync $ \(AOP uri pos title) -> do
8181
applyOneCmd' :: Uri -> OneHint -> IdeGhcM (IdeResult WorkspaceEdit)
8282
applyOneCmd' uri oneHint = pluginGetFile "applyOne: " uri $ \fp -> do
8383
revMapp <- reverseFileMap
84-
let resultFail = return $ IdeResultFail
85-
(IdeError PluginError
86-
(T.pack "applyOne: no access to the persisted file.")
87-
Null
88-
)
89-
withMappedFile fp resultFail $ \file' -> do
84+
let defaultResult = do
85+
debugm "applyOne: no access to the persisted file."
86+
return $ IdeResultOk mempty
87+
withMappedFile fp defaultResult $ \file' -> do
9088
res <- liftToGhc $ applyHint file' (Just oneHint) revMapp
9189
logm $ "applyOneCmd:file=" ++ show fp
9290
logm $ "applyOneCmd:res=" ++ show res
@@ -104,13 +102,11 @@ applyAllCmd = CmdSync $ \uri -> do
104102

105103
applyAllCmd' :: Uri -> IdeGhcM (IdeResult WorkspaceEdit)
106104
applyAllCmd' uri = pluginGetFile "applyAll: " uri $ \fp -> do
107-
let resultFail = return $ IdeResultFail
108-
(IdeError PluginError
109-
(T.pack "applyAll: no access to the persisted file.")
110-
Null
111-
)
105+
let defaultResult = do
106+
debugm "applyAll: no access to the persisted file."
107+
return $ IdeResultOk mempty
112108
revMapp <- reverseFileMap
113-
withMappedFile fp resultFail $ \file' -> do
109+
withMappedFile fp defaultResult $ \file' -> do
114110
res <- liftToGhc $ applyHint file' Nothing revMapp
115111
logm $ "applyAllCmd:res=" ++ show res
116112
case res of
@@ -127,12 +123,12 @@ lintCmd = CmdSync $ \uri -> do
127123
-- AZ:TODO: Why is this in IdeGhcM?
128124
lintCmd' :: Uri -> IdeGhcM (IdeResult PublishDiagnosticsParams)
129125
lintCmd' uri = pluginGetFile "lintCmd: " uri $ \fp -> do
130-
let resultFail = return $ IdeResultFail
131-
(IdeError PluginError
132-
(T.pack "lintCmd: no access to the persisted file.")
133-
Null
134-
)
135-
withMappedFile fp resultFail $ \file' -> do
126+
let
127+
defaultResult = do
128+
debugm "lintCmd: no access to the persisted file."
129+
return
130+
$ IdeResultOk (PublishDiagnosticsParams (filePathToUri fp) $ List [])
131+
withMappedFile fp defaultResult $ \file' -> do
136132
eitherErrorResult <- liftIO
137133
(try $ runExceptT $ runLintCmd file' [] :: IO
138134
(Either IOException (Either [Diagnostic] [Idea]))

src/Haskell/Ide/Engine/Plugin/HaRe.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,12 +216,11 @@ makeRefactorResult changedFiles = do
216216

217217
origTextResult <- case mvf of
218218
Nothing -> do
219-
let resultFail = return $ IdeResultFail
220-
(IdeError PluginError
221-
(T.pack "makeRefactorResult: no access to the persisted file.")
222-
Null
223-
)
224-
withMappedFile fp resultFail (fmap IdeResultOk . liftIO . T.readFile)
219+
let defaultResult = do
220+
debugm "makeRefactorResult: no access to the persisted file."
221+
return $ IdeResultOk mempty
222+
223+
withMappedFile fp defaultResult (fmap IdeResultOk . liftIO . T.readFile)
225224
Just vf -> return $ IdeResultOk $ Rope.toText $ _text vf
226225

227226
case origTextResult of

src/Haskell/Ide/Engine/Plugin/HsImport.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import qualified GHC.Generics as Generics
1717
import qualified HsImport
1818
import Haskell.Ide.Engine.Config
1919
import Haskell.Ide.Engine.MonadTypes
20+
import Haskell.Ide.Engine.MonadFunctions (debugm)
2021
import qualified Haskell.Ide.Engine.Support.HieExtras as Hie
2122
import qualified Language.Haskell.LSP.Types as J
2223
import qualified Language.Haskell.LSP.Types.Lens as J
@@ -128,12 +129,10 @@ importModule uri impStyle modName =
128129
pluginGetFile "hsimport cmd: " uri $ \origInput -> do
129130
shouldFormat <- formatOnImportOn <$> getConfig
130131
fileMap <- reverseFileMap
131-
let resultFail = return $ IdeResultFail
132-
(IdeError PluginError
133-
(T.pack $ "hsImport: no access to the persisted file.")
134-
Null
135-
)
136-
withMappedFile origInput resultFail $ \input -> do
132+
let defaultResult = do
133+
debugm "hsimport: no access to the persisted file."
134+
return $ IdeResultOk mempty
135+
withMappedFile origInput defaultResult $ \input -> do
137136
tmpDir <- liftIO getTemporaryDirectory
138137
(output, outputH) <- liftIO $ openTempFile tmpDir "hsimportOutput"
139138
liftIO $ hClose outputH

0 commit comments

Comments
 (0)