diff --git a/.vscode/launch.json b/.vscode/launch.json index eabbe74502e..3cfe86350f5 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -18,6 +18,14 @@ "vmArgs": "-ea", "projectName": "rascal" }, + { + "type": "java", + "name": "Attach RascalNotebook", + "request": "attach", + "hostName": "localhost", + "port": 8000, + "projectName": "rascal-notebook" + }, { "type": "java", "name": "Launch RascalShell in rascal-core", diff --git a/src/org/rascalmpl/library/lang/rascal/tutor/TutorCommandExecutor.java b/src/org/rascalmpl/library/lang/rascal/tutor/TutorCommandExecutor.java index e9216ae413d..533245d5f2c 100644 --- a/src/org/rascalmpl/library/lang/rascal/tutor/TutorCommandExecutor.java +++ b/src/org/rascalmpl/library/lang/rascal/tutor/TutorCommandExecutor.java @@ -39,7 +39,7 @@ public TutorCommandExecutor(PathConfig pcfg) throws IOException, URISyntaxExcept shellHTMLOutput = new ByteArrayOutputStream(); shellInputNotUsed = new ByteArrayInputStream("***this inputstream should not be used***".getBytes()); - repl = new RascalInterpreterREPL(false, false, false, null) { + repl = new RascalInterpreterREPL(false, false, null) { @Override protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, OutputStream stderr) { Evaluator eval = ShellEvaluatorFactory.getDefaultEvaluator(input, stdout, stderr); diff --git a/src/org/rascalmpl/library/util/TermREPL.java b/src/org/rascalmpl/library/util/TermREPL.java index a07dfa107d3..3756de1c35f 100644 --- a/src/org/rascalmpl/library/util/TermREPL.java +++ b/src/org/rascalmpl/library/util/TermREPL.java @@ -80,7 +80,6 @@ public static class TheREPL implements ILanguageProtocol { private final IValueFactory vf; private final AbstractFunction stacktrace; - public TheREPL(IValueFactory vf, IString title, IString welcome, IString prompt, IString quit, ISourceLocation history, IFunction handler, IFunction completor, IValue stacktrace, InputStream input, OutputStream stderr, OutputStream stdout) { this.vf = vf; @@ -98,7 +97,6 @@ public TheREPL(IValueFactory vf, IString title, IString welcome, IString prompt, this.stacktrace = (AbstractFunction) stacktrace; this.currentPrompt = prompt.getValue(); this.quit = quit.getValue(); - } @Override diff --git a/src/org/rascalmpl/repl/BaseRascalREPL.java b/src/org/rascalmpl/repl/BaseRascalREPL.java index c1e7a3a6f37..9cdbce0c74b 100755 --- a/src/org/rascalmpl/repl/BaseRascalREPL.java +++ b/src/org/rascalmpl/repl/BaseRascalREPL.java @@ -62,13 +62,11 @@ protected State getState() { protected String currentPrompt = ReadEvalPrintDialogMessages.PROMPT; private StringBuffer currentCommand; protected final StandardTextWriter indentedPrettyPrinter; - private final boolean htmlOutput; private final boolean allowColors; private final static IValueFactory VF = ValueFactoryFactory.getValueFactory(); protected final REPLContentServerManager contentManager = new REPLContentServerManager(); - public BaseRascalREPL(boolean prettyPrompt, boolean allowColors, boolean htmlOutput) throws IOException, URISyntaxException { - this.htmlOutput = htmlOutput; + public BaseRascalREPL(boolean prettyPrompt, boolean allowColors) throws IOException, URISyntaxException { this.allowColors = allowColors; if (allowColors) { @@ -152,13 +150,11 @@ private static interface OutputWriter { } protected void printResult(IRascalResult result, Map output, Map metadata) throws IOException { - String mimeType = "text/" + (htmlOutput ? "html" : "plain"); - if (result == null || result.getValue() == null) { - output.put(mimeType, stringStream("ok\n")); + output.put("text/plain", stringStream("ok\n")); return; } - else if (result.getStaticType() == RascalValueFactory.Content) { + else if (result.getStaticType().isSubtypeOf(RascalValueFactory.Content) && !result.getStaticType().isBottom()) { // we have interactive output in HTML form to serve serveContent(result, output, metadata); output.put("text/plain", stringStream("ok\n")); @@ -185,10 +181,10 @@ public void finishOutput() { writeOutput(result, writer); if (out.getBuffer().length() == 0) { - output.put(mimeType, stringStream("ok\n")); + output.put("text/plain", stringStream("ok\n")); } else { - output.put(mimeType, stringStream(out.toString())); + output.put("text/plain", stringStream(out.toString())); } } } @@ -216,11 +212,7 @@ private void serveContent(IRascalResult result, Map output, metadata.put("url", URL); - if (!htmlOutput) { - // if there is HTML output we can see it inline - getOutputWriter().println("Serving \'" + id + "\' at |" + URL + "|"); - } - + output.put("text/plain", stringStream("Serving \'" + id + "\' at |" + URL + "|")); output.put("text/html", stringStream("")); } diff --git a/src/org/rascalmpl/repl/RascalInterpreterREPL.java b/src/org/rascalmpl/repl/RascalInterpreterREPL.java index d70ec41984b..5b9b6a0a9bf 100644 --- a/src/org/rascalmpl/repl/RascalInterpreterREPL.java +++ b/src/org/rascalmpl/repl/RascalInterpreterREPL.java @@ -39,9 +39,9 @@ public abstract class RascalInterpreterREPL extends BaseRascalREPL { protected Evaluator eval; private boolean measureCommandTime; - public RascalInterpreterREPL(boolean prettyPrompt, boolean allowColors, boolean htmlOutput, File persistentHistory) + public RascalInterpreterREPL(boolean prettyPrompt, boolean allowColors, File persistentHistory) throws IOException, URISyntaxException { - super(prettyPrompt, allowColors, htmlOutput); + super(prettyPrompt, allowColors); } public void cleanEnvironment() { @@ -49,20 +49,15 @@ public void cleanEnvironment() { } public RascalInterpreterREPL() throws IOException, URISyntaxException{ - super(true, true, false); + super(true, true); } - public RascalInterpreterREPL(boolean htmlOutput) throws IOException, URISyntaxException{ - super(true, true, htmlOutput); - } - @Override protected Function liftProviderFunction(IFunction callback) { - return (t) -> { - synchronized(eval) { - return callback.call(t); - } + synchronized(eval) { + return callback.call(t); + } }; } diff --git a/src/org/rascalmpl/shell/REPLRunner.java b/src/org/rascalmpl/shell/REPLRunner.java index 24716ed7b87..708e7259978 100755 --- a/src/org/rascalmpl/shell/REPLRunner.java +++ b/src/org/rascalmpl/shell/REPLRunner.java @@ -32,7 +32,7 @@ private static File getHistoryFile() throws IOException { public REPLRunner(InputStream stdin, OutputStream stderr, OutputStream stdout, Terminal term) throws IOException, URISyntaxException { - super(makeInterpreter(stdin, stderr, stdout, true, term.isAnsiSupported(), false, getHistoryFile(), term), null, + super(makeInterpreter(stdin, stderr, stdout, true, term.isAnsiSupported(), getHistoryFile(), term), null, stdin, stderr, stdout, true, term.isAnsiSupported(), getHistoryFile(), term, null); } @@ -41,10 +41,10 @@ public REPLRunner(ILanguageProtocol language) throws IOException, URISyntaxExcep } private static ILanguageProtocol makeInterpreter(InputStream stdin, OutputStream stderr, OutputStream stdout, - boolean prettyPrompt, boolean allowColors, boolean htmlOutput, File persistentHistory, Terminal terminal) + boolean prettyPrompt, boolean allowColors, File persistentHistory, Terminal terminal) throws IOException, URISyntaxException { RascalInterpreterREPL repl = - new RascalInterpreterREPL(prettyPrompt, allowColors, htmlOutput, getHistoryFile()) { + new RascalInterpreterREPL(prettyPrompt, allowColors, getHistoryFile()) { @Override protected Evaluator constructEvaluator(InputStream input, OutputStream stdout, OutputStream stderr) { return ShellEvaluatorFactory.getDefaultEvaluator(input, stdout, stderr);