Fix problem with fileModSummary

This commit is contained in:
Nikolay Yakimov 2015-07-03 22:31:52 +03:00
parent 0ad438461b
commit 8f931eb928
4 changed files with 17 additions and 5 deletions

View File

@ -26,6 +26,7 @@ import Language.Haskell.GhcMod.SrcUtils
import Language.Haskell.GhcMod.Doc import Language.Haskell.GhcMod.Doc
import Language.Haskell.GhcMod.Logging import Language.Haskell.GhcMod.Logging
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.FileMapping (fileModSummaryWithMapping)
---------------------------------------------------------------- ----------------------------------------------------------------
-- CASE SPLITTING -- CASE SPLITTING
@ -51,7 +52,7 @@ splits file lineNo colNo =
crdl <- cradle crdl <- cradle
style <- getStyle style <- getStyle
dflag <- G.getSessionDynFlags dflag <- G.getSessionDynFlags
modSum <- Gap.fileModSummary (cradleCurrentDir crdl </> file) modSum <- fileModSummaryWithMapping (cradleCurrentDir crdl </> file)
whenFound' opt (getSrcSpanTypeForSplit modSum lineNo colNo) $ \x -> case x of whenFound' opt (getSrcSpanTypeForSplit modSum lineNo colNo) $ \x -> case x of
(SplitInfo varName bndLoc (varLoc,varT) _matches) -> do (SplitInfo varName bndLoc (varLoc,varT) _matches) -> do
let varName' = showName dflag style varName -- Convert name to string let varName' = showName dflag style varName -- Convert name to string

View File

@ -3,6 +3,7 @@ module Language.Haskell.GhcMod.FileMapping
, loadMappedFiles , loadMappedFiles
, unloadMappedFile , unloadMappedFile
, mapFile , mapFile
, fileModSummaryWithMapping
) where ) where
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
@ -48,3 +49,11 @@ mkMappedTarget tid taoc _ = return $ mkTarget tid taoc Nothing
unloadMappedFile :: IOish m => FilePath -> GhcModT m () unloadMappedFile :: IOish m => FilePath -> GhcModT m ()
unloadMappedFile = (delMMappedFile =<<) . getCanonicalFileNameSafe unloadMappedFile = (delMMappedFile =<<) . getCanonicalFileNameSafe
fileModSummaryWithMapping :: (IOish m, GmState m, GhcMonad m, GmEnv m) =>
FilePath -> m ModSummary
fileModSummaryWithMapping fn = do
mmf <- getCanonicalFileNameSafe fn >>= lookupMMappedFile
case mmf of
Just (RedirectedMapping to) -> fileModSummary to
_ -> fileModSummary fn

View File

@ -27,6 +27,7 @@ import Language.Haskell.GhcMod.Logging (gmLog)
import Language.Haskell.GhcMod.Pretty (showDoc) import Language.Haskell.GhcMod.Pretty (showDoc)
import Language.Haskell.GhcMod.Doc import Language.Haskell.GhcMod.Doc
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.FileMapping (fileModSummaryWithMapping)
import Outputable (PprStyle) import Outputable (PprStyle)
import qualified Type as Ty import qualified Type as Ty
import qualified HsBinds as Ty import qualified HsBinds as Ty
@ -76,7 +77,7 @@ sig file lineNo colNo =
opt <- options opt <- options
style <- getStyle style <- getStyle
dflag <- G.getSessionDynFlags dflag <- G.getSessionDynFlags
modSum <- Gap.fileModSummary file modSum <- fileModSummaryWithMapping file
whenFound opt (getSignature modSum lineNo colNo) $ \s -> whenFound opt (getSignature modSum lineNo colNo) $ \s ->
case s of case s of
Signature loc names ty -> Signature loc names ty ->
@ -345,7 +346,7 @@ refine file lineNo colNo (Expression expr) =
opt <- options opt <- options
style <- getStyle style <- getStyle
dflag <- G.getSessionDynFlags dflag <- G.getSessionDynFlags
modSum <- Gap.fileModSummary file modSum <- fileModSummaryWithMapping file
p <- G.parseModule modSum p <- G.parseModule modSum
tcm@TypecheckedModule{tm_typechecked_source = tcs} <- G.typecheckModule p tcm@TypecheckedModule{tm_typechecked_source = tcs} <- G.typecheckModule p
ety <- G.exprType expr ety <- G.exprType expr
@ -422,7 +423,7 @@ auto file lineNo colNo =
opt <- options opt <- options
style <- getStyle style <- getStyle
dflag <- G.getSessionDynFlags dflag <- G.getSessionDynFlags
modSum <- Gap.fileModSummary file modSum <- fileModSummaryWithMapping file
p <- G.parseModule modSum p <- G.parseModule modSum
tcm@TypecheckedModule { tcm@TypecheckedModule {
tm_typechecked_source = tcs tm_typechecked_source = tcs

View File

@ -22,6 +22,7 @@ import Language.Haskell.GhcMod.Logging
import Language.Haskell.GhcMod.Monad import Language.Haskell.GhcMod.Monad
import Language.Haskell.GhcMod.SrcUtils import Language.Haskell.GhcMod.SrcUtils
import Language.Haskell.GhcMod.Types import Language.Haskell.GhcMod.Types
import Language.Haskell.GhcMod.FileMapping (fileModSummaryWithMapping)
---------------------------------------------------------------- ----------------------------------------------------------------
@ -60,7 +61,7 @@ types file lineNo colNo =
runGmlT' [Left file] deferErrors $ runGmlT' [Left file] deferErrors $
withContext $ do withContext $ do
crdl <- cradle crdl <- cradle
modSum <- Gap.fileModSummary (cradleCurrentDir crdl </> file) modSum <- fileModSummaryWithMapping (cradleCurrentDir crdl </> file)
srcSpanTypes <- getSrcSpanType modSum lineNo colNo srcSpanTypes <- getSrcSpanType modSum lineNo colNo
dflag <- G.getSessionDynFlags dflag <- G.getSessionDynFlags
st <- getStyle st <- getStyle