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

Draft
wants to merge 22 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
31cb437
Working on jline3
DavyLandman May 28, 2024
c67a197
Working on jline3
DavyLandman May 29, 2024
08ffabd
Working on jline3
DavyLandman May 30, 2024
b02f63f
Cleaning up pom to drop jline2 related dependencies
DavyLandman Oct 15, 2024
57b43d1
Removing InputStream and OutputStreams from the evaluator
DavyLandman Oct 15, 2024
61d4387
Rewriting away old parts of the jline2 code
DavyLandman Oct 15, 2024
94b9425
Rewrote TerminalProgressBarMonitor
DavyLandman Oct 15, 2024
1fd8348
Working on migrating to the new repl api
DavyLandman Oct 22, 2024
91998c1
Got the first working repl to do multiline
DavyLandman Oct 24, 2024
3aa2626
Got ctrl+c to work correctly
DavyLandman Oct 24, 2024
de6d79f
Added lines to the continuation prompt
DavyLandman Oct 24, 2024
38989b9
A bit more tweaking of the prompts
DavyLandman Oct 24, 2024
3145e2f
Added initial support for command completion
DavyLandman Nov 20, 2024
79bdf53
Added module completion support
DavyLandman Nov 21, 2024
27bf01f
Also added support for keywords and identifier completion
DavyLandman Nov 21, 2024
c0387b0
Support ctrl+c to interrupt a running rascal command
DavyLandman Nov 21, 2024
3d53007
Added location completion support
DavyLandman Nov 21, 2024
26d6052
Tuned completion a bit around locations and strings
DavyLandman Nov 25, 2024
922c61e
Fixed word lexer test
DavyLandman Nov 25, 2024
11a9103
Detect keywords and escape them in completions
DavyLandman Nov 25, 2024
4adaced
Updated todo list
DavyLandman Nov 25, 2024
2370802
Added queued command support
DavyLandman Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "java",
"name": "RascalShell2",
"request": "launch",
"mainClass": "org.rascalmpl.shell.RascalShell2",
"projectName": "rascal",
"console": "integratedTerminal"
},
{
"type": "java",
"name": "Launch DocRunner",
Expand Down Expand Up @@ -38,7 +46,7 @@
"request": "launch",
"mainClass": "org.rascalmpl.shell.RascalShell",
"projectName": "rascal",
"cwd" : "${workspaceFolder}/../rascal-tutor",
"cwd": "${workspaceFolder}/../rascal-tutor",
"vmArgs": "-Xss80m -Xmx2g -ea"
},
{
Expand All @@ -47,7 +55,7 @@
"request": "attach",
"projectName": "rascal",
"hostName": "localhost",
"port": 9001
"port": 9213
},
{
"type": "java",
Expand Down
38 changes: 30 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
<rascal.test.memory>2</rascal.test.memory>
<maven.compiler.release>11</maven.compiler.release>
<rascal-maven.version>0.28.4</rascal-maven.version>
<jline.version>3.27.0</jline.version>
</properties>

<licenses>
Expand Down Expand Up @@ -332,10 +333,6 @@
<exclude>org.fusesource.jansi.internal.*</exclude>
</excludes>
</relocation>
<relocation>
<pattern>jline</pattern>
<shadedPattern>org.rascalmpl.jline</shadedPattern>
</relocation>
</relocations>
<filters>
<filter>
Expand Down Expand Up @@ -464,10 +461,35 @@
<artifactId>gson</artifactId>
<version>2.10.1</version>
</dependency>
<dependency>
<groupId>jline</groupId>
<artifactId>jline</artifactId>
<version>2.14.6</version>
<dependency> <!-- line reader/completion/history support -->
<groupId>org.jline</groupId>
<artifactId>jline-reader</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency> <!-- terminal API -->
<groupId>org.jline</groupId>
<artifactId>jline-terminal</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency> <!-- interaction with native APIs for console features, after jdk22 we can switch to FFM -->
<groupId>org.jline</groupId>
<artifactId>jline-terminal-jni</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency> <!-- styling api -->
<groupId>org.jline</groupId>
<artifactId>jline-style</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency> <!-- command registyr and extra features -->
<groupId>org.jline</groupId>
<artifactId>jline-console</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency> <!-- raw ansi commands -->
<groupId>org.jline</groupId>
<artifactId>jansi-core</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
Expand Down
125 changes: 0 additions & 125 deletions src/org/rascalmpl/checker/StaticChecker.java

This file was deleted.

20 changes: 11 additions & 9 deletions src/org/rascalmpl/debug/IRascalMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,21 @@
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;


import org.jline.terminal.Terminal;
import org.jline.utils.InfoCmp.Capability;
import org.rascalmpl.interpreter.BatchProgressMonitor;
import org.rascalmpl.interpreter.NullRascalMonitor;
import org.rascalmpl.repl.TerminalProgressBarMonitor;

import io.usethesource.vallang.ISourceLocation;
import jline.Terminal;
import jline.TerminalFactory;

public interface IRascalMonitor {
/**
Expand Down Expand Up @@ -158,8 +161,8 @@ default void jobStep(String name, String message) {
* and otherwise default to a dumn terminal console progress logger.
* @return
*/
public static IRascalMonitor buildConsoleMonitor(InputStream in, OutputStream out) {
return buildConsoleMonitor(in, out, inBatchMode());
public static IRascalMonitor buildConsoleMonitor(Terminal term) {
return buildConsoleMonitor(term, inBatchMode());
}

public static boolean inBatchMode() {
Expand All @@ -168,12 +171,11 @@ public static boolean inBatchMode() {
;
}

public static IRascalMonitor buildConsoleMonitor(InputStream in, OutputStream out, boolean batchMode) {
Terminal terminal = TerminalFactory.get();
public static IRascalMonitor buildConsoleMonitor(Terminal terminal, boolean batchMode) {

return !batchMode && terminal.isAnsiSupported()
? new TerminalProgressBarMonitor(out, in, terminal)
: new BatchProgressMonitor(new PrintStream(out))
return !batchMode && TerminalProgressBarMonitor.shouldWorkIn(terminal)
? new TerminalProgressBarMonitor(terminal)
: new BatchProgressMonitor(terminal.writer())
;
}

Expand Down
8 changes: 6 additions & 2 deletions src/org/rascalmpl/interpreter/BatchProgressMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ public class BatchProgressMonitor implements IRascalMonitor {
PrintWriter out;

public BatchProgressMonitor() {
this.out = new PrintWriter(System.err);
this(new PrintWriter(System.err, true));
}

public BatchProgressMonitor(PrintStream out) {
this.out = new PrintWriter(out);
this(new PrintWriter(out));
}

public BatchProgressMonitor(PrintWriter out) {
this.out = out;
}

@Override
Expand Down
Loading