Skip to content

Commit

Permalink
Fixes #1814; not in a way I would want, but it works for now
Browse files Browse the repository at this point in the history
  • Loading branch information
jurgenvinju committed Jun 26, 2023
1 parent 331a52f commit 83023f6
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
3 changes: 1 addition & 2 deletions src/org/rascalmpl/exceptions/Throw.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.rascalmpl.interpreter.control_exceptions.ControlException;
import org.rascalmpl.interpreter.utils.LimitedResultWriter;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import org.rascalmpl.uri.URIUtil;

import io.usethesource.vallang.ISourceLocation;
Expand Down Expand Up @@ -84,7 +83,7 @@ private static String toString(IValue value, int length){
try {
stw.write(value, lros);
}
catch (IOLimitReachedException iolrex){
catch (/*IOLimitReachedException*/ RuntimeException iolrex){
// This is fine, ignore.
}
catch (IOException ioex) {
Expand Down
7 changes: 3 additions & 4 deletions src/org/rascalmpl/interpreter/result/AbstractFunction.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.rascalmpl.interpreter.staticErrors.UnexpectedKeywordArgumentType;
import org.rascalmpl.interpreter.staticErrors.UnexpectedType;
import org.rascalmpl.interpreter.utils.LimitedResultWriter;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import org.rascalmpl.interpreter.utils.Names;
import org.rascalmpl.uri.URIUtil;
import org.rascalmpl.values.RascalValueFactory;
Expand Down Expand Up @@ -265,12 +264,12 @@ private String strval(IValue value) {
new StandardTextWriter(true, 2).write(value, w);
return w.toString();
}
catch (IOLimitReachedException e) {
return w.toString();
}
catch (IOException e) {
return "...";
}
catch (/*IOLimitReachedException*/ RuntimeException e) {
return w.toString();
}
}
protected void printHeader(StringBuilder b, IValue[] actuals) {
b.append(moduleName());
Expand Down
3 changes: 1 addition & 2 deletions src/org/rascalmpl/interpreter/result/Result.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.rascalmpl.interpreter.staticErrors.UnexpectedType;
import org.rascalmpl.interpreter.staticErrors.UnsupportedOperation;
import org.rascalmpl.interpreter.utils.LimitedResultWriter;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import io.usethesource.vallang.IBool;
import io.usethesource.vallang.IReal;
import io.usethesource.vallang.IValue;
Expand Down Expand Up @@ -129,7 +128,7 @@ public String toString(int length){
try {
stw.write(getValue(), lros);
}
catch (IOLimitReachedException iolrex){
catch (/*IOLimitReachedException*/ RuntimeException iolrex){
// This is fine, ignore.
}
catch (IOException ioex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static class IOLimitReachedException extends RuntimeException {
private static final long serialVersionUID = -1396788285349799099L;

public IOLimitReachedException(){
super("Limit reached");
super("Limit reached", null, true, false);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.rascalmpl.interpreter.control_exceptions.InterruptException;
import org.rascalmpl.interpreter.result.Result;
import org.rascalmpl.interpreter.staticErrors.StaticError;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import org.rascalmpl.parser.gtd.exception.ParseError;
import org.rascalmpl.values.RascalValueFactory;
import org.rascalmpl.values.parsetrees.TreeAdapter;
Expand Down Expand Up @@ -53,7 +52,7 @@ public static String resultMessage(Result<IValue> result) {
LimitedResultWriter lros = new LimitedResultWriter(1000);
try{
stw.write(value, lros);
}catch(IOLimitReachedException iolrex){
}catch(/*IOLimitReachedException*/ RuntimeException iolrex){
// This is fine, ignore.
}catch(IOException ioex){
// This can never happen.
Expand Down Expand Up @@ -165,7 +164,7 @@ public static void throwMessage(PrintWriter out, Throw e, StandardTextWriter pre
prettyPrinter.write(e.getException(), lros);
}
}
catch(IOLimitReachedException iolrex){
catch(/*IOLimitReachedException*/ RuntimeException iolrex){
// This is fine, ignore.
}
catch(IOException ioex){
Expand Down
1 change: 1 addition & 0 deletions src/org/rascalmpl/library/ParseTree.rsc
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ Then in a next run, we load the parser and use it:
import ParseTree;
p = loadParsers(|test-temp:///E.parsers|);
p(type(sort("E"), ()), "e+e", |src:///|);
```
}
@benefits{
* loaded parsers can be used immediately without the need of loadig and executing a parser generator.
Expand Down
3 changes: 1 addition & 2 deletions src/org/rascalmpl/library/Prelude.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.rascalmpl.exceptions.RuntimeExceptionFactory;
import org.rascalmpl.exceptions.Throw;
import org.rascalmpl.ideservices.IDEServices;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import org.rascalmpl.repl.LimitedLineWriter;
import org.rascalmpl.types.TypeReifier;
import org.rascalmpl.unicode.UnicodeOffsetLengthReader;
Expand Down Expand Up @@ -915,7 +914,7 @@ public void iprint(IValue arg, IInteger lineLimit){
try {
w.write(arg, output);
}
catch (IOLimitReachedException e) {
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore, it's what we wanted
}
catch (IOException e) {
Expand Down
2 changes: 1 addition & 1 deletion src/org/rascalmpl/library/util/Reflective.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private String printResult(IRascalResult result) throws IOException {
try (Writer wrt = new LimitedWriter(out, CHAR_LIMIT)) {
singleLinePrettyPrinter.write(value, wrt);
}
catch (IOLimitReachedException e) {
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore since this is what we wanted
}
}
Expand Down
13 changes: 9 additions & 4 deletions src/org/rascalmpl/repl/BaseRascalREPL.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import org.rascalmpl.interpreter.asserts.Ambiguous;
import org.rascalmpl.interpreter.result.IRascalResult;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import org.rascalmpl.interpreter.utils.ReadEvalPrintDialogMessages;
import org.rascalmpl.interpreter.utils.StringUtils;
import org.rascalmpl.interpreter.utils.StringUtils.OffsetLengthTerm;
Expand Down Expand Up @@ -233,15 +232,19 @@ else if (type.isString()) {
try (Writer wrt = new LimitedWriter(new LimitedLineWriter(w, LINE_LIMIT), CHAR_LIMIT)) {
indentedPrettyPrinter.write(value, wrt);
}
catch (IOLimitReachedException e) {
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore since this is what we wanted
// if we catch IOLimitReachedException we get an IllegalArgument exception instead
// "Self-suppression not permitted"
}
w.write("\n---\n");
try (Writer wrt = new LimitedWriter(new LimitedLineWriter(w, LINE_LIMIT), CHAR_LIMIT)) {
((IString) value).write(wrt);
}
catch (IOLimitReachedException e) {
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore since this is what we wanted
// if we catch IOLimitReachedException we get an IllegalArgument exception instead
// "Self-suppression not permitted"
}
w.write("\n---");
});
Expand All @@ -252,8 +255,10 @@ else if (type.isString()) {
try (Writer wrt = new LimitedWriter(new LimitedLineWriter(w, LINE_LIMIT), CHAR_LIMIT)) {
indentedPrettyPrinter.write(value, wrt);
}
catch (IOLimitReachedException e) {
catch (/*IOLimitReachedException*/ RuntimeException e) {
// ignore since this is what we wanted
// if we catch IOLimitReachedException we get an IllegalArgument exception instead
// "Self-suppression not permitted"
}
});
}
Expand Down
3 changes: 1 addition & 2 deletions src/org/rascalmpl/values/parsetrees/TreeAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.fusesource.jansi.Ansi.Color;
import org.rascalmpl.exceptions.ImplementationError;
import org.rascalmpl.interpreter.utils.LimitedResultWriter;
import org.rascalmpl.interpreter.utils.LimitedResultWriter.IOLimitReachedException;
import org.rascalmpl.values.RascalValueFactory;
import org.rascalmpl.values.ValueFactoryFactory;
import org.rascalmpl.values.parsetrees.visitors.TreeVisitor;
Expand Down Expand Up @@ -830,7 +829,7 @@ public static String yield(IConstructor tree, boolean highlight, int limit) {
unparse(tree, highlight, stream);
return stream.toString();
}
catch (IOLimitReachedException e) {
catch (/*IOLimitReachedException*/ RuntimeException e) {
return stream.toString();
}
catch (IOException e) {
Expand Down

0 comments on commit 83023f6

Please sign in to comment.