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
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
56 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
a58f57e
Added clear capability
DavyLandman Dec 17, 2024
0a911ac
Remove old implementation of REPL
DavyLandman Dec 17, 2024
43d4b65
Rewrote everything into output streams to reduce all the strings
DavyLandman Dec 18, 2024
d793d68
Working on support for the parametric repl and compiler
DavyLandman Dec 19, 2024
98c3e8b
Finished rewriting REPL framework to prepare for compiler and parametric
DavyLandman Dec 20, 2024
f498c27
Cleaning more old code and getting history to work correctly
DavyLandman Dec 20, 2024
712e848
Forgotten commit after rename
DavyLandman Dec 20, 2024
9f84a1a
Cleaning up old code
DavyLandman Dec 20, 2024
bcac0a1
Implemented TermREPL support
DavyLandman Dec 20, 2024
dc1ce03
Supported ctrl+\ escape in the REPL
DavyLandman Dec 27, 2024
e95c18d
Updated todo list
DavyLandman Dec 27, 2024
f74a9cb
Refactored some names
DavyLandman Dec 29, 2024
b516619
Fixed performance issues with the progress bar
DavyLandman Dec 29, 2024
993af6d
Cherry-picking the fix in 4c14ae6
DavyLandman Jan 2, 2025
fa645ec
Merge remote-tracking branch 'origin/main' into migrate-jline3
DavyLandman Jan 2, 2025
61d4ff8
We have to overwrite println as it doesn't use the regular write func…
DavyLandman Jan 7, 2025
7e2d844
Avoid deadlock by sharing the lock of the writer
DavyLandman Jan 7, 2025
7460c65
Merge remote-tracking branch 'origin/main' into migrate-jline3
DavyLandman Jan 9, 2025
7d2d546
Implemented parse error reporting by highlighting the error in the RE…
DavyLandman Jan 9, 2025
51434a3
Removing input stream reader as it breaks copy and paste
DavyLandman Jan 10, 2025
f27104d
Using ansi library in progress bar instead of own escapes
DavyLandman Jan 10, 2025
b0200c2
Removing old code
DavyLandman Jan 10, 2025
a0cdd3e
Added license headers to all the files in the REPL
DavyLandman Jan 10, 2025
227196a
Wrote documentation for all the classes
DavyLandman Jan 10, 2025
60a0e01
Removed java compile error
DavyLandman Jan 10, 2025
085e226
Made sure junit tests dont fight with jline3
DavyLandman Jan 10, 2025
139078a
Made sure line numbers start at 1 not at 0
DavyLandman Jan 10, 2025
cf981f3
No need for shading, especially in the unshaded jar
DavyLandman Jan 13, 2025
87dd9ed
Fixed detection of newline character in maven
DavyLandman Jan 13, 2025
1fd9767
Apply suggestions from code review
DavyLandman Jan 13, 2025
689b983
Process review remarks
DavyLandman Jan 14, 2025
6962a02
Everyone uses getOutPrinter and getErrorPrinter now
DavyLandman Jan 15, 2025
eeed5d4
REPL server uses asReader interface for string
DavyLandman Jan 15, 2025
f589f74
Solve progress bar in test sometimes hiding a line
DavyLandman Jan 16, 2025
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
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,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 +47,7 @@
"request": "attach",
"projectName": "rascal",
"hostName": "localhost",
"port": 9001
"port": 9213
DavyLandman marked this conversation as resolved.
Show resolved Hide resolved
},
{
"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: 8 additions & 12 deletions src/org/rascalmpl/debug/IRascalMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,18 @@
*******************************************************************************/
package org.rascalmpl.debug;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
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.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 +155,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 +165,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
11 changes: 10 additions & 1 deletion src/org/rascalmpl/ideservices/BasicIDEServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;

import org.jline.terminal.Terminal;
import org.rascalmpl.debug.IRascalMonitor;
import org.rascalmpl.uri.URIResolverRegistry;
import org.rascalmpl.uri.URIUtil;
Expand All @@ -34,16 +35,24 @@
public class BasicIDEServices implements IDEServices {
private final IRascalMonitor monitor;
private final PrintWriter stderr;
private final Terminal terminal;

public BasicIDEServices(PrintWriter stderr, IRascalMonitor monitor){
public BasicIDEServices(PrintWriter stderr, IRascalMonitor monitor, Terminal terminal){
this.stderr = stderr;
this.monitor = monitor;
this.terminal = terminal;
}

@Override
public PrintWriter stderr() {
return stderr;
}

@Override
public Terminal activeTerminal() {
return terminal;
}


public void browse(ISourceLocation loc, String title, int viewColumn){
browse(loc.getURI(), title, viewColumn);
Expand Down
11 changes: 11 additions & 0 deletions src/org/rascalmpl/ideservices/IDEServices.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.io.PrintWriter;
import java.net.URI;

import org.jline.terminal.Terminal;
import org.rascalmpl.debug.IRascalMonitor;
import org.rascalmpl.uri.LogicalMapResolver;
import org.rascalmpl.uri.URIResolverRegistry;
Expand Down Expand Up @@ -73,6 +74,16 @@ default void unregisterLanguage(IConstructor language) {
throw new UnsupportedOperationException("registerLanguage is not implemented in this environment.");
}

/**
* Get access to the current terminal. <br>
* used for features such as clearing the terminal, and starting a nested REPL. <br>
* Can return null if there is no active terminal.
* @return a terminal if there is one, null otherwise.
*/
default Terminal activeTerminal() {
return null;
}

/**
* Asks the IDE to apply document edits as defined in the standard library module
* analysis::diff::edits::TextEdits, according to the semantics defined in
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));
DavyLandman marked this conversation as resolved.
Show resolved Hide resolved
}

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

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import java.io.PrintWriter;

import org.rascalmpl.repl.ReplTextWriter;
import org.rascalmpl.repl.streams.ReplTextWriter;

import io.usethesource.vallang.ISourceLocation;

Expand Down
Loading