Do not insert additional new lines in REPL
This commit is contained in:
@@ -24,8 +24,8 @@ import java.io.File
|
||||
import java.net.URLClassLoader
|
||||
|
||||
// using '#' to avoid collisions with xml escaping
|
||||
private val SOURCE_CHARS: List<String> = listOf("\n", "#")
|
||||
private val XML_REPLACEMENTS: List<String> = listOf("#n", "#diez")
|
||||
private val SOURCE_CHARS: List<String> = listOf("\r", "\n", "#")
|
||||
private val XML_REPLACEMENTS: List<String> = listOf("#r", "#n", "#diez")
|
||||
|
||||
private val END_LINE: String = LineSeparator.getSystemLineSeparator().separatorString
|
||||
private const val XML_PREAMBLE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
@@ -45,6 +45,7 @@ fun String.replInputAsXml(): String {
|
||||
|
||||
fun String.replAddLineBreak() = this + END_LINE
|
||||
fun String.replRemoveLineBreaksInTheEnd() = trimEnd(*END_LINE.toCharArray())
|
||||
fun String.replNormalizeLineBreaks() = replace(END_LINE, "\n")
|
||||
|
||||
fun makeScriptBaseName(codeLine: ReplCodeLine) =
|
||||
"Line_${codeLine.no}${if (codeLine.generation > REPL_CODE_LINE_FIRST_GEN) "_gen_${codeLine.generation}" else ""}"
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.execution.process.OSProcessHandler
|
||||
import com.intellij.execution.process.ProcessOutputTypes
|
||||
import com.intellij.openapi.util.Key
|
||||
import org.jetbrains.kotlin.cli.common.repl.replInputAsXml
|
||||
import org.jetbrains.kotlin.cli.common.repl.replNormalizeLineBreaks
|
||||
import org.jetbrains.kotlin.cli.common.repl.replRemoveLineBreaksInTheEnd
|
||||
import org.jetbrains.kotlin.cli.common.repl.replUnescapeLineBreaks
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleKeeper
|
||||
@@ -123,7 +124,7 @@ class KtScratchReplExecutor(file: ScratchFile) : ScratchExecutor(file) {
|
||||
|
||||
val root = output.firstChild as Element
|
||||
val outputType = root.getAttribute("type")
|
||||
val content = root.textContent.replUnescapeLineBreaks().replRemoveLineBreaksInTheEnd()
|
||||
val content = root.textContent.replUnescapeLineBreaks().replNormalizeLineBreaks().replRemoveLineBreaksInTheEnd()
|
||||
|
||||
LOG.printDebugMessage("REPL output: $outputType $content")
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.execution.process.OSProcessHandler
|
||||
import com.intellij.execution.process.ProcessOutputTypes
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.cli.common.repl.replNormalizeLineBreaks
|
||||
import org.jetbrains.kotlin.cli.common.repl.replUnescapeLineBreaks
|
||||
import org.jetbrains.kotlin.console.actions.logError
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
@@ -75,7 +76,7 @@ class ReplOutputHandler(
|
||||
|
||||
val root = output.firstChild as Element
|
||||
val outputType = ReplEscapeType.valueOfOrNull(root.getAttribute("type"))
|
||||
val content = root.textContent.replUnescapeLineBreaks()
|
||||
val content = root.textContent.replUnescapeLineBreaks().replNormalizeLineBreaks()
|
||||
|
||||
when (outputType) {
|
||||
INITIAL_PROMPT -> buildWarningIfNeededBeforeInit(content)
|
||||
|
||||
-2
@@ -1,6 +1,4 @@
|
||||
foo() // ERROR: error: unresolved reference: foo...
|
||||
/** unresolved.kts:1 error: unresolved reference: foo
|
||||
|
||||
foo()
|
||||
|
||||
^ */
|
||||
@@ -6,20 +6,13 @@ fun goo(a: String) { // ERROR: error: unresolved reference: goo...
|
||||
super.goo(a)
|
||||
}
|
||||
/** unresolvedMultiline.kts:1 error: unresolved reference: foo
|
||||
|
||||
foo.forEach {
|
||||
|
||||
^
|
||||
|
||||
error: cannot choose among the following candidates without completing type inference:
|
||||
@HidesMembers public inline fun <T> Iterable<???>.forEach(action: (???) -> Unit): Unit defined in kotlin.collections
|
||||
@HidesMembers public inline fun <K, V> Map<out ???, ???>.forEach(action: (Map.Entry<???, ???>) -> Unit): Unit defined in kotlin.collections
|
||||
|
||||
foo.forEach {
|
||||
|
||||
^ */
|
||||
/** unresolvedMultiline.kts:5 error: unresolved reference: goo
|
||||
|
||||
super.goo(a)
|
||||
|
||||
^ */
|
||||
Reference in New Issue
Block a user