@@ -107,9 +107,9 @@ import Language.LSP.Protocol.Types (CodeAction (..),
107
107
WorkspaceEdit (WorkspaceEdit ),
108
108
type (|? ) (InL , InR ))
109
109
110
- #if __GLASGOW_HASKELL__ < 910
110
+
111
111
import Development.IDE.GHC.Compat (HsExpansion (HsExpanded ))
112
- #endif
112
+
113
113
114
114
data Log
115
115
= LogShake Shake. Log
@@ -271,11 +271,11 @@ collectNamesRule = defineNoDiagnostics mempty $ \CollectNames nfp -> runMaybeT $
271
271
-- | Collects all 'Name's of a given source file, to be used
272
272
-- in the variable usage analysis.
273
273
getNames :: TcModuleResult -> UniqFM Name [Name ]
274
- #if __GLASGOW_HASKELL__ < 910
274
+
275
275
getNames (tmrRenamed -> (group,_,_,_)) = collectNames group
276
- #else
277
- getNames (tmrRenamed -> (group,_,_,_,_)) = collectNames group
278
- #endif
276
+
277
+
278
+
279
279
280
280
data CollectRecords = CollectRecords
281
281
deriving (Eq , Show , Generic )
@@ -441,10 +441,16 @@ showRecordPat names = fmap printOutputable . mapConPatDetail (\case
441
441
_ -> Nothing )
442
442
443
443
showRecordPatFlds :: Pat GhcTc -> Maybe [Name ]
444
- showRecordPatFlds (ConPat _ _ args) = fmap (fmap ((\ case FieldOcc x _ -> getName x) . unLoc . hfbLHS . unLoc) . rec_flds) (m args)
444
+ showRecordPatFlds (ConPat _ _ args) = do
445
+ fields <- processRecCon args
446
+ names <- mapM getFieldName (rec_flds fields)
447
+ pure names
445
448
where
446
- m (RecCon flds) = Just $ processRecordFlds flds
447
- m _ = Nothing
449
+ processRecCon (RecCon flds) = Just $ processRecordFlds flds
450
+ processRecCon _ = Nothing
451
+ getOccName (FieldOcc x _) = Just $ getName x
452
+ getOccName _ = Nothing
453
+ getFieldName = getOccName . unLoc . hfbLHS . unLoc
448
454
showRecordPatFlds _ = Nothing
449
455
450
456
showRecordCon :: Outputable (HsExpr (GhcPass c )) => HsExpr (GhcPass c ) -> Maybe Text
@@ -454,10 +460,12 @@ showRecordCon expr@(RecordCon _ _ flds) =
454
460
showRecordCon _ = Nothing
455
461
456
462
showRecordConFlds :: p ~ GhcTc => HsExpr p -> Maybe [Name ]
457
- showRecordConFlds (RecordCon _ _ flds) = mapM (m . unLoc . hfbRHS . unLoc) (rec_flds $ processRecordFlds flds)
463
+ showRecordConFlds (RecordCon _ _ flds) =
464
+ mapM getFieldName (rec_flds $ processRecordFlds flds)
458
465
where
459
- m (HsVar _ lidp) = Just $ getName lidp
460
- m _ = Nothing
466
+ getVarName (HsVar _ lidp) = Just $ getName lidp
467
+ getVarName _ = Nothing
468
+ getFieldName = getVarName . unLoc . hfbRHS . unLoc
461
469
showRecordConFlds _ = Nothing
462
470
463
471
@@ -485,11 +493,11 @@ getRecCons :: LHsExpr GhcTc -> ([RecordInfo], Bool)
485
493
-- because there is a possibility that there were be more than one result per
486
494
-- branch
487
495
488
- #if __GLASGOW_HASKELL__ >= 910
489
- getRecCons (unLoc -> XExpr ( ExpandedThingTc a _)) = (collectRecords a, False )
490
- #else
496
+
497
+
498
+
491
499
getRecCons (unLoc -> XExpr (ExpansionExpr (HsExpanded _ a))) = (collectRecords a, True )
492
- #endif
500
+
493
501
getRecCons e@ (unLoc -> RecordCon _ _ flds)
494
502
| isJust (rec_dotdot flds) = (mkRecInfo e, False )
495
503
where
0 commit comments