From 9cbc5859f85fd23fb51a030e8ee0f874d7f14a35 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Thu, 14 Apr 2022 15:24:07 +0800 Subject: [PATCH 1/3] Unify ppr style --- ghcide/src/Development/IDE/Spans/Common.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ghcide/src/Development/IDE/Spans/Common.hs b/ghcide/src/Development/IDE/Spans/Common.hs index 0a60120138..62a573142c 100644 --- a/ghcide/src/Development/IDE/Spans/Common.hs +++ b/ghcide/src/Development/IDE/Spans/Common.hs @@ -24,6 +24,7 @@ import qualified Data.Text as T import GHC.Generics import GHC +import GHC.Utils.Outputable (withPprStyle, defaultUserStyle) import Development.IDE.GHC.Compat import Development.IDE.GHC.Orphans () @@ -35,7 +36,7 @@ type DocMap = NameEnv SpanDoc type KindMap = NameEnv TyThing showGhc :: Outputable a => a -> T.Text -showGhc = showSD . ppr +showGhc = showSD . withPprStyle defaultUserStyle . ppr showSD :: SDoc -> T.Text showSD = T.pack . unsafePrintSDoc @@ -62,7 +63,7 @@ safeTyThingId _ = Nothing -- Possible documentation for an element in the code data SpanDoc = SpanDocString HsDocString SpanDocUris - | SpanDocText [T.Text] SpanDocUris + | SpanDocText [T.Text] SpanDocUris deriving stock (Eq, Show, Generic) deriving anyclass NFData From 8166d367bfc1e29c4666527d1f6e102a9aaed826 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Thu, 14 Apr 2022 15:42:41 +0800 Subject: [PATCH 2/3] Fix test --- ghcide/test/exe/Main.hs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/ghcide/test/exe/Main.hs b/ghcide/test/exe/Main.hs index 96ad20c9df..754a0915c9 100644 --- a/ghcide/test/exe/Main.hs +++ b/ghcide/test/exe/Main.hs @@ -4288,11 +4288,7 @@ findDefinitionAndHoverTests = let , test no yes outL45 outSig "top-level signature #767" , test broken broken innL48 innSig "inner signature #767" , test no yes holeL60 hleInfo "hole without internal name #831" - , if ghcVersion >= GHC92 then - -- Broken on GHC 9.2 and above due to printing of uniques - test no yes holeL65 [] "hole with variable" - else - test no yes holeL65 hleInfo2 "hole with variable" + , test no yes holeL65 hleInfo2 "hole with variable" , test no skip cccL17 docLink "Haddock html links" , testM yes yes imported importedSig "Imported symbol" , testM yes yes reexported reexportedSig "Imported symbol (reexported)" From ebac11c0249cff75b1a4a1460d15818d60b65dc6 Mon Sep 17 00:00:00 2001 From: Lei Zhu Date: Thu, 14 Apr 2022 16:23:03 +0800 Subject: [PATCH 3/3] Compatible changes --- .../Development/IDE/GHC/Compat/Outputable.hs | 18 +++++++++++++++--- ghcide/src/Development/IDE/Spans/Common.hs | 1 - 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs b/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs index 57f3cc368c..f1ace4693b 100644 --- a/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs +++ b/ghcide/src/Development/IDE/GHC/Compat/Outputable.hs @@ -13,6 +13,8 @@ module Development.IDE.GHC.Compat.Outputable ( mkPrintUnqualified, mkPrintUnqualifiedDefault, PrintUnqualified(..), + defaultUserStyle, + withPprStyle, -- * Parser errors PsWarning, PsError, @@ -43,7 +45,8 @@ import GHC.Types.SourceError import GHC.Types.SrcLoc import GHC.Unit.State import GHC.Utils.Error hiding (mkWarnMsg) -import GHC.Utils.Outputable +import GHC.Utils.Outputable as Out hiding (defaultUserStyle) +import qualified GHC.Utils.Outputable as Out import GHC.Utils.Panic #elif MIN_VERSION_ghc(9,0,0) import GHC.Driver.Session @@ -52,14 +55,16 @@ import GHC.Types.Name.Reader (GlobalRdrEnv) import GHC.Types.SrcLoc import GHC.Utils.Error as Err hiding (mkWarnMsg) import qualified GHC.Utils.Error as Err -import GHC.Utils.Outputable as Out +import GHC.Utils.Outputable as Out hiding (defaultUserStyle) +import qualified GHC.Utils.Outputable as Out #else import Development.IDE.GHC.Compat.Core (GlobalRdrEnv) import DynFlags import ErrUtils hiding (mkWarnMsg) import qualified ErrUtils as Err import HscTypes -import Outputable as Out +import Outputable as Out hiding (defaultUserStyle) +import qualified Outputable as Out import SrcLoc #endif @@ -178,3 +183,10 @@ mkWarnMsg = #else Err.mkWarnMsg #endif + +defaultUserStyle :: PprStyle +#if MIN_VERSION_ghc(9,0,0) +defaultUserStyle = Out.defaultUserStyle +#else +defaultUserStyle = Out.defaultUserStyle unsafeGlobalDynFlags +#endif diff --git a/ghcide/src/Development/IDE/Spans/Common.hs b/ghcide/src/Development/IDE/Spans/Common.hs index 62a573142c..54ee952f49 100644 --- a/ghcide/src/Development/IDE/Spans/Common.hs +++ b/ghcide/src/Development/IDE/Spans/Common.hs @@ -24,7 +24,6 @@ import qualified Data.Text as T import GHC.Generics import GHC -import GHC.Utils.Outputable (withPprStyle, defaultUserStyle) import Development.IDE.GHC.Compat import Development.IDE.GHC.Orphans ()