@@ -26,6 +26,33 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
26
26
27
27
var myClassLoader : AbstractFileClassLoader = uninitialized
28
28
29
+ private var BlackWhite : AnyRef = uninitialized
30
+ private var BlackWhite_apply : java.lang.reflect.Method = uninitialized
31
+ private var FansiStr_plainText : java.lang.reflect.Method = uninitialized
32
+ private def pprintInit ()(using Context ): Unit = {
33
+ if BlackWhite_apply == null then
34
+ val cl = classLoader()
35
+ val pprintCls = Class .forName(" dotty.shaded.pprint.PPrinter$BlackWhite$" , false , cl)
36
+ BlackWhite = pprintCls.getField(" MODULE$" ).get(null )
37
+ BlackWhite_apply = pprintCls.getMethod(" apply" ,
38
+ classOf [Any ], // value
39
+ classOf [Int ], // width
40
+ classOf [Int ], // height
41
+ classOf [Int ], // indentation
42
+ classOf [Int ], // initialOffset
43
+ classOf [Boolean ], // escape Unicode
44
+ classOf [Boolean ], // show field names
45
+ )
46
+ val fansiStrCls = Class .forName(" dotty.shaded.fansi.Str" , false , cl)
47
+ FansiStr_plainText = fansiStrCls.getMethod(" plainText" )
48
+ end if
49
+ }
50
+ private def pprintRender (value : Any , width : Int , height : Int , initialOffset : Int )(using Context ): String = {
51
+ pprintInit()
52
+ val fansiStr = BlackWhite_apply .invoke(BlackWhite , value, width, height, 2 , initialOffset, false , true )
53
+ FansiStr_plainText .invoke(fansiStr).asInstanceOf [String ]
54
+ }
55
+
29
56
30
57
/** Class loader used to load compiled code */
31
58
private [repl] def classLoader ()(using Context ) =
@@ -55,7 +82,8 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
55
82
/** Return a String representation of a value we got from `classLoader()`. */
56
83
private [repl] def replStringOf (sym : Symbol , value : Object )(using Context ): String = {
57
84
// pretty-print things with 100 cols 50 rows by default,
58
- dotty.shaded.pprint.PPrinter .BlackWhite .apply(value, width = 100 , height = 50 ).plainText
85
+ // dotty.shaded.pprint.PPrinter.BlackWhite.apply(value, width = 100, height = 50).plainText
86
+ pprintRender(value, width = 100 , height = 50 , initialOffset = 0 /* TODO: include offset */ )
59
87
}
60
88
61
89
/** Load the value of the symbol using reflection.
0 commit comments