Skip to content

Commit 90569a7

Browse files
author
Santiago Weight
committed
confusing
1 parent 8dc0bf2 commit 90569a7

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

ghcide/src/Development/IDE/GHC/ExactPrint.hs

+3
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ import GHC (EpAnn (..),
102102
import GHC.Parser.Annotation (AnnContext (..),
103103
DeltaPos (SameLine),
104104
EpaLocation (EpaDelta))
105+
import Debug.Trace (traceShowM)
105106
#endif
106107

107108
------------------------------------------------------------------------------
@@ -188,8 +189,10 @@ transform ::
188189
Either String WorkspaceEdit
189190
transform dflags ccs uri f a = do
190191
let src = printA a
192+
traceShowM src
191193
a' <- transformA a $ runGraft f dflags
192194
let res = printA a'
195+
traceShowM res
193196
pure $ diffText ccs (uri, T.pack src) (T.pack res) IncludeDeletions
194197

195198
------------------------------------------------------------------------------

plugins/hls-refine-destruct-plugin/src/Wingman/Debug.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ traceShowId = Debug.Trace.traceShowId
6161
#else
6262
traceM _ = pure ()
6363
trace _ = id
64-
traceShowId = id
64+
traceShowId = Debug.Trace.traceShowId
6565
#endif

plugins/hls-refine-destruct-plugin/src/Wingman/EmptyCase.hs

+17-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
{-# LANGUAGE TypeFamilies #-}
44

55
{-# LANGUAGE NoMonoLocalBinds #-}
6+
{-# LANGUAGE BangPatterns #-}
67

78
module Wingman.EmptyCase where
89

@@ -33,9 +34,12 @@ import Wingman.CodeGen (destructionFor)
3334
import Wingman.GHC
3435
import Wingman.Judgements
3536
import Wingman.LanguageServer
36-
import Wingman.Types
37-
import GHC (LocatedA, SrcSpanAnnA, SrcSpanAnn' (..))
37+
import Wingman.Types hiding (traceShowId)
38+
import GHC (LocatedA, SrcSpanAnnA, SrcSpanAnn' (..), EpAnn (..))
3839
import GHC.Hs (LocatedL)
40+
import Debug.Trace
41+
import GHC.Plugins (generatedSrcSpan)
42+
import Language.Haskell.GHC.ExactPrint
3943

4044

4145
data EmptyCaseT = EmptyCaseT
@@ -70,10 +74,12 @@ emptyCaseInteraction = Interaction $
7074
destructionFor
7175
(foldMap (hySingleton . occName . fst) bindings)
7276
ty
77+
traceShowM matches
7378
edits <- liftMaybe $ hush $
7479
mkWorkspaceEdits le_dflags ccs fc_uri (unTrack pm) $
7580
graftMatchGroup (RealSrcSpan (unTrack ss) Nothing) $
7681
noLocA matches
82+
traceShowM edits
7783
pure
7884
( range
7985
, Metadata
@@ -85,6 +91,8 @@ emptyCaseInteraction = Interaction $
8591
)
8692
(\ _ _ _ we -> pure $ pure $ RawEdit we)
8793

94+
instance Show (GenLocated SrcSpanAnnA (Match GhcPs (GenLocated SrcSpanAnnA (HsExpr GhcPs)))) where
95+
show = unsafeRender
8896

8997
scrutinzedType :: EmptyCaseSort Type -> Maybe Type
9098
scrutinzedType (EmptyCase ty) = pure ty
@@ -107,6 +115,12 @@ hush (Left _) = Nothing
107115
hush (Right a) = Just a
108116

109117

118+
instance Show (EpAnn AnnListItem) where
119+
show = unsafeRender
120+
121+
instance Show (EpAnn EpAnnHsCase) where
122+
show = unsafeRender . fmap showAst
123+
110124
------------------------------------------------------------------------------
111125
-- | Graft a 'RunTacticResults' into the correct place in an AST. Correctly
112126
-- deals with top-level holes, in which we might need to fiddle with the
@@ -118,7 +132,7 @@ graftMatchGroup
118132
graftMatchGroup ss l =
119133
hoistGraft (runExcept . runExceptString) $ graftExprWithM ss $ \case
120134
L span (HsCase ext scrut mg) -> do
121-
pure $ Just $ L span $ HsCase ext scrut $ mg { mg_alts = l }
135+
pure $ Just $ traceShowId $ L span $ HsCase ext scrut $ mg { mg_alts = l }
122136
L span (HsLamCase ext mg) -> do
123137
pure $ Just $ L span $ HsLamCase ext $ mg { mg_alts = l }
124138
(_ :: LHsExpr GhcPs) -> pure Nothing

plugins/hls-refine-destruct-plugin/src/Wingman/LanguageServer.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ mkWorkspaceEdits
571571
-> Graft (Either String) ParsedSource
572572
-> Either UserFacingMessage WorkspaceEdit
573573
mkWorkspaceEdits dflags ccs uri pm g = do
574-
let response = transform dflags ccs uri g pm
574+
let (traceShowId -> response) = transform dflags ccs uri g pm
575575
in first (InfrastructureError . T.pack) response
576576

577577

plugins/hls-refine-destruct-plugin/src/Wingman/StaticPlugin.hs

+7
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ staticPlugin = mempty
2424
, staticPlugins = staticPlugins df
2525
#endif
2626
}
27+
#if MIN_VERSION_ghc(9,2,0)
28+
29+
30+
, staticPlugins = []
31+
#else
32+
, staticPlugins = []
33+
#endif
2734
}
2835

2936

0 commit comments

Comments
 (0)