[cli-repl][ide-console] Add logging of internal errors
Rename `jvmStatic` to `@JvmStatic`
This commit is contained in:
committed by
Pavel V. Talanov
parent
38285496cb
commit
9bf0c8453d
@@ -112,6 +112,6 @@ public class KotlinConsoleKeeper(val project: Project) {
|
||||
}
|
||||
|
||||
companion object {
|
||||
jvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, KotlinConsoleKeeper::class.java)
|
||||
@JvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, KotlinConsoleKeeper::class.java)
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,6 @@ import com.intellij.execution.process.OSProcessHandler
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.openapi.util.text.StringUtil
|
||||
import org.jetbrains.kotlin.console.actions.logError
|
||||
import org.jetbrains.kotlin.console.highlight.KotlinHistoryHighlighter
|
||||
import org.jetbrains.kotlin.console.highlight.KotlinReplOutputHighlighter
|
||||
import org.jetbrains.kotlin.diagnostics.Severity
|
||||
@@ -68,7 +67,7 @@ public class KotlinReplOutputHandler(
|
||||
"REPL_INCOMPLETE",
|
||||
"COMPILE_ERROR" -> outputHighlighter.highlightCompilerErrors(createCompilerMessages(content))
|
||||
"RUNTIME_ERROR" -> outputHighlighter.printRuntimeError("${content.trim()}\n")
|
||||
"INNER_ERROR" -> logError(this.javaClass, content)
|
||||
"INTERNAL_ERROR" -> outputHighlighter.printInternalErrorMessage(content)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -31,6 +31,7 @@ import com.intellij.psi.PsiDocumentManager
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleHistoryManager
|
||||
import org.jetbrains.kotlin.console.KotlinConsoleRunner
|
||||
import org.jetbrains.kotlin.console.SeverityDetails
|
||||
import org.jetbrains.kotlin.console.actions.logError
|
||||
import org.jetbrains.kotlin.console.gutter.IconWithTooltip
|
||||
import org.jetbrains.kotlin.console.gutter.KotlinConsoleErrorRenderer
|
||||
import org.jetbrains.kotlin.console.gutter.KotlinConsoleIndicatorRenderer
|
||||
@@ -108,7 +109,7 @@ public class KotlinReplOutputHighlighter(
|
||||
}
|
||||
|
||||
fun highlightCompilerErrors(compilerMessages: List<SeverityDetails>) = WriteCommandAction.runWriteCommandAction(project) {
|
||||
val lastCommandStartOffset = historyDocument.textLength - historyManager.lastCommandLength
|
||||
val lastCommandStartOffset = historyDocument.textLength - historyManager.lastCommandLength - 1
|
||||
val lastCommandStartLine = historyDocument.getLineNumber(lastCommandStartOffset)
|
||||
val historyCommandRunIndicator = historyMarkup.allHighlighters.filter {
|
||||
historyDocument.getLineNumber(it.startOffset) == lastCommandStartLine && it.gutterIconRenderer != null
|
||||
@@ -144,6 +145,12 @@ public class KotlinReplOutputHighlighter(
|
||||
printOutput(errorText, ConsoleViewContentType.ERROR_OUTPUT, ReplIcons.RUNTIME_EXCEPTION)
|
||||
}
|
||||
|
||||
fun printInternalErrorMessage(internalErrorText: String) = WriteCommandAction.runWriteCommandAction(project) {
|
||||
val promptText = "Internal error occurred. Please, send report to developers.\n"
|
||||
printOutput(promptText, ConsoleViewContentType.ERROR_OUTPUT, ReplIcons.RUNTIME_EXCEPTION)
|
||||
logError(this.javaClass, internalErrorText)
|
||||
}
|
||||
|
||||
private fun getAttributesForSeverity(start: Int, end: Int, severity: Severity): TextAttributes {
|
||||
val attributes = when (severity) {
|
||||
Severity.ERROR -> getAttributesForSeverity(HighlightInfoType.ERROR, HighlightSeverity.ERROR, CodeInsightColors.ERRORS_ATTRIBUTES, start, end)
|
||||
|
||||
Reference in New Issue
Block a user