@@ -35,6 +35,9 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
35
35
/** (value, maxElements) => String */
36
36
private var myReplStringOf : (Object , Int ) => String = _
37
37
38
+ /** info to add if output got truncated */
39
+ private val infoOutputGotTruncated = " ... large output truncated, print value to show all"
40
+
38
41
/** Class loader used to load compiled code */
39
42
private [repl] def classLoader ()(using Context ) =
40
43
if (myClassLoader != null && myClassLoader.root == ctx.settings.outputDir.value) myClassLoader
@@ -52,7 +55,6 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
52
55
}
53
56
54
57
myClassLoader = new AbstractFileClassLoader (ctx.settings.outputDir.value, parent)
55
- val maxPrintElements = ctx.settings.VreplMaxPrintElements .valueIn(ctx.settingsState)
56
58
myReplStringOf = {
57
59
// We need to use the ScalaRunTime class coming from the scala-library
58
60
// on the user classpath, and not the one available in the current
@@ -61,17 +63,19 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
61
63
// For old API, try to clean up extraneous newlines by stripping suffix and maybe prefix newline.
62
64
val scalaRuntime = Class .forName(" scala.runtime.ScalaRunTime" , true , myClassLoader)
63
65
val renderer = " stringOf" // was: replStringOf
64
- try {
65
- val meth = scalaRuntime.getMethod(renderer, classOf [ Object ], classOf [ Int ], classOf [ Boolean ])
66
- val truly = java.lang. Boolean . TRUE
67
-
68
- ( value : Object , maxElements : Int ) => meth.invoke(null , value, maxElements, truly).asInstanceOf [String ]
69
- } catch {
70
- case _ : NoSuchMethodException =>
71
- val meth = scalaRuntime.getMethod(renderer, classOf [Object ], classOf [Int ])
72
-
73
- ( value : Object , maxElements : Int ) => meth.invoke( null , value, maxElements). asInstanceOf [ String ]
66
+ def stringOfMaybeTruncated ( value : Object , maxElements : Int ) : String = {
67
+ try {
68
+ val meth = scalaRuntime.getMethod(renderer, classOf [ Object ], classOf [ Int ], classOf [ Boolean ])
69
+ val truly = java.lang. Boolean . TRUE
70
+ meth.invoke(null , value, maxElements, truly).asInstanceOf [String ]
71
+ } catch {
72
+ case _ : NoSuchMethodException =>
73
+ val meth = scalaRuntime.getMethod(renderer, classOf [Object ], classOf [Int ])
74
+ meth.invoke( null , value, maxElements). asInstanceOf [ String ]
75
+ }
74
76
}
77
+
78
+ stringOfMaybeTruncated
75
79
}
76
80
myClassLoader
77
81
}
@@ -83,10 +87,9 @@ private[repl] class Rendering(parentClassLoader: Option[ClassLoader] = None):
83
87
* https://github.com/scala/bug/issues/12337
84
88
*/
85
89
private [repl] def truncate (str : String ): String =
86
- val showTruncated = " ... large output truncated, print value to show all"
87
90
val ncp = str.codePointCount(0 , str.length) // to not cut inside code point
88
91
if ncp <= MaxStringElements then str
89
- else str.substring(0 , str.offsetByCodePoints(0 , MaxStringElements - 1 )) + showTruncated
92
+ else str.substring(0 , str.offsetByCodePoints(0 , MaxStringElements - 1 )) + infoOutputGotTruncated
90
93
91
94
/** Return a String representation of a value we got from `classLoader()`. */
92
95
private [repl] def replStringOf (value : Object )(using Context ): String =
0 commit comments