diff options
author | Paul Phillips <paulp@improving.org> | 2011-01-29 19:27:13 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-01-29 19:27:13 +0000 |
commit | f89016a8736f7b09ea1dd74baa6c45bb39e47444 (patch) | |
tree | 332c043a83574c6c2e1e9788439dacadceafb6f9 /src/compiler/scala/tools/nsc/interpreter/Completion.scala | |
parent | 80488e4218a0a72dec3ba727e6de276da87f1398 (diff) | |
download | scala-f89016a8736f7b09ea1dd74baa6c45bb39e47444.tar.gz scala-f89016a8736f7b09ea1dd74baa6c45bb39e47444.tar.bz2 scala-f89016a8736f7b09ea1dd74baa6c45bb39e47444.zip |
Bringing lots more encapsulation to the repl.
interfaces from implementations and isolating jline better so it doesn't
become an accidental dependency or have other unexpected effects. No
review.
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/Completion.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/Completion.scala | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/Completion.scala b/src/compiler/scala/tools/nsc/interpreter/Completion.scala index 3436c6631e..79f0317533 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Completion.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Completion.scala @@ -7,30 +7,37 @@ package scala.tools.nsc package interpreter import java.util.{ List => JList } +import Completion._ /** An implementation-agnostic completion interface which makes no * reference to the jline classes. */ trait Completion { type ExecResult - trait Instance { - def complete(buffer: String, cursor: Int, candidates: JList[CharSequence]): Int - } def resetVerbosity(): Unit def execute(line: String): Option[ExecResult] - def completer(): Instance + def completer(): ScalaCompleter +} +object NoCompletion extends Completion { + type ExecResult = Nothing + def resetVerbosity() = () + def execute(line: String) = None + def completer() = NullCompleter } object Completion { - object Empty extends Completion { - type ExecResult = Nothing - object NullCompleter extends Instance { - def complete(buffer: String, cursor: Int, candidates: JList[CharSequence]) = -1 - } - def resetVerbosity() = () - def execute(line: String) = None - def completer() = NullCompleter + def empty: Completion = NoCompletion + + case class Candidates(cursor: Int, candidates: List[String]) { } + val NoCandidates = Candidates(-1, Nil) + + object NullCompleter extends ScalaCompleter { + def complete(buffer: String, cursor: Int): Candidates = NoCandidates + } + trait ScalaCompleter { + def complete(buffer: String, cursor: Int): Candidates } + def looksLikeInvocation(code: String) = ( (code != null) && (code startsWith ".") |