17
17
package org.jetbrains.kotlin.idea.debugger.evaluate
18
18
19
19
import com.intellij.debugger.engine.evaluation.EvaluateExceptionUtil
20
+ import com.intellij.diagnostic.LogMessageEx
21
+ import com.intellij.openapi.diagnostic.Attachment
20
22
import com.intellij.openapi.util.Key
21
23
import com.intellij.psi.PsiElement
22
24
import com.intellij.psi.PsiFile
23
25
import com.intellij.psi.PsiManager
24
26
import com.intellij.psi.impl.PsiModificationTrackerImpl
27
+ import com.intellij.util.ExceptionUtil
25
28
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
26
29
import org.jetbrains.kotlin.idea.caches.resolve.analyze
27
30
import org.jetbrains.kotlin.idea.caches.resolve.analyzeFullyAndGetResult
@@ -32,6 +35,8 @@ import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.*
32
35
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.ErrorMessage
33
36
import org.jetbrains.kotlin.idea.refactoring.introduce.extractionEngine.AnalysisResult.Status
34
37
import org.jetbrains.kotlin.idea.util.application.runReadAction
38
+ import org.jetbrains.kotlin.idea.util.attachment.attachmentByPsiFile
39
+ import org.jetbrains.kotlin.idea.util.attachment.mergeAttachments
35
40
import org.jetbrains.kotlin.idea.util.psi.patternMatching.toRange
36
41
import org.jetbrains.kotlin.psi.*
37
42
import org.jetbrains.kotlin.psi.codeFragmentUtil.suppressDiagnosticsInDebugMode
@@ -49,13 +54,16 @@ fun getFunctionForExtractedFragment(
49
54
50
55
fun getErrorMessageForExtractFunctionResult (analysisResult : AnalysisResult , tmpFile : KtFile ): String {
51
56
if (KotlinInternalMode .enabled) {
52
- LOG .error(" Couldn't extract function for debugger:\n " +
53
- " FILE NAME: ${breakpointFile.name} \n " +
54
- " BREAKPOINT LINE: $breakpointLine \n " +
55
- " CODE FRAGMENT:\n ${codeFragment.text} \n " +
56
- " ERRORS:\n ${analysisResult.messages.map { " $it : ${it.renderMessage()} " }.joinToString(" \n " )} \n " +
57
- " TMPFILE_TEXT:\n ${tmpFile.text} \n " +
58
- " FILE TEXT: \n ${breakpointFile.text} \n " )
57
+ val attachments = arrayOf(attachmentByPsiFile(tmpFile),
58
+ attachmentByPsiFile(breakpointFile),
59
+ attachmentByPsiFile(codeFragment),
60
+ Attachment (" breakpoint.info" , " line: $breakpointLine " ),
61
+ Attachment (" context.info" , codeFragment.context?.text ? : " null" ),
62
+ Attachment (" errors.info" , analysisResult.messages.map { " $it : ${it.renderMessage()} " }.joinToString(" \n " )))
63
+ LOG .error(LogMessageEx .createEvent(
64
+ " Internal error during evaluate expression" ,
65
+ ExceptionUtil .getThrowableText(Throwable (" Extract function fails with ${analysisResult.messages.joinToString { it.name }} " )),
66
+ mergeAttachments(* attachments)))
59
67
}
60
68
return analysisResult.messages.map { errorMessage ->
61
69
val message = when (errorMessage) {
0 commit comments