Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use absolute file paths in module graph.

  • Loading branch information...
commit cb6ec0190ec7145fe22226b3e55000d18a4442f1 1 parent 10c5926
@nominolo authored
View
20 src/Scion/Ghc.hs
@@ -2,7 +2,7 @@
module Scion.Ghc
( -- * Converting from GHC error messages
ghcSpanToLocation, ghcErrMsgToNote, ghcWarnMsgToNote,
- ghcMessagesToNotes, scionColToGhcCol
+ ghcMessagesToNotes, scionColToGhcCol, fromGhcModSummary
)
where
@@ -22,6 +22,7 @@ import qualified Data.MultiSet as MS
import qualified Data.Text as T
import Data.String ( fromString )
+import System.Directory ( canonicalizePath )
-- * Converting from Ghc types.
@@ -81,9 +82,12 @@ ghcMessagesToNotes base_dir (warns, errs) =
where
map_bag2ms f = MS.fromList . map f . Bag.bagToList
-fromGhcModSummary :: Ghc.ModSummary -> ModuleSummary
-fromGhcModSummary ms =
- ModuleSummary
+fromGhcModSummary :: MonadIO m => Ghc.ModSummary -> m ModuleSummary
+fromGhcModSummary ms = do
+ path <- case Ghc.ml_hs_file (Ghc.ms_location ms) of
+ Just fp -> io $ canonicalizePath fp
+ Nothing -> error "Module has no location"
+ return $ ModuleSummary
{ ms_module = convert (Ghc.moduleName (Ghc.ms_mod ms))
, ms_fileType = case Ghc.ms_hsc_src ms of
Ghc.HsSrcFile -> HaskellFile
@@ -91,15 +95,9 @@ fromGhcModSummary ms =
, ms_imports =
map (convert . Ghc.unLoc
. Ghc.ideclName . Ghc.unLoc) (Ghc.ms_imps ms)
- , ms_location =
- case Ghc.ml_hs_file (Ghc.ms_location ms) of
- Just fp -> fp
- Nothing -> error "Module has no location"
+ , ms_location = path
}
-instance Convert Ghc.ModSummary ModuleSummary where
- convert = fromGhcModSummary
-
instance Convert Ghc.ModuleName ModuleName where
convert m = fromString (Ghc.moduleNameString m)
View
4 src/Scion/Session.hs
@@ -37,7 +37,7 @@ import Data.Maybe
import Data.Time.Clock ( getCurrentTime )
import Data.Time.Clock.POSIX ( posixSecondsToUTCTime )
import System.Directory ( doesFileExist, getTemporaryDirectory,
- removeDirectoryRecursive )
+ removeDirectoryRecursive, canonicalizePath )
import System.Exit ( ExitCode(..) )
import System.FilePath ( dropFileName, (</>), takeFileName, makeRelative )
import System.IO
@@ -379,6 +379,6 @@ fileSessions path = do
fileInSession :: FilePath -> SessionId -> ScionM Bool
fileInSession path0 sid = do
home <- sessionHomeDir <$> getSessionState sid
- let path = makeRelative home path0
+ path <- io $ canonicalizePath $ home </> path0
mods <- sessionModules sid
return $ not $ null [ m | m <- mods, ms_location m == path ]
View
5 src/Scion/Worker/Commands.hs
@@ -5,8 +5,7 @@ import Scion.Types.Compiler
import Scion.Types.Worker
import Scion.Types.Commands as C
import Scion.Types.Session
-import Scion.Utils.Convert
-import Scion.Ghc
+import Scion.Ghc( fromGhcModSummary )
import qualified GHC as Ghc
import qualified DynFlags as Ghc
@@ -129,4 +128,4 @@ load how_much = do
moduleGraph :: Worker [ModuleSummary]
moduleGraph = do
- map convert <$> Ghc.getModuleGraph
+ mapM fromGhcModSummary =<< Ghc.getModuleGraph
View
4 src/Scion/Worker/Main.hs
@@ -238,10 +238,10 @@ initGhcSession targets args1 _debugMsg kont = do
dflags0 <- Ghc.getSessionDynFlags
notes_ref <- liftIO $ newIORef []
- base_dir <- liftIO $ getCurrentDirectory
+ base_dir <- liftIO $ canonicalizePath =<< getCurrentDirectory
let addNote :: NoteKind -> Ghc.SrcSpan -> SDoc -> IO ()
- addNote nkind loc msg =
+ addNote nkind loc msg =
let note = Note { noteKind = nkind
, noteLoc = ghcSpanToLocation base_dir loc
, noteMessage = fromString (showSDoc msg) } in
Please sign in to comment.
Something went wrong with that request. Please try again.