Skip to content

Commit

Permalink
Tidy a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpj committed Jul 31, 2023
1 parent 75096d7 commit 861aef6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 39 deletions.
4 changes: 0 additions & 4 deletions ghcide/src/Development/IDE/GHC/Compat.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ module Development.IDE.GHC.Compat(
enrichHie,
writeHieFile,
readHieFile,
supportsHieFiles,
setHieDir,
dontWriteHieFiles,
module Compat.HieTypes,
Expand Down Expand Up @@ -406,9 +405,6 @@ pattern PFailedWithErrorMessages msgs
#endif
{-# COMPLETE POk, PFailedWithErrorMessages #-}

supportsHieFiles :: Bool
supportsHieFiles = True

hieExportNames :: HieFile -> [(SrcSpan, Name)]
hieExportNames = nameListFromAvails . hie_exports

Expand Down
42 changes: 8 additions & 34 deletions ghcide/src/Development/IDE/GHC/Compat/Units.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Development.IDE.GHC.Compat.Units (
unitExposedModules,
unitDepends,
unitHaddockInterfaces,
unitInfoId,
mkUnit,
unitPackageNameString,
unitPackageVersion,
-- * UnitId helpers
Expand Down Expand Up @@ -72,10 +72,14 @@ import qualified GHC.Driver.Session as DynFlags
import GHC.Types.Unique.Set
import qualified GHC.Unit.Info as UnitInfo
import GHC.Unit.State (LookupResult, UnitInfo,
UnitState (unitInfoMap))
UnitState (unitInfoMap),
lookupUnit', mkUnit,
unitDepends,
unitExposedModules,
unitPackageNameString,
unitPackageVersion)
import qualified GHC.Unit.State as State
import GHC.Unit.Types hiding (moduleUnit,
toUnitId)
import GHC.Unit.Types
import qualified GHC.Unit.Types as Unit
import GHC.Utils.Outputable

Expand Down Expand Up @@ -197,35 +201,13 @@ getUnitInfoMap =
lookupUnit :: HscEnv -> Unit -> Maybe UnitInfo
lookupUnit env pid = State.lookupUnit (unitState env) pid

lookupUnit' :: Bool -> UnitInfoMap -> PreloadUnitClosure -> Unit -> Maybe UnitInfo
lookupUnit' = State.lookupUnit'

preloadClosureUs :: HscEnv -> PreloadUnitClosure
#if MIN_VERSION_ghc(9,2,0)
preloadClosureUs = State.preloadClosure . unitState
#else
preloadClosureUs = State.preloadClosure . unitState
#endif

unitExposedModules :: UnitInfo -> [(ModuleName, Maybe Module)]
unitExposedModules ue =
UnitInfo.unitExposedModules ue

unitDepends :: UnitInfo -> [UnitId]
unitDepends = State.unitDepends

unitPackageNameString :: UnitInfo -> String
unitPackageNameString =
UnitInfo.unitPackageNameString

unitPackageVersion :: UnitInfo -> Version
unitPackageVersion =
UnitInfo.unitPackageVersion

unitInfoId :: UnitInfo -> Unit
unitInfoId =
UnitInfo.mkUnit

unitHaddockInterfaces :: UnitInfo -> [FilePath]
unitHaddockInterfaces =
#if MIN_VERSION_ghc(9,2,0)
Expand Down Expand Up @@ -257,18 +239,10 @@ installedModule = Module

#endif

toUnitId :: Unit -> UnitId
toUnitId =
Unit.toUnitId

moduleUnitId :: Module -> UnitId
moduleUnitId =
Unit.toUnitId . Unit.moduleUnit

moduleUnit :: Module -> Unit
moduleUnit =
Unit.moduleUnit

filterInplaceUnits :: [UnitId] -> [PackageFlag] -> ([UnitId], [PackageFlag])
filterInplaceUnits us packageFlags =
partitionEithers (map isInplace packageFlags)
Expand Down
2 changes: 1 addition & 1 deletion ghcide/src/Development/IDE/Types/HscEnvEq.hs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ newHscEnvEqWithImportPaths envImportPaths hscEnv deps = do
-- When module is re-exported from another package,
-- the origin module is represented by value in Just
Just otherPkgMod -> otherPkgMod
Nothing -> mkModule (unitInfoId pkg) modName
Nothing -> mkModule (mkUnit pkg) modName
]

doOne m = do
Expand Down

0 comments on commit 861aef6

Please sign in to comment.