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 32 commits into
base: main
Choose a base branch
from
Open

Migrate to jline3 #2063

wants to merge 32 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
  • 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
@@ -47,7 +47,7 @@
"request": "attach",
"projectName": "rascal",
"hostName": "localhost",
"port": 9001
"port": 9213
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this port and why has it changed?

Copy link
Member Author

Choose a reason for hiding this comment

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

it's for remote debugging, and I should revert it, or at least not part of this PR.

@@ -232,26 +224,26 @@ public void decCallNesting() {
private static final Object dummy = new Object();

/**
* Promotes the monitor to the outputstream automatically if so required.
* Promotes the monitor to the PrintWriter automatically if so required.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add some explanation on the different constructors and how to use them? The current comments are quite terse (and non-existent for two of the four constructors).

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but that's not part of this PR, as I'm trying to reduce the changes to code not related to the REPL.

}
}
}
}

private static void addIt(SortedSet<String> result, String v, String qualifier, String originalTerm) {
private static void addIt(SortedMap<String, String> result, String category, String v, String qualifier, String originalTerm) {
Copy link
Contributor

Choose a reason for hiding this comment

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

addIt? add what?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷🏼 I'm trying to be minimal here, and not change more than needed. The name is roughly: add these entries to the map in result?

src/org/rascalmpl/repl/BaseREPL.java 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.

// we do not have to filter out prefixes
word = RascalQualifiedNames.unescape(word); // remove escape that the interpreter cannot deal with
int rootedIndex = word.lastIndexOf("::");
String moduleRoot = rootedIndex == -1? "": word.substring(0, rootedIndex);
Copy link
Contributor

Choose a reason for hiding this comment

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

Whitespace is a little messed up here

Copy link
Member Author

Choose a reason for hiding this comment

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

image
which messy whitespace?

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?

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.

2 participants