on master help sign in
Use a consistent include dir for cwd (#114)
dcd7cb4Moritz Kiefer
src/Development/IDE/Core/Compile.hs+1−1
@@ -158,7 +158,7 @@ upgradeWarningToError (nfp, fd) = (nfp, fd{_severity = Just DsError})
158
158
159addRelativeImport :: ParsedModule -> DynFlags -> DynFlags
159addRelativeImport :: ParsedModule -> DynFlags -> DynFlags
160addRelativeImport modu dflags = dflags
160addRelativeImport modu dflags = dflags
161− {importPaths = nubOrd $ maybeToList (moduleImportPaths modu) ++ importPaths dflags}
161+ {importPaths = nubOrd $ maybeToList (moduleImportPath modu) ++ importPaths dflags}
162
162
163mkTcModuleResult
163mkTcModuleResult
164 :: GhcMonad m
164 :: GhcMonad m
src/Development/IDE/GHC/Util.hs+15−6
@@ -17,7 +17,7 @@ module Development.IDE.GHC.Util(
17 prettyPrint,
17 prettyPrint,
18 runGhcEnv,
18 runGhcEnv,
19 textToStringBuffer,
19 textToStringBuffer,
20− moduleImportPaths,
20+ moduleImportPath,
21 HscEnvEq, hscEnv, newHscEnvEq
21 HscEnvEq, hscEnv, newHscEnvEq
22 ) where
22 ) where
23
23
@@ -103,16 +103,25 @@ fakeDynFlags = defaultDynFlags settings mempty
103 , pc_WORD_SIZE=8
103 , pc_WORD_SIZE=8
104 }
104 }
105
105
106−moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
106+moduleImportPath :: GHC.ParsedModule -> Maybe FilePath
107−moduleImportPaths pm
107+moduleImportPath pm
108− | rootModDir == "." = Just rootPathDir
108+ | rootModDir == "." = Just rootPathDir
109− | otherwise =
109+ | otherwise = do
110− dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
110+ dir <- dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
111+ -- For modules with more than one component, this can be empty, e.g.,
112+ -- stripSuffix (normalise ./A) (normalise ./A) for A/B.daml.
113+ -- We make a best effort attemp at not duplicating file paths
114+ -- by mapping the current directory to '.' if 'rootPathDir' starts with '.' and
115+ -- to an empty string otherwise.
116+ pure $! if null dir then dotDir else dir
111 where
117 where
118+ dotDir = if "." `isPrefixOf` rootPathDir then "." else ""
112 ms = GHC.pm_mod_summary pm
119 ms = GHC.pm_mod_summary pm
113 file = GHC.ms_hspp_file ms
120 file = GHC.ms_hspp_file ms
114 mod' = GHC.ms_mod ms
121 mod' = GHC.ms_mod ms
122+ -- ./src/A for file ./src/A/B.daml
115 rootPathDir = takeDirectory file
123 rootPathDir = takeDirectory file
124+ -- A for module A.B
116 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
125 rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
117
126
118-- | An HscEnv with equality.
127-- | An HscEnv with equality.