Skip to content

Commit bbb720f

Browse files
committed
Fix Outline build with GHC <9.2
1 parent 937efe7 commit bbb720f

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

ghcide/src/Development/IDE/LSP/Outline.hs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLNam
111111
{ _name = showRdrName n
112112
, _kind = SkConstructor
113113
, _selectionRange = realSrcSpanToRange l'
114+
#if MIN_VERSION_ghc(9,2,0)
114115
, _children = Just $ List $ childs
115116
}
116117
| con <- dd_cons
@@ -126,6 +127,14 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLNam
126127
, _kind = SkField
127128
}
128129
cvtFld _ = Nothing
130+
#else
131+
, _children = conArgRecordFields (con_args x)
132+
}
133+
| L (locA -> (RealSrcSpan l _ )) x <- dd_cons
134+
, L (locA -> (RealSrcSpan l' _)) n <- getConNames' x
135+
]
136+
}
137+
where
129138
-- | Extract the record fields of a constructor
130139
conArgRecordFields (RecCon (L _ lcdfs)) = Just $ List
131140
[ (defDocumentSymbol l :: DocumentSymbol)
@@ -136,6 +145,7 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLNam
136145
, L (locA -> (RealSrcSpan l _)) n <- rdrNameFieldOcc . unLoc <$> cd_fld_names cdf
137146
]
138147
conArgRecordFields _ = Nothing
148+
#endif
139149
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ SynDecl { tcdLName = L (locA -> (RealSrcSpan l' _)) n })) = Just
140150
(defDocumentSymbol l :: DocumentSymbol) { _name = showRdrName n
141151
, _kind = SkTypeParameter
@@ -248,17 +258,14 @@ pprText = pack . showSDocUnsafe . ppr
248258
-- the version of getConNames for ghc9 is restricted to only the renaming phase
249259
#if !MIN_VERSION_ghc(9,2,0)
250260
getConNames' :: ConDecl GhcPs -> [Located (IdP GhcPs)]
251-
#else
252-
getConNames' :: ConDecl GhcPs -> [XRec GhcPs (IdP GhcPs)]
253-
#endif
254261
getConNames' ConDeclH98 {con_name = name} = [name]
255262
getConNames' ConDeclGADT {con_names = names} = names
256263
#if !MIN_VERSION_ghc(8,10,0)
257264
getConNames' (XConDecl NoExt) = []
258265
#elif !MIN_VERSION_ghc(9,0,0)
259266
getConNames' (XConDecl x) = noExtCon x
260267
#endif
261-
268+
#else
262269
hsConDeclsBinders :: LConDecl GhcPs
263270
-> ([Located (IdP GhcPs)], [LFieldOcc GhcPs])
264271
-- See hsLTyClDeclBinders for what this does
@@ -299,4 +306,4 @@ hsConDeclsBinders cons
299306
get_flds :: Located [LConDeclField GhcPs]
300307
-> ([LFieldOcc GhcPs])
301308
get_flds flds = concatMap (cd_fld_names . unLoc) (unLoc flds)
302-
309+
#endif

0 commit comments

Comments
 (0)