summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/interpreter/package.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-02-11 04:00:46 +0000
committerPaul Phillips <paulp@improving.org>2011-02-11 04:00:46 +0000
commite9f1ccb0308f207303af2507415379c4d8dbcd6a (patch)
tree63405092a3b6eee03ee1ecef6a7da1578dd23b42 /src/compiler/scala/tools/nsc/interpreter/package.scala
parent8e380b67366ab83d81fd401632af17d7cc0c2205 (diff)
downloadscala-e9f1ccb0308f207303af2507415379c4d8dbcd6a.tar.gz
scala-e9f1ccb0308f207303af2507415379c4d8dbcd6a.tar.bz2
scala-e9f1ccb0308f207303af2507415379c4d8dbcd6a.zip
This addresses a few long standing irritations ...
This addresses a few long standing irritations with jline, rewriting chunks of it along the way. No longer does columnar output spill over and double space everything if you're unlucky with the chosen widths. Pagination works for a higher definition of work. Etc. Also, for those who enjoy operating missile systems from their repls, crash recovery now requests your permission before replaying the session. Closes #4194, no review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/package.scala')
-rw-r--r--src/compiler/scala/tools/nsc/interpreter/package.scala18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/package.scala b/src/compiler/scala/tools/nsc/interpreter/package.scala
index 42826e9c6d..e2e6cb6651 100644
--- a/src/compiler/scala/tools/nsc/interpreter/package.scala
+++ b/src/compiler/scala/tools/nsc/interpreter/package.scala
@@ -23,7 +23,9 @@ package scala.tools.nsc
* IMain contains { global: Global }
*/
package object interpreter {
- type JClass = java.lang.Class[_]
+ type JClass = java.lang.Class[_]
+ type JList[T] = java.util.List[T]
+ type JCollection[T] = java.util.Collection[T]
private[nsc] val DebugProperty = "scala.repl.debug"
private[nsc] val TraceProperty = "scala.repl.trace"
@@ -31,6 +33,10 @@ package object interpreter {
private[nsc] var isReplDebug = sys.props contains DebugProperty // Also set by -Yrepl-debug
private[nsc] implicit def enrichClass[T](clazz: Class[T]) = new RichClass[T](clazz)
+ private[interpreter] implicit def javaCharSeqCollectionToScala(xs: JCollection[_ <: CharSequence]): List[String] = {
+ import collection.JavaConverters._
+ xs.asScala.toList map ("" + _)
+ }
/** Debug output */
private[nsc] def repldbg(msg: String) = if (isReplDebug) Console println msg
@@ -43,6 +49,16 @@ package object interpreter {
x
}
+ // Longest common prefix
+ def longestCommonPrefix(xs: List[String]): String = {
+ if (xs.isEmpty || xs.contains("")) ""
+ else xs.head.head match {
+ case ch =>
+ if (xs.tail forall (_.head == ch)) "" + ch + longestCommonPrefix(xs map (_.tail))
+ else ""
+ }
+ }
+
private[nsc] def words(s: String) = s.trim split "\\s+" toList
private[nsc] def isQuoted(s: String) =
(s.length >= 2) && (s.head == s.last) && ("\"'" contains s.head)