Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JLine3 #7645

Closed
wants to merge 1 commit into from
Closed

Use JLine3 #7645

wants to merge 1 commit into from

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Jan 15, 2019

Minimal changes to support new API,
with basic completion and history.
JLine handles continuation line edit.

Gets the ball rolling finally.

  • Backend, nail down interface and protocol
  • Colorization
  • Excise old continuation handling
  • History and related features
  • Compile to functions, frontend manages inputs
  • Coursier convenience
  • Hook up -x formatting and contribute to jline
  • Fix // print
  • Support camel-cased, anagram-style completion as previously

Fixes scala/bug#11367

@scala-jenkins scala-jenkins added this to the 2.13.0-RC1 milestone Jan 15, 2019
@retronym
Copy link
Member

retronym commented Jan 15, 2019

Thanks for this.

It's nice that autocomplete doesn't burn lines of console anymore, the options are updated in-place on subsequent typing. now takes you into the matrix of completions to navigate with a cursor. Previously, we'd detect and emit the signature for the first candidate. I'm sure JLine3 has a better way to render this, perhaps in a status bar.

I noticed that ^A ^E no longer go to line start/end all the time. It's probably worth extracting a self-contained, Java-written version of the basic way we rig up JLine in readiness to get support on the JLine mailing list.

@SethTisue
Copy link
Member

is there anything here that must land early, e.g. in 2.13.0-RC1, in order for the rest to land later in some 2.13.x (perhaps x=0, who knows?)

@allanrenucci
Copy link
Contributor

Here is the implementation in Dotty for reference. I believe it would be straigforward to port our syntax highlighter

Minimal changes to support new API,
with basic completion and history.
JLine handles continuation line edit.
@som-snytt
Copy link
Contributor Author

I would accept a hint about how I might have broken

tools.test.osgi.reflection.toolbox.ReflectionToolBoxTest.basicMirrorThroughOsgi

Error Message

java.lang.ClassNotFoundException: scala.tools.reflect.ToolBoxFactory cannot be found by PAXEXAM-PROBE-5cbfb121-3e82-4a02-ae19-41d33580c408_0.0.0

Stacktrace

sbt.ForkMain$ForkError: java.lang.ClassNotFoundException: scala.tools.reflect.ToolBoxFactory cannot be found by PAXEXAM-PROBE-5cbfb121-3e82-4a02-ae19-41d33580c408_0.0.0
	at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:508)

@adriaanm
Copy link
Contributor

We'll take care of the random breakage, I'm happy for you to focus on the core of the jline upgrade.

@som-snytt
Copy link
Contributor Author

I need the green check before I take a step into the mine field. (For now, I'll branch and add features over the pit of quicksand.)

@som-snytt som-snytt closed this Jan 20, 2019
@som-snytt som-snytt deleted the issue/jline3 branch January 20, 2019 14:32
@SethTisue SethTisue removed this from the 2.13.0-RC1 milestone Jan 21, 2019
@adriaanm adriaanm added this to the 2.13.0-RC1 milestone Jan 21, 2019
@adriaanm
Copy link
Contributor

adriaanm commented Jan 21, 2019

The osgi minefield looks clear after

diff --git a/build.sbt b/build.sbt
index 21b1f1c..ebf67b7 100644
--- a/build.sbt
+++ b/build.sbt
@@ -457,7 +457,14 @@ lazy val compiler = configureAsSubproject(project)
       "-doc-root-content", (sourceDirectory in Compile).value + "/rootdoc.txt"
     ),
     Osgi.headers ++= Seq(
-      "Import-Package" -> ("jline.*;resolution:=optional," +
+      "Import-Package" -> ("org.jline.keymap.*;resolution:=optional,"+
+                           "org.jline.reader.*;resolution:=optional,"+
+                           "org.jline.style.*;resolution:=optional,"+
+                           "org.jline.terminal;resolution:=optional,"+
+                           "org.jline.terminal.impl;resolution:=optional,"+
+                           "org.jline.terminal.impl.jansi.*;resolution:=optional,"+
+                           "org.jline.terminal.spi;resolution:=optional,"+
+                           "org.jline.utils;resolution:=optional,"+
                            raw"""scala.*;version="$${range;[==,=+);$${ver}}",""" +
                            "*"),
       "Class-Path" -> "scala-reflect.jar scala-library.jar"

I don't think we're going to get a ✅ on shipping the LGPL jna library, so we should also drop that dependency. It looks like jansi is all we need? I pushed these diffs to jline3 on my fork (test run: https://scala-ci.typesafe.com/job/scala-2.13.x-validate-main/6696/)

@adriaanm
Copy link
Contributor

Just one test failure in that run, btw: test/files/run/repl-paste-parse.scala.

@som-snytt
Copy link
Contributor Author

Right, that was just output order because of ripping out startup dance. I'll PR with updates and more acceptable functionality.

@adriaanm
Copy link
Contributor

Excellent, thank you. Let me know if there’s other minefields I can throw myself at :-)

@SethTisue SethTisue removed this from the 2.13.0-RC1 milestone Feb 22, 2019
@smarter
Copy link
Member

smarter commented Mar 20, 2019

I don't think we're going to get a white_check_mark on shipping the LGPL jna library, so we should also drop that dependency.

JNA can be used as Apache2: https://github.com/java-native-access/jna/blob/16aac5fcac290ac05804da222e779e2dba365aa5/LICENSE#L1-L6

@som-snytt
Copy link
Contributor Author

Thanks. BTW, I just checked out this branch locally to push it over the line, or over the cliff. The current REPL is totally unusable in comparison. :)

@SethTisue
Copy link
Member

At a coffeeshop in Bern today I was openly drooling at the prospect of getting JLine 3 support in Scala 2. I think the other patrons were staring.

@SethTisue
Copy link
Member

SethTisue commented Mar 5, 2020

At a coffeeshop in Bern today I was openly drooling at the prospect of getting JLine 3 support in Scala 2.

Strangely enough, I will be at a coffeeshop in Bern again tomorrow, almost exactly one year later, again drooling over the same thing.

Residents of Bern: “THAT guy again?"

@SethTisue
Copy link
Member

SethTisue commented Mar 5, 2020

I've now been through this PR and extracted remaining TODOs at https://github.com/scala/scala-dev/labels/t%3Ajline3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
8 participants