diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleExecutor.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleExecutor.kt
index f8c25ff566c..f36b77ab6c9 100644
--- a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleExecutor.kt
+++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleExecutor.kt
@@ -22,6 +22,8 @@ import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.console.actions.logError
import org.jetbrains.kotlin.console.highlight.KotlinHistoryHighlighter
+private val XML_PREAMBLE = ""
+
public class KotlinConsoleExecutor(
private val runner: KotlinConsoleRunner,
private val historyManager: KotlinConsoleHistoryManager
@@ -49,11 +51,11 @@ public class KotlinConsoleExecutor(
val processInputOS = processHandler.processInput ?: return logError(javaClass, "
Broken process stream
")
val charset = (processHandler as? BaseOSProcessHandler)?.charset ?: Charsets.UTF_8
- val xmlRes = "${ReplConstants.XML_PREAMBLE}" +
+ val xmlRes = "$XML_PREAMBLE" +
"" +
- "${StringUtil.escapeXml(
- StringUtil.replace(command.trim(), ReplConstants.SOURCE_CHARS, ReplConstants.XML_REPLACEMENTS)
- )}" +
+ "${StringUtil.escapeXml(
+ StringUtil.replace(command.trim(), SOURCE_CHARS, XML_REPLACEMENTS)
+ )}" +
""
val bytes = ("$xmlRes\n").toByteArray(charset)
processInputOS.write(bytes)
diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt
index 34fffd0f7ff..8ecc4aabad2 100644
--- a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt
+++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinConsoleKeeper.kt
@@ -34,7 +34,6 @@ import org.jetbrains.kotlin.console.actions.errorNotification
import org.jetbrains.kotlin.utils.PathUtil
import java.io.File
import java.util.concurrent.ConcurrentHashMap
-import kotlin.platform.platformStatic
public class KotlinConsoleKeeper(val project: Project) {
private val consoleMap: MutableMap = ConcurrentHashMap()
@@ -45,7 +44,7 @@ public class KotlinConsoleKeeper(val project: Project) {
fun run(module: Module): KotlinConsoleRunner? {
val path = module.moduleFilePath
- val cmdLine = createCommandLine(module) ?: return errorNotification(project, "
Module SDK not found
") let { null }
+ val cmdLine = createCommandLine(module) ?: return errorNotification(project, "Module SDK not found") let { null }
val consoleRunner = KotlinConsoleRunner(path, cmdLine, module, project, REPL_TITLE)
consoleRunner.initAndRun()
@@ -113,6 +112,6 @@ public class KotlinConsoleKeeper(val project: Project) {
companion object {
private val REPL_TITLE = "Kotlin REPL"
- platformStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass())
+ jvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, javaClass())
}
}
\ No newline at end of file
diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinReplOutputHandler.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinReplOutputHandler.kt
index f863c3add2c..73100365532 100644
--- a/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinReplOutputHandler.kt
+++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/KotlinReplOutputHandler.kt
@@ -29,6 +29,11 @@ import java.io.ByteArrayInputStream
import java.nio.charset.Charset
import javax.xml.parsers.DocumentBuilderFactory
+private val XML_PREFIX = " = arrayOf("#n", "#diez")
+public val SOURCE_CHARS: Array = arrayOf("\n", "#")
+
data class SeverityDetails(val severity: Severity, val description: String, val range: TextRange)
public class KotlinReplOutputHandler(
@@ -41,12 +46,12 @@ public class KotlinReplOutputHandler(
override fun notifyTextAvailable(text: String, key: Key<*>?) {
// skip "/usr/lib/jvm/java-8-oracle/bin/java -cp ..." intro
- if (!text.startsWith(ReplConstants.XML_PREFIX)) return super.notifyTextAvailable(text, key)
+ if (!text.startsWith(XML_PREFIX)) return super.notifyTextAvailable(text, key)
val output = dBuilder.parse(strToSource(text))
val root = output.firstChild as Element
val outputType = root.getAttribute("type")
- val content = StringUtil.replace(root.textContent, ReplConstants.XML_REPLACEMENTS, ReplConstants.SOURCE_CHARS).trim()
+ val content = StringUtil.replace(root.textContent, XML_REPLACEMENTS, SOURCE_CHARS).trim()
when (outputType) {
"INITIAL_PROMPT" -> super.notifyTextAvailable("$content\n", key)
diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplConstants.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplConstants.kt
deleted file mode 100644
index 523fc39d420..00000000000
--- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplConstants.kt
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2010-2015 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.jetbrains.kotlin.console
-
-public object ReplConstants {
- public val XML_PREFIX: String = ""
-
- public val SOURCE_CHARS: Array = arrayOf("\n", "#")
- public val XML_REPLACEMENTS: Array = arrayOf("#n", "#diez")
-}
\ No newline at end of file
diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt
index c1c7bbf5ea9..63d0ac4fff9 100644
--- a/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt
+++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/actions/RunExecuteActions.kt
@@ -27,19 +27,16 @@ import com.intellij.openapi.vfs.VirtualFile
import org.jetbrains.kotlin.console.KotlinConsoleKeeper
fun errorNotification(project: Project?, message: String) {
- val tag = "KOTLIN REPL ERROR"
- val title = "Kotlin REPL Configuration Error"
- Notifications.Bus.notify(Notification(tag, title, message, NotificationType.ERROR), project)
+ val errorTag = "KOTLIN REPL ERROR"
+ val errorTitle = "Kotlin REPL Configuration Error"
+ Notifications.Bus.notify(Notification(errorTag, errorTitle, message, NotificationType.ERROR), project)
}
-fun logError(cl: Class<*>, message: String) {
- val logger = Logger.getInstance(cl)
- logger.error(message)
-}
+fun logError(cl: Class<*>, message: String) = with(Logger.getInstance(cl)) { error(message) }
public class RunKotlinConsoleAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
- val project = e.project ?: return errorNotification(null, "
Project not found
")
+ val project = e.project ?: return errorNotification(null, "Project not found")
KotlinConsoleModuleDialog(project).showIfNeeded(e.dataContext)
}
@@ -47,8 +44,9 @@ public class RunKotlinConsoleAction : AnAction() {
public class KtExecuteCommandAction(private val consoleFile: VirtualFile) : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
- val project = e.project ?: return errorNotification(null, "
Cannot find project
")
- val ktConsole = KotlinConsoleKeeper.getInstance(project).getConsoleByVirtualFile(consoleFile) ?: return errorNotification(project, "
Action performed in an invalid console
")
+ val project = e.project ?: return errorNotification(null, "Cannot find project")
+ val ktConsole = KotlinConsoleKeeper.getInstance(project).getConsoleByVirtualFile(consoleFile)
+ ?: return errorNotification(project, "Action performed in an invalid console")
ktConsole.executor.executeCommand()
}