diff --git a/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java b/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java index 5dbec31d67..81f014e030 100644 --- a/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java +++ b/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/ReplEngineConnExecutor.java @@ -159,7 +159,7 @@ public ExecuteResponse executeLine(EngineExecutionContext engineExecutorContext, String message = outputStream.toString(); System.setOut(oldStream); - System.out.println(message); + engineExecutorContext.appendStdout(message); ResultSetWriter resultSetWriter = engineExecutorContext.createResultSetWriter(ResultSetFactory.TEXT_TYPE); try { diff --git a/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/javarepl/JavaReplCompiler.java b/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/javarepl/JavaReplCompiler.java index 7be4369735..9878ed5025 100644 --- a/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/javarepl/JavaReplCompiler.java +++ b/linkis-engineconn-plugins/repl/src/main/java/org/apache/linkis/engineplugin/repl/executor/javarepl/JavaReplCompiler.java @@ -54,7 +54,7 @@ public class JavaReplCompiler { Pattern.compile("\\s+implements\\s+([\\w\\.]+)\\s*\\{\n"); private static final Pattern METHODS_PATTERN = - Pattern.compile("\n(private|public|protected)\\s+"); + Pattern.compile("(?<=\\})\\s+(private|public|protected)\\s+"); private static final Pattern FIELD_PATTERN = Pattern.compile("[^\n]+=[^\n]+;"); diff --git a/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md b/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md index 5eb8c6c1b2..e04aec5d29 100644 --- a/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md +++ b/linkis-engineconn-plugins/repl/src/main/resources/repl-ec.md @@ -71,6 +71,43 @@ import org.apache.commons.lang3.StringUtils; } ``` +#### 1.3. Multiple methods + +```text +import org.apache.commons.lang3.StringUtils; + + public void sayHello() { + System.out.println("hello"); + System.out.println(StringUtils.isEmpty("hello")); + } + public void sayHi() { + System.out.println("hi"); + System.out.println(StringUtils.isEmpty("hi")); + } +``` + +```json +{ + "executionContent":{ + "code":"import org.apache.commons.lang3.StringUtils;\n\n public void sayHello() {\n System.out.println(\"hello\");\n System.out.println(StringUtils.isEmpty(\"hello\"));\n }\n public void sayHi() {\n System.out.println(\"hi\");\n System.out.println(StringUtils.isEmpty(\"hi\"));\n }", + "runType":"repl" + }, + "params":{ + "configuration":{ + "runtime":{ + "linkis.repl.type":"java", + "linkis.repl.method.name":"sayHi" + } + } + }, + "labels":{ + "engineType":"repl-1", + "userCreator":"linkis-IDE" + } +} +``` + + ### 2. Submitting scala tasks with Restful API ```text