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

Migrate to jline3 #2063

Open
wants to merge 56 commits into
base: main
Choose a base branch
from
Open

Migrate to jline3 #2063

wants to merge 56 commits into from

Conversation

DavyLandman
Copy link
Member

@DavyLandman DavyLandman commented Oct 24, 2024

This PR migrates the REPL to jline3, numerous issues are solved, but it also required a redesign of all the REPL classes.

This breaks some stuff, which could not be avoided. The most noticeble is that all Input&OutputStreams were removed from the evaluator. That was (in hindsight) not a good design choice, as they are about bytes, while we want to print text. This gets messy when we have to figure out which charset we should write to the stream.

Todo's:

  • add back ctrl+/ support
  • add back "measure time feature"
  • test that the nested REPL work
  • fix a few bugs around the progress bar when recovering prints
  • diagnose why the progress bar got slower (in fixing it, it got 3x as fast as current main)
  • fix merge conflicts with main
  • add some javadocs & license headers

@DavyLandman DavyLandman marked this pull request as ready for review December 20, 2024 16:13
.vscode/launch.json Outdated Show resolved Hide resolved
src/org/rascalmpl/interpreter/Evaluator.java Show resolved Hide resolved
src/org/rascalmpl/interpreter/Evaluator.java Outdated Show resolved Hide resolved
src/org/rascalmpl/repl/BaseREPL.java Show resolved Hide resolved
src/org/rascalmpl/repl/TerminalProgressBarMonitor.java Outdated Show resolved Hide resolved
private final NavigableMap<String, String> setOptions;
private final BiConsumer<String, List<Candidate>> completeIdentifier;
private final BiConsumer<String, List<Candidate>> completeModule;
public RascalCommandCompletion(NavigableMap<String, String> setOptions, BiConsumer<String, List<Candidate>> completeIdentifier, BiConsumer<String, List<Candidate>> completeModule) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the BiConsumer approach? Because a simple function returning a list of candidates is less efficient?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the end yes, and since this is called frequently, I thought to keep the design of jline3 (namely: here, append onto this list) around. I've not measured it if concatenation would be an acceptable performance tradeoff.

sw.write(value, wrt);
}
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore since this is what we wanted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not completely understand this, but does this mean e should be an instance of IOLimitReacheException but we cannot catch that directly? If so, should we not check for this explicitly to make sure we are not ignoring another RuntimeException?

Copy link

codecov bot commented Jan 2, 2025

Codecov Report

Attention: Patch coverage is 6.70578% with 1113 lines in your changes missing coverage. Please review.

Project coverage is 49%. Comparing base (7da84cf) to head (f589f74).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...org/rascalmpl/repl/TerminalProgressBarMonitor.java 0% 122 Missing ⚠️
.../org/rascalmpl/repl/rascal/RascalValuePrinter.java 0% 115 Missing ⚠️
src/org/rascalmpl/library/util/TermREPL.java 0% 86 Missing ⚠️
src/org/rascalmpl/repl/BaseREPL.java 0% 79 Missing ⚠️
.../org/rascalmpl/repl/rascal/RascalReplServices.java 0% 78 Missing ⚠️
...c/org/rascalmpl/repl/rascal/ParseErrorPrinter.java 0% 73 Missing ⚠️
...g/rascalmpl/repl/rascal/RascalInterpreterREPL.java 0% 72 Missing ⚠️
...rc/org/rascalmpl/repl/rascal/RascalLineParser.java 50% 48 Missing and 12 partials ⚠️
...lmpl/repl/completers/RascalLocationCompletion.java 0% 53 Missing ⚠️
...ascalmpl/repl/completers/RascalQualifiedNames.java 0% 52 Missing ⚠️
... and 28 more
Additional details and impacted files
@@           Coverage Diff           @@
##              main   #2063   +/-   ##
=======================================
  Coverage       49%     49%           
- Complexity    6237    6251   +14     
=======================================
  Files          663     675   +12     
  Lines        59211   59268   +57     
  Branches      8629    8641   +12     
=======================================
+ Hits         29509   29573   +64     
+ Misses       27473   27461   -12     
- Partials      2229    2234    +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sungshik sungshik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an impressive amount of work! Very nice improvements 🙂. Replacing streams with writers looks good: cleaner and less code. Regarding my comments:

  • Most of them are nits
  • I turned on full pedantic mode a few times to add suggestions for user-facing messages (and a few typos in comments). It's hopefully easy to batch them using the corresponding button and quickly be done with them.
  • The bigger things (but non-essential) to consider, are related to moving code to more general, REPL-unspecific packages (e.g., I imagine we might want to reuse the completers in IDEs as well). See the comments for details.
  • I don't have a separate comment for this, but I've been seeing some null arguments and returns occasionally, and also some checker annotations, but not consistently everywhere I think? This could be something to improve (but not necessarily in this PR).
  • Some of the deeper details of the implementation were a bit hard for me to get a good feel for (e.g., sequences of jline invocations; the way in which the progress bar is manipulated). I haven't seen anything obviously wrong with it, but it's very well possible I might have missed something in those code fragments.

src/org/rascalmpl/interpreter/BatchProgressMonitor.java Outdated Show resolved Hide resolved
src/org/rascalmpl/interpreter/Evaluator.java Show resolved Hide resolved
src/org/rascalmpl/interpreter/Evaluator.java Show resolved Hide resolved
src/org/rascalmpl/interpreter/Evaluator.java Outdated Show resolved Hide resolved
src/org/rascalmpl/repl/rascal/RascalLineParser.java Outdated Show resolved Hide resolved
src/org/rascalmpl/repl/rascal/RascalLineParser.java Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants