Minor: clarify exception messages during Evaluate Expression
This commit is contained in:
@@ -156,7 +156,8 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, val sourcePosition: Sour
|
|||||||
|
|
||||||
val attachments = arrayOf(attachmentByPsiFile(sourcePosition.file),
|
val attachments = arrayOf(attachmentByPsiFile(sourcePosition.file),
|
||||||
attachmentByPsiFile(codeFragment),
|
attachmentByPsiFile(codeFragment),
|
||||||
Attachment("breakpoint.info", "line: ${sourcePosition.line}"))
|
Attachment("breakpoint.info", "line: ${sourcePosition.line}"),
|
||||||
|
Attachment("context.info", codeFragment.context?.text ?: "null"))
|
||||||
LOG.error(LogMessageEx.createEvent(
|
LOG.error(LogMessageEx.createEvent(
|
||||||
"Couldn't evaluate expression",
|
"Couldn't evaluate expression",
|
||||||
ExceptionUtil.getThrowableText(e),
|
ExceptionUtil.getThrowableText(e),
|
||||||
|
|||||||
+15
-7
@@ -17,11 +17,14 @@
|
|||||||
package org.jetbrains.kotlin.idea.debugger.evaluate
|
package org.jetbrains.kotlin.idea.debugger.evaluate
|
||||||
|
|
||||||
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil
|
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil
|
||||||
|
import com.intellij.diagnostic.LogMessageEx
|
||||||
|
import com.intellij.openapi.diagnostic.Attachment
|
||||||
import com.intellij.openapi.util.Key
|
import com.intellij.openapi.util.Key
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import com.intellij.psi.PsiManager
|
import com.intellij.psi.PsiManager
|
||||||
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
||||||
|
import com.intellij.util.ExceptionUtil
|
||||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
|
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
|
||||||
@@ -32,6 +35,8 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*
|
|||||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.ErrorMessage
|
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.ErrorMessage
|
||||||
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.Status
|
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.Status
|
||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
|
import org.jetbrains.kotlin.idea.util.attachment.attachmentByPsiFile
|
||||||
|
import org.jetbrains.kotlin.idea.util.attachment.mergeAttachments
|
||||||
import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange
|
import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
|
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
|
||||||
@@ -49,13 +54,16 @@ fun getFunctionForExtractedFragment(
|
|||||||
|
|
||||||
fun getErrorMessageForExtractFunctionResult(analysisResult: AnalysisResult, tmpFile: KtFile): String {
|
fun getErrorMessageForExtractFunctionResult(analysisResult: AnalysisResult, tmpFile: KtFile): String {
|
||||||
if (KotlinInternalMode.enabled) {
|
if (KotlinInternalMode.enabled) {
|
||||||
LOG.error("Couldn't extract function for debugger:\n" +
|
val attachments = arrayOf(attachmentByPsiFile(tmpFile),
|
||||||
"FILE NAME: ${breakpointFile.name}\n" +
|
attachmentByPsiFile(breakpointFile),
|
||||||
"BREAKPOINT LINE: $breakpointLine\n" +
|
attachmentByPsiFile(codeFragment),
|
||||||
"CODE FRAGMENT:\n${codeFragment.text}\n" +
|
Attachment("breakpoint.info", "line: $breakpointLine"),
|
||||||
"ERRORS:\n${analysisResult.messages.map { "$it: ${it.renderMessage()}" }.joinToString("\n")}\n" +
|
Attachment("context.info", codeFragment.context?.text ?: "null"),
|
||||||
"TMPFILE_TEXT:\n${tmpFile.text}\n" +
|
Attachment("errors.info", analysisResult.messages.map { "$it: ${it.renderMessage()}" }.joinToString("\n")))
|
||||||
"FILE TEXT: \n${breakpointFile.text}\n")
|
LOG.error(LogMessageEx.createEvent(
|
||||||
|
"Internal error during evaluate expression",
|
||||||
|
ExceptionUtil.getThrowableText(Throwable("Extract function fails with ${analysisResult.messages.joinToString { it.name }}")),
|
||||||
|
mergeAttachments(*attachments)))
|
||||||
}
|
}
|
||||||
return analysisResult.messages.map { errorMessage ->
|
return analysisResult.messages.map { errorMessage ->
|
||||||
val message = when(errorMessage) {
|
val message = when(errorMessage) {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.util.attachment
|
package org.jetbrains.kotlin.idea.util.attachment
|
||||||
|
|
||||||
import com.intellij.psi.PsiFile
|
|
||||||
import com.intellij.openapi.diagnostic.Attachment
|
|
||||||
import com.intellij.diagnostic.AttachmentFactory
|
import com.intellij.diagnostic.AttachmentFactory
|
||||||
|
import com.intellij.openapi.diagnostic.Attachment
|
||||||
|
import com.intellij.psi.PsiFile
|
||||||
|
|
||||||
fun attachmentByPsiFileAsArray(file: PsiFile?): Array<Attachment> {
|
fun attachmentByPsiFileAsArray(file: PsiFile?): Array<Attachment> {
|
||||||
val attachment = attachmentByPsiFile(file)
|
val attachment = attachmentByPsiFile(file)
|
||||||
@@ -48,9 +48,9 @@ fun mergeAttachments(vararg attachments: Attachment?): Attachment {
|
|||||||
val builder = StringBuilder()
|
val builder = StringBuilder()
|
||||||
attachments.forEach {
|
attachments.forEach {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
builder.append("\n----- START ${it.path} -----\n")
|
builder.append("----- START ${it.path} -----\n")
|
||||||
builder.append(it.displayText)
|
builder.append(it.displayText)
|
||||||
builder.append("\n----- END ${it.path} -----\n")
|
builder.append("\n----- END ${it.path} -----\n\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user