i18n: add bundle for idea-repl
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
0.to.execute=<{0}> to execute
|
||||
build.and.restart=Build and restart
|
||||
build.module.0.and.restart=Build module ''{0}'' and restart
|
||||
cannot.find.project=Cannot find project
|
||||
choose.context.module=Choose context module...
|
||||
error=Error:
|
||||
executed.command=Executed command
|
||||
history.of.executed.commands=History of executed commands
|
||||
info=Info:
|
||||
input.line=Input line
|
||||
kotlin.repl=Kotlin REPL
|
||||
kotlin.repl.configuration.error=Kotlin REPL Configuration Error
|
||||
no.modules.were.found=No modules were found
|
||||
project.not.found=Project not found
|
||||
result=Result
|
||||
runtime.exception=Runtime exception
|
||||
system.help=System help
|
||||
there.were.compilation.errors.in.module.0=There were compilation errors in module {0}
|
||||
waiting.for.input=Waiting for input...
|
||||
warning=Warning:
|
||||
write.your.commands.here=Write your commands here
|
||||
you.re.running.the.repl.with.outdated.classes=You’re running the REPL with outdated classes:\u0020
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin
|
||||
|
||||
import org.jetbrains.annotations.NonNls
|
||||
import org.jetbrains.annotations.PropertyKey
|
||||
import org.jetbrains.kotlin.util.AbstractKotlinBundle
|
||||
|
||||
@NonNls
|
||||
private const val BUNDLE = "messages.KotlinIdeaReplBundle"
|
||||
|
||||
object KotlinIdeaReplBundle : AbstractKotlinBundle(BUNDLE) {
|
||||
@JvmStatic
|
||||
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any): String = getMessage(key, *params)
|
||||
}
|
||||
@@ -10,12 +10,13 @@ import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.idea.util.JavaParametersBuilder
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
private const val REPL_TITLE = "Kotlin REPL"
|
||||
private val REPL_TITLE: String get() = KotlinIdeaReplBundle.message("kotlin.repl")
|
||||
|
||||
class KotlinConsoleKeeper(val project: Project) {
|
||||
private val consoleMap: MutableMap<VirtualFile, KotlinConsoleRunner> = ConcurrentHashMap()
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.psi.impl.PsiFileFactoryImpl
|
||||
import com.intellij.testFramework.LightVirtualFile
|
||||
import com.intellij.util.containers.ContainerUtil
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.console.actions.BuildAndRestartConsoleAction
|
||||
import org.jetbrains.kotlin.console.actions.KtExecuteCommandAction
|
||||
import org.jetbrains.kotlin.console.gutter.ConsoleGutterContentProvider
|
||||
@@ -122,7 +123,7 @@ class KotlinConsoleRunner(
|
||||
var compilerHelper: ConsoleCompilerHelper by Delegates.notNull()
|
||||
|
||||
private val consoleScriptDefinition = object : KotlinScriptDefinition(Any::class) {
|
||||
override val name = "Kotlin REPL"
|
||||
override val name = KotlinIdeaReplBundle.message("kotlin.repl")
|
||||
override fun isScript(fileName: String): Boolean = fileName.startsWith(consoleView.virtualFile.name)
|
||||
override fun getScriptName(script: KtScript) = Name.identifier("REPL")
|
||||
}
|
||||
@@ -212,7 +213,7 @@ class KotlinConsoleRunner(
|
||||
val executeCommandAction = ActionManager.getInstance().getAction(KOTLIN_SHELL_EXECUTE_ACTION_ID)
|
||||
val executeCommandActionShortcutText = KeymapUtil.getFirstKeyboardShortcutText(executeCommandAction)
|
||||
|
||||
editor.setPlaceholder("<$executeCommandActionShortcutText> to execute")
|
||||
editor.setPlaceholder(KotlinIdeaReplBundle.message("0.to.execute", executeCommandActionShortcutText))
|
||||
editor.setShowPlaceholderWhenFocused(true)
|
||||
|
||||
val placeholderAttrs = TextAttributes()
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.openapi.editor.markup.HighlighterLayer
|
||||
import com.intellij.openapi.editor.markup.HighlighterTargetArea
|
||||
import com.intellij.openapi.editor.markup.TextAttributes
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.console.actions.logError
|
||||
import org.jetbrains.kotlin.console.gutter.ConsoleErrorRenderer
|
||||
import org.jetbrains.kotlin.console.gutter.ConsoleIndicatorRenderer
|
||||
@@ -78,12 +79,12 @@ class ReplOutputProcessor(
|
||||
fun printBuildInfoWarningIfNeeded() {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) return
|
||||
if (runner.previousCompilationFailed) return printWarningMessage(
|
||||
"There were compilation errors in module ${runner.module.name}",
|
||||
KotlinIdeaReplBundle.message("there.were.compilation.errors.in.module.0", runner.module.name),
|
||||
false
|
||||
)
|
||||
if (runner.compilerHelper.moduleIsUpToDate()) return
|
||||
|
||||
val compilerWarningMessage = "You’re running the REPL with outdated classes: "
|
||||
val compilerWarningMessage = KotlinIdeaReplBundle.message("you.re.running.the.repl.with.outdated.classes")
|
||||
printWarningMessage(compilerWarningMessage, true)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,10 +11,11 @@ import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleKeeper
|
||||
|
||||
class ConsoleModuleDialog(private val project: Project) {
|
||||
private val TITLE = "Choose context module..."
|
||||
private val TITLE get() = KotlinIdeaReplBundle.message("choose.context.module")
|
||||
|
||||
fun showIfNeeded(dataContext: DataContext) {
|
||||
val module = getModule(dataContext)
|
||||
@@ -22,7 +23,7 @@ class ConsoleModuleDialog(private val project: Project) {
|
||||
|
||||
val modules = ModuleManager.getInstance(project).modules
|
||||
|
||||
if (modules.isEmpty()) return errorNotification(project, "No modules were found")
|
||||
if (modules.isEmpty()) return errorNotification(project, KotlinIdeaReplBundle.message("no.modules.were.found"))
|
||||
if (modules.size == 1) return runConsole(modules.first())
|
||||
|
||||
val moduleActions = modules.sortedBy { it.name }.map { createRunAction(it) }
|
||||
|
||||
@@ -14,12 +14,13 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleKeeper
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleRunner
|
||||
|
||||
fun errorNotification(project: Project?, message: String) {
|
||||
val errorTag = "KOTLIN REPL ERROR"
|
||||
val errorTitle = "Kotlin REPL Configuration Error"
|
||||
val errorTitle = KotlinIdeaReplBundle.message("kotlin.repl.configuration.error")
|
||||
Notifications.Bus.notify(Notification(errorTag, errorTitle, message, NotificationType.ERROR), project)
|
||||
}
|
||||
|
||||
@@ -27,7 +28,7 @@ fun logError(cl: Class<*>, message: String, t: Throwable? = null) = with(Logger.
|
||||
|
||||
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, KotlinIdeaReplBundle.message("project.not.found"))
|
||||
|
||||
ConsoleModuleDialog(project).showIfNeeded(e.dataContext)
|
||||
}
|
||||
@@ -35,7 +36,7 @@ class RunKotlinConsoleAction : AnAction() {
|
||||
|
||||
class KtExecuteCommandAction(private val consoleFile: VirtualFile) : AnAction() {
|
||||
override fun actionPerformed(e: AnActionEvent) {
|
||||
val project = e.project ?: return errorNotification(null, "Cannot find project")
|
||||
val project = e.project ?: return errorNotification(null, KotlinIdeaReplBundle.message("cannot.find.project"))
|
||||
val ktConsole = KotlinConsoleKeeper.getInstance(project).getConsoleByVirtualFile(consoleFile) ?: return
|
||||
|
||||
ktConsole.executor.executeCommand()
|
||||
@@ -44,7 +45,9 @@ class KtExecuteCommandAction(private val consoleFile: VirtualFile) : AnAction()
|
||||
|
||||
class BuildAndRestartConsoleAction(
|
||||
private val runner: KotlinConsoleRunner
|
||||
) : AnAction("Build and restart", "Build module '${runner.module.name}' and restart", AllIcons.Actions.Restart) {
|
||||
) : AnAction(
|
||||
KotlinIdeaReplBundle.message("build.and.restart"),
|
||||
KotlinIdeaReplBundle.message("build.module.0.and.restart", runner.module.name), AllIcons.Actions.Restart) {
|
||||
|
||||
override fun actionPerformed(e: AnActionEvent) = runner.compilerHelper.compileModule()
|
||||
}
|
||||
@@ -17,14 +17,15 @@
|
||||
package org.jetbrains.kotlin.console.gutter
|
||||
|
||||
import com.intellij.openapi.editor.markup.GutterIconRenderer
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.console.SeverityDetails
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
|
||||
class ConsoleErrorRenderer(private val messages: List<SeverityDetails>) : GutterIconRenderer() {
|
||||
private fun msgType(severity: Severity) = when (severity) {
|
||||
Severity.ERROR -> "Error:"
|
||||
Severity.WARNING -> "Warning:"
|
||||
Severity.INFO -> "Info:"
|
||||
Severity.ERROR -> KotlinIdeaReplBundle.message("error")
|
||||
Severity.WARNING -> KotlinIdeaReplBundle.message("warning")
|
||||
Severity.INFO -> KotlinIdeaReplBundle.message("info")
|
||||
}
|
||||
|
||||
override fun getTooltipText(): String {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.jetbrains.kotlin.console.gutter
|
||||
|
||||
import com.intellij.icons.AllIcons
|
||||
import org.jetbrains.kotlin.KotlinIdeaReplBundle
|
||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
||||
import javax.swing.Icon
|
||||
|
||||
@@ -24,15 +25,23 @@ data class IconWithTooltip(val icon: Icon, val tooltip: String?)
|
||||
|
||||
object ReplIcons {
|
||||
val BUILD_WARNING_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Warning, null)
|
||||
val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.History, "History of executed commands")
|
||||
val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, "Write your commands here")
|
||||
val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon, "Waiting for input...")
|
||||
val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.RunConfigurations.TestState.Run, "Executed command")
|
||||
val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Debugger.PromptInput, "Input line")
|
||||
val HISTORY_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.History,
|
||||
KotlinIdeaReplBundle.message("history.of.executed.commands")
|
||||
)
|
||||
val EDITOR_INDICATOR: IconWithTooltip = IconWithTooltip(KotlinIcons.LAUNCH, KotlinIdeaReplBundle.message("write.your.commands.here"))
|
||||
val EDITOR_READLINE_INDICATOR: IconWithTooltip = IconWithTooltip(AllIcons.General.Balloon,
|
||||
KotlinIdeaReplBundle.message("waiting.for.input")
|
||||
)
|
||||
val COMMAND_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.RunConfigurations.TestState.Run,
|
||||
KotlinIdeaReplBundle.message("executed.command")
|
||||
)
|
||||
val READLINE_MARKER: IconWithTooltip = IconWithTooltip(AllIcons.Debugger.PromptInput, KotlinIdeaReplBundle.message("input.line"))
|
||||
|
||||
// command result icons
|
||||
val SYSTEM_HELP: IconWithTooltip = IconWithTooltip(AllIcons.Actions.Help, "System help")
|
||||
val RESULT: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.Equal, "Result")
|
||||
val SYSTEM_HELP: IconWithTooltip = IconWithTooltip(AllIcons.Actions.Help, KotlinIdeaReplBundle.message("system.help"))
|
||||
val RESULT: IconWithTooltip = IconWithTooltip(AllIcons.Vcs.Equal, KotlinIdeaReplBundle.message("result"))
|
||||
val COMPILER_ERROR: Icon = AllIcons.General.Error
|
||||
val RUNTIME_EXCEPTION: IconWithTooltip = IconWithTooltip(AllIcons.General.BalloonWarning, "Runtime exception")
|
||||
val RUNTIME_EXCEPTION: IconWithTooltip = IconWithTooltip(AllIcons.General.BalloonWarning,
|
||||
KotlinIdeaReplBundle.message("runtime.exception")
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user