File tree 4 files changed +58
-57
lines changed
ghcide/src/Development/IDE
plugins/hls-explicit-record-fields-plugin/src/Ide/Plugin 4 files changed +58
-57
lines changed Original file line number Diff line number Diff line change @@ -10,8 +10,7 @@ module Development.IDE.GHC.CoreFile
10
10
, readBinCoreFile
11
11
, writeBinCoreFile
12
12
, getImplicitBinds
13
- , occNamePrefixes
14
- , stripOccNamePrefix ) where
13
+ ) where
15
14
16
15
import Control.Monad
17
16
import Control.Monad.IO.Class
@@ -30,7 +29,6 @@ import GHC.Iface.Env
30
29
#if MIN_VERSION_ghc(9,11,0)
31
30
import qualified GHC.Iface.Load as Iface
32
31
#endif
33
- import Data.Monoid (First (.. ))
34
32
import GHC.Iface.Recomp.Binary (fingerprintBinMem )
35
33
import GHC.IfaceToCore
36
34
import GHC.Types.Id.Make
@@ -225,53 +223,3 @@ tc_iface_bindings (TopIfaceRec vs) = do
225
223
vs' <- traverse (\ (v, e) -> (v,) <$> tcIfaceExpr e) vs
226
224
pure $ Rec vs'
227
225
228
- -- | Prefixes that can occur in a GHC OccName
229
- occNamePrefixes :: [T. Text ]
230
- occNamePrefixes =
231
- [
232
- -- long ones
233
- " $con2tag_"
234
- , " $tag2con_"
235
- , " $maxtag_"
236
-
237
- -- four chars
238
- , " $sel:"
239
- , " $tc'"
240
-
241
- -- three chars
242
- , " $dm"
243
- , " $co"
244
- , " $tc"
245
- , " $cp"
246
- , " $fx"
247
-
248
- -- two chars
249
- , " $W"
250
- , " $w"
251
- , " $m"
252
- , " $b"
253
- , " $c"
254
- , " $d"
255
- , " $i"
256
- , " $s"
257
- , " $f"
258
- , " $r"
259
- , " C:"
260
- , " N:"
261
- , " D:"
262
- , " $p"
263
- , " $L"
264
- , " $f"
265
- , " $t"
266
- , " $c"
267
- , " $m"
268
- ]
269
-
270
- -- | When e.g. DuplicateRecordFields is enabled, compiler generates
271
- -- names like "$sel:accessor:One" and "$sel:accessor:Two" to
272
- -- disambiguate record selectors
273
- -- https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields#Implementation
274
- stripOccNamePrefix :: T. Text -> T. Text
275
- stripOccNamePrefix name = T. takeWhile (/= ' :' ) $ fromMaybe name $
276
- getFirst $ foldMap (First . (`T.stripPrefix` name))
277
- occNamePrefixes
Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ module Development.IDE.GHC.Util(
27
27
dontWriteHieFiles ,
28
28
disableWarningsAsErrors ,
29
29
printOutputable ,
30
- getExtensions
30
+ getExtensions ,
31
+ stripOccNamePrefix ,
31
32
) where
32
33
33
34
import Control.Concurrent
@@ -62,6 +63,7 @@ import GHC.IO.Handle.Types
62
63
import Ide.PluginUtils (unescape )
63
64
import System.FilePath
64
65
66
+ import Data.Monoid (First (.. ))
65
67
import GHC.Data.EnumSet
66
68
import GHC.Data.FastString
67
69
import GHC.Data.StringBuffer
@@ -271,3 +273,55 @@ printOutputable =
271
273
272
274
getExtensions :: ParsedModule -> [Extension ]
273
275
getExtensions = toList . extensionFlags . ms_hspp_opts . pm_mod_summary
276
+
277
+ -- | When e.g. DuplicateRecordFields is enabled, compiler generates
278
+ -- names like "$sel:accessor:One" and "$sel:accessor:Two" to
279
+ -- disambiguate record selectors
280
+ -- https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields/DuplicateRecordFields#Implementation
281
+ stripOccNamePrefix :: T. Text -> T. Text
282
+ stripOccNamePrefix name = T. takeWhile (/= ' :' ) $ fromMaybe name $
283
+ getFirst $ foldMap (First . (`T.stripPrefix` name))
284
+ occNamePrefixes
285
+
286
+ -- | Prefixes that can occur in a GHC OccName
287
+ occNamePrefixes :: [T. Text ]
288
+ occNamePrefixes =
289
+ [
290
+ -- long ones
291
+ " $con2tag_"
292
+ , " $tag2con_"
293
+ , " $maxtag_"
294
+
295
+ -- four chars
296
+ , " $sel:"
297
+ , " $tc'"
298
+
299
+ -- three chars
300
+ , " $dm"
301
+ , " $co"
302
+ , " $tc"
303
+ , " $cp"
304
+ , " $fx"
305
+
306
+ -- two chars
307
+ , " $W"
308
+ , " $w"
309
+ , " $m"
310
+ , " $b"
311
+ , " $c"
312
+ , " $d"
313
+ , " $i"
314
+ , " $s"
315
+ , " $f"
316
+ , " $r"
317
+ , " C:"
318
+ , " N:"
319
+ , " D:"
320
+ , " $p"
321
+ , " $L"
322
+ , " $f"
323
+ , " $t"
324
+ , " $c"
325
+ , " $m"
326
+ ]
327
+
Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ import Development.IDE.Core.PositionMapping
43
43
import Development.IDE.GHC.Compat hiding (isQual , ppr )
44
44
import qualified Development.IDE.GHC.Compat as GHC
45
45
import Development.IDE.GHC.Compat.Util
46
- import Development.IDE.GHC.CoreFile (stripOccNamePrefix )
47
46
import Development.IDE.GHC.Error
48
47
import Development.IDE.GHC.Util
49
48
import Development.IDE.Plugin.Completions.Types
Original file line number Diff line number Diff line change @@ -81,9 +81,9 @@ import Development.IDE.GHC.Compat.Core (Extension (NamedFieldPuns
81
81
mapConPatDetail , mapLoc ,
82
82
pattern RealSrcSpan ,
83
83
plusUFM_C , unitUFM )
84
- import Development.IDE.GHC.CoreFile (stripOccNamePrefix )
85
84
import Development.IDE.GHC.Util (getExtensions ,
86
- printOutputable )
85
+ printOutputable ,
86
+ stripOccNamePrefix )
87
87
import Development.IDE.Graph (RuleResult )
88
88
import Development.IDE.Graph.Classes (Hashable , NFData )
89
89
import Development.IDE.Spans.Pragmas (NextPragmaInfo (.. ),
You can’t perform that action at this time.
0 commit comments