@@ -13,14 +13,14 @@ import Control.Monad.IO.Class
13
13
import Data.Functor
14
14
import Data.Generics
15
15
import Data.Maybe
16
- import Data.Text (Text , pack )
17
16
import qualified Data.Text as T
18
17
import Development.IDE.Core.Rules
19
18
import Development.IDE.Core.Shake
20
19
import Development.IDE.GHC.Compat
21
20
import Development.IDE.GHC.Error (rangeToRealSrcSpan ,
22
21
realSrcSpanToRange )
23
22
import Development.IDE.Types.Location
23
+ import Development.IDE.GHC.Util (printOutputable )
24
24
import Language.LSP.Server (LspM )
25
25
import Language.LSP.Types (DocumentSymbol (.. ),
26
26
DocumentSymbolParams (DocumentSymbolParams , _textDocument ),
@@ -47,7 +47,7 @@ moduleOutline ideState DocumentSymbolParams{ _textDocument = TextDocumentIdentif
47
47
moduleSymbol = hsmodName >>= \ case
48
48
(L (locA -> (RealSrcSpan l _)) m) -> Just $
49
49
(defDocumentSymbol l :: DocumentSymbol )
50
- { _name = pprText m
50
+ { _name = printOutputable m
51
51
, _kind = SkFile
52
52
, _range = Range (Position 0 0 ) (Position maxBound 0 ) -- _ltop is 0 0 0 0
53
53
}
@@ -70,18 +70,18 @@ moduleOutline ideState DocumentSymbolParams{ _textDocument = TextDocumentIdentif
70
70
documentSymbolForDecl :: LHsDecl GhcPs -> Maybe DocumentSymbol
71
71
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ FamDecl { tcdFam = FamilyDecl { fdLName = L _ n, fdInfo, fdTyVars } }))
72
72
= Just (defDocumentSymbol l :: DocumentSymbol )
73
- { _name = showRdrName n
74
- <> (case pprText fdTyVars of
73
+ { _name = printOutputable n
74
+ <> (case printOutputable fdTyVars of
75
75
" " -> " "
76
76
t -> " " <> t
77
77
)
78
- , _detail = Just $ pprText fdInfo
78
+ , _detail = Just $ printOutputable fdInfo
79
79
, _kind = SkFunction
80
80
}
81
81
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ ClassDecl { tcdLName = L _ name, tcdSigs, tcdTyVars }))
82
82
= Just (defDocumentSymbol l :: DocumentSymbol )
83
- { _name = showRdrName name
84
- <> (case pprText tcdTyVars of
83
+ { _name = printOutputable name
84
+ <> (case printOutputable tcdTyVars of
85
85
" " -> " "
86
86
t -> " " <> t
87
87
)
@@ -90,7 +90,7 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ ClassDecl { tcdLNa
90
90
, _children =
91
91
Just $ List
92
92
[ (defDocumentSymbol l :: DocumentSymbol )
93
- { _name = showRdrName n
93
+ { _name = printOutputable n
94
94
, _kind = SkMethod
95
95
, _selectionRange = realSrcSpanToRange l'
96
96
}
@@ -100,12 +100,12 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ ClassDecl { tcdLNa
100
100
}
101
101
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLName = L _ name, tcdDataDefn = HsDataDefn { dd_cons } }))
102
102
= Just (defDocumentSymbol l :: DocumentSymbol )
103
- { _name = showRdrName name
103
+ { _name = printOutputable name
104
104
, _kind = SkStruct
105
105
, _children =
106
106
Just $ List
107
107
[ (defDocumentSymbol l :: DocumentSymbol )
108
- { _name = showRdrName n
108
+ { _name = printOutputable n
109
109
, _kind = SkConstructor
110
110
, _selectionRange = realSrcSpanToRange l'
111
111
#if MIN_VERSION_ghc(9,2,0)
@@ -123,7 +123,7 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLNam
123
123
where
124
124
cvtFld :: LFieldOcc GhcPs -> Maybe DocumentSymbol
125
125
cvtFld (L (RealSrcSpan l _) n) = Just $ (defDocumentSymbol l :: DocumentSymbol )
126
- { _name = showRdrName (unLoc (rdrNameFieldOcc n))
126
+ { _name = printOutputable (unLoc (rdrNameFieldOcc n))
127
127
, _kind = SkField
128
128
}
129
129
cvtFld _ = Nothing
@@ -138,7 +138,7 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLNam
138
138
-- | Extract the record fields of a constructor
139
139
conArgRecordFields (RecCon (L _ lcdfs)) = Just $ List
140
140
[ (defDocumentSymbol l :: DocumentSymbol )
141
- { _name = showRdrName n
141
+ { _name = printOutputable n
142
142
, _kind = SkField
143
143
}
144
144
| L _ cdf <- lcdfs
@@ -147,12 +147,12 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ DataDecl { tcdLNam
147
147
conArgRecordFields _ = Nothing
148
148
#endif
149
149
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (TyClD _ SynDecl { tcdLName = L (locA -> (RealSrcSpan l' _)) n })) = Just
150
- (defDocumentSymbol l :: DocumentSymbol ) { _name = showRdrName n
150
+ (defDocumentSymbol l :: DocumentSymbol ) { _name = printOutputable n
151
151
, _kind = SkTypeParameter
152
152
, _selectionRange = realSrcSpanToRange l'
153
153
}
154
154
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (InstD _ ClsInstD { cid_inst = ClsInstDecl { cid_poly_ty } }))
155
- = Just (defDocumentSymbol l :: DocumentSymbol ) { _name = pprText cid_poly_ty
155
+ = Just (defDocumentSymbol l :: DocumentSymbol ) { _name = printOutputable cid_poly_ty
156
156
, _kind = SkInterface
157
157
}
158
158
#if MIN_VERSION_ghc(9,2,0)
@@ -161,8 +161,8 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (InstD _ DataFamInstD { dfi
161
161
documentSymbolForDecl (L (RealSrcSpan l _) (InstD _ DataFamInstD { dfid_inst = DataFamInstDecl HsIB { hsib_body = FamEqn { feqn_tycon, feqn_pats } } }))
162
162
#endif
163
163
= Just (defDocumentSymbol l :: DocumentSymbol )
164
- { _name = showRdrName (unLoc feqn_tycon) <> " " <> T. unwords
165
- (map pprText feqn_pats)
164
+ { _name = printOutputable (unLoc feqn_tycon) <> " " <> T. unwords
165
+ (map printOutputable feqn_pats)
166
166
, _kind = SkInterface
167
167
}
168
168
#if MIN_VERSION_ghc(9,2,0)
@@ -171,24 +171,24 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (InstD _ TyFamInstD { tfid_
171
171
documentSymbolForDecl (L (RealSrcSpan l _) (InstD _ TyFamInstD { tfid_inst = TyFamInstDecl HsIB { hsib_body = FamEqn { feqn_tycon, feqn_pats } } }))
172
172
#endif
173
173
= Just (defDocumentSymbol l :: DocumentSymbol )
174
- { _name = showRdrName (unLoc feqn_tycon) <> " " <> T. unwords
175
- (map pprText feqn_pats)
174
+ { _name = printOutputable (unLoc feqn_tycon) <> " " <> T. unwords
175
+ (map printOutputable feqn_pats)
176
176
, _kind = SkInterface
177
177
}
178
178
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (DerivD _ DerivDecl { deriv_type })) =
179
179
gfindtype deriv_type <&> \ (L (_ :: SrcSpan ) name) ->
180
- (defDocumentSymbol l :: DocumentSymbol ) { _name = pprText @ (HsType GhcPs )
180
+ (defDocumentSymbol l :: DocumentSymbol ) { _name = printOutputable @ (HsType GhcPs )
181
181
name
182
182
, _kind = SkInterface
183
183
}
184
184
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (ValD _ FunBind {fun_id = L _ name})) = Just
185
185
(defDocumentSymbol l :: DocumentSymbol )
186
- { _name = showRdrName name
186
+ { _name = printOutputable name
187
187
, _kind = SkFunction
188
188
}
189
189
documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (ValD _ PatBind {pat_lhs})) = Just
190
190
(defDocumentSymbol l :: DocumentSymbol )
191
- { _name = pprText pat_lhs
191
+ { _name = printOutputable pat_lhs
192
192
, _kind = SkFunction
193
193
}
194
194
@@ -204,7 +204,7 @@ documentSymbolForDecl (L (locA -> (RealSrcSpan l _)) (ForD _ x)) = Just
204
204
ForeignExport {} -> Just " export"
205
205
XForeignDecl {} -> Nothing
206
206
}
207
- where name = showRdrName $ unLoc $ fd_name x
207
+ where name = printOutputable $ unLoc $ fd_name x
208
208
209
209
documentSymbolForDecl _ = Nothing
210
210
@@ -228,7 +228,7 @@ documentSymbolForImportSummary importSymbols =
228
228
documentSymbolForImport :: LImportDecl GhcPs -> Maybe DocumentSymbol
229
229
documentSymbolForImport (L (locA -> (RealSrcSpan l _)) ImportDecl { ideclName, ideclQualified }) = Just
230
230
(defDocumentSymbol l :: DocumentSymbol )
231
- { _name = " import " <> pprText ideclName
231
+ { _name = " import " <> printOutputable ideclName
232
232
, _kind = SkModule
233
233
#if MIN_VERSION_ghc(8,10,0)
234
234
, _detail = case ideclQualified of { NotQualified -> Nothing ; _ -> Just " qualified" }
@@ -249,12 +249,6 @@ defDocumentSymbol l = DocumentSymbol { .. } where
249
249
_children = Nothing
250
250
_tags = Nothing
251
251
252
- showRdrName :: RdrName -> Text
253
- showRdrName = pprText
254
-
255
- pprText :: Outputable a => a -> Text
256
- pprText = pack . showSDocUnsafe . ppr
257
-
258
252
-- the version of getConNames for ghc9 is restricted to only the renaming phase
259
253
#if !MIN_VERSION_ghc(9,2,0)
260
254
getConNames' :: ConDecl GhcPs -> [Located (IdP GhcPs )]
0 commit comments