From b9dfd499dd1e4640b853235b5b850427f637a07a Mon Sep 17 00:00:00 2001 From: Neil Mitchell <35463327+neil-da@users.noreply.github.com> Date: Mon, 6 May 2019 18:35:43 +0100 Subject: [PATCH] Minor IDE cleanups (#945) * Kill RealLocated, it just duplicates something already in GHC * Move some things back to UtilGHC, they are useful for setting DynFlags values --- .../IDE/Functions/Documentation.hs | 3 ++- src/Development/IDE/UtilGHC.hs | 23 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/Development/IDE/Functions/Documentation.hs b/src/Development/IDE/Functions/Documentation.hs index 4e5a9301..ce1c89a6 100644 --- a/src/Development/IDE/Functions/Documentation.hs +++ b/src/Development/IDE/Functions/Documentation.hs @@ -13,9 +13,10 @@ import Data.Maybe import qualified Data.Text as T import Development.IDE.Functions.GHCError import Development.IDE.Functions.SpanInfo -import Development.IDE.UtilGHC import FastString import GHC +import SrcLoc + getDocumentation :: Name -- ^ The name you want documentation for. diff --git a/src/Development/IDE/UtilGHC.hs b/src/Development/IDE/UtilGHC.hs index 95e9ac0c..1e7050ae 100644 --- a/src/Development/IDE/UtilGHC.hs +++ b/src/Development/IDE/UtilGHC.hs @@ -24,7 +24,9 @@ module Development.IDE.UtilGHC( importGenerated, mkImport, runGhcFast, - Development.IDE.UtilGHC.RealLocated, + setImports, + setPackageState, + setThisInstalledUnitId, modIsInternal ) where @@ -168,6 +170,23 @@ fakeLlvmConfig :: (LlvmTargets, LlvmPasses) fakeLlvmConfig = ([], []) +setThisInstalledUnitId :: UnitId -> DynFlags -> DynFlags +setThisInstalledUnitId unitId dflags = + dflags {thisInstalledUnitId = toInstalledUnitId unitId} + +setImports :: [FilePath] -> DynFlags -> DynFlags +setImports paths dflags = dflags { importPaths = paths } + +setPackageState :: PackageState -> DynFlags -> DynFlags +setPackageState state dflags = + dflags + { pkgDatabase = pkgStateDb state + , pkgState = pkgStateState state + , thisUnitIdInsts_ = pkgThisUnitIdInsts state + } + + + -- Orphan instances for types from the GHC API. instance Show CoreModule where show = prettyPrint instance NFData CoreModule where rnf !_ = () @@ -194,5 +213,3 @@ instance Show (GenLocated SrcSpan ModuleName) where show = prettyPrint instance Show PackageName where show = prettyPrint instance Show Packages.PackageState where show _ = "PackageState" instance Show Name where show = prettyPrint - -type RealLocated = GenLocated RealSrcSpan