Skip to content

Commit

Permalink
Merge pull request #4762 from retronym/topic/completely-2.12
Browse files Browse the repository at this point in the history
Remove the old REPL tab completion implementation
  • Loading branch information
retronym committed Sep 29, 2015
2 parents fd5994f + 9f8961c commit d770340
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 522 deletions.
1 change: 0 additions & 1 deletion src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ trait ScalaSettings extends AbsScalaSettings
val YconstOptimization = BooleanSetting ("-Yconst-opt", "Perform optimization with constant values.")
val Ycompacttrees = BooleanSetting ("-Ycompact-trees", "Use compact tree printer when displaying trees.")
val noCompletion = BooleanSetting ("-Yno-completion", "Disable tab-completion in the REPL.")
val completion = ChoiceSetting ("-Ycompletion", "provider", "Select tab-completion in the REPL.", List("pc","adhoc","none"), "pc")
val Xdce = BooleanSetting ("-Ydead-code", "Perform dead code elimination.")
val debug = BooleanSetting ("-Ydebug", "Increase the quantity of debugging output.")
//val doc = BooleanSetting ("-Ydoc", "Generate documentation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import jconsole.history.{History => JHistory}


import scala.tools.nsc.interpreter
import scala.tools.nsc.interpreter.{Completion, JLineCompletion, NoCompletion}
import scala.tools.nsc.interpreter.{Completion, NoCompletion}
import scala.tools.nsc.interpreter.Completion.Candidates
import scala.tools.nsc.interpreter.session.History

Expand Down Expand Up @@ -125,21 +125,16 @@ private class JLineConsoleReader extends jconsole.ConsoleReader with interpreter
// adapt the JLine completion interface
def completer =
new Completer {
val tc = completion.completer()
val tc = completion
def complete(_buf: String, cursor: Int, candidates: JList[CharSequence]): Int = {
val buf = if (_buf == null) "" else _buf
val Candidates(newCursor, newCandidates) = tc.complete(buf, cursor)
val Candidates(newCursor, newCandidates) = completion.complete(buf, cursor)
newCandidates foreach (candidates add _)
newCursor
}
}

// a last bit of nastiness: parsing help depending on the flavor of completer (fixme)
completion match {
case _: JLineCompletion =>
val jlineCompleter = new ArgumentCompleter(new JLineDelimiter, completer)
jlineCompleter setStrict false
this addCompleter jlineCompleter
case NoCompletion => ()
case _ => this addCompleter completer
}
Expand Down
17 changes: 2 additions & 15 deletions src/repl/scala/tools/nsc/interpreter/Completion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,22 @@ import Completion._
*/
trait Completion {
def resetVerbosity(): Unit
def completer(): ScalaCompleter
def complete(buffer: String, cursor: Int): Candidates
}
object NoCompletion extends Completion {
def resetVerbosity() = ()
def completer() = NullCompleter
def complete(buffer: String, cursor: Int) = NoCandidates
}

object Completion {
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 ".")
&& !(code == ".")
&& !(code startsWith "./")
&& !(code startsWith "..")
)
object Forwarder {
def apply(forwardTo: () => Option[CompletionAware]): CompletionAware = new CompletionAware {
def completions(verbosity: Int) = forwardTo() map (_ completions verbosity) getOrElse Nil
override def follow(s: String) = forwardTo() flatMap (_ follow s)
}
}
}
53 changes: 0 additions & 53 deletions src/repl/scala/tools/nsc/interpreter/CompletionAware.scala

This file was deleted.

85 changes: 0 additions & 85 deletions src/repl/scala/tools/nsc/interpreter/CompletionOutput.scala

This file was deleted.

7 changes: 1 addition & 6 deletions src/repl/scala/tools/nsc/interpreter/ILoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -840,12 +840,7 @@ class ILoop(in0: Option[BufferedReader], protected val out: JPrintWriter)
}

def mkReader(maker: ReaderMaker) = maker { () =>
settings.completion.value match {
case _ if settings.noCompletion => NoCompletion
case "none" => NoCompletion
case "adhoc" => new JLineCompletion(intp) // JLineCompletion is a misnomer; it's not tied to jline
case "pc" | _ => new PresentationCompilerCompleter(intp)
}
if (settings.noCompletion) NoCompletion else new PresentationCompilerCompleter(intp)
}

def internalClass(kind: String) = s"scala.tools.nsc.interpreter.$kind.InteractiveReader"
Expand Down
Loading

0 comments on commit d770340

Please sign in to comment.