mirror of
https://github.com/haskell/ghcide.git
synced 2024-12-13 09:34:31 +03:00
Use a consistent include dir for cwd (#114)
This only matters for the DAML codebase (so I’ll add a test on that side) where we use relative paths: Previously, we would produce the include dir "." for moduleImportPath "./A.daml" and "" for moduleImportPath "./A/B.daml". This resulted in us ending up with ./A.daml and A.daml in the Shake graph which resulted in issues like https://github.com/digital-asset/daml/issues/2929. We should move this logic completely over to the DAML repo at some point but I’ll leave that for a separate PR.
This commit is contained in:
parent
79301b472e
commit
dcd7cb499e
@ -158,7 +158,7 @@ upgradeWarningToError (nfp, fd) = (nfp, fd{_severity = Just DsError})
|
|||||||
|
|
||||||
addRelativeImport :: ParsedModule -> DynFlags -> DynFlags
|
addRelativeImport :: ParsedModule -> DynFlags -> DynFlags
|
||||||
addRelativeImport modu dflags = dflags
|
addRelativeImport modu dflags = dflags
|
||||||
{importPaths = nubOrd $ maybeToList (moduleImportPaths modu) ++ importPaths dflags}
|
{importPaths = nubOrd $ maybeToList (moduleImportPath modu) ++ importPaths dflags}
|
||||||
|
|
||||||
mkTcModuleResult
|
mkTcModuleResult
|
||||||
:: GhcMonad m
|
:: GhcMonad m
|
||||||
|
@ -17,7 +17,7 @@ module Development.IDE.GHC.Util(
|
|||||||
prettyPrint,
|
prettyPrint,
|
||||||
runGhcEnv,
|
runGhcEnv,
|
||||||
textToStringBuffer,
|
textToStringBuffer,
|
||||||
moduleImportPaths,
|
moduleImportPath,
|
||||||
HscEnvEq, hscEnv, newHscEnvEq
|
HscEnvEq, hscEnv, newHscEnvEq
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -103,16 +103,25 @@ fakeDynFlags = defaultDynFlags settings mempty
|
|||||||
, pc_WORD_SIZE=8
|
, pc_WORD_SIZE=8
|
||||||
}
|
}
|
||||||
|
|
||||||
moduleImportPaths :: GHC.ParsedModule -> Maybe FilePath
|
moduleImportPath :: GHC.ParsedModule -> Maybe FilePath
|
||||||
moduleImportPaths pm
|
moduleImportPath pm
|
||||||
| rootModDir == "." = Just rootPathDir
|
| rootModDir == "." = Just rootPathDir
|
||||||
| otherwise =
|
| otherwise = do
|
||||||
dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
|
dir <- dropTrailingPathSeparator <$> stripSuffix (normalise rootModDir) (normalise rootPathDir)
|
||||||
|
-- For modules with more than one component, this can be empty, e.g.,
|
||||||
|
-- stripSuffix (normalise ./A) (normalise ./A) for A/B.daml.
|
||||||
|
-- We make a best effort attemp at not duplicating file paths
|
||||||
|
-- by mapping the current directory to '.' if 'rootPathDir' starts with '.' and
|
||||||
|
-- to an empty string otherwise.
|
||||||
|
pure $! if null dir then dotDir else dir
|
||||||
where
|
where
|
||||||
|
dotDir = if "." `isPrefixOf` rootPathDir then "." else ""
|
||||||
ms = GHC.pm_mod_summary pm
|
ms = GHC.pm_mod_summary pm
|
||||||
file = GHC.ms_hspp_file ms
|
file = GHC.ms_hspp_file ms
|
||||||
mod' = GHC.ms_mod ms
|
mod' = GHC.ms_mod ms
|
||||||
|
-- ./src/A for file ./src/A/B.daml
|
||||||
rootPathDir = takeDirectory file
|
rootPathDir = takeDirectory file
|
||||||
|
-- A for module A.B
|
||||||
rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
|
rootModDir = takeDirectory . moduleNameSlashes . GHC.moduleName $ mod'
|
||||||
|
|
||||||
-- | An HscEnv with equality.
|
-- | An HscEnv with equality.
|
||||||
|
Loading…
Reference in New Issue
Block a user