Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,17 @@ public InterpreterResult interpret(String[] lines, InterpreterContext context) {
Code r = null;

String incomplete = "";
for (String s : linesToRun) {
for (int l = 0; l < linesToRun.length; l++) {
String s = linesToRun[l];
// check if next line starts with "." (but not ".." or "./") it is treated as an invocation
if (l + 1 < linesToRun.length) {
String nextLine = linesToRun[l + 1].trim();
if (nextLine.startsWith(".") && !nextLine.startsWith("..") && !nextLine.startsWith("./")) {
incomplete += s + "\n";
continue;
}
}

scala.tools.nsc.interpreter.Results.Result res = null;
try {
res = imain.interpret(incomplete + s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public void testSimpleStatement() {
assertEquals("1", result.message());
}

@Test
public void testNextlineInvoke() {
InterpreterResult result = flink.interpret("\"123\"\n .toInt", context);
assertEquals("res0: Int = 123\n", result.message());
}

@Test
public void testWordCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,17 @@ private InterpreterResult interpret(String[] lines) {
Code code = null;

String incomplete = "";
for (String s : linesToRun) {
for (int l = 0; l < linesToRun.length; l++) {
String s = linesToRun[l];
// check if next line starts with "." (but not ".." or "./") it is treated as an invocation
if (l + 1 < linesToRun.length) {
String nextLine = linesToRun[l + 1].trim();
if (nextLine.startsWith(".") && !nextLine.startsWith("..") && !nextLine.startsWith("./")) {
incomplete += s + "\n";
continue;
}
}

try {
code = getResultCode(imain.interpret(incomplete + s));
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public void testInterpret() {

assertEquals(InterpreterResult.Code.SUCCESS, result.code());
assertTrue(result.message().contains(sizeVal + ": Int = " + ignite.cluster().nodes().size()));

result = intp.interpret("\"123\"\n .toInt", INTP_CONTEXT);
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
}

@Test
Expand All @@ -92,4 +95,5 @@ public void testInterpretInvalidInput() {

assertEquals(InterpreterResult.Code.ERROR, result.code());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,18 @@ public InterpreterResult interpretInput(String[] lines) {
out.reset();
Code r = null;
String incomplete = "";
for (String s : linesToRun) {

for (int l = 0; l < linesToRun.length; l++) {
String s = linesToRun[l];
// check if next line starts with "." (but not ".." or "./") it is treated as an invocation
if (l + 1 < linesToRun.length) {
String nextLine = linesToRun[l + 1].trim();
if (nextLine.startsWith(".") && !nextLine.startsWith("..") && !nextLine.startsWith("./")) {
incomplete += s + "\n";
continue;
}
}

scala.tools.nsc.interpreter.Results.Result res = null;
try {
res = intp.interpret(incomplete + s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ public void testBasicIntp() {
*/
}

@Test
public void testNextLineInvocation() {
assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("\"123\"\n.toInt", context).code());
}

@Test
public void testEndWithComment() {
assertEquals(InterpreterResult.Code.SUCCESS, repl.interpret("val c=1\n//comment", context).code());
Expand Down