Skip to content

Commit

Permalink
3.20.0 Regression - Groovy REPL highlight syntax errors while typing…
Browse files Browse the repository at this point in the history
… is broken, fixes #748
  • Loading branch information
mattirn committed Nov 18, 2021
1 parent ab07ff1 commit d98f164
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions groovy/src/main/java/org/jline/script/GroovyEngine.java
Expand Up @@ -1415,24 +1415,29 @@ public Class<?> evaluateClass(String objectStatement) {
}

public Object execute(String statement) {
try {
return _execute(statement);
} catch (Exception e) {
if (Log.isDebugEnabled()) {
e.printStackTrace();
}
}
return null;
}

private Object _execute(String statement) throws Exception {
PrintStream origOut = System.out;
PrintStream origErr = System.err;
if (nullstream != null) {
System.setOut(nullstream);
System.setErr(nullstream);
}
Object out = null;
try {
out = executeStatement(shell, imports, statement);
} catch (Exception e) {
if (Log.isDebugEnabled()) {
e.printStackTrace();
}
return executeStatement(shell, imports, statement);
} finally {
System.setOut(origOut);
System.setErr(origErr);
}
return out;
}

private String stripVarType(String statement) {
Expand Down Expand Up @@ -1790,7 +1795,7 @@ private CmdDesc checkSyntax(CmdLine line) {
// do nothing
} else {
try {
execute(objEquation);
_execute(objEquation);
} catch (MissingPropertyException e) {
mainDesc.addAll(doExceptionMessage(e));
out.setErrorPattern(Pattern.compile("\\b" + e.getProperty() + "\\b"));
Expand Down Expand Up @@ -1823,7 +1828,7 @@ private CmdDesc checkSyntax(CmdLine line) {
mainDesc.addAll(doExceptionMessage(e));
}
} catch (NullPointerException e) {
// do nothing
throw e;
} catch (Exception e) {
mainDesc.addAll(doExceptionMessage(e));
}
Expand Down

0 comments on commit d98f164

Please sign in to comment.