Repl, minor: more meaningful method names

This commit is contained in:
Pavel V. Talanov
2015-10-22 17:25:39 +03:00
parent e08ce5545e
commit b07fb88a22
3 changed files with 24 additions and 24 deletions
@@ -121,9 +121,9 @@ public class ReplFromTerminal {
private void doRun() {
try {
replWriter.printlnInit("Welcome to Kotlin version " + KotlinVersion.VERSION +
" (JRE " + System.getProperty("java.runtime.version") + ")");
replWriter.printlnInit("Type :help for help, :quit for quit");
replWriter.printlnWelcomeMessage("Welcome to Kotlin version " + KotlinVersion.VERSION +
" (JRE " + System.getProperty("java.runtime.version") + ")");
replWriter.printlnWelcomeMessage("Type :help for help, :quit for quit");
WhatNextAfterOneLine next = WhatNextAfterOneLine.READ_LINE;
while (true) {
next = one(next);
@@ -185,17 +185,17 @@ public class ReplFromTerminal {
ReplInterpreter.LineResult lineResult = getReplInterpreter().eval(line);
if (lineResult.getType() == ReplInterpreter.LineResultType.SUCCESS) {
if (!lineResult.isUnit()) {
replWriter.printlnResult(lineResult.getValue());
replWriter.outputCommandResult(lineResult.getValue());
}
}
else if (lineResult.getType() == ReplInterpreter.LineResultType.INCOMPLETE) {
replWriter.printlnIncomplete();
replWriter.notifyIncomplete();
}
else if (lineResult.getType() == ReplInterpreter.LineResultType.COMPILE_ERROR) {
replWriter.printlnCompileError(lineResult.getErrorText());
replWriter.outputCompileError(lineResult.getErrorText());
}
else if (lineResult.getType() == ReplInterpreter.LineResultType.RUNTIME_ERROR) {
replWriter.printlnRuntimeError(lineResult.getErrorText());
replWriter.outputRuntimeError(lineResult.getErrorText());
}
else {
throw new IllegalStateException("unknown line result type: " + lineResult);
@@ -206,11 +206,11 @@ public class ReplFromTerminal {
private boolean oneCommand(@NotNull String command) throws Exception {
List<String> split = splitCommand(command);
if (split.size() >= 1 && command.equals("help")) {
replWriter.printlnHelp("Available commands:\n" +
":help show this help\n" +
":quit exit the interpreter\n" +
":dump bytecode dump classes to terminal\n" +
":load <file> load script from specified file"
replWriter.printlnHelpMessage("Available commands:\n" +
":help show this help\n" +
":quit exit the interpreter\n" +
":dump bytecode dump classes to terminal\n" +
":load <file> load script from specified file"
);
return true;
}
@@ -228,8 +228,8 @@ public class ReplFromTerminal {
return true;
}
else {
replWriter.printlnHelp("Unknown command\n" +
"Type :help for help"
replWriter.printlnHelpMessage("Unknown command\n" +
"Type :help for help"
);
return true;
}
@@ -39,7 +39,7 @@ public class ReplSystemInWrapper(
if (isLastByteProcessed) {
if (isReplScriptExecuting) {
isReadLineStartSent = false
replWriter.printlnReadLineEnd()
replWriter.notifyReadLineEnd()
}
isLastByteProcessed = false
@@ -48,7 +48,7 @@ public class ReplSystemInWrapper(
while (isXmlIncomplete) {
if (!isReadLineStartSent && isReplScriptExecuting) {
replWriter.printlnReadLineStart()
replWriter.notifyReadLineStart()
isReadLineStartSent = true
}
@@ -60,13 +60,13 @@ public class ReplSystemOutWrapper(private val ideMode: Boolean, standardOut: Pri
return "$XML_PREAMBLE<output type=\"$escapeType\">${StringUtil.escapeXml(singleLine)}</output>"
}
fun printlnInit(x: String) = printlnWithEscaping(x, EscapeType.INITIAL_PROMPT)
fun printlnHelp(x: String) = printlnWithEscaping(x, EscapeType.HELP_PROMPT)
fun printlnResult(x: Any?) = printlnWithEscaping(x.toString(), EscapeType.REPL_RESULT)
fun printlnReadLineStart() = printlnWithEscaping("", EscapeType.READLINE_START)
fun printlnReadLineEnd() = printlnWithEscaping("", EscapeType.READLINE_END)
fun printlnIncomplete() = printlnWithEscaping("", EscapeType.REPL_INCOMPLETE)
fun printlnCompileError(x: String) = printlnWithEscaping(x, EscapeType.COMPILE_ERROR)
fun printlnRuntimeError(x: String) = printlnWithEscaping(x, EscapeType.RUNTIME_ERROR)
fun printlnWelcomeMessage(x: String) = printlnWithEscaping(x, EscapeType.INITIAL_PROMPT)
fun printlnHelpMessage(x: String) = printlnWithEscaping(x, EscapeType.HELP_PROMPT)
fun outputCommandResult(x: Any?) = printlnWithEscaping(x.toString(), EscapeType.REPL_RESULT)
fun notifyReadLineStart() = printlnWithEscaping("", EscapeType.READLINE_START)
fun notifyReadLineEnd() = printlnWithEscaping("", EscapeType.READLINE_END)
fun notifyIncomplete() = printlnWithEscaping("", EscapeType.REPL_INCOMPLETE)
fun outputCompileError(x: String) = printlnWithEscaping(x, EscapeType.COMPILE_ERROR)
fun outputRuntimeError(x: String) = printlnWithEscaping(x, EscapeType.RUNTIME_ERROR)
fun sendInternalErrorReport(x: String) = printlnWithEscaping(x, EscapeType.INTERNAL_ERROR)
}