Github user ScrapCodes commented on a diff in the pull request:

    https://github.com/apache/spark/pull/6903#discussion_r32891497
  
    --- Diff: 
repl/scala-2.11/src/main/scala/org/apache/spark/repl/SparkILoop.scala ---
    @@ -98,875 +60,39 @@ class SparkILoop(in0: Option[BufferedReader], 
protected val out: JPrintWriter)
         echo("Type :help for more information.")
       }
     
    -  override def echoCommandMessage(msg: String) {
    -    intp.reporter printUntruncatedMessage msg
    -  }
    -
    -  // lazy val power = new Power(intp, new 
StdReplVals(this))(tagOfStdReplVals, classTag[StdReplVals])
    -  def history = in.history
    -
    -  // classpath entries added via :cp
    -  var addedClasspath: String = ""
    -
    -  /** A reverse list of commands to replay if the user requests a :replay 
*/
    -  var replayCommandStack: List[String] = Nil
    -
    -  /** A list of commands to replay if the user requests a :replay */
    -  def replayCommands = replayCommandStack.reverse
    -
    -  /** Record a command for replay should the user request a :replay */
    -  def addReplay(cmd: String) = replayCommandStack ::= cmd
    -
    -  def savingReplayStack[T](body: => T): T = {
    -    val saved = replayCommandStack
    -    try body
    -    finally replayCommandStack = saved
    -  }
    -  def savingReader[T](body: => T): T = {
    -    val saved = in
    -    try body
    -    finally in = saved
    -  }
    -
    -  /** Close the interpreter and set the var to null. */
    -  def closeInterpreter() {
    -    if (intp ne null) {
    -      intp.close()
    -      intp = null
    -    }
    -  }
    -
    -  class SparkILoopInterpreter extends SparkIMain(settings, out) {
    -    outer =>
    -
    -    override lazy val formatting = new Formatting {
    -      def prompt = SparkILoop.this.prompt
    -    }
    -    override protected def parentClassLoader =
    -      settings.explicitParentLoader.getOrElse( 
classOf[SparkILoop].getClassLoader )
    -  }
    -
    -  /** Create a new interpreter. */
    -  def createInterpreter() {
    -    if (addedClasspath != "")
    -      settings.classpath append addedClasspath
    -
    -    intp = new SparkILoopInterpreter
    -  }
    -
    -  /** print a friendly help message */
    -  def helpCommand(line: String): Result = {
    -    if (line == "") helpSummary()
    -    else uniqueCommand(line) match {
    -      case Some(lc) => echo("\n" + lc.help)
    -      case _        => ambiguousError(line)
    -    }
    -  }
    -  private def helpSummary() = {
    -    val usageWidth  = commands map (_.usageMsg.length) max
    -    val formatStr   = "%-" + usageWidth + "s %s"
    -
    -    echo("All commands can be abbreviated, e.g. :he instead of :help.")
    -
    -    commands foreach { cmd =>
    -      echo(formatStr.format(cmd.usageMsg, cmd.help))
    -    }
    -  }
    -  private def ambiguousError(cmd: String): Result = {
    -    matchingCommands(cmd) match {
    -      case Nil  => echo(cmd + ": no such command.  Type :help for help.")
    -      case xs   => echo(cmd + " is ambiguous: did you mean " + xs.map(":" 
+ _.name).mkString(" or ") + "?")
    -    }
    -    Result(keepRunning = true, None)
    -  }
    -  private def matchingCommands(cmd: String) = commands filter (_.name 
startsWith cmd)
    -  private def uniqueCommand(cmd: String): Option[LoopCommand] = {
    -    // this lets us add commands willy-nilly and only requires enough 
command to disambiguate
    -    matchingCommands(cmd) match {
    -      case List(x)  => Some(x)
    -      // exact match OK even if otherwise appears ambiguous
    -      case xs       => xs find (_.name == cmd)
    -    }
    -  }
    -
    -  /** Show the history */
    -  lazy val historyCommand = new LoopCommand("history", "show the history 
(optional num is commands to show)") {
    -    override def usage = "[num]"
    -    def defaultLines = 20
    -
    -    def apply(line: String): Result = {
    -      if (history eq NoHistory)
    -        return "No history available."
    -
    -      val xs      = words(line)
    -      val current = history.index
    -      val count   = try xs.head.toInt catch { case _: Exception => 
defaultLines }
    -      val lines   = history.asStrings takeRight count
    -      val offset  = current - lines.size + 1
    -
    -      for ((line, index) <- lines.zipWithIndex)
    -        echo("%3d  %s".format(index + offset, line))
    -    }
    -  }
    -
    -  // When you know you are most likely breaking into the middle
    -  // of a line being typed.  This softens the blow.
    -  protected def echoAndRefresh(msg: String) = {
    -    echo("\n" + msg)
    -    in.redrawLine()
    -  }
    -  protected def echo(msg: String) = {
    -    out println msg
    -    out.flush()
    -  }
    -
    -  /** Search the history */
    -  def searchHistory(_cmdline: String) {
    -    val cmdline = _cmdline.toLowerCase
    -    val offset  = history.index - history.size + 1
    -
    -    for ((line, index) <- history.asStrings.zipWithIndex ; if 
line.toLowerCase contains cmdline)
    -      echo("%d %s".format(index + offset, line))
    -  }
    -
    -  private val currentPrompt = Properties.shellPromptString
    -
    -  /** Prompt to print when awaiting input */
    -  def prompt = currentPrompt
    -
       import LoopCommand.{ cmd, nullary }
     
    -  /** Standard commands **/
    -  lazy val standardCommands = List(
    -    cmd("cp", "<path>", "add a jar or directory to the classpath", 
addClasspath),
    -    cmd("edit", "<id>|<line>", "edit history", editCommand),
    -    cmd("help", "[command]", "print this summary or command-specific 
help", helpCommand),
    -    historyCommand,
    -    cmd("h?", "<string>", "search the history", searchHistory),
    -    cmd("imports", "[name name ...]", "show import history, identifying 
sources of names", importsCommand),
    -    //cmd("implicits", "[-v]", "show the implicits in scope", 
intp.implicitsCommand),
    -    cmd("javap", "<path|class>", "disassemble a file or class name", 
javapCommand),
    -    cmd("line", "<id>|<line>", "place line(s) at the end of history", 
lineCommand),
    -    cmd("load", "<path>", "interpret lines in a file", loadCommand),
    -    cmd("paste", "[-raw] [path]", "enter paste mode or paste a file", 
pasteCommand),
    -    // nullary("power", "enable power user mode", powerCmd),
    -    nullary("quit", "exit the interpreter", () => Result(keepRunning = 
false, None)),
    -    nullary("replay", "reset execution and replay all previous commands", 
replay),
    -    nullary("reset", "reset the repl to its initial state, forgetting all 
session entries", resetCommand),
    -    cmd("save", "<path>", "save replayable session to a file", 
saveCommand),
    -    shCommand,
    -    cmd("settings", "[+|-]<options>", "+enable/-disable flags, set 
compiler options", changeSettings),
    -    nullary("silent", "disable/enable automatic printing of results", 
verbosity),
    -//    cmd("type", "[-v] <expr>", "display the type of an expression 
without evaluating it", typeCommand),
    -//    cmd("kind", "[-v] <expr>", "display the kind of expression's type", 
kindCommand),
    -    nullary("warnings", "show the suppressed warnings from the most recent 
line which had any", warningsCommand)
    -  )
    -
    -  /** Power user commands */
    -//  lazy val powerCommands: List[LoopCommand] = List(
    -//    cmd("phase", "<phase>", "set the implicit phase for power commands", 
phaseCommand)
    -//  )
    -
    -  private def importsCommand(line: String): Result = {
    -    val tokens    = words(line)
    -    val handlers  = intp.languageWildcardHandlers ++ intp.importHandlers
    -
    -    handlers.filterNot(_.importedSymbols.isEmpty).zipWithIndex foreach {
    -      case (handler, idx) =>
    -        val (types, terms) = handler.importedSymbols partition 
(_.name.isTypeName)
    -        val imps           = handler.implicitSymbols
    -        val found          = tokens filter (handler importsSymbolNamed _)
    -        val typeMsg        = if (types.isEmpty) "" else types.size + " 
types"
    -        val termMsg        = if (terms.isEmpty) "" else terms.size + " 
terms"
    -        val implicitMsg    = if (imps.isEmpty) "" else imps.size + " are 
implicit"
    -        val foundMsg       = if (found.isEmpty) "" else found.mkString(" 
// imports: ", ", ", "")
    -        val statsMsg       = List(typeMsg, termMsg, implicitMsg) filterNot 
(_ == "") mkString ("(", ", ", ")")
    -
    -        intp.reporter.printMessage("%2d) %-30s %s%s".format(
    -          idx + 1,
    -          handler.importString,
    -          statsMsg,
    -          foundMsg
    -        ))
    -    }
    -  }
    -
    -  private def findToolsJar() = 
PathResolver.SupplementalLocations.platformTools
    -
    -  private def addToolsJarToLoader() = {
    -    val cl = findToolsJar() match {
    -      case Some(tools) => ScalaClassLoader.fromURLs(Seq(tools.toURL), 
intp.classLoader)
    -      case _           => intp.classLoader
    -    }
    -    if (Javap.isAvailable(cl)) {
    -      repldbg(":javap available.")
    -      cl
    -    }
    -    else {
    -      repldbg(":javap unavailable: no tools.jar at " + jdkHome)
    -      intp.classLoader
    -    }
    -  }
    -//
    -//  protected def newJavap() =
    -//    JavapClass(addToolsJarToLoader(), new 
IMain.ReplStrippingWriter(intp), Some(intp))
    -//
    -//  private lazy val javap = substituteAndLog[Javap]("javap", 
NoJavap)(newJavap())
    -
    -  // Still todo: modules.
    -//  private def typeCommand(line0: String): Result = {
    -//    line0.trim match {
    -//      case "" => ":type [-v] <expression>"
    -//      case s  => intp.typeCommandInternal(s stripPrefix "-v " trim, 
verbose = s startsWith "-v ")
    -//    }
    -//  }
    -
    -//  private def kindCommand(expr: String): Result = {
    -//    expr.trim match {
    -//      case "" => ":kind [-v] <expression>"
    -//      case s  => intp.kindCommandInternal(s stripPrefix "-v " trim, 
verbose = s startsWith "-v ")
    -//    }
    -//  }
    -
    -  private def warningsCommand(): Result = {
    -    if (intp.lastWarnings.isEmpty)
    -      "Can't find any cached warnings."
    -    else
    -      intp.lastWarnings foreach { case (pos, msg) => 
intp.reporter.warning(pos, msg) }
    -  }
    +  private val blockedCommands = Set("implicits", "javap", "power", "type", 
"kind")
    --- End diff --
    
    Why did you block these commands, may be to retain the original behavior or 
something ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to