Skip to content

Commit

Permalink
Merge pull request #10716 from hvesalai/2.13.x
Browse files Browse the repository at this point in the history
Remove SHELLOPTS=vi and -Xjline support, reinstate -Xnojline
  • Loading branch information
SethTisue committed Apr 8, 2024
2 parents 270f4bf + c83dafe commit 1776aec
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 24 deletions.
2 changes: 1 addition & 1 deletion project/ScalaOptionParser.scala
Expand Up @@ -83,7 +83,7 @@ object ScalaOptionParser {

// TODO retrieve these data programmatically, ala https://github.com/scala/scala-tool-support/blob/master/bash-completion/src/main/scala/BashCompletion.scala
private def booleanSettingNames = List("-X", "-Xasync", "-Xcheckinit", "-Xdev", "-Xdisable-assertions", "-Xexperimental", "-Xfatal-warnings", "-Xlog-free-terms", "-Xlog-free-types", "-Xlog-implicit-conversions", "-Xlog-reflective-calls",
"-Xno-forwarders", "-Xno-patmat-analysis", "-Xnon-strict-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
"-Xnojline", "-Xno-forwarders", "-Xno-patmat-analysis", "-Xnon-strict-patmat-analysis", "-Xprint-pos", "-Xprint-types", "-Xprompt", "-Xresident", "-Xshow-phases", "-Xverify", "-Y",
"-Ybreak-cycles", "-Ydebug", "-Ydebug-type-error", "-Ycompact-trees", "-YdisableFlatCpCaching", "-Ydoc-debug",
"-Yide-debug",
"-Ylog-classpath", "-Ymacro-debug-lite", "-Ymacro-debug-verbose", "-Ymacro-no-expand",
Expand Down
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/settings/ScalaSettings.scala
Expand Up @@ -100,8 +100,6 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
val maxwarns = IntSetting ("-Xmaxwarns", "Maximum warnings to print", 100, None, _ => None)
val Xmigration = ScalaVersionSetting ("-Xmigration", "version", "Warn about constructs whose behavior may have changed since version.", initial = NoScalaVersion, default = Some(AnyScalaVersion))
val Xnojline = BooleanSetting ("-Xnojline", "Do not use JLine for editing.")
.withDeprecationMessage("Replaced by -Xjline:off")
.withPostSetHook(_ => Xjline.value = "off")
val Xjline = ChoiceSetting (
name = "-Xjline",
helpArg = "mode",
Expand All @@ -112,6 +110,8 @@ trait ScalaSettings extends StandardScalaSettings with Warnings { _: MutableSett
"emacs key bindings.",
"vi key bindings",
"No JLine editing."))
.withDeprecationMessage("Replaced by use of '~/.inputrc'. Set 'editing-mode' to 'vi', 'emacs' or 'dumb'")

val Xverify = BooleanSetting ("-Xverify", "Verify generic signatures in generated bytecode.")
val plugin = MultiStringSetting ("-Xplugin", "paths", "Load a plugin from each classpath.")
val disable = MultiStringSetting ("-Xplugin-disable", "plugin", "Disable plugins by name.")
Expand Down
4 changes: 2 additions & 2 deletions src/manual/scala/man1/scalac.scala
Expand Up @@ -239,8 +239,8 @@ object scalac extends Command {
CmdOption("Xno-patmat-analysis"),
"Don't perform exhaustivity/unreachability analysis. Also, ignore " & MItalic("@switch") & " annotation."),
Definition(
CmdOption("Xjline"),
"The JLine keybindings to use: emacs/vi/off."),
CmdOption("Xnojline"),
"Do not use JLine at all for REPL input."),
Definition(
CmdOptionBound("Xplugin:", Argument("paths")),
"Load a plugin from each classpath."),
Expand Down
2 changes: 1 addition & 1 deletion src/partest/scala/tools/partest/ReplTest.scala
Expand Up @@ -32,7 +32,7 @@ abstract class ReplTest extends DirectTest {
// final because we need to enforce the existence of a couple settings.
final override def settings: Settings = {
val s = super.settings
s.Xjline.value = "off"
s.Xnojline.value = true
if (getClass.getClassLoader.getParent != null) {
s.classpath.value = s.classpath.value match {
case "" => testOutput.toString
Expand Down
10 changes: 0 additions & 10 deletions src/repl-frontend/scala/tools/nsc/interpreter/jline/Reader.scala
Expand Up @@ -14,7 +14,6 @@ package scala.tools.nsc.interpreter
package jline

import org.jline.builtins.InputRC
import org.jline.keymap.KeyMap
import org.jline.reader.Parser.ParseContext
import org.jline.reader._
import org.jline.reader.impl.{CompletionMatcherImpl, DefaultParser, LineReaderImpl}
Expand Down Expand Up @@ -150,8 +149,6 @@ object Reader {
case NonFatal(_) =>
} //ignore

val keyMap = reader.getKeyMaps.get("main")

object ScalaShowType {
val Name = "scala-show-type"
private var lastInvokeLocation: Option[(String, Int)] = None
Expand Down Expand Up @@ -180,13 +177,6 @@ object Reader {
}
reader.getWidgets().put(ScalaShowType.Name, () => ScalaShowType())

locally {
import LineReader._
// VIINS, VICMD, EMACS
val keymap = if (config.viMode) VIINS else EMACS
reader.getKeyMaps.put(MAIN, reader.getKeyMaps.get(keymap));
keyMap.bind(new Reference(ScalaShowType.Name), KeyMap.alt(KeyMap.ctrl('t')))
}
def secure(p: java.nio.file.Path): Unit = {
try scala.reflect.internal.util.OwnerOnlyChmod.chmodFileOrCreateEmpty(p)
catch { case scala.util.control.NonFatal(e) =>
Expand Down
Expand Up @@ -38,8 +38,7 @@ object ShellConfig {
val batchText: String = if (settings.execute.isSetByUser) settings.execute.value else ""
val batchMode: Boolean = batchText.nonEmpty
val doCompletion: Boolean = !(settings.noCompletion.value || batchMode)
val haveInteractiveConsole: Boolean = settings.Xjline.value != "off"
override val viMode = super.viMode || settings.Xjline.value == "vi"
val haveInteractiveConsole: Boolean = !settings.Xnojline.value
def xsource: String = if (settings.isScala3: @nowarn) settings.source.value.versionString else ""
}
case _ => new ShellConfig {
Expand All @@ -48,8 +47,7 @@ object ShellConfig {
val batchText: String = ""
val batchMode: Boolean = false
val doCompletion: Boolean = !settings.noCompletion.value
val haveInteractiveConsole: Boolean = settings.Xjline.value != "off"
override val viMode = super.viMode || settings.Xjline.value == "vi"
val haveInteractiveConsole: Boolean = !settings.Xnojline.value
def xsource: String = if (settings.isScala3: @nowarn) settings.source.value.versionString else ""
}
}
Expand All @@ -62,7 +60,6 @@ trait ShellConfig {
def batchMode: Boolean
def doCompletion: Boolean
def haveInteractiveConsole: Boolean
def viMode: Boolean = envOrNone("SHELLOPTS").map(_.split(":").contains("vi")).getOrElse(false)

// source compatibility, i.e., -Xsource
def xsource: String
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/type-tag-leak.scala
Expand Up @@ -19,7 +19,7 @@ object Test extends Test {
def main(args: Array[String]): Unit = {
for (i <- 1 to 16) {
val settings = new scala.tools.nsc.Settings
settings.Xjline.value = "off"
settings.Xnojline.value = true
settings.usejavacp.value = true

val intp = new IMain(settings, new shell.ReplReporterImpl(settings, new PrintWriter(new StringWriter)))
Expand Down
Expand Up @@ -13,7 +13,7 @@ class CompletionTest {

def newIMain(classBased: Boolean = false): IMain = {
val settings = new Settings()
settings.Xjline.value = "off"
settings.Xnojline.value = true
settings.usejavacp.value = true
settings.Yreplclassbased.value = classBased

Expand Down
2 changes: 1 addition & 1 deletion test/macro-annot/run/repl/repl_2.scala
Expand Up @@ -4,7 +4,7 @@ import scala.tools.nsc.interpreter.shell._
object Test extends App {
private def repl(code: String): String = {
val s = new Settings
s.Xjline.value = "off"
s.Xnojline.value = true
s.usejavacp.value = false
s.classpath.value = sys.props("sbt.paths.tests.classpath")
s.plugin.value = List(sys.props("sbt.paths.plugin.jar"))
Expand Down

0 comments on commit 1776aec

Please sign in to comment.