@@ -60,7 +60,9 @@ import Development.IDE.Graph.Classes (Hashable,
60
60
import Development.IDE.Spans.Pragmas (NextPragmaInfo (.. ),
61
61
getFirstPragma ,
62
62
insertNewPragma )
63
- import Development.IDE.Types.Logger (cmapWithPrio )
63
+ import Development.IDE.Types.Logger (Priority (.. ),
64
+ cmapWithPrio ,
65
+ logWith , (<+>) )
64
66
import GHC.Generics (Generic )
65
67
import qualified HaskellWorks.Data.IntervalMap.FingerTree as IM
66
68
import Ide.PluginUtils (getNormalizedFilePath ,
@@ -86,11 +88,14 @@ import Language.LSP.Types (CodeAction (..),
86
88
import qualified Language.LSP.Types.Lens as L
87
89
88
90
89
- data Log = LogShake Shake. Log
91
+ data Log
92
+ = LogShake Shake. Log
93
+ | LogCollectedRecords [RecordInfo ]
90
94
91
95
instance Pretty Log where
92
96
pretty = \ case
93
97
LogShake shakeLog -> pretty shakeLog
98
+ LogCollectedRecords recs -> " Collected records with wildcards:" <+> pretty recs
94
99
95
100
descriptor :: Recorder (WithPriority Log ) -> PluginId -> PluginDescriptor IdeState
96
101
descriptor recorder plId = (defaultPluginDescriptor plId)
@@ -146,8 +151,9 @@ collectRecordsRule :: Recorder (WithPriority Log) -> Rules ()
146
151
collectRecordsRule recorder = define (cmapWithPrio LogShake recorder) $ \ CollectRecords nfp -> do
147
152
tmr <- use TypeCheck nfp
148
153
let exts = getEnabledExtensions <$> tmr
149
- recs = getRecords <$> tmr
150
- renderedRecs = mapMaybe renderRecordInfo <$> recs
154
+ recs = concat $ maybeToList (getRecords <$> tmr)
155
+ logWith recorder Debug (LogCollectedRecords recs)
156
+ let renderedRecs = traverse renderRecordInfo recs
151
157
recMap = buildIntervalMap <$> renderedRecs
152
158
pure ([] , CRR <$> recMap <*> exts)
153
159
@@ -188,12 +194,19 @@ data RecordInfo
188
194
= RecordInfoPat SrcSpan (Pat (GhcPass 'Renamed))
189
195
| RecordInfoCon SrcSpan (HsExpr (GhcPass 'Renamed))
190
196
197
+ instance Pretty RecordInfo where
198
+ pretty (RecordInfoPat ss p) = pretty (printOutputable ss) <> " :" <+> pretty (printOutputable p)
199
+ pretty (RecordInfoCon ss e) = pretty (printOutputable ss) <> " :" <+> pretty (printOutputable e)
200
+
191
201
data RenderedRecordInfo = RenderedRecordInfo
192
202
{ renderedSrcSpan :: SrcSpan
193
203
, renderedRecord :: Text
194
204
}
195
205
deriving (Generic )
196
206
207
+ instance Pretty RenderedRecordInfo where
208
+ pretty (RenderedRecordInfo ss r) = pretty (printOutputable ss) <> " :" <+> pretty r
209
+
197
210
instance NFData RenderedRecordInfo
198
211
199
212
renderRecordInfo :: RecordInfo -> Maybe RenderedRecordInfo
0 commit comments